From 8ca2fffa7885efef2e4b88a533469d34f70d6c30 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Thu, 11 Jul 2019 17:50:00 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02060=20[WIP]=20Initialisation=20of=20the?= =?UTF-8?q?=20portal=20application:=20Remove=20Silex=20framework=20files?= =?UTF-8?q?=20from=20embedded=20libs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/silex/composer.json | 6 - lib/silex/composer.lock | 823 ------ lib/silex/vendor/autoload.php | 7 - lib/silex/vendor/composer/ClassLoader.php | 445 ---- lib/silex/vendor/composer/LICENSE | 21 - .../vendor/composer/autoload_classmap.php | 16 - lib/silex/vendor/composer/autoload_files.php | 12 - .../vendor/composer/autoload_namespaces.php | 11 - lib/silex/vendor/composer/autoload_psr4.php | 20 - lib/silex/vendor/composer/autoload_real.php | 70 - lib/silex/vendor/composer/autoload_static.php | 122 - lib/silex/vendor/composer/installed.json | 833 ------ .../vendor/paragonie/random_compat/LICENSE | 22 - .../paragonie/random_compat/build-phar.sh | 5 - .../paragonie/random_compat/composer.json | 37 - .../dist/random_compat.phar.pubkey | 5 - .../dist/random_compat.phar.pubkey.asc | 11 - .../random_compat/lib/byte_safe_strings.php | 181 -- .../random_compat/lib/cast_to_int.php | 75 - .../random_compat/lib/error_polyfill.php | 49 - .../paragonie/random_compat/lib/random.php | 223 -- .../lib/random_bytes_com_dotnet.php | 88 - .../lib/random_bytes_dev_urandom.php | 167 -- .../lib/random_bytes_libsodium.php | 88 - .../lib/random_bytes_libsodium_legacy.php | 92 - .../random_compat/lib/random_bytes_mcrypt.php | 77 - .../random_compat/lib/random_int.php | 190 -- .../random_compat/other/build_phar.php | 57 - .../random_compat/psalm-autoload.php | 9 - .../vendor/paragonie/random_compat/psalm.xml | 16 - lib/silex/vendor/pimple/pimple/.gitignore | 3 - lib/silex/vendor/pimple/pimple/.travis.yml | 40 - lib/silex/vendor/pimple/pimple/CHANGELOG | 59 - lib/silex/vendor/pimple/pimple/LICENSE | 19 - lib/silex/vendor/pimple/pimple/README.rst | 326 --- lib/silex/vendor/pimple/pimple/composer.json | 29 - .../pimple/pimple/ext/pimple/.gitignore | 30 - .../vendor/pimple/pimple/ext/pimple/README.md | 12 - .../vendor/pimple/pimple/ext/pimple/config.m4 | 63 - .../pimple/pimple/ext/pimple/config.w32 | 13 - .../pimple/pimple/ext/pimple/php_pimple.h | 137 - .../vendor/pimple/pimple/ext/pimple/pimple.c | 1114 -------- .../pimple/pimple/ext/pimple/pimple_compat.h | 81 - .../pimple/pimple/ext/pimple/tests/001.phpt | 45 - .../pimple/pimple/ext/pimple/tests/002.phpt | 15 - .../pimple/pimple/ext/pimple/tests/003.phpt | 16 - .../pimple/pimple/ext/pimple/tests/004.phpt | 30 - .../pimple/pimple/ext/pimple/tests/005.phpt | 27 - .../pimple/pimple/ext/pimple/tests/006.phpt | 51 - .../pimple/pimple/ext/pimple/tests/007.phpt | 22 - .../pimple/pimple/ext/pimple/tests/008.phpt | 29 - .../pimple/pimple/ext/pimple/tests/009.phpt | 13 - .../pimple/pimple/ext/pimple/tests/010.phpt | 45 - .../pimple/pimple/ext/pimple/tests/011.phpt | 19 - .../pimple/pimple/ext/pimple/tests/012.phpt | 28 - .../pimple/pimple/ext/pimple/tests/013.phpt | 33 - .../pimple/pimple/ext/pimple/tests/014.phpt | 30 - .../pimple/pimple/ext/pimple/tests/015.phpt | 17 - .../pimple/pimple/ext/pimple/tests/016.phpt | 24 - .../pimple/pimple/ext/pimple/tests/017.phpt | 17 - .../pimple/pimple/ext/pimple/tests/017_1.phpt | 17 - .../pimple/pimple/ext/pimple/tests/018.phpt | 23 - .../pimple/pimple/ext/pimple/tests/019.phpt | 18 - .../pimple/pimple/ext/pimple/tests/bench.phpb | 51 - .../pimple/ext/pimple/tests/bench_shared.phpb | 25 - lib/silex/vendor/pimple/pimple/lib/Pimple.php | 214 -- .../vendor/pimple/pimple/phpunit.xml.dist | 14 - .../pimple/pimple/src/Pimple/Container.php | 298 --- .../Exception/ExpectedInvokableException.php | 38 - .../Exception/FrozenServiceException.php | 45 - .../InvalidServiceIdentifierException.php | 45 - .../Exception/UnknownIdentifierException.php | 45 - .../pimple/src/Pimple/Psr11/Container.php | 55 - .../src/Pimple/Psr11/ServiceLocator.php | 75 - .../pimple/src/Pimple/ServiceIterator.php | 69 - .../src/Pimple/ServiceProviderInterface.php | 46 - .../src/Pimple/Tests/Fixtures/Invokable.php | 38 - .../Pimple/Tests/Fixtures/NonInvokable.php | 34 - .../Tests/Fixtures/PimpleServiceProvider.php | 54 - .../src/Pimple/Tests/Fixtures/Service.php | 35 - .../PimpleServiceProviderInterfaceTest.php | 76 - .../pimple/src/Pimple/Tests/PimpleTest.php | 589 ----- .../src/Pimple/Tests/Psr11/ContainerTest.php | 77 - .../Pimple/Tests/Psr11/ServiceLocatorTest.php | 134 - .../src/Pimple/Tests/ServiceIteratorTest.php | 52 - lib/silex/vendor/psr/container/.gitignore | 3 - lib/silex/vendor/psr/container/LICENSE | 21 - lib/silex/vendor/psr/container/README.md | 5 - lib/silex/vendor/psr/container/composer.json | 27 - .../src/ContainerExceptionInterface.php | 13 - .../psr/container/src/ContainerInterface.php | 37 - .../src/NotFoundExceptionInterface.php | 13 - lib/silex/vendor/psr/log/.gitignore | 1 - lib/silex/vendor/psr/log/LICENSE | 19 - .../vendor/psr/log/Psr/Log/AbstractLogger.php | 128 - .../log/Psr/Log/InvalidArgumentException.php | 7 - lib/silex/vendor/psr/log/Psr/Log/LogLevel.php | 18 - .../psr/log/Psr/Log/LoggerAwareInterface.php | 18 - .../psr/log/Psr/Log/LoggerAwareTrait.php | 26 - .../psr/log/Psr/Log/LoggerInterface.php | 123 - .../vendor/psr/log/Psr/Log/LoggerTrait.php | 140 - .../vendor/psr/log/Psr/Log/NullLogger.php | 28 - .../log/Psr/Log/Test/LoggerInterfaceTest.php | 140 - lib/silex/vendor/psr/log/README.md | 45 - lib/silex/vendor/psr/log/composer.json | 26 - lib/silex/vendor/silex/silex/.gitignore | 5 - lib/silex/vendor/silex/silex/.travis.yml | 60 - lib/silex/vendor/silex/silex/LICENSE | 19 - lib/silex/vendor/silex/silex/README.rst | 64 - lib/silex/vendor/silex/silex/bin/build | 67 - lib/silex/vendor/silex/silex/bin/compile | 9 - .../silex/bin/skeleton/fat_composer.json | 23 - .../vendor/silex/silex/bin/skeleton/index.php | 11 - .../silex/bin/skeleton/slim_composer.json | 5 - lib/silex/vendor/silex/silex/composer.json | 72 - .../vendor/silex/silex/doc/changelog.rst | 398 --- lib/silex/vendor/silex/silex/doc/conf.py | 17 - .../vendor/silex/silex/doc/contributing.rst | 34 - .../silex/silex/doc/cookbook/assets.rst | 66 - .../silex/doc/cookbook/error_handler.rst | 38 - .../silex/silex/doc/cookbook/form_no_csrf.rst | 36 - .../doc/cookbook/guard_authentication.rst | 183 -- .../vendor/silex/silex/doc/cookbook/index.rst | 40 - .../silex/doc/cookbook/json_request_body.rst | 95 - .../silex/doc/cookbook/multiple_loggers.rst | 69 - .../silex/doc/cookbook/session_storage.rst | 89 - .../silex/silex/doc/cookbook/sub_requests.rst | 137 - .../translating_validation_messages.rst | 20 - .../silex/doc/cookbook/validator_yaml.rst | 35 - lib/silex/vendor/silex/silex/doc/index.rst | 19 - .../vendor/silex/silex/doc/internals.rst | 84 - lib/silex/vendor/silex/silex/doc/intro.rst | 50 - .../vendor/silex/silex/doc/middlewares.rst | 162 -- .../silex/doc/organizing_controllers.rst | 84 - lib/silex/vendor/silex/silex/doc/phar.rst | 109 - .../vendor/silex/silex/doc/providers.rst | 262 -- .../silex/silex/doc/providers/asset.rst | 69 - .../vendor/silex/silex/doc/providers/csrf.rst | 53 - .../silex/silex/doc/providers/doctrine.rst | 137 - .../vendor/silex/silex/doc/providers/form.rst | 216 -- .../silex/silex/doc/providers/http_cache.rst | 128 - .../silex/doc/providers/http_fragment.rst | 70 - .../silex/silex/doc/providers/index.rst | 24 - .../silex/silex/doc/providers/locale.rst | 24 - .../silex/silex/doc/providers/monolog.rst | 115 - .../silex/silex/doc/providers/remember_me.rst | 69 - .../silex/silex/doc/providers/security.rst | 709 ----- .../silex/silex/doc/providers/serializer.rst | 85 - .../doc/providers/service_controller.rst | 142 - .../silex/silex/doc/providers/session.rst | 120 - .../silex/silex/doc/providers/swiftmailer.rst | 156 -- .../silex/silex/doc/providers/translation.rst | 193 -- .../vendor/silex/silex/doc/providers/twig.rst | 237 -- .../silex/doc/providers/url_generator.rst | 79 - .../silex/silex/doc/providers/validator.rst | 217 -- .../silex/silex/doc/providers/var_dumper.rst | 44 - lib/silex/vendor/silex/silex/doc/services.rst | 269 -- lib/silex/vendor/silex/silex/doc/testing.rst | 222 -- lib/silex/vendor/silex/silex/doc/usage.rst | 799 ------ .../vendor/silex/silex/doc/web_servers.rst | 184 -- lib/silex/vendor/silex/silex/exclude.txt | 5 - lib/silex/vendor/silex/silex/phpunit.xml.dist | 24 - .../Silex/Api/BootableProviderInterface.php | 33 - .../Silex/Api/ControllerProviderInterface.php | 32 - .../Api/EventListenerProviderInterface.php | 25 - .../vendor/silex/silex/src/Silex/Api/LICENSE | 19 - .../silex/silex/src/Silex/Api/composer.json | 34 - .../src/Silex/AppArgumentValueResolver.php | 47 - .../silex/silex/src/Silex/Application.php | 506 ---- .../silex/src/Silex/Application/FormTrait.php | 54 - .../src/Silex/Application/MonologTrait.php | 36 - .../src/Silex/Application/SecurityTrait.php | 53 - .../Silex/Application/SwiftmailerTrait.php | 33 - .../Silex/Application/TranslationTrait.php | 51 - .../silex/src/Silex/Application/TwigTrait.php | 65 - .../Silex/Application/UrlGeneratorTrait.php | 48 - .../silex/src/Silex/CallbackResolver.php | 78 - .../src/Silex/ConstraintValidatorFactory.php | 87 - .../silex/silex/src/Silex/Controller.php | 122 - .../silex/src/Silex/ControllerCollection.php | 240 -- .../src/Silex/ControllerProviderInterface.php | 29 - .../silex/src/Silex/ControllerResolver.php | 54 - .../Silex/EventListener/ConverterListener.php | 66 - .../Silex/EventListener/LocaleListener.php | 42 - .../src/Silex/EventListener/LogListener.php | 134 - .../EventListener/MiddlewareListener.php | 96 - .../StringToResponseListener.php | 51 - .../Exception/ControllerFrozenException.php | 21 - .../silex/src/Silex/ExceptionHandler.php | 56 - .../src/Silex/ExceptionListenerWrapper.php | 93 - .../silex/silex/src/Silex/HttpCache.php | 39 - .../silex/silex/src/Silex/LazyUrlMatcher.php | 69 - .../Silex/Provider/AssetServiceProvider.php | 97 - .../Silex/Provider/CsrfServiceProvider.php | 48 - .../Provider/DoctrineServiceProvider.php | 129 - .../ExceptionHandlerServiceProvider.php | 32 - .../Provider/Form/SilexFormExtension.php | 122 - .../Silex/Provider/FormServiceProvider.php | 89 - .../Silex/Provider/HttpCache/HttpCache.php | 39 - .../Provider/HttpCacheServiceProvider.php | 61 - .../Provider/HttpFragmentServiceProvider.php | 86 - .../Provider/HttpKernelServiceProvider.php | 101 - .../silex/silex/src/Silex/Provider/LICENSE | 19 - .../Silex/Provider/Locale/LocaleListener.php | 84 - .../Silex/Provider/LocaleServiceProvider.php | 40 - .../Silex/Provider/MonologServiceProvider.php | 146 -- .../Provider/RememberMeServiceProvider.php | 107 - .../Provider/Routing/LazyRequestMatcher.php | 55 - .../Routing/RedirectableUrlMatcher.php | 55 - .../Silex/Provider/RoutingServiceProvider.php | 87 - .../Provider/SecurityServiceProvider.php | 696 ----- .../Provider/SerializerServiceProvider.php | 50 - .../ServiceControllerServiceProvider.php | 26 - .../Provider/Session/SessionListener.php | 39 - .../Provider/Session/TestSessionListener.php | 39 - .../Silex/Provider/SessionServiceProvider.php | 86 - .../Provider/SwiftmailerServiceProvider.php | 140 - .../Provider/TranslationServiceProvider.php | 98 - .../src/Silex/Provider/Twig/RuntimeLoader.php | 41 - .../src/Silex/Provider/TwigCoreExtension.php | 56 - .../Silex/Provider/TwigServiceProvider.php | 199 -- .../Provider/UrlGeneratorServiceProvider.php | 37 - .../Validator/ConstraintValidatorFactory.php | 63 - .../Provider/ValidatorServiceProvider.php | 62 - .../Provider/VarDumperServiceProvider.php | 58 - .../silex/src/Silex/Provider/composer.json | 31 - .../src/Silex/RedirectableUrlMatcher.php | 55 - .../vendor/silex/silex/src/Silex/Route.php | 202 -- .../silex/src/Silex/Route/SecurityTrait.php | 31 - .../src/Silex/ServiceControllerResolver.php | 60 - .../src/Silex/ServiceProviderInterface.php | 37 - .../silex/silex/src/Silex/Translator.php | 48 - .../silex/silex/src/Silex/Util/Compiler.php | 188 -- .../silex/src/Silex/ViewListenerWrapper.php | 87 - .../silex/silex/src/Silex/WebTestCase.php | 65 - .../Tests/Application/FormApplication.php | 19 - .../Silex/Tests/Application/FormTraitTest.php | 45 - .../Tests/Application/MonologApplication.php | 19 - .../Tests/Application/MonologTraitTest.php | 48 - .../Tests/Application/SecurityApplication.php | 19 - .../Tests/Application/SecurityTraitTest.php | 91 - .../Application/SwiftmailerApplication.php | 19 - .../Application/SwiftmailerTraitTest.php | 45 - .../Application/TranslationApplication.php | 19 - .../Application/TranslationTraitTest.php | 47 - .../Tests/Application/TwigApplication.php | 19 - .../Silex/Tests/Application/TwigTraitTest.php | 81 - .../Application/UrlGeneratorApplication.php | 19 - .../Application/UrlGeneratorTraitTest.php | 39 - .../tests/Silex/Tests/ApplicationTest.php | 725 ----- .../Silex/Tests/CallbackResolverTest.php | 82 - .../Silex/Tests/CallbackServicesTest.php | 110 - .../Silex/Tests/ControllerCollectionTest.php | 345 --- .../Silex/Tests/ControllerResolverTest.php | 44 - .../tests/Silex/Tests/ControllerTest.php | 133 - .../Tests/EventListener/LogListenerTest.php | 94 - .../Silex/Tests/ExceptionHandlerTest.php | 404 --- .../Silex/Tests/Fixtures/Php7Controller.php | 22 - .../tests/Silex/Tests/Fixtures/manifest.json | 3 - .../tests/Silex/Tests/FunctionalTest.php | 59 - .../silex/tests/Silex/Tests/JsonTest.php | 57 - .../tests/Silex/Tests/LazyDispatcherTest.php | 60 - .../Silex/Tests/LazyRequestMatcherTest.php | 78 - .../tests/Silex/Tests/LazyUrlMatcherTest.php | 109 - .../silex/tests/Silex/Tests/LocaleTest.php | 84 - .../tests/Silex/Tests/MiddlewareTest.php | 308 --- .../Provider/AssetServiceProviderTest.php | 52 - .../Provider/DoctrineServiceProviderTest.php | 117 - .../Provider/FormServiceProviderTest.php | 363 --- .../DisableCsrfExtension.php | 22 - .../Provider/HttpCacheServiceProviderTest.php | 81 - .../HttpFragmentServiceProviderTest.php | 49 - .../Provider/MonologServiceProviderTest.php | 257 -- .../RememberMeServiceProviderTest.php | 107 - .../Provider/RoutingServiceProviderTest.php | 122 - .../Provider/SecurityServiceProviderTest.php | 491 ---- .../TokenAuthenticator.php | 79 - .../SerializerServiceProviderTest.php | 37 - .../Provider/SessionServiceProviderTest.php | 126 - .../tests/Silex/Tests/Provider/SpoolStub.php | 47 - .../SwiftmailerServiceProviderTest.php | 134 - .../TranslationServiceProviderTest.php | 182 -- .../Provider/TwigServiceProviderTest.php | 165 -- .../UrlGeneratorServiceProviderTest.php | 119 - .../Provider/ValidatorServiceProviderTest.php | 206 -- .../Constraint/Custom.php | 29 - .../Constraint/CustomValidator.php | 32 - .../tests/Silex/Tests/Route/SecurityRoute.php | 19 - .../Silex/Tests/Route/SecurityTraitTest.php | 86 - .../silex/tests/Silex/Tests/RouterTest.php | 286 -- .../ServiceControllerResolverRouterTest.php | 43 - .../Tests/ServiceControllerResolverTest.php | 98 - .../silex/tests/Silex/Tests/StreamTest.php | 53 - .../tests/Silex/Tests/WebTestCaseTest.php | 78 - .../vendor/silex/silex/tests/bootstrap.php | 10 - lib/silex/vendor/symfony/debug/.gitignore | 3 - .../vendor/symfony/debug/BufferingLogger.php | 37 - lib/silex/vendor/symfony/debug/CHANGELOG.md | 64 - lib/silex/vendor/symfony/debug/Debug.php | 63 - .../vendor/symfony/debug/DebugClassLoader.php | 409 --- .../vendor/symfony/debug/ErrorHandler.php | 758 ------ .../Exception/ClassNotFoundException.php | 33 - .../debug/Exception/ContextErrorException.php | 40 - .../debug/Exception/FatalErrorException.php | 82 - .../debug/Exception/FatalThrowableError.php | 44 - .../debug/Exception/FlattenException.php | 263 -- .../debug/Exception/OutOfMemoryException.php | 21 - .../debug/Exception/SilencedErrorContext.php | 67 - .../Exception/UndefinedFunctionException.php | 33 - .../Exception/UndefinedMethodException.php | 33 - .../vendor/symfony/debug/ExceptionHandler.php | 410 --- .../ClassNotFoundFatalErrorHandler.php | 206 -- .../FatalErrorHandlerInterface.php | 32 - .../UndefinedFunctionFatalErrorHandler.php | 84 - .../UndefinedMethodFatalErrorHandler.php | 66 - lib/silex/vendor/symfony/debug/LICENSE | 19 - lib/silex/vendor/symfony/debug/README.md | 13 - .../symfony/debug/Resources/ext/README.md | 134 - .../symfony/debug/Resources/ext/config.m4 | 63 - .../symfony/debug/Resources/ext/config.w32 | 13 - .../debug/Resources/ext/php_symfony_debug.h | 60 - .../debug/Resources/ext/symfony_debug.c | 283 -- .../debug/Resources/ext/tests/001.phpt | 155 -- .../debug/Resources/ext/tests/002.phpt | 65 - .../debug/Resources/ext/tests/002_1.phpt | 48 - .../debug/Resources/ext/tests/003.phpt | 87 - .../debug/Symfony/Component/Debug/.gitignore | 3 - .../Symfony/Component/Debug/CHANGELOG.md | 27 - .../debug/Symfony/Component/Debug/Debug.php | 62 - .../Component/Debug/DebugClassLoader.php | 224 -- .../Symfony/Component/Debug/ErrorHandler.php | 731 ------ .../Exception/ClassNotFoundException.php | 33 - .../Debug/Exception/ContextErrorException.php | 36 - .../Debug/Exception/DummyException.php | 21 - .../Debug/Exception/FatalErrorException.php | 94 - .../Debug/Exception/FatalThrowableError.php | 44 - .../Debug/Exception/FlattenException.php | 292 --- .../Debug/Exception/OutOfMemoryException.php | 21 - .../Exception/UndefinedFunctionException.php | 33 - .../Exception/UndefinedMethodException.php | 33 - .../Component/Debug/ExceptionHandler.php | 476 ---- .../ClassNotFoundFatalErrorHandler.php | 212 -- .../FatalErrorHandlerInterface.php | 32 - .../UndefinedFunctionFatalErrorHandler.php | 84 - .../UndefinedMethodFatalErrorHandler.php | 60 - .../debug/Symfony/Component/Debug/LICENSE | 19 - .../debug/Symfony/Component/Debug/README.md | 43 - .../Component/Debug/Resources/ext/README.rst | 72 - .../Component/Debug/Resources/ext/config.m4 | 63 - .../Component/Debug/Resources/ext/config.w32 | 13 - .../Debug/Resources/ext/php_symfony_debug.h | 55 - .../Debug/Resources/ext/symfony_debug.c | 224 -- .../Debug/Resources/ext/tests/001.phpt | 151 -- .../Debug/Tests/DebugClassLoaderTest.php | 205 -- .../Debug/Tests/ErrorHandlerTest.php | 485 ---- .../Tests/Exception/FlattenExceptionTest.php | 256 -- .../Debug/Tests/ExceptionHandlerTest.php | 116 - .../ClassNotFoundFatalErrorHandlerTest.php | 202 -- ...UndefinedFunctionFatalErrorHandlerTest.php | 80 - .../UndefinedMethodFatalErrorHandlerTest.php | 66 - .../Debug/Tests/Fixtures/ClassAlias.php | 3 - .../Debug/Tests/Fixtures/PEARClass.php | 5 - .../Debug/Tests/Fixtures/casemismatch.php | 7 - .../Debug/Tests/Fixtures/notPsr0Bis.php | 7 - .../Tests/Fixtures/psr4/Psr4CaseMismatch.php | 7 - .../Debug/Tests/Fixtures/reallyNotPsr0.php | 7 - .../Debug/Tests/Fixtures2/RequiredTwice.php | 7 - .../Debug/Tests/MockExceptionHandler.php | 24 - .../Symfony/Component/Debug/composer.json | 45 - .../debug/Symfony/Component/Debug/exclude.txt | 5 - .../Symfony/Component/Debug/phpunit.xml.dist | 27 - .../debug/Tests/DebugClassLoaderTest.php | 425 --- .../symfony/debug/Tests/ErrorHandlerTest.php | 548 ---- .../Tests/Exception/FlattenExceptionTest.php | 302 --- .../debug/Tests/ExceptionHandlerTest.php | 133 - .../ClassNotFoundFatalErrorHandlerTest.php | 176 -- ...UndefinedFunctionFatalErrorHandlerTest.php | 81 - .../UndefinedMethodFatalErrorHandlerTest.php | 76 - .../debug/Tests/Fixtures/AnnotatedClass.php | 13 - .../debug/Tests/Fixtures/ClassAlias.php | 3 - .../debug/Tests/Fixtures/DeprecatedClass.php | 12 - .../Tests/Fixtures/DeprecatedInterface.php | 12 - .../Tests/Fixtures/ExtendedFinalMethod.php | 17 - .../debug/Tests/Fixtures/FinalClass.php | 10 - .../debug/Tests/Fixtures/FinalMethod.php | 17 - .../debug/Tests/Fixtures/InternalClass.php | 15 - .../Tests/Fixtures/InternalInterface.php | 10 - .../debug/Tests/Fixtures/InternalTrait.php | 10 - .../debug/Tests/Fixtures/InternalTrait2.php | 23 - .../Tests/Fixtures/NonDeprecatedInterface.php | 7 - .../debug/Tests/Fixtures/PEARClass.php | 5 - .../symfony/debug/Tests/Fixtures/Throwing.php | 3 - .../debug/Tests/Fixtures/ToStringThrower.php | 24 - .../debug/Tests/Fixtures/casemismatch.php | 7 - .../debug/Tests/Fixtures/notPsr0Bis.php | 7 - .../Tests/Fixtures/psr4/Psr4CaseMismatch.php | 7 - .../debug/Tests/Fixtures/reallyNotPsr0.php | 7 - .../debug/Tests/Fixtures2/RequiredTwice.php | 7 - .../vendor/symfony/debug/Tests/HeaderMock.php | 38 - .../debug/Tests/MockExceptionHandler.php | 24 - .../debug/Tests/phpt/debug_class_loader.phpt | 26 - .../Tests/phpt/decorate_exception_hander.phpt | 47 - .../debug/Tests/phpt/exception_rethrown.phpt | 35 - .../phpt/fatal_with_nested_handlers.phpt | 42 - lib/silex/vendor/symfony/debug/composer.json | 40 - .../vendor/symfony/debug/phpunit.xml.dist | 33 - .../symfony/event-dispatcher/.gitignore | 3 - .../symfony/event-dispatcher/CHANGELOG.md | 42 - .../ContainerAwareEventDispatcher.php | 197 -- .../Debug/TraceableEventDispatcher.php | 322 --- .../TraceableEventDispatcherInterface.php | 36 - .../Debug/WrappedListener.php | 114 - .../RegisterListenersPass.php | 139 - .../vendor/symfony/event-dispatcher/Event.php | 58 - .../event-dispatcher/EventDispatcher.php | 236 -- .../EventDispatcherInterface.php | 93 - .../EventSubscriberInterface.php | 46 - .../symfony/event-dispatcher/GenericEvent.php | 175 -- .../ImmutableEventDispatcher.php | 91 - .../vendor/symfony/event-dispatcher/LICENSE | 19 - .../vendor/symfony/event-dispatcher/README.md | 15 - .../Component/EventDispatcher/.gitignore | 3 - .../Component/EventDispatcher/CHANGELOG.md | 23 - .../ContainerAwareEventDispatcher.php | 202 -- .../Debug/TraceableEventDispatcher.php | 335 --- .../TraceableEventDispatcherInterface.php | 34 - .../EventDispatcher/Debug/WrappedListener.php | 71 - .../RegisterListenersPass.php | 110 - .../Component/EventDispatcher/Event.php | 130 - .../EventDispatcher/EventDispatcher.php | 185 -- .../EventDispatcherInterface.php | 96 - .../EventSubscriberInterface.php | 50 - .../EventDispatcher/GenericEvent.php | 186 -- .../ImmutableEventDispatcher.php | 93 - .../Symfony/Component/EventDispatcher/LICENSE | 19 - .../Component/EventDispatcher/README.md | 27 - .../Tests/AbstractEventDispatcherTest.php | 369 --- .../ContainerAwareEventDispatcherTest.php | 249 -- .../Debug/TraceableEventDispatcherTest.php | 199 -- .../RegisterListenersPassTest.php | 200 -- .../Tests/EventDispatcherTest.php | 22 - .../EventDispatcher/Tests/EventTest.php | 100 - .../Tests/GenericEventTest.php | 139 - .../Tests/ImmutableEventDispatcherTest.php | 105 - .../Component/EventDispatcher/composer.json | 43 - .../Component/EventDispatcher/exclude.txt | 5 - .../EventDispatcher/phpunit.xml.dist | 28 - .../Tests/AbstractEventDispatcherTest.php | 442 ---- .../ContainerAwareEventDispatcherTest.php | 210 -- .../Debug/TraceableEventDispatcherTest.php | 257 -- .../RegisterListenersPassTest.php | 179 -- .../Tests/EventDispatcherTest.php | 22 - .../event-dispatcher/Tests/EventTest.php | 55 - .../Tests/GenericEventTest.php | 140 - .../Tests/ImmutableEventDispatcherTest.php | 106 - .../symfony/event-dispatcher/composer.json | 47 - .../symfony/event-dispatcher/phpunit.xml.dist | 31 - .../vendor/symfony/http-foundation/.gitignore | 3 - .../symfony/http-foundation/AcceptHeader.php | 168 -- .../http-foundation/AcceptHeaderItem.php | 209 -- .../symfony/http-foundation/ApacheRequest.php | 43 - .../http-foundation/BinaryFileResponse.php | 359 --- .../symfony/http-foundation/CHANGELOG.md | 159 -- .../vendor/symfony/http-foundation/Cookie.php | 289 -- .../Exception/ConflictingHeadersException.php | 21 - .../Exception/RequestExceptionInterface.php | 21 - .../SuspiciousOperationException.php | 20 - .../ExpressionRequestMatcher.php | 47 - .../File/Exception/AccessDeniedException.php | 28 - .../File/Exception/FileException.php | 21 - .../File/Exception/FileNotFoundException.php | 28 - .../Exception/UnexpectedTypeException.php | 20 - .../File/Exception/UploadException.php | 21 - .../symfony/http-foundation/File/File.php | 136 - .../File/MimeType/ExtensionGuesser.php | 94 - .../MimeType/ExtensionGuesserInterface.php | 27 - .../MimeType/FileBinaryMimeTypeGuesser.php | 85 - .../File/MimeType/FileinfoMimeTypeGuesser.php | 69 - .../MimeType/MimeTypeExtensionGuesser.php | 807 ------ .../File/MimeType/MimeTypeGuesser.php | 142 - .../MimeType/MimeTypeGuesserInterface.php | 35 - .../symfony/http-foundation/File/Stream.php | 28 - .../http-foundation/File/UploadedFile.php | 266 -- .../symfony/http-foundation/FileBag.php | 144 - .../symfony/http-foundation/HeaderBag.php | 331 --- .../symfony/http-foundation/IpUtils.php | 156 -- .../symfony/http-foundation/JsonResponse.php | 220 -- .../vendor/symfony/http-foundation/LICENSE | 19 - .../symfony/http-foundation/ParameterBag.php | 234 -- .../vendor/symfony/http-foundation/README.md | 14 - .../http-foundation/RedirectResponse.php | 109 - .../symfony/http-foundation/Request.php | 2154 --------------- .../http-foundation/RequestMatcher.php | 178 -- .../RequestMatcherInterface.php | 27 - .../symfony/http-foundation/RequestStack.php | 103 - .../symfony/http-foundation/Response.php | 1298 --------- .../http-foundation/ResponseHeaderBag.php | 340 --- .../symfony/http-foundation/ServerBag.php | 102 - .../Session/Attribute/AttributeBag.php | 148 -- .../Attribute/AttributeBagInterface.php | 72 - .../Attribute/NamespacedAttributeBag.php | 153 -- .../Session/Flash/AutoExpireFlashBag.php | 161 -- .../Session/Flash/FlashBag.php | 152 -- .../Session/Flash/FlashBagInterface.php | 93 - .../http-foundation/Session/Session.php | 273 -- .../Session/SessionBagInterface.php | 46 - .../Session/SessionBagProxy.php | 82 - .../Session/SessionInterface.php | 180 -- .../Handler/AbstractSessionHandler.php | 168 -- .../Handler/MemcacheSessionHandler.php | 120 - .../Handler/MemcachedSessionHandler.php | 122 - .../Storage/Handler/MongoDbSessionHandler.php | 255 -- .../Handler/NativeFileSessionHandler.php | 55 - .../Storage/Handler/NativeSessionHandler.php | 24 - .../Storage/Handler/NullSessionHandler.php | 76 - .../Storage/Handler/PdoSessionHandler.php | 812 ------ .../Storage/Handler/StrictSessionHandler.php | 103 - .../Handler/WriteCheckSessionHandler.php | 92 - .../Session/Storage/MetadataBag.php | 168 -- .../Storage/MockArraySessionStorage.php | 256 -- .../Storage/MockFileSessionStorage.php | 152 -- .../Session/Storage/NativeSessionStorage.php | 445 ---- .../Storage/PhpBridgeSessionStorage.php | 59 - .../Session/Storage/Proxy/AbstractProxy.php | 122 - .../Session/Storage/Proxy/NativeProxy.php | 40 - .../Storage/Proxy/SessionHandlerProxy.php | 85 - .../Storage/SessionStorageInterface.php | 137 - .../http-foundation/StreamedResponse.php | 144 - .../Component/HttpFoundation/.gitignore | 3 - .../Component/HttpFoundation/AcceptHeader.php | 172 -- .../HttpFoundation/AcceptHeaderItem.php | 226 -- .../HttpFoundation/ApacheRequest.php | 43 - .../HttpFoundation/BinaryFileResponse.php | 321 --- .../Component/HttpFoundation/CHANGELOG.md | 122 - .../Component/HttpFoundation/Cookie.php | 210 -- .../ExpressionRequestMatcher.php | 47 - .../File/Exception/AccessDeniedException.php | 30 - .../File/Exception/FileException.php | 21 - .../File/Exception/FileNotFoundException.php | 30 - .../Exception/UnexpectedTypeException.php | 20 - .../File/Exception/UploadException.php | 21 - .../Component/HttpFoundation/File/File.php | 160 -- .../File/MimeType/ExtensionGuesser.php | 96 - .../MimeType/ExtensionGuesserInterface.php | 27 - .../MimeType/FileBinaryMimeTypeGuesser.php | 87 - .../File/MimeType/FileinfoMimeTypeGuesser.php | 71 - .../MimeType/MimeTypeExtensionGuesser.php | 807 ------ .../File/MimeType/MimeTypeGuesser.php | 144 - .../MimeType/MimeTypeGuesserInterface.php | 35 - .../HttpFoundation/File/UploadedFile.php | 309 --- .../Component/HttpFoundation/FileBag.php | 155 -- .../Component/HttpFoundation/HeaderBag.php | 348 --- .../Component/HttpFoundation/IpUtils.php | 128 - .../Component/HttpFoundation/JsonResponse.php | 226 -- .../Symfony/Component/HttpFoundation/LICENSE | 19 - .../Component/HttpFoundation/ParameterBag.php | 319 --- .../Component/HttpFoundation/README.md | 56 - .../HttpFoundation/RedirectResponse.php | 106 - .../Component/HttpFoundation/Request.php | 1954 -------------- .../HttpFoundation/RequestMatcher.php | 182 -- .../RequestMatcherInterface.php | 33 - .../Component/HttpFoundation/RequestStack.php | 103 - .../stubs/SessionHandlerInterface.php | 102 - .../Component/HttpFoundation/Response.php | 1269 --------- .../HttpFoundation/ResponseHeaderBag.php | 322 --- .../Component/HttpFoundation/ServerBag.php | 98 - .../Session/Attribute/AttributeBag.php | 157 -- .../Attribute/AttributeBagInterface.php | 72 - .../Attribute/NamespacedAttributeBag.php | 160 -- .../Session/Flash/AutoExpireFlashBag.php | 175 -- .../HttpFoundation/Session/Flash/FlashBag.php | 180 -- .../Session/Flash/FlashBagInterface.php | 93 - .../HttpFoundation/Session/Session.php | 251 -- .../Session/SessionBagInterface.php | 48 - .../Session/SessionInterface.php | 208 -- .../Handler/LegacyPdoSessionHandler.php | 268 -- .../Handler/MemcacheSessionHandler.php | 119 - .../Handler/MemcachedSessionHandler.php | 125 - .../Storage/Handler/MongoDbSessionHandler.php | 188 -- .../Handler/NativeFileSessionHandler.php | 58 - .../Storage/Handler/NativeSessionHandler.php | 24 - .../Storage/Handler/NullSessionHandler.php | 72 - .../Storage/Handler/PdoSessionHandler.php | 695 ----- .../Handler/WriteCheckSessionHandler.php | 91 - .../Session/Storage/MetadataBag.php | 170 -- .../Storage/MockArraySessionStorage.php | 268 -- .../Storage/MockFileSessionStorage.php | 138 - .../Session/Storage/NativeSessionStorage.php | 420 --- .../Storage/PhpBridgeSessionStorage.php | 68 - .../Session/Storage/Proxy/AbstractProxy.php | 154 -- .../Session/Storage/Proxy/NativeProxy.php | 41 - .../Storage/Proxy/SessionHandlerProxy.php | 95 - .../Storage/SessionStorageInterface.php | 153 -- .../HttpFoundation/StreamedResponse.php | 123 - .../Tests/AcceptHeaderItemTest.php | 112 - .../HttpFoundation/Tests/AcceptHeaderTest.php | 102 - .../Tests/ApacheRequestTest.php | 92 - .../Tests/BinaryFileResponseTest.php | 250 -- .../HttpFoundation/Tests/ClockMock.php | 24 - .../HttpFoundation/Tests/CookieTest.php | 147 -- .../Tests/ExpressionRequestMatcherTest.php | 68 - .../HttpFoundation/Tests/File/FakeFile.php | 45 - .../HttpFoundation/Tests/File/FileTest.php | 182 -- .../Tests/File/Fixtures/directory/.empty | 0 .../Tests/File/Fixtures/other-file.example | 0 .../HttpFoundation/Tests/File/Fixtures/test | Bin 35 -> 0 bytes .../Tests/File/Fixtures/test.gif | Bin 35 -> 0 bytes .../Tests/File/MimeType/MimeTypeTest.php | 102 - .../Tests/File/UploadedFileTest.php | 272 -- .../HttpFoundation/Tests/FileBagTest.php | 148 -- .../HttpFoundation/Tests/HeaderBagTest.php | 216 -- .../HttpFoundation/Tests/IpUtilsTest.php | 84 - .../HttpFoundation/Tests/JsonResponseTest.php | 229 -- .../HttpFoundation/Tests/ParameterBagTest.php | 266 -- .../Tests/RedirectResponseTest.php | 83 - .../Tests/RequestMatcherTest.php | 150 -- .../HttpFoundation/Tests/RequestStackTest.php | 69 - .../HttpFoundation/Tests/RequestTest.php | 1826 ------------- .../Tests/ResponseHeaderBagTest.php | 297 --- .../HttpFoundation/Tests/ResponseTest.php | 874 ------- .../HttpFoundation/Tests/ResponseTestCase.php | 88 - .../HttpFoundation/Tests/ServerBagTest.php | 154 -- .../Session/Attribute/AttributeBagTest.php | 193 -- .../Attribute/NamespacedAttributeBagTest.php | 183 -- .../Session/Flash/AutoExpireFlashBagTest.php | 155 -- .../Tests/Session/Flash/FlashBagTest.php | 154 -- .../Tests/Session/SessionTest.php | 227 -- .../Handler/LegacyPdoSessionHandlerTest.php | 116 - .../Handler/MemcacheSessionHandlerTest.php | 132 - .../Handler/MemcachedSessionHandlerTest.php | 131 - .../Handler/MongoDbSessionHandlerTest.php | 255 -- .../Handler/NativeFileSessionHandlerTest.php | 81 - .../Handler/NativeSessionHandlerTest.php | 40 - .../Handler/NullSessionHandlerTest.php | 58 - .../Storage/Handler/PdoSessionHandlerTest.php | 359 --- .../Handler/WriteCheckSessionHandlerTest.php | 94 - .../Tests/Session/Storage/MetadataBagTest.php | 134 - .../Storage/MockArraySessionStorageTest.php | 106 - .../Storage/MockFileSessionStorageTest.php | 126 - .../Storage/NativeSessionStorageTest.php | 258 -- .../Storage/PhpBridgeSessionStorageTest.php | 123 - .../Storage/Proxy/AbstractProxyTest.php | 217 -- .../Session/Storage/Proxy/NativeProxyTest.php | 35 - .../Storage/Proxy/SessionHandlerProxyTest.php | 127 - .../Tests/StreamedResponseTest.php | 121 - .../Component/HttpFoundation/composer.json | 36 - .../Component/HttpFoundation/exclude.txt | 5 - .../Component/HttpFoundation/phpunit.xml.dist | 28 - .../Tests/AcceptHeaderItemTest.php | 113 - .../Tests/AcceptHeaderTest.php | 103 - .../Tests/ApacheRequestTest.php | 93 - .../Tests/BinaryFileResponseTest.php | 352 --- .../http-foundation/Tests/CookieTest.php | 223 -- .../Tests/ExpressionRequestMatcherTest.php | 69 - .../http-foundation/Tests/File/FakeFile.php | 45 - .../http-foundation/Tests/File/FileTest.php | 180 -- .../Tests/File/Fixtures/.unknownextension | 1 - .../Tests/File/Fixtures/directory/.empty | 0 .../Tests/File/Fixtures/other-file.example | 0 .../http-foundation/Tests/File/Fixtures/test | Bin 35 -> 0 bytes .../Tests/File/Fixtures/test.gif | Bin 35 -> 0 bytes .../Tests/File/MimeType/MimeTypeTest.php | 90 - .../Tests/File/UploadedFileTest.php | 273 -- .../http-foundation/Tests/FileBagTest.php | 175 -- .../http-foundation/Tests/HeaderBagTest.php | 205 -- .../http-foundation/Tests/IpUtilsTest.php | 104 - .../Tests/JsonResponseTest.php | 257 -- .../Tests/ParameterBagTest.php | 194 -- .../Tests/RedirectResponseTest.php | 97 - .../Tests/RequestMatcherTest.php | 151 -- .../Tests/RequestStackTest.php | 70 - .../http-foundation/Tests/RequestTest.php | 2329 ----------------- .../Tests/ResponseHeaderBagTest.php | 363 --- .../http-foundation/Tests/ResponseTest.php | 1003 ------- .../Tests/ResponseTestCase.php | 89 - .../http-foundation/Tests/ServerBagTest.php | 170 -- .../Session/Attribute/AttributeBagTest.php | 186 -- .../Attribute/NamespacedAttributeBagTest.php | 182 -- .../Session/Flash/AutoExpireFlashBagTest.php | 161 -- .../Tests/Session/Flash/FlashBagTest.php | 132 - .../Tests/Session/SessionTest.php | 242 -- .../Handler/AbstractSessionHandlerTest.php | 61 - .../Storage/Handler/Fixtures/common.inc | 151 -- .../Handler/Fixtures/empty_destroys.expected | 17 - .../Handler/Fixtures/empty_destroys.php | 8 - .../Handler/Fixtures/read_only.expected | 14 - .../Storage/Handler/Fixtures/read_only.php | 8 - .../Handler/Fixtures/regenerate.expected | 24 - .../Storage/Handler/Fixtures/regenerate.php | 10 - .../Storage/Handler/Fixtures/storage.expected | 20 - .../Storage/Handler/Fixtures/storage.php | 24 - .../Handler/Fixtures/with_cookie.expected | 15 - .../Storage/Handler/Fixtures/with_cookie.php | 8 - .../Fixtures/with_cookie_and_session.expected | 24 - .../Fixtures/with_cookie_and_session.php | 13 - .../Handler/MemcacheSessionHandlerTest.php | 135 - .../Handler/MemcachedSessionHandlerTest.php | 139 - .../Handler/MongoDbSessionHandlerTest.php | 333 --- .../Handler/NativeFileSessionHandlerTest.php | 77 - .../Handler/NativeSessionHandlerTest.php | 38 - .../Handler/NullSessionHandlerTest.php | 59 - .../Storage/Handler/PdoSessionHandlerTest.php | 376 --- .../Handler/StrictSessionHandlerTest.php | 189 -- .../Handler/WriteCheckSessionHandlerTest.php | 97 - .../Tests/Session/Storage/MetadataBagTest.php | 139 - .../Storage/MockArraySessionStorageTest.php | 131 - .../Storage/MockFileSessionStorageTest.php | 127 - .../Storage/NativeSessionStorageTest.php | 277 -- .../Storage/PhpBridgeSessionStorageTest.php | 96 - .../Storage/Proxy/AbstractProxyTest.php | 113 - .../Session/Storage/Proxy/NativeProxyTest.php | 38 - .../Storage/Proxy/SessionHandlerProxyTest.php | 124 - .../Tests/StreamedResponseTest.php | 126 - .../Tests/schema/http-status-codes.rng | 31 - .../Tests/schema/iana-registry.rng | 198 -- .../symfony/http-foundation/composer.json | 38 - .../symfony/http-foundation/phpunit.xml.dist | 31 - .../vendor/symfony/http-kernel/.gitignore | 5 - .../symfony/http-kernel/Bundle/Bundle.php | 229 -- .../http-kernel/Bundle/BundleInterface.php | 84 - .../vendor/symfony/http-kernel/CHANGELOG.md | 151 -- .../CacheClearer/CacheClearerInterface.php | 27 - .../CacheClearer/ChainCacheClearer.php | 56 - .../CacheClearer/Psr6CacheClearer.php | 58 - .../http-kernel/CacheWarmer/CacheWarmer.php | 32 - .../CacheWarmer/CacheWarmerAggregate.php | 90 - .../CacheWarmer/CacheWarmerInterface.php | 32 - .../CacheWarmer/WarmableInterface.php | 27 - .../vendor/symfony/http-kernel/Client.php | 205 -- .../Config/EnvParametersResource.php | 99 - .../http-kernel/Config/FileLocator.php | 54 - .../Controller/ArgumentResolver.php | 94 - .../ArgumentResolver/DefaultValueResolver.php | 40 - .../RequestAttributeValueResolver.php | 40 - .../ArgumentResolver/RequestValueResolver.php | 40 - .../ArgumentResolver/ServiceValueResolver.php | 58 - .../ArgumentResolver/SessionValueResolver.php | 46 - .../VariadicValueResolver.php | 48 - .../Controller/ArgumentResolverInterface.php | 35 - .../ArgumentValueResolverInterface.php | 43 - .../ContainerControllerResolver.php | 121 - .../Controller/ControllerReference.php | 44 - .../Controller/ControllerResolver.php | 258 -- .../ControllerResolverInterface.php | 57 - .../Controller/TraceableArgumentResolver.php | 44 - .../TraceableControllerResolver.php | 69 - .../ControllerMetadata/ArgumentMetadata.php | 115 - .../ArgumentMetadataFactory.php | 129 - .../ArgumentMetadataFactoryInterface.php | 27 - .../DataCollector/AjaxDataCollector.php | 38 - .../DataCollector/ConfigDataCollector.php | 332 --- .../DataCollector/DataCollector.php | 128 - .../DataCollector/DataCollectorInterface.php | 37 - .../DataCollector/DumpDataCollector.php | 315 --- .../DataCollector/EventDataCollector.php | 124 - .../DataCollector/ExceptionDataCollector.php | 112 - .../LateDataCollectorInterface.php | 25 - .../DataCollector/LoggerDataCollector.php | 278 -- .../DataCollector/MemoryDataCollector.php | 120 - .../DataCollector/RequestDataCollector.php | 404 --- .../DataCollector/RouterDataCollector.php | 108 - .../DataCollector/TimeDataCollector.php | 149 -- .../DataCollector/Util/ValueExporter.php | 99 - .../http-kernel/Debug/FileLinkFormatter.php | 88 - .../Debug/TraceableEventDispatcher.php | 82 - .../AddAnnotatedClassesToCachePass.php | 153 -- .../AddClassesToCachePass.php | 25 - .../ConfigurableExtension.php | 42 - .../ControllerArgumentValueResolverPass.php | 48 - .../DependencyInjection/Extension.php | 77 - .../FragmentRendererPass.php | 67 - .../LazyLoadingFragmentHandler.php | 79 - .../DependencyInjection/LoggerPass.php | 41 - .../MergeExtensionConfigurationPass.php | 41 - ...RegisterControllerArgumentLocatorsPass.php | 174 -- ...oveEmptyControllerArgumentLocatorsPass.php | 76 - .../ResettableServicePass.php | 66 - .../DependencyInjection/ServicesResetter.php | 39 - .../Event/FilterControllerArgumentsEvent.php | 52 - .../Event/FilterControllerEvent.php | 53 - .../http-kernel/Event/FilterResponseEvent.php | 55 - .../http-kernel/Event/FinishRequestEvent.php | 21 - .../http-kernel/Event/GetResponseEvent.php | 58 - .../GetResponseForControllerResultEvent.php | 61 - .../Event/GetResponseForExceptionEvent.php | 90 - .../symfony/http-kernel/Event/KernelEvent.php | 82 - .../http-kernel/Event/PostResponseEvent.php | 46 - .../EventListener/AbstractSessionListener.php | 76 - .../AbstractTestSessionListener.php | 89 - .../AddRequestFormatsListener.php | 50 - .../EventListener/DebugHandlersListener.php | 156 -- .../EventListener/DumpListener.php | 55 - .../EventListener/ExceptionListener.php | 129 - .../EventListener/FragmentListener.php | 99 - .../EventListener/LocaleListener.php | 83 - .../EventListener/ProfilerListener.php | 128 - .../EventListener/ResponseListener.php | 56 - .../EventListener/RouterListener.php | 171 -- .../EventListener/SaveSessionListener.php | 66 - .../EventListener/SessionListener.php | 40 - .../StreamedResponseListener.php | 49 - .../EventListener/SurrogateListener.php | 65 - .../EventListener/TestSessionListener.php | 40 - .../EventListener/TranslatorListener.php | 69 - .../EventListener/ValidateRequestListener.php | 53 - .../Exception/AccessDeniedHttpException.php | 29 - .../Exception/BadRequestHttpException.php | 28 - .../Exception/ConflictHttpException.php | 28 - .../Exception/GoneHttpException.php | 28 - .../http-kernel/Exception/HttpException.php | 51 - .../Exception/HttpExceptionInterface.php | 34 - .../Exception/LengthRequiredHttpException.php | 28 - .../MethodNotAllowedHttpException.php | 31 - .../Exception/NotAcceptableHttpException.php | 28 - .../Exception/NotFoundHttpException.php | 28 - .../PreconditionFailedHttpException.php | 28 - .../PreconditionRequiredHttpException.php | 30 - .../ServiceUnavailableHttpException.php | 34 - .../TooManyRequestsHttpException.php | 36 - .../Exception/UnauthorizedHttpException.php | 31 - .../UnprocessableEntityHttpException.php | 28 - .../UnsupportedMediaTypeHttpException.php | 28 - .../AbstractSurrogateFragmentRenderer.php | 110 - .../Fragment/EsiFragmentRenderer.php | 28 - .../http-kernel/Fragment/FragmentHandler.php | 112 - .../Fragment/FragmentRendererInterface.php | 42 - .../Fragment/HIncludeFragmentRenderer.php | 165 -- .../Fragment/InlineFragmentRenderer.php | 152 -- .../Fragment/RoutableFragmentRenderer.php | 90 - .../Fragment/SsiFragmentRenderer.php | 28 - .../HttpCache/AbstractSurrogate.php | 134 - .../symfony/http-kernel/HttpCache/Esi.php | 115 - .../http-kernel/HttpCache/HttpCache.php | 714 ----- .../HttpCache/ResponseCacheStrategy.php | 96 - .../ResponseCacheStrategyInterface.php | 37 - .../symfony/http-kernel/HttpCache/Ssi.php | 98 - .../symfony/http-kernel/HttpCache/Store.php | 485 ---- .../http-kernel/HttpCache/StoreInterface.php | 83 - .../HttpCache/SurrogateInterface.php | 92 - .../vendor/symfony/http-kernel/HttpKernel.php | 299 --- .../http-kernel/HttpKernelInterface.php | 43 - .../vendor/symfony/http-kernel/Kernel.php | 969 ------- .../symfony/http-kernel/KernelEvents.php | 103 - .../symfony/http-kernel/KernelInterface.php | 165 -- lib/silex/vendor/symfony/http-kernel/LICENSE | 19 - .../http-kernel/Log/DebugLoggerInterface.php | 40 - .../vendor/symfony/http-kernel/Log/Logger.php | 111 - .../Profiler/FileProfilerStorage.php | 292 --- .../symfony/http-kernel/Profiler/Profile.php | 287 -- .../symfony/http-kernel/Profiler/Profiler.php | 265 -- .../Profiler/ProfilerStorageInterface.php | 57 - .../vendor/symfony/http-kernel/README.md | 16 - .../http-kernel/RebootableInterface.php | 30 - .../http-kernel/Resources/welcome.html.php | 84 - .../Symfony/Component/HttpKernel/.gitignore | 5 - .../Component/HttpKernel/Bundle/Bundle.php | 215 -- .../HttpKernel/Bundle/BundleInterface.php | 102 - .../Symfony/Component/HttpKernel/CHANGELOG.md | 68 - .../CacheClearer/CacheClearerInterface.php | 27 - .../CacheClearer/ChainCacheClearer.php | 55 - .../HttpKernel/CacheWarmer/CacheWarmer.php | 32 - .../CacheWarmer/CacheWarmerAggregate.php | 74 - .../CacheWarmer/CacheWarmerInterface.php | 32 - .../CacheWarmer/WarmableInterface.php | 27 - .../Symfony/Component/HttpKernel/Client.php | 228 -- .../Config/EnvParametersResource.php | 95 - .../HttpKernel/Config/FileLocator.php | 56 - .../Controller/ControllerReference.php | 46 - .../Controller/ControllerResolver.php | 170 -- .../ControllerResolverInterface.php | 63 - .../TraceableControllerResolver.php | 66 - .../DataCollector/ConfigDataCollector.php | 245 -- .../DataCollector/DataCollector.php | 58 - .../DataCollector/DataCollectorInterface.php | 45 - .../DataCollector/DumpDataCollector.php | 298 --- .../DataCollector/EventDataCollector.php | 107 - .../DataCollector/ExceptionDataCollector.php | 104 - .../LateDataCollectorInterface.php | 25 - .../DataCollector/LoggerDataCollector.php | 164 -- .../DataCollector/MemoryDataCollector.php | 109 - .../DataCollector/RequestDataCollector.php | 338 --- .../DataCollector/RouterDataCollector.php | 102 - .../DataCollector/TimeDataCollector.php | 136 - .../DataCollector/Util/ValueExporter.php | 78 - .../HttpKernel/Debug/ErrorHandler.php | 25 - .../HttpKernel/Debug/ExceptionHandler.php | 25 - .../Debug/TraceableEventDispatcher.php | 98 - .../AddClassesToCachePass.php | 46 - .../ConfigurableExtension.php | 45 - .../ContainerAwareHttpKernel.php | 77 - .../DependencyInjection/Extension.php | 44 - .../MergeExtensionConfigurationPass.php | 41 - .../RegisterListenersPass.php | 23 - .../Event/FilterControllerEvent.php | 110 - .../HttpKernel/Event/FilterResponseEvent.php | 68 - .../HttpKernel/Event/FinishRequestEvent.php | 21 - .../HttpKernel/Event/GetResponseEvent.php | 73 - .../GetResponseForControllerResultEvent.php | 67 - .../Event/GetResponseForExceptionEvent.php | 73 - .../HttpKernel/Event/KernelEvent.php | 104 - .../HttpKernel/Event/PostResponseEvent.php | 73 - .../AddRequestFormatsListener.php | 57 - .../EventListener/DebugHandlersListener.php | 136 - .../HttpKernel/EventListener/DumpListener.php | 55 - .../EventListener/ErrorsLoggerListener.php | 51 - .../HttpKernel/EventListener/EsiListener.php | 23 - .../EventListener/ExceptionListener.php | 125 - .../EventListener/FragmentListener.php | 106 - .../EventListener/LocaleListener.php | 111 - .../EventListener/ProfilerListener.php | 158 -- .../EventListener/ResponseListener.php | 58 - .../EventListener/RouterListener.php | 169 -- .../EventListener/SaveSessionListener.php | 66 - .../EventListener/SessionListener.php | 53 - .../StreamedResponseListener.php | 51 - .../EventListener/SurrogateListener.php | 58 - .../EventListener/TestSessionListener.php | 83 - .../EventListener/TranslatorListener.php | 69 - .../Exception/AccessDeniedHttpException.php | 33 - .../Exception/BadRequestHttpException.php | 32 - .../Exception/ConflictHttpException.php | 32 - .../Exception/FatalErrorException.php | 21 - .../HttpKernel/Exception/FlattenException.php | 23 - .../Exception/GoneHttpException.php | 32 - .../HttpKernel/Exception/HttpException.php | 41 - .../Exception/HttpExceptionInterface.php | 34 - .../Exception/LengthRequiredHttpException.php | 32 - .../MethodNotAllowedHttpException.php | 35 - .../Exception/NotAcceptableHttpException.php | 32 - .../Exception/NotFoundHttpException.php | 32 - .../PreconditionFailedHttpException.php | 32 - .../PreconditionRequiredHttpException.php | 34 - .../ServiceUnavailableHttpException.php | 38 - .../TooManyRequestsHttpException.php | 40 - .../Exception/UnauthorizedHttpException.php | 35 - .../UnprocessableEntityHttpException.php | 32 - .../UnsupportedMediaTypeHttpException.php | 32 - .../AbstractSurrogateFragmentRenderer.php | 95 - .../Fragment/EsiFragmentRenderer.php | 28 - .../HttpKernel/Fragment/FragmentHandler.php | 148 -- .../Fragment/FragmentRendererInterface.php | 42 - .../Fragment/HIncludeFragmentRenderer.php | 164 -- .../Fragment/InlineFragmentRenderer.php | 152 -- .../Fragment/RoutableFragmentRenderer.php | 90 - .../Fragment/SsiFragmentRenderer.php | 28 - .../Component/HttpKernel/HttpCache/Esi.php | 290 -- .../HttpCache/EsiResponseCacheStrategy.php | 31 - .../EsiResponseCacheStrategyInterface.php | 28 - .../HttpKernel/HttpCache/HttpCache.php | 709 ----- .../HttpCache/ResponseCacheStrategy.php | 85 - .../ResponseCacheStrategyInterface.php | 41 - .../Component/HttpKernel/HttpCache/Ssi.php | 195 -- .../Component/HttpKernel/HttpCache/Store.php | 449 ---- .../HttpKernel/HttpCache/StoreInterface.php | 96 - .../HttpCache/SurrogateInterface.php | 103 - .../Component/HttpKernel/HttpKernel.php | 291 -- .../HttpKernel/HttpKernelInterface.php | 47 - .../Symfony/Component/HttpKernel/Kernel.php | 785 ------ .../Component/HttpKernel/KernelEvents.php | 127 - .../Component/HttpKernel/KernelInterface.php | 211 -- .../Symfony/Component/HttpKernel/LICENSE | 19 - .../HttpKernel/Log/DebugLoggerInterface.php | 38 - .../HttpKernel/Log/LoggerInterface.php | 54 - .../Component/HttpKernel/Log/NullLogger.php | 60 - .../Profiler/BaseMemcacheProfilerStorage.php | 306 --- .../Profiler/FileProfilerStorage.php | 278 -- .../Profiler/MemcacheProfilerStorage.php | 107 - .../Profiler/MemcachedProfilerStorage.php | 103 - .../Profiler/MongoDbProfilerStorage.php | 257 -- .../Profiler/MysqlProfilerStorage.php | 79 - .../Profiler/PdoProfilerStorage.php | 262 -- .../Component/HttpKernel/Profiler/Profile.php | 275 -- .../HttpKernel/Profiler/Profiler.php | 295 --- .../Profiler/ProfilerStorageInterface.php | 59 - .../Profiler/RedisProfilerStorage.php | 390 --- .../Profiler/SqliteProfilerStorage.php | 139 - .../Symfony/Component/HttpKernel/README.md | 99 - .../HttpKernel/TerminableInterface.php | 39 - .../HttpKernel/Tests/Bundle/BundleTest.php | 44 - .../CacheClearer/ChainCacheClearerTest.php | 57 - .../CacheWarmer/CacheWarmerAggregateTest.php | 100 - .../Tests/CacheWarmer/CacheWarmerTest.php | 67 - .../Component/HttpKernel/Tests/ClientTest.php | 179 -- .../Config/EnvParametersResourceTest.php | 106 - .../Tests/Config/FileLocatorTest.php | 47 - .../Controller/ControllerResolverTest.php | 242 -- .../DataCollector/ConfigDataCollectorTest.php | 80 - .../DataCollector/DumpDataCollectorTest.php | 138 - .../ExceptionDataCollectorTest.php | 39 - .../DataCollector/LoggerDataCollectorTest.php | 85 - .../DataCollector/MemoryDataCollectorTest.php | 58 - .../RequestDataCollectorTest.php | 222 -- .../DataCollector/TimeDataCollectorTest.php | 51 - .../DataCollector/Util/ValueExporterTest.php | 43 - .../Debug/TraceableEventDispatcherTest.php | 117 - .../ContainerAwareHttpKernelTest.php | 165 -- .../MergeExtensionConfigurationPassTest.php | 57 - .../AddRequestFormatsListenerTest.php | 83 - .../DebugHandlersListenerTest.php | 106 - .../Tests/EventListener/DumpListenerTest.php | 82 - .../EventListener/ExceptionListenerTest.php | 146 -- .../EventListener/FragmentListenerTest.php | 96 - .../EventListener/LocaleListenerTest.php | 103 - .../EventListener/ProfilerListenerTest.php | 107 - .../EventListener/ResponseListenerTest.php | 94 - .../EventListener/RouterListenerTest.php | 131 - .../EventListener/SurrogateListenerTest.php | 66 - .../EventListener/TestSessionListenerTest.php | 132 - .../EventListener/TranslatorListenerTest.php | 117 - .../Fixtures/BaseBundle/Resources/foo.txt | 0 .../Fixtures/BaseBundle/Resources/hide.txt | 0 .../Fixtures/Bundle1Bundle/Resources/foo.txt | 0 .../Tests/Fixtures/Bundle1Bundle/bar.txt | 0 .../Tests/Fixtures/Bundle1Bundle/foo.txt | 0 .../Tests/Fixtures/Bundle2Bundle/foo.txt | 0 .../Fixtures/ChildBundle/Resources/foo.txt | 0 .../Fixtures/ChildBundle/Resources/hide.txt | 0 .../ExtensionAbsentBundle.php | 18 - .../ExtensionLoadedExtension.php | 22 - .../ExtensionLoadedBundle.php | 18 - .../ExtensionNotValidExtension.php | 20 - .../ExtensionNotValidBundle.php | 18 - .../Command/BarCommand.php | 18 - .../Command/FooCommand.php | 22 - .../ExtensionPresentExtension.php | 22 - .../ExtensionPresentBundle.php | 18 - .../Tests/Fixtures/FooBarBundle.php | 19 - .../Tests/Fixtures/KernelForOverrideName.php | 28 - .../Tests/Fixtures/KernelForTest.php | 37 - .../Fixtures/Resources/BaseBundle/hide.txt | 0 .../Fixtures/Resources/Bundle1Bundle/foo.txt | 0 .../Fixtures/Resources/ChildBundle/foo.txt | 0 .../Fixtures/Resources/FooBundle/foo.txt | 0 .../HttpKernel/Tests/Fixtures/TestClient.php | 31 - .../Tests/Fixtures/TestEventDispatcher.php | 28 - .../Fragment/EsiFragmentRendererTest.php | 103 - .../Tests/Fragment/FragmentHandlerTest.php | 95 - .../Fragment/HIncludeFragmentRendererTest.php | 88 - .../Fragment/InlineFragmentRendererTest.php | 210 -- .../Fragment/RoutableFragmentRendererTest.php | 93 - .../HttpKernel/Tests/HttpCache/EsiTest.php | 225 -- .../Tests/HttpCache/HttpCacheTest.php | 1225 --------- .../Tests/HttpCache/HttpCacheTestCase.php | 176 -- .../HttpKernel/Tests/HttpCache/SsiTest.php | 214 -- .../HttpKernel/Tests/HttpCache/StoreTest.php | 269 -- .../Tests/HttpCache/TestHttpKernel.php | 91 - .../HttpCache/TestMultipleHttpKernel.php | 80 - .../HttpKernel/Tests/HttpKernelTest.php | 314 --- .../Component/HttpKernel/Tests/KernelTest.php | 850 ------ .../Component/HttpKernel/Tests/Logger.php | 128 - .../Profiler/AbstractProfilerStorageTest.php | 254 -- .../Profiler/FileProfilerStorageTest.php | 100 - .../Profiler/MemcacheProfilerStorageTest.php | 49 - .../Profiler/MemcachedProfilerStorageTest.php | 49 - .../Tests/Profiler/Mock/MemcacheMock.php | 254 -- .../Tests/Profiler/Mock/MemcachedMock.php | 219 -- .../Tests/Profiler/Mock/RedisMock.php | 247 -- .../Profiler/MongoDbProfilerStorageTest.php | 165 -- .../Tests/Profiler/ProfilerTest.php | 85 - .../Profiler/RedisProfilerStorageTest.php | 49 - .../Profiler/SqliteProfilerStorageTest.php | 50 - .../HttpKernel/Tests/TestHttpKernel.php | 41 - .../HttpKernel/Tests/UriSignerTest.php | 51 - .../Component/HttpKernel/UriSigner.php | 109 - .../Component/HttpKernel/composer.json | 62 - .../Symfony/Component/HttpKernel/exclude.txt | 5 - .../Component/HttpKernel/phpunit.xml.dist | 27 - .../http-kernel/TerminableInterface.php | 32 - .../http-kernel/Tests/Bundle/BundleTest.php | 104 - .../CacheClearer/ChainCacheClearerTest.php | 61 - .../CacheClearer/Psr6CacheClearerTest.php | 69 - .../CacheWarmer/CacheWarmerAggregateTest.php | 107 - .../Tests/CacheWarmer/CacheWarmerTest.php | 68 - .../symfony/http-kernel/Tests/ClientTest.php | 183 -- .../Config/EnvParametersResourceTest.php | 110 - .../Tests/Config/FileLocatorTest.php | 48 - .../ServiceValueResolverTest.php | 93 - .../Tests/Controller/ArgumentResolverTest.php | 349 --- .../ContainerControllerResolverTest.php | 308 --- .../Controller/ControllerResolverTest.php | 331 --- .../ArgumentMetadataFactoryTest.php | 148 -- .../ArgumentMetadataTest.php | 46 - .../Tests/DataCollector/Compiler.log | 4 - .../DataCollector/ConfigDataCollectorTest.php | 66 - .../Tests/DataCollector/DataCollectorTest.php | 38 - .../DataCollector/DumpDataCollectorTest.php | 115 - .../ExceptionDataCollectorTest.php | 59 - .../DataCollector/LoggerDataCollectorTest.php | 144 - .../DataCollector/MemoryDataCollectorTest.php | 59 - .../RequestDataCollectorTest.php | 334 --- .../DataCollector/TimeDataCollectorTest.php | 55 - .../DataCollector/Util/ValueExporterTest.php | 51 - .../Tests/Debug/FileLinkFormatterTest.php | 67 - .../Debug/TraceableEventDispatcherTest.php | 121 - .../AddAnnotatedClassesToCachePassTest.php | 99 - ...ontrollerArgumentValueResolverPassTest.php | 67 - .../FragmentRendererPassTest.php | 105 - .../LazyLoadingFragmentHandlerTest.php | 66 - .../DependencyInjection/LoggerPassTest.php | 56 - .../MergeExtensionConfigurationPassTest.php | 55 - ...sterControllerArgumentLocatorsPassTest.php | 389 --- ...mptyControllerArgumentLocatorsPassTest.php | 148 -- .../ResettableServicePassTest.php | 78 - .../ServicesResetterTest.php | 42 - .../FilterControllerArgumentsEventTest.php | 17 - .../GetResponseForExceptionEventTest.php | 27 - .../AddRequestFormatsListenerTest.php | 84 - .../DebugHandlersListenerTest.php | 155 -- .../Tests/EventListener/DumpListenerTest.php | 81 - .../EventListener/ExceptionListenerTest.php | 178 -- .../EventListener/FragmentListenerTest.php | 122 - .../EventListener/LocaleListenerTest.php | 102 - .../EventListener/ProfilerListenerTest.php | 71 - .../EventListener/ResponseListenerTest.php | 95 - .../EventListener/RouterListenerTest.php | 226 -- .../EventListener/SaveSessionListenerTest.php | 49 - .../EventListener/SessionListenerTest.php | 79 - .../EventListener/SurrogateListenerTest.php | 67 - .../EventListener/TestSessionListenerTest.php | 164 -- .../EventListener/TranslatorListenerTest.php | 118 - .../ValidateRequestListenerTest.php | 43 - .../AccessDeniedHttpExceptionTest.php | 13 - .../Exception/BadRequestHttpExceptionTest.php | 13 - .../Exception/ConflictHttpExceptionTest.php | 13 - .../Tests/Exception/GoneHttpExceptionTest.php | 13 - .../Tests/Exception/HttpExceptionTest.php | 53 - .../LengthRequiredHttpExceptionTest.php | 13 - .../MethodNotAllowedHttpExceptionTest.php | 24 - .../NotAcceptableHttpExceptionTest.php | 13 - .../Exception/NotFoundHttpExceptionTest.php | 13 - .../PreconditionFailedHttpExceptionTest.php | 13 - .../PreconditionRequiredHttpExceptionTest.php | 13 - .../ServiceUnavailableHttpExceptionTest.php | 29 - .../TooManyRequestsHttpExceptionTest.php | 29 - .../UnauthorizedHttpExceptionTest.php | 24 - .../UnprocessableEntityHttpExceptionTest.php | 28 - .../UnsupportedMediaTypeHttpExceptionTest.php | 23 - .../Tests/Fixtures/123/Kernel123.php | 37 - .../Fixtures/BaseBundle/Resources/foo.txt | 0 .../Fixtures/BaseBundle/Resources/hide.txt | 0 .../Fixtures/Bundle1Bundle/Resources/foo.txt | 0 .../Tests/Fixtures/Bundle1Bundle/bar.txt | 0 .../Tests/Fixtures/Bundle1Bundle/foo.txt | 0 .../Tests/Fixtures/Bundle2Bundle/foo.txt | 0 .../Fixtures/ChildBundle/Resources/foo.txt | 0 .../Fixtures/ChildBundle/Resources/hide.txt | 0 .../Tests/Fixtures/ClearableService.php | 13 - .../Controller/BasicTypesController.php | 19 - .../Fixtures/Controller/ExtendingRequest.php | 18 - .../Fixtures/Controller/ExtendingSession.php | 18 - .../Controller/NullableController.php | 19 - .../Controller/VariadicController.php | 19 - .../DataCollector/CloneVarDataCollector.php | 46 - .../ExtensionAbsentBundle.php | 18 - .../ExtensionLoadedExtension.php | 22 - .../ExtensionLoadedBundle.php | 18 - .../ExtensionNotValidExtension.php | 20 - .../ExtensionNotValidBundle.php | 18 - .../Command/BarCommand.php | 17 - .../Command/FooCommand.php | 22 - .../ExtensionPresentExtension.php | 22 - .../ExtensionPresentBundle.php | 18 - .../Tests/Fixtures/KernelForOverrideName.php | 28 - .../Tests/Fixtures/KernelForTest.php | 37 - .../Tests/Fixtures/KernelWithoutBundles.php | 33 - .../Tests/Fixtures/ResettableService.php | 13 - .../Fixtures/Resources/BaseBundle/hide.txt | 0 .../Fixtures/Resources/Bundle1Bundle/foo.txt | 0 .../Fixtures/Resources/ChildBundle/foo.txt | 0 .../Fixtures/Resources/FooBundle/foo.txt | 0 .../http-kernel/Tests/Fixtures/TestClient.php | 31 - .../Tests/Fixtures/TestEventDispatcher.php | 32 - .../Fragment/EsiFragmentRendererTest.php | 118 - .../Tests/Fragment/FragmentHandlerTest.php | 99 - .../Fragment/HIncludeFragmentRendererTest.php | 89 - .../Fragment/InlineFragmentRendererTest.php | 250 -- .../Fragment/RoutableFragmentRendererTest.php | 94 - .../Fragment/SsiFragmentRendererTest.php | 97 - .../http-kernel/Tests/HttpCache/EsiTest.php | 248 -- .../Tests/HttpCache/HttpCacheTest.php | 1482 ----------- .../Tests/HttpCache/HttpCacheTestCase.php | 185 -- .../HttpCache/ResponseCacheStrategyTest.php | 222 -- .../http-kernel/Tests/HttpCache/SsiTest.php | 215 -- .../http-kernel/Tests/HttpCache/StoreTest.php | 301 --- .../Tests/HttpCache/TestHttpKernel.php | 92 - .../HttpCache/TestMultipleHttpKernel.php | 81 - .../http-kernel/Tests/HttpKernelTest.php | 403 --- .../symfony/http-kernel/Tests/KernelTest.php | 1060 -------- .../http-kernel/Tests/Log/LoggerTest.php | 212 -- .../symfony/http-kernel/Tests/Logger.php | 88 - .../Profiler/FileProfilerStorageTest.php | 350 --- .../Tests/Profiler/ProfilerTest.php | 105 - .../http-kernel/Tests/TestHttpKernel.php | 42 - .../http-kernel/Tests/UriSignerTest.php | 64 - .../vendor/symfony/http-kernel/UriSigner.php | 106 - .../vendor/symfony/http-kernel/composer.json | 72 - .../symfony/http-kernel/phpunit.xml.dist | 40 - .../vendor/symfony/polyfill-mbstring/LICENSE | 19 - .../symfony/polyfill-mbstring/Mbstring.php | 664 ----- .../symfony/polyfill-mbstring/README.md | 13 - .../Resources/unidata/lowerCase.php | 1101 -------- .../Resources/unidata/upperCase.php | 1109 -------- .../symfony/polyfill-mbstring/bootstrap.php | 56 - .../symfony/polyfill-mbstring/composer.json | 34 - .../vendor/symfony/polyfill-php70/LICENSE | 19 - .../vendor/symfony/polyfill-php70/Php70.php | 74 - .../vendor/symfony/polyfill-php70/README.md | 28 - .../Resources/stubs/ArithmeticError.php | 5 - .../Resources/stubs/AssertionError.php | 5 - .../Resources/stubs/DivisionByZeroError.php | 5 - .../polyfill-php70/Resources/stubs/Error.php | 5 - .../Resources/stubs/ParseError.php | 5 - ...SessionUpdateTimestampHandlerInterface.php | 23 - .../Resources/stubs/TypeError.php | 5 - .../symfony/polyfill-php70/bootstrap.php | 27 - .../symfony/polyfill-php70/composer.json | 33 - lib/silex/vendor/symfony/routing/.gitignore | 3 - .../symfony/routing/Annotation/Route.php | 144 - lib/silex/vendor/symfony/routing/CHANGELOG.md | 228 -- .../vendor/symfony/routing/CompiledRoute.php | 169 -- .../RoutingResolverPass.php | 49 - .../routing/Exception/ExceptionInterface.php | 21 - .../Exception/InvalidParameterException.php | 21 - .../Exception/MethodNotAllowedException.php | 41 - .../MissingMandatoryParametersException.php | 22 - .../Exception/NoConfigurationException.php | 21 - .../Exception/ResourceNotFoundException.php | 23 - .../Exception/RouteNotFoundException.php | 21 - .../ConfigurableRequirementsInterface.php | 55 - .../Generator/Dumper/GeneratorDumper.php | 37 - .../Dumper/GeneratorDumperInterface.php | 39 - .../Generator/Dumper/PhpGeneratorDumper.php | 118 - .../routing/Generator/UrlGenerator.php | 321 --- .../Generator/UrlGeneratorInterface.php | 86 - lib/silex/vendor/symfony/routing/LICENSE | 19 - .../routing/Loader/AnnotationClassLoader.php | 269 -- .../Loader/AnnotationDirectoryLoader.php | 93 - .../routing/Loader/AnnotationFileLoader.php | 142 - .../symfony/routing/Loader/ClosureLoader.php | 46 - .../Configurator/CollectionConfigurator.php | 79 - .../Configurator/ImportConfigurator.php | 49 - .../Loader/Configurator/RouteConfigurator.php | 31 - .../Configurator/RoutingConfigurator.php | 54 - .../Loader/Configurator/Traits/AddTrait.php | 54 - .../Loader/Configurator/Traits/RouteTrait.php | 131 - .../ServiceRouterLoader.php | 40 - .../routing/Loader/DirectoryLoader.php | 58 - .../routing/Loader/ObjectRouteLoader.php | 95 - .../symfony/routing/Loader/PhpFileLoader.php | 75 - .../symfony/routing/Loader/XmlFileLoader.php | 352 --- .../symfony/routing/Loader/YamlFileLoader.php | 226 -- .../Loader/schema/routing/routing-1.0.xsd | 148 -- .../Matcher/Dumper/DumperCollection.php | 159 -- .../routing/Matcher/Dumper/DumperRoute.php | 57 - .../routing/Matcher/Dumper/MatcherDumper.php | 37 - .../Matcher/Dumper/MatcherDumperInterface.php | 39 - .../Matcher/Dumper/PhpMatcherDumper.php | 441 ---- .../Matcher/Dumper/StaticPrefixCollection.php | 238 -- .../Matcher/RedirectableUrlMatcher.php | 65 - .../RedirectableUrlMatcherInterface.php | 31 - .../Matcher/RequestMatcherInterface.php | 39 - .../routing/Matcher/TraceableUrlMatcher.php | 141 - .../symfony/routing/Matcher/UrlMatcher.php | 250 -- .../routing/Matcher/UrlMatcherInterface.php | 41 - lib/silex/vendor/symfony/routing/README.md | 13 - .../vendor/symfony/routing/RequestContext.php | 336 --- .../routing/RequestContextAwareInterface.php | 27 - lib/silex/vendor/symfony/routing/Route.php | 558 ---- .../symfony/routing/RouteCollection.php | 280 -- .../routing/RouteCollectionBuilder.php | 380 --- .../vendor/symfony/routing/RouteCompiler.php | 316 --- .../routing/RouteCompilerInterface.php | 30 - lib/silex/vendor/symfony/routing/Router.php | 384 --- .../symfony/routing/RouterInterface.php | 32 - .../Symfony/Component/Routing/.gitignore | 3 - .../Component/Routing/Annotation/Route.php | 162 -- .../Symfony/Component/Routing/CHANGELOG.md | 177 -- .../Component/Routing/CompiledRoute.php | 166 -- .../Routing/Exception/ExceptionInterface.php | 23 - .../Exception/InvalidParameterException.php | 23 - .../Exception/MethodNotAllowedException.php | 46 - .../MissingMandatoryParametersException.php | 24 - .../Exception/ResourceNotFoundException.php | 25 - .../Exception/RouteNotFoundException.php | 23 - .../ConfigurableRequirementsInterface.php | 55 - .../Generator/Dumper/GeneratorDumper.php | 45 - .../Dumper/GeneratorDumperInterface.php | 41 - .../Generator/Dumper/PhpGeneratorDumper.php | 124 - .../Routing/Generator/UrlGenerator.php | 340 --- .../Generator/UrlGeneratorInterface.php | 88 - .../routing/Symfony/Component/Routing/LICENSE | 19 - .../Routing/Loader/AnnotationClassLoader.php | 268 -- .../Loader/AnnotationDirectoryLoader.php | 77 - .../Routing/Loader/AnnotationFileLoader.php | 121 - .../Routing/Loader/ClosureLoader.php | 52 - .../Routing/Loader/PhpFileLoader.php | 72 - .../Routing/Loader/XmlFileLoader.php | 256 -- .../Routing/Loader/YamlFileLoader.php | 217 -- .../Loader/schema/routing/routing-1.0.xsd | 65 - .../Routing/Matcher/ApacheUrlMatcher.php | 122 - .../Matcher/Dumper/ApacheMatcherDumper.php | 281 -- .../Matcher/Dumper/DumperCollection.php | 159 -- .../Matcher/Dumper/DumperPrefixCollection.php | 105 - .../Routing/Matcher/Dumper/DumperRoute.php | 64 - .../Routing/Matcher/Dumper/MatcherDumper.php | 45 - .../Matcher/Dumper/MatcherDumperInterface.php | 39 - .../Matcher/Dumper/PhpMatcherDumper.php | 412 --- .../Matcher/RedirectableUrlMatcher.php | 67 - .../RedirectableUrlMatcherInterface.php | 35 - .../Matcher/RequestMatcherInterface.php | 39 - .../Routing/Matcher/TraceableUrlMatcher.php | 131 - .../Component/Routing/Matcher/UrlMatcher.php | 255 -- .../Routing/Matcher/UrlMatcherInterface.php | 43 - .../Symfony/Component/Routing/README.md | 36 - .../Component/Routing/RequestContext.php | 364 --- .../Routing/RequestContextAwareInterface.php | 36 - .../Symfony/Component/Routing/Route.php | 655 ----- .../Component/Routing/RouteCollection.php | 285 -- .../Component/Routing/RouteCompiler.php | 229 -- .../Routing/RouteCompilerInterface.php | 32 - .../Symfony/Component/Routing/Router.php | 346 --- .../Component/Routing/RouterInterface.php | 32 - .../Routing/Tests/Annotation/RouteTest.php | 60 - .../Routing/Tests/CompiledRouteTest.php | 26 - .../AnnotatedClasses/AbstractClass.php | 16 - .../Fixtures/AnnotatedClasses/BarClass.php | 19 - .../Fixtures/AnnotatedClasses/FooClass.php | 16 - .../Tests/Fixtures/CustomXmlFileLoader.php | 26 - .../Tests/Fixtures/RedirectableUrlMatcher.php | 30 - .../Routing/Tests/Fixtures/annotated.php | 0 .../Tests/Fixtures/dumper/url_matcher1.apache | 163 -- .../Tests/Fixtures/dumper/url_matcher1.php | 312 --- .../Tests/Fixtures/dumper/url_matcher2.apache | 7 - .../Tests/Fixtures/dumper/url_matcher2.php | 344 --- .../Tests/Fixtures/dumper/url_matcher3.php | 50 - .../Routing/Tests/Fixtures/empty.yml | 0 .../Component/Routing/Tests/Fixtures/foo.xml | 0 .../Component/Routing/Tests/Fixtures/foo1.xml | 0 .../Routing/Tests/Fixtures/incomplete.yml | 2 - .../Routing/Tests/Fixtures/missing_id.xml | 8 - .../Routing/Tests/Fixtures/missing_path.xml | 8 - .../Tests/Fixtures/namespaceprefix.xml | 13 - .../Fixtures/nonesense_resource_plus_path.yml | 3 - .../nonesense_type_without_resource.yml | 3 - .../Routing/Tests/Fixtures/nonvalid.xml | 11 - .../Routing/Tests/Fixtures/nonvalid.yml | 1 - .../Routing/Tests/Fixtures/nonvalid2.yml | 1 - .../Routing/Tests/Fixtures/nonvalidkeys.yml | 3 - .../Routing/Tests/Fixtures/nonvalidnode.xml | 8 - .../Routing/Tests/Fixtures/nonvalidroute.xml | 13 - .../Routing/Tests/Fixtures/null_values.xml | 12 - .../Tests/Fixtures/special_route_name.yml | 2 - .../Routing/Tests/Fixtures/validpattern.php | 28 - .../Routing/Tests/Fixtures/validpattern.xml | 25 - .../Routing/Tests/Fixtures/validpattern.yml | 22 - .../Routing/Tests/Fixtures/validresource.php | 18 - .../Routing/Tests/Fixtures/validresource.xml | 13 - .../Routing/Tests/Fixtures/validresource.yml | 8 - .../Fixtures/with_define_path_variable.php | 5 - .../Routing/Tests/Fixtures/withdoctype.xml | 3 - .../Dumper/PhpGeneratorDumperTest.php | 150 -- .../Tests/Generator/UrlGeneratorTest.php | 678 ----- .../Loader/AbstractAnnotationLoaderTest.php | 31 - .../Loader/AnnotationClassLoaderTest.php | 158 -- .../Loader/AnnotationDirectoryLoaderTest.php | 53 - .../Tests/Loader/AnnotationFileLoaderTest.php | 47 - .../Tests/Loader/ClosureLoaderTest.php | 48 - .../Tests/Loader/PhpFileLoaderTest.php | 82 - .../Tests/Loader/XmlFileLoaderTest.php | 138 - .../Tests/Loader/YamlFileLoaderTest.php | 108 - .../Matcher/Dumper/DumperCollectionTest.php | 33 - .../Dumper/DumperPrefixCollectionTest.php | 123 - .../Dumper/LegacyApacheMatcherDumperTest.php | 204 -- .../Matcher/Dumper/PhpMatcherDumperTest.php | 264 -- .../Matcher/LegacyApacheUrlMatcherTest.php | 156 -- .../Matcher/RedirectableUrlMatcherTest.php | 86 - .../Tests/Matcher/TraceableUrlMatcherTest.php | 101 - .../Routing/Tests/Matcher/UrlMatcherTest.php | 429 --- .../Routing/Tests/RequestContextTest.php | 159 -- .../Routing/Tests/RouteCollectionTest.php | 304 --- .../Routing/Tests/RouteCompilerTest.php | 253 -- .../Component/Routing/Tests/RouteTest.php | 280 -- .../Component/Routing/Tests/RouterTest.php | 161 -- .../Symfony/Component/Routing/composer.json | 47 - .../Symfony/Component/Routing/exclude.txt | 5 - .../Component/Routing/phpunit.xml.dist | 27 - .../routing/Tests/Annotation/RouteTest.php | 50 - .../routing/Tests/CompiledRouteTest.php | 27 - .../RoutingResolverPassTest.php | 36 - .../AnnotatedClasses/AbstractClass.php | 16 - .../Fixtures/AnnotatedClasses/BarClass.php | 19 - .../Fixtures/AnnotatedClasses/BazClass.php | 19 - .../Fixtures/AnnotatedClasses/FooClass.php | 16 - .../Fixtures/AnnotatedClasses/FooTrait.php | 13 - .../Tests/Fixtures/CustomCompiledRoute.php | 18 - .../Tests/Fixtures/CustomRouteCompiler.php | 26 - .../Tests/Fixtures/CustomXmlFileLoader.php | 26 - .../AnonymousClassInTrait.php | 24 - .../OtherAnnotatedClasses/NoStartTagClass.php | 3 - .../OtherAnnotatedClasses/VariadicClass.php | 19 - .../Tests/Fixtures/RedirectableUrlMatcher.php | 30 - .../routing/Tests/Fixtures/annotated.php | 0 .../routing/Tests/Fixtures/bad_format.yml | 3 - .../symfony/routing/Tests/Fixtures/bar.xml | 0 .../controller/import__controller.xml | 10 - .../controller/import__controller.yml | 4 - .../Fixtures/controller/import_controller.xml | 8 - .../Fixtures/controller/import_controller.yml | 3 - .../controller/import_override_defaults.xml | 10 - .../controller/import_override_defaults.yml | 5 - .../Fixtures/controller/override_defaults.xml | 10 - .../Fixtures/controller/override_defaults.yml | 5 - .../Tests/Fixtures/controller/routing.xml | 14 - .../Tests/Fixtures/controller/routing.yml | 11 - .../Fixtures/directory/recurse/routes1.yml | 2 - .../Fixtures/directory/recurse/routes2.yml | 2 - .../Tests/Fixtures/directory/routes3.yml | 2 - .../Fixtures/directory_import/import.yml | 3 - .../Tests/Fixtures/dumper/url_matcher0.php | 39 - .../Tests/Fixtures/dumper/url_matcher1.php | 312 --- .../Tests/Fixtures/dumper/url_matcher2.php | 349 --- .../Tests/Fixtures/dumper/url_matcher3.php | 53 - .../Tests/Fixtures/dumper/url_matcher4.php | 104 - .../Tests/Fixtures/dumper/url_matcher5.php | 162 -- .../Tests/Fixtures/dumper/url_matcher6.php | 199 -- .../Tests/Fixtures/dumper/url_matcher7.php | 229 -- .../symfony/routing/Tests/Fixtures/empty.yml | 0 .../routing/Tests/Fixtures/file_resource.yml | 0 .../symfony/routing/Tests/Fixtures/foo.xml | 0 .../symfony/routing/Tests/Fixtures/foo1.xml | 0 .../routing/Tests/Fixtures/incomplete.yml | 2 - .../routing/Tests/Fixtures/list_defaults.xml | 20 - .../Tests/Fixtures/list_in_list_defaults.xml | 22 - .../Tests/Fixtures/list_in_map_defaults.xml | 22 - .../Tests/Fixtures/list_null_values.xml | 22 - .../routing/Tests/Fixtures/map_defaults.xml | 20 - .../Tests/Fixtures/map_in_list_defaults.xml | 22 - .../Tests/Fixtures/map_in_map_defaults.xml | 22 - .../Tests/Fixtures/map_null_values.xml | 22 - .../routing/Tests/Fixtures/missing_id.xml | 8 - .../routing/Tests/Fixtures/missing_path.xml | 8 - .../Tests/Fixtures/namespaceprefix.xml | 16 - .../Fixtures/nonesense_resource_plus_path.yml | 3 - .../nonesense_type_without_resource.yml | 3 - .../routing/Tests/Fixtures/nonvalid.xml | 10 - .../routing/Tests/Fixtures/nonvalid.yml | 1 - .../routing/Tests/Fixtures/nonvalid2.yml | 1 - .../routing/Tests/Fixtures/nonvalidkeys.yml | 3 - .../routing/Tests/Fixtures/nonvalidnode.xml | 8 - .../routing/Tests/Fixtures/nonvalidroute.xml | 12 - .../routing/Tests/Fixtures/null_values.xml | 12 - .../routing/Tests/Fixtures/php_dsl.php | 21 - .../routing/Tests/Fixtures/php_dsl_sub.php | 14 - .../Tests/Fixtures/scalar_defaults.xml | 33 - .../Tests/Fixtures/special_route_name.yml | 2 - .../routing/Tests/Fixtures/validpattern.php | 18 - .../routing/Tests/Fixtures/validpattern.xml | 15 - .../routing/Tests/Fixtures/validpattern.yml | 13 - .../routing/Tests/Fixtures/validresource.php | 18 - .../routing/Tests/Fixtures/validresource.xml | 13 - .../routing/Tests/Fixtures/validresource.yml | 8 - .../Fixtures/with_define_path_variable.php | 5 - .../routing/Tests/Fixtures/withdoctype.xml | 3 - .../Dumper/PhpGeneratorDumperTest.php | 181 -- .../Tests/Generator/UrlGeneratorTest.php | 724 ----- .../Loader/AbstractAnnotationLoaderTest.php | 33 - .../Loader/AnnotationClassLoaderTest.php | 255 -- .../Loader/AnnotationDirectoryLoaderTest.php | 98 - .../Tests/Loader/AnnotationFileLoaderTest.php | 91 - .../Tests/Loader/ClosureLoaderTest.php | 49 - .../Tests/Loader/DirectoryLoaderTest.php | 74 - .../Tests/Loader/ObjectRouteLoaderTest.php | 123 - .../Tests/Loader/PhpFileLoaderTest.php | 120 - .../Tests/Loader/XmlFileLoaderTest.php | 364 --- .../Tests/Loader/YamlFileLoaderTest.php | 185 -- .../Matcher/Dumper/DumperCollectionTest.php | 34 - .../Matcher/Dumper/PhpMatcherDumperTest.php | 459 ---- .../Dumper/StaticPrefixCollectionTest.php | 175 -- .../Matcher/RedirectableUrlMatcherTest.php | 111 - .../Tests/Matcher/TraceableUrlMatcherTest.php | 122 - .../routing/Tests/Matcher/UrlMatcherTest.php | 441 ---- .../routing/Tests/RequestContextTest.php | 160 -- .../Tests/RouteCollectionBuilderTest.php | 364 --- .../routing/Tests/RouteCollectionTest.php | 305 --- .../routing/Tests/RouteCompilerTest.php | 389 --- .../symfony/routing/Tests/RouteTest.php | 258 -- .../symfony/routing/Tests/RouterTest.php | 162 -- .../vendor/symfony/routing/composer.json | 56 - .../vendor/symfony/routing/phpunit.xml.dist | 30 - lib/silex/vendor/twig/twig/.editorconfig | 18 - lib/silex/vendor/twig/twig/.gitignore | 5 - lib/silex/vendor/twig/twig/.php_cs.dist | 16 - lib/silex/vendor/twig/twig/.travis.yml | 49 - lib/silex/vendor/twig/twig/CHANGELOG | 984 ------- lib/silex/vendor/twig/twig/LICENSE | 31 - lib/silex/vendor/twig/twig/README.rst | 15 - lib/silex/vendor/twig/twig/composer.json | 50 - lib/silex/vendor/twig/twig/doc/advanced.rst | 962 ------- .../vendor/twig/twig/doc/advanced_legacy.rst | 885 ------- lib/silex/vendor/twig/twig/doc/api.rst | 590 ----- .../vendor/twig/twig/doc/coding_standards.rst | 101 - lib/silex/vendor/twig/twig/doc/deprecated.rst | 224 -- .../vendor/twig/twig/doc/filters/abs.rst | 18 - .../vendor/twig/twig/doc/filters/batch.rst | 51 - .../twig/twig/doc/filters/capitalize.rst | 11 - .../twig/doc/filters/convert_encoding.rst | 28 - .../vendor/twig/twig/doc/filters/date.rst | 100 - .../twig/twig/doc/filters/date_modify.rst | 23 - .../vendor/twig/twig/doc/filters/default.rst | 33 - .../vendor/twig/twig/doc/filters/escape.rst | 119 - .../vendor/twig/twig/doc/filters/first.rst | 25 - .../vendor/twig/twig/doc/filters/format.rst | 16 - .../vendor/twig/twig/doc/filters/index.rst | 37 - .../vendor/twig/twig/doc/filters/join.rst | 23 - .../twig/twig/doc/filters/json_encode.rst | 21 - .../vendor/twig/twig/doc/filters/keys.rst | 11 - .../vendor/twig/twig/doc/filters/last.rst | 25 - .../vendor/twig/twig/doc/filters/length.rst | 21 - .../vendor/twig/twig/doc/filters/lower.rst | 10 - .../vendor/twig/twig/doc/filters/merge.rst | 48 - .../vendor/twig/twig/doc/filters/nl2br.rst | 22 - .../twig/twig/doc/filters/number_format.rst | 56 - .../vendor/twig/twig/doc/filters/raw.rst | 36 - .../vendor/twig/twig/doc/filters/replace.rst | 19 - .../vendor/twig/twig/doc/filters/reverse.rst | 47 - .../vendor/twig/twig/doc/filters/round.rst | 37 - .../vendor/twig/twig/doc/filters/slice.rst | 71 - .../vendor/twig/twig/doc/filters/sort.rst | 18 - .../vendor/twig/twig/doc/filters/split.rst | 53 - .../twig/twig/doc/filters/striptags.rst | 29 - .../vendor/twig/twig/doc/filters/title.rst | 11 - .../vendor/twig/twig/doc/filters/trim.rst | 45 - .../vendor/twig/twig/doc/filters/upper.rst | 10 - .../twig/twig/doc/filters/url_encode.rst | 34 - .../twig/twig/doc/functions/attribute.rst | 26 - .../vendor/twig/twig/doc/functions/block.rst | 41 - .../twig/twig/doc/functions/constant.rst | 29 - .../vendor/twig/twig/doc/functions/cycle.rst | 28 - .../vendor/twig/twig/doc/functions/date.rst | 55 - .../vendor/twig/twig/doc/functions/dump.rst | 69 - .../twig/twig/doc/functions/include.rst | 84 - .../vendor/twig/twig/doc/functions/index.rst | 20 - .../vendor/twig/twig/doc/functions/max.rst | 20 - .../vendor/twig/twig/doc/functions/min.rst | 20 - .../vendor/twig/twig/doc/functions/parent.rst | 20 - .../vendor/twig/twig/doc/functions/random.rst | 29 - .../vendor/twig/twig/doc/functions/range.rst | 58 - .../vendor/twig/twig/doc/functions/source.rst | 32 - .../doc/functions/template_from_string.rst | 32 - lib/silex/vendor/twig/twig/doc/index.rst | 19 - .../vendor/twig/twig/doc/installation.rst | 116 - lib/silex/vendor/twig/twig/doc/internals.rst | 142 - lib/silex/vendor/twig/twig/doc/intro.rst | 86 - lib/silex/vendor/twig/twig/doc/recipes.rst | 568 ---- .../vendor/twig/twig/doc/tags/autoescape.rst | 81 - lib/silex/vendor/twig/twig/doc/tags/block.rst | 11 - lib/silex/vendor/twig/twig/doc/tags/do.rst | 12 - lib/silex/vendor/twig/twig/doc/tags/embed.rst | 178 -- .../vendor/twig/twig/doc/tags/extends.rst | 272 -- .../vendor/twig/twig/doc/tags/filter.rst | 21 - lib/silex/vendor/twig/twig/doc/tags/flush.rst | 17 - lib/silex/vendor/twig/twig/doc/tags/for.rst | 172 -- lib/silex/vendor/twig/twig/doc/tags/from.rst | 8 - lib/silex/vendor/twig/twig/doc/tags/if.rst | 76 - .../vendor/twig/twig/doc/tags/import.rst | 57 - .../vendor/twig/twig/doc/tags/include.rst | 90 - lib/silex/vendor/twig/twig/doc/tags/index.rst | 25 - lib/silex/vendor/twig/twig/doc/tags/macro.rst | 103 - .../vendor/twig/twig/doc/tags/sandbox.rst | 30 - lib/silex/vendor/twig/twig/doc/tags/set.rst | 78 - .../vendor/twig/twig/doc/tags/spaceless.rst | 37 - lib/silex/vendor/twig/twig/doc/tags/use.rst | 124 - .../vendor/twig/twig/doc/tags/verbatim.rst | 24 - lib/silex/vendor/twig/twig/doc/tags/with.rst | 44 - lib/silex/vendor/twig/twig/doc/templates.rst | 909 ------- .../vendor/twig/twig/doc/tests/constant.rst | 22 - .../vendor/twig/twig/doc/tests/defined.rst | 30 - .../twig/twig/doc/tests/divisibleby.rst | 14 - .../vendor/twig/twig/doc/tests/empty.rst | 22 - lib/silex/vendor/twig/twig/doc/tests/even.rst | 10 - .../vendor/twig/twig/doc/tests/index.rst | 15 - .../vendor/twig/twig/doc/tests/iterable.rst | 19 - lib/silex/vendor/twig/twig/doc/tests/null.rst | 12 - lib/silex/vendor/twig/twig/doc/tests/odd.rst | 10 - .../vendor/twig/twig/doc/tests/sameas.rst | 14 - lib/silex/vendor/twig/twig/exclude.txt | 5 - .../vendor/twig/twig/ext/twig/.gitignore | 30 - lib/silex/vendor/twig/twig/ext/twig/config.m4 | 8 - .../vendor/twig/twig/ext/twig/config.w32 | 8 - .../vendor/twig/twig/ext/twig/php_twig.h | 35 - lib/silex/vendor/twig/twig/ext/twig/twig.c | 1215 --------- .../vendor/twig/twig/lib/Twig/Autoloader.php | 54 - .../twig/twig/lib/Twig/BaseNodeVisitor.php | 54 - .../twig/twig/lib/Twig/Cache/Filesystem.php | 93 - .../vendor/twig/twig/lib/Twig/Cache/Null.php | 40 - .../twig/twig/lib/Twig/CacheInterface.php | 58 - .../vendor/twig/twig/lib/Twig/Compiler.php | 284 -- .../twig/twig/lib/Twig/CompilerInterface.php | 34 - .../twig/lib/Twig/ContainerRuntimeLoader.php | 39 - .../vendor/twig/twig/lib/Twig/Environment.php | 1600 ----------- lib/silex/vendor/twig/twig/lib/Twig/Error.php | 363 --- .../twig/twig/lib/Twig/Error/Loader.php | 40 - .../twig/twig/lib/Twig/Error/Runtime.php | 22 - .../twig/twig/lib/Twig/Error/Syntax.php | 55 - .../twig/lib/Twig/ExistsLoaderInterface.php | 31 - .../twig/twig/lib/Twig/ExpressionParser.php | 741 ------ .../vendor/twig/twig/lib/Twig/Extension.php | 69 - .../twig/twig/lib/Twig/Extension/Core.php | 1612 ------------ .../twig/twig/lib/Twig/Extension/Debug.php | 67 - .../twig/twig/lib/Twig/Extension/Escaper.php | 112 - .../lib/Twig/Extension/GlobalsInterface.php | 24 - .../Twig/Extension/InitRuntimeInterface.php | 24 - .../twig/lib/Twig/Extension/Optimizer.php | 35 - .../twig/twig/lib/Twig/Extension/Profiler.php | 49 - .../twig/twig/lib/Twig/Extension/Sandbox.php | 103 - .../twig/twig/lib/Twig/Extension/Staging.php | 112 - .../twig/lib/Twig/Extension/StringLoader.php | 47 - .../twig/twig/lib/Twig/ExtensionInterface.php | 90 - .../twig/lib/Twig/FactoryRuntimeLoader.php | 39 - .../Twig/FileExtensionEscapingStrategy.php | 60 - .../vendor/twig/twig/lib/Twig/Filter.php | 84 - .../twig/twig/lib/Twig/Filter/Function.php | 40 - .../twig/twig/lib/Twig/Filter/Method.php | 42 - .../vendor/twig/twig/lib/Twig/Filter/Node.php | 42 - .../twig/lib/Twig/FilterCallableInterface.php | 24 - .../twig/twig/lib/Twig/FilterInterface.php | 43 - .../vendor/twig/twig/lib/Twig/Function.php | 74 - .../twig/twig/lib/Twig/Function/Function.php | 41 - .../twig/twig/lib/Twig/Function/Method.php | 43 - .../twig/twig/lib/Twig/Function/Node.php | 42 - .../lib/Twig/FunctionCallableInterface.php | 24 - .../twig/twig/lib/Twig/FunctionInterface.php | 40 - lib/silex/vendor/twig/twig/lib/Twig/Lexer.php | 424 --- .../twig/twig/lib/Twig/LexerInterface.php | 32 - .../twig/twig/lib/Twig/Loader/Array.php | 97 - .../twig/twig/lib/Twig/Loader/Chain.php | 151 -- .../twig/twig/lib/Twig/Loader/Filesystem.php | 290 -- .../twig/twig/lib/Twig/Loader/String.php | 58 - .../twig/twig/lib/Twig/LoaderInterface.php | 57 - .../vendor/twig/twig/lib/Twig/Markup.php | 39 - lib/silex/vendor/twig/twig/lib/Twig/Node.php | 256 -- .../twig/twig/lib/Twig/Node/AutoEscape.php | 36 - .../vendor/twig/twig/lib/Twig/Node/Block.php | 41 - .../twig/lib/Twig/Node/BlockReference.php | 34 - .../vendor/twig/twig/lib/Twig/Node/Body.php | 21 - .../twig/twig/lib/Twig/Node/CheckSecurity.php | 80 - .../vendor/twig/twig/lib/Twig/Node/Do.php | 35 - .../vendor/twig/twig/lib/Twig/Node/Embed.php | 46 - .../twig/twig/lib/Twig/Node/Expression.php | 22 - .../twig/lib/Twig/Node/Expression/Array.php | 83 - .../lib/Twig/Node/Expression/AssignName.php | 25 - .../twig/lib/Twig/Node/Expression/Binary.php | 37 - .../lib/Twig/Node/Expression/Binary/Add.php | 20 - .../lib/Twig/Node/Expression/Binary/And.php | 20 - .../Node/Expression/Binary/BitwiseAnd.php | 20 - .../Twig/Node/Expression/Binary/BitwiseOr.php | 20 - .../Node/Expression/Binary/BitwiseXor.php | 20 - .../Twig/Node/Expression/Binary/Concat.php | 20 - .../lib/Twig/Node/Expression/Binary/Div.php | 20 - .../Twig/Node/Expression/Binary/EndsWith.php | 32 - .../lib/Twig/Node/Expression/Binary/Equal.php | 19 - .../Twig/Node/Expression/Binary/FloorDiv.php | 26 - .../Twig/Node/Expression/Binary/Greater.php | 19 - .../Node/Expression/Binary/GreaterEqual.php | 19 - .../lib/Twig/Node/Expression/Binary/In.php | 30 - .../lib/Twig/Node/Expression/Binary/Less.php | 19 - .../Twig/Node/Expression/Binary/LessEqual.php | 19 - .../Twig/Node/Expression/Binary/Matches.php | 30 - .../lib/Twig/Node/Expression/Binary/Mod.php | 20 - .../lib/Twig/Node/Expression/Binary/Mul.php | 20 - .../Twig/Node/Expression/Binary/NotEqual.php | 19 - .../lib/Twig/Node/Expression/Binary/NotIn.php | 30 - .../lib/Twig/Node/Expression/Binary/Or.php | 20 - .../lib/Twig/Node/Expression/Binary/Power.php | 34 - .../lib/Twig/Node/Expression/Binary/Range.php | 30 - .../Node/Expression/Binary/StartsWith.php | 32 - .../lib/Twig/Node/Expression/Binary/Sub.php | 20 - .../Twig/Node/Expression/BlockReference.php | 93 - .../twig/lib/Twig/Node/Expression/Call.php | 291 -- .../lib/Twig/Node/Expression/Conditional.php | 33 - .../lib/Twig/Node/Expression/Constant.php | 25 - .../Node/Expression/ExtensionReference.php | 32 - .../twig/lib/Twig/Node/Expression/Filter.php | 41 - .../Twig/Node/Expression/Filter/Default.php | 45 - .../lib/Twig/Node/Expression/Function.php | 45 - .../twig/lib/Twig/Node/Expression/GetAttr.php | 74 - .../lib/Twig/Node/Expression/MethodCall.php | 43 - .../twig/lib/Twig/Node/Expression/Name.php | 102 - .../lib/Twig/Node/Expression/NullCoalesce.php | 48 - .../twig/lib/Twig/Node/Expression/Parent.php | 44 - .../lib/Twig/Node/Expression/TempName.php | 28 - .../twig/lib/Twig/Node/Expression/Test.php | 42 - .../Twig/Node/Expression/Test/Constant.php | 48 - .../lib/Twig/Node/Expression/Test/Defined.php | 61 - .../Twig/Node/Expression/Test/Divisibleby.php | 35 - .../lib/Twig/Node/Expression/Test/Even.php | 34 - .../lib/Twig/Node/Expression/Test/Null.php | 33 - .../lib/Twig/Node/Expression/Test/Odd.php | 34 - .../lib/Twig/Node/Expression/Test/Sameas.php | 31 - .../twig/lib/Twig/Node/Expression/Unary.php | 29 - .../lib/Twig/Node/Expression/Unary/Neg.php | 20 - .../lib/Twig/Node/Expression/Unary/Not.php | 20 - .../lib/Twig/Node/Expression/Unary/Pos.php | 20 - .../vendor/twig/twig/lib/Twig/Node/Flush.php | 33 - .../vendor/twig/twig/lib/Twig/Node/For.php | 113 - .../twig/twig/lib/Twig/Node/ForLoop.php | 52 - .../vendor/twig/twig/lib/Twig/Node/If.php | 68 - .../vendor/twig/twig/lib/Twig/Node/Import.php | 51 - .../twig/twig/lib/Twig/Node/Include.php | 90 - .../vendor/twig/twig/lib/Twig/Node/Macro.php | 125 - .../vendor/twig/twig/lib/Twig/Node/Module.php | 461 ---- .../vendor/twig/twig/lib/Twig/Node/Print.php | 36 - .../twig/twig/lib/Twig/Node/Sandbox.php | 44 - .../twig/lib/Twig/Node/SandboxedPrint.php | 51 - .../vendor/twig/twig/lib/Twig/Node/Set.php | 98 - .../twig/twig/lib/Twig/Node/SetTemp.php | 40 - .../twig/twig/lib/Twig/Node/Spaceless.php | 37 - .../vendor/twig/twig/lib/Twig/Node/Text.php | 36 - .../vendor/twig/twig/lib/Twig/Node/With.php | 64 - .../twig/lib/Twig/NodeCaptureInterface.php | 21 - .../twig/twig/lib/Twig/NodeInterface.php | 32 - .../twig/lib/Twig/NodeOutputInterface.php | 21 - .../twig/twig/lib/Twig/NodeTraverser.php | 84 - .../twig/lib/Twig/NodeVisitor/Escaper.php | 154 -- .../twig/lib/Twig/NodeVisitor/Optimizer.php | 253 -- .../lib/Twig/NodeVisitor/SafeAnalysis.php | 150 -- .../twig/lib/Twig/NodeVisitor/Sandbox.php | 77 - .../twig/lib/Twig/NodeVisitorInterface.php | 45 - .../vendor/twig/twig/lib/Twig/Parser.php | 410 --- .../twig/twig/lib/Twig/ParserInterface.php | 29 - .../twig/lib/Twig/Profiler/Dumper/Base.php | 62 - .../lib/Twig/Profiler/Dumper/Blackfire.php | 72 - .../twig/lib/Twig/Profiler/Dumper/Html.php | 47 - .../twig/lib/Twig/Profiler/Dumper/Text.php | 35 - .../lib/Twig/Profiler/Node/EnterProfile.php | 39 - .../lib/Twig/Profiler/Node/LeaveProfile.php | 33 - .../Twig/Profiler/NodeVisitor/Profiler.php | 67 - .../twig/twig/lib/Twig/Profiler/Profile.php | 170 -- .../twig/lib/Twig/RuntimeLoaderInterface.php | 29 - .../twig/lib/Twig/Sandbox/SecurityError.php | 21 - .../Sandbox/SecurityNotAllowedFilterError.php | 33 - .../SecurityNotAllowedFunctionError.php | 33 - .../Sandbox/SecurityNotAllowedMethodError.php | 40 - .../SecurityNotAllowedPropertyError.php | 40 - .../Sandbox/SecurityNotAllowedTagError.php | 33 - .../twig/lib/Twig/Sandbox/SecurityPolicy.php | 125 - .../Twig/Sandbox/SecurityPolicyInterface.php | 26 - .../twig/twig/lib/Twig/SimpleFilter.php | 121 - .../twig/twig/lib/Twig/SimpleFunction.php | 111 - .../vendor/twig/twig/lib/Twig/SimpleTest.php | 73 - .../vendor/twig/twig/lib/Twig/Source.php | 53 - .../lib/Twig/SourceContextLoaderInterface.php | 33 - .../vendor/twig/twig/lib/Twig/Template.php | 706 ----- .../twig/twig/lib/Twig/TemplateInterface.php | 48 - .../twig/twig/lib/Twig/TemplateWrapper.php | 133 - lib/silex/vendor/twig/twig/lib/Twig/Test.php | 37 - .../twig/twig/lib/Twig/Test/Function.php | 38 - .../lib/Twig/Test/IntegrationTestCase.php | 249 -- .../vendor/twig/twig/lib/Twig/Test/Method.php | 40 - .../vendor/twig/twig/lib/Twig/Test/Node.php | 40 - .../twig/twig/lib/Twig/Test/NodeTestCase.php | 75 - .../twig/lib/Twig/TestCallableInterface.php | 22 - .../twig/twig/lib/Twig/TestInterface.php | 27 - lib/silex/vendor/twig/twig/lib/Twig/Token.php | 207 -- .../vendor/twig/twig/lib/Twig/TokenParser.php | 33 - .../twig/lib/Twig/TokenParser/AutoEscape.php | 83 - .../twig/twig/lib/Twig/TokenParser/Block.php | 73 - .../twig/twig/lib/Twig/TokenParser/Do.php | 34 - .../twig/twig/lib/Twig/TokenParser/Embed.php | 67 - .../twig/lib/Twig/TokenParser/Extends.php | 46 - .../twig/twig/lib/Twig/TokenParser/Filter.php | 53 - .../twig/twig/lib/Twig/TokenParser/Flush.php | 34 - .../twig/twig/lib/Twig/TokenParser/For.php | 127 - .../twig/twig/lib/Twig/TokenParser/From.php | 66 - .../twig/twig/lib/Twig/TokenParser/If.php | 86 - .../twig/twig/lib/Twig/TokenParser/Import.php | 41 - .../twig/lib/Twig/TokenParser/Include.php | 65 - .../twig/twig/lib/Twig/TokenParser/Macro.php | 60 - .../twig/lib/Twig/TokenParser/Sandbox.php | 61 - .../twig/twig/lib/Twig/TokenParser/Set.php | 75 - .../twig/lib/Twig/TokenParser/Spaceless.php | 51 - .../twig/twig/lib/Twig/TokenParser/Use.php | 70 - .../twig/twig/lib/Twig/TokenParser/With.php | 52 - .../twig/twig/lib/Twig/TokenParserBroker.php | 120 - .../lib/Twig/TokenParserBrokerInterface.php | 44 - .../twig/lib/Twig/TokenParserInterface.php | 43 - .../vendor/twig/twig/lib/Twig/TokenStream.php | 196 -- .../lib/Twig/Util/DeprecationCollector.php | 86 - .../lib/Twig/Util/TemplateDirIterator.php | 28 - lib/silex/vendor/twig/twig/phpunit.xml.dist | 33 - .../twig/twig/src/Cache/CacheInterface.php | 11 - .../twig/twig/src/Cache/FilesystemCache.php | 11 - .../vendor/twig/twig/src/Cache/NullCache.php | 11 - lib/silex/vendor/twig/twig/src/Compiler.php | 11 - .../vendor/twig/twig/src/Environment.php | 11 - .../vendor/twig/twig/src/Error/Error.php | 11 - .../twig/twig/src/Error/LoaderError.php | 11 - .../twig/twig/src/Error/RuntimeError.php | 11 - .../twig/twig/src/Error/SyntaxError.php | 11 - .../vendor/twig/twig/src/ExpressionParser.php | 11 - .../twig/src/Extension/AbstractExtension.php | 11 - .../twig/twig/src/Extension/CoreExtension.php | 11 - .../twig/src/Extension/DebugExtension.php | 11 - .../twig/src/Extension/EscaperExtension.php | 11 - .../twig/src/Extension/ExtensionInterface.php | 11 - .../twig/src/Extension/GlobalsInterface.php | 11 - .../src/Extension/InitRuntimeInterface.php | 11 - .../twig/src/Extension/OptimizerExtension.php | 11 - .../twig/src/Extension/ProfilerExtension.php | 11 - .../Extension/RuntimeExtensionInterface.php | 19 - .../twig/src/Extension/SandboxExtension.php | 11 - .../twig/src/Extension/StagingExtension.php | 11 - .../src/Extension/StringLoaderExtension.php | 11 - .../src/FileExtensionEscapingStrategy.php | 11 - lib/silex/vendor/twig/twig/src/Lexer.php | 11 - .../twig/twig/src/Loader/ArrayLoader.php | 11 - .../twig/twig/src/Loader/ChainLoader.php | 11 - .../twig/src/Loader/ExistsLoaderInterface.php | 11 - .../twig/twig/src/Loader/FilesystemLoader.php | 11 - .../twig/twig/src/Loader/LoaderInterface.php | 11 - .../Loader/SourceContextLoaderInterface.php | 11 - lib/silex/vendor/twig/twig/src/Markup.php | 11 - .../twig/twig/src/Node/AutoEscapeNode.php | 11 - .../vendor/twig/twig/src/Node/BlockNode.php | 11 - .../twig/twig/src/Node/BlockReferenceNode.php | 11 - .../vendor/twig/twig/src/Node/BodyNode.php | 11 - .../twig/twig/src/Node/CheckSecurityNode.php | 11 - .../vendor/twig/twig/src/Node/DoNode.php | 11 - .../vendor/twig/twig/src/Node/EmbedNode.php | 11 - .../Node/Expression/AbstractExpression.php | 11 - .../src/Node/Expression/ArrayExpression.php | 11 - .../Node/Expression/AssignNameExpression.php | 11 - .../Node/Expression/Binary/AbstractBinary.php | 11 - .../src/Node/Expression/Binary/AddBinary.php | 11 - .../src/Node/Expression/Binary/AndBinary.php | 11 - .../Expression/Binary/BitwiseAndBinary.php | 11 - .../Expression/Binary/BitwiseOrBinary.php | 11 - .../Expression/Binary/BitwiseXorBinary.php | 11 - .../Node/Expression/Binary/ConcatBinary.php | 11 - .../src/Node/Expression/Binary/DivBinary.php | 11 - .../Node/Expression/Binary/EndsWithBinary.php | 11 - .../Node/Expression/Binary/EqualBinary.php | 11 - .../Node/Expression/Binary/FloorDivBinary.php | 11 - .../Node/Expression/Binary/GreaterBinary.php | 11 - .../Expression/Binary/GreaterEqualBinary.php | 11 - .../src/Node/Expression/Binary/InBinary.php | 11 - .../src/Node/Expression/Binary/LessBinary.php | 11 - .../Expression/Binary/LessEqualBinary.php | 11 - .../Node/Expression/Binary/MatchesBinary.php | 11 - .../src/Node/Expression/Binary/ModBinary.php | 11 - .../src/Node/Expression/Binary/MulBinary.php | 11 - .../Node/Expression/Binary/NotEqualBinary.php | 11 - .../Node/Expression/Binary/NotInBinary.php | 11 - .../src/Node/Expression/Binary/OrBinary.php | 11 - .../Node/Expression/Binary/PowerBinary.php | 11 - .../Node/Expression/Binary/RangeBinary.php | 11 - .../Expression/Binary/StartsWithBinary.php | 11 - .../src/Node/Expression/Binary/SubBinary.php | 11 - .../Expression/BlockReferenceExpression.php | 11 - .../src/Node/Expression/CallExpression.php | 11 - .../Node/Expression/ConditionalExpression.php | 11 - .../Node/Expression/ConstantExpression.php | 11 - .../Node/Expression/Filter/DefaultFilter.php | 11 - .../src/Node/Expression/FilterExpression.php | 11 - .../Node/Expression/FunctionExpression.php | 11 - .../src/Node/Expression/GetAttrExpression.php | 11 - .../Node/Expression/MethodCallExpression.php | 11 - .../src/Node/Expression/NameExpression.php | 11 - .../Expression/NullCoalesceExpression.php | 11 - .../src/Node/Expression/ParentExpression.php | 11 - .../Node/Expression/TempNameExpression.php | 11 - .../src/Node/Expression/Test/ConstantTest.php | 11 - .../src/Node/Expression/Test/DefinedTest.php | 11 - .../Node/Expression/Test/DivisiblebyTest.php | 11 - .../src/Node/Expression/Test/EvenTest.php | 11 - .../src/Node/Expression/Test/NullTest.php | 11 - .../twig/src/Node/Expression/Test/OddTest.php | 11 - .../src/Node/Expression/Test/SameasTest.php | 11 - .../src/Node/Expression/TestExpression.php | 11 - .../Node/Expression/Unary/AbstractUnary.php | 11 - .../src/Node/Expression/Unary/NegUnary.php | 11 - .../src/Node/Expression/Unary/NotUnary.php | 11 - .../src/Node/Expression/Unary/PosUnary.php | 11 - .../vendor/twig/twig/src/Node/FlushNode.php | 11 - .../vendor/twig/twig/src/Node/ForLoopNode.php | 11 - .../vendor/twig/twig/src/Node/ForNode.php | 11 - .../vendor/twig/twig/src/Node/IfNode.php | 11 - .../vendor/twig/twig/src/Node/ImportNode.php | 11 - .../vendor/twig/twig/src/Node/IncludeNode.php | 11 - .../vendor/twig/twig/src/Node/MacroNode.php | 11 - .../vendor/twig/twig/src/Node/ModuleNode.php | 11 - lib/silex/vendor/twig/twig/src/Node/Node.php | 11 - .../twig/src/Node/NodeCaptureInterface.php | 11 - .../twig/src/Node/NodeOutputInterface.php | 11 - .../vendor/twig/twig/src/Node/PrintNode.php | 11 - .../vendor/twig/twig/src/Node/SandboxNode.php | 11 - .../twig/twig/src/Node/SandboxedPrintNode.php | 11 - .../vendor/twig/twig/src/Node/SetNode.php | 11 - .../vendor/twig/twig/src/Node/SetTempNode.php | 11 - .../twig/twig/src/Node/SpacelessNode.php | 11 - .../vendor/twig/twig/src/Node/TextNode.php | 11 - .../vendor/twig/twig/src/Node/WithNode.php | 11 - .../vendor/twig/twig/src/NodeTraverser.php | 11 - .../src/NodeVisitor/AbstractNodeVisitor.php | 11 - .../src/NodeVisitor/EscaperNodeVisitor.php | 11 - .../src/NodeVisitor/NodeVisitorInterface.php | 11 - .../src/NodeVisitor/OptimizerNodeVisitor.php | 11 - .../NodeVisitor/SafeAnalysisNodeVisitor.php | 11 - .../src/NodeVisitor/SandboxNodeVisitor.php | 11 - lib/silex/vendor/twig/twig/src/Parser.php | 11 - .../twig/src/Profiler/Dumper/BaseDumper.php | 11 - .../src/Profiler/Dumper/BlackfireDumper.php | 11 - .../twig/src/Profiler/Dumper/HtmlDumper.php | 11 - .../twig/src/Profiler/Dumper/TextDumper.php | 11 - .../src/Profiler/Node/EnterProfileNode.php | 11 - .../src/Profiler/Node/LeaveProfileNode.php | 11 - .../NodeVisitor/ProfilerNodeVisitor.php | 11 - .../vendor/twig/twig/src/Profiler/Profile.php | 11 - .../RuntimeLoader/ContainerRuntimeLoader.php | 11 - .../RuntimeLoader/FactoryRuntimeLoader.php | 11 - .../RuntimeLoader/RuntimeLoaderInterface.php | 11 - .../twig/twig/src/Sandbox/SecurityError.php | 11 - .../Sandbox/SecurityNotAllowedFilterError.php | 11 - .../SecurityNotAllowedFunctionError.php | 11 - .../Sandbox/SecurityNotAllowedMethodError.php | 11 - .../SecurityNotAllowedPropertyError.php | 11 - .../Sandbox/SecurityNotAllowedTagError.php | 11 - .../twig/twig/src/Sandbox/SecurityPolicy.php | 11 - .../src/Sandbox/SecurityPolicyInterface.php | 11 - lib/silex/vendor/twig/twig/src/Source.php | 11 - lib/silex/vendor/twig/twig/src/Template.php | 11 - .../vendor/twig/twig/src/TemplateWrapper.php | 11 - .../twig/src/Test/IntegrationTestCase.php | 11 - .../twig/twig/src/Test/NodeTestCase.php | 11 - lib/silex/vendor/twig/twig/src/Token.php | 11 - .../src/TokenParser/AbstractTokenParser.php | 11 - .../src/TokenParser/AutoEscapeTokenParser.php | 11 - .../twig/src/TokenParser/BlockTokenParser.php | 11 - .../twig/src/TokenParser/DoTokenParser.php | 11 - .../twig/src/TokenParser/EmbedTokenParser.php | 11 - .../src/TokenParser/ExtendsTokenParser.php | 11 - .../src/TokenParser/FilterTokenParser.php | 11 - .../twig/src/TokenParser/FlushTokenParser.php | 11 - .../twig/src/TokenParser/ForTokenParser.php | 11 - .../twig/src/TokenParser/FromTokenParser.php | 11 - .../twig/src/TokenParser/IfTokenParser.php | 11 - .../src/TokenParser/ImportTokenParser.php | 11 - .../src/TokenParser/IncludeTokenParser.php | 11 - .../twig/src/TokenParser/MacroTokenParser.php | 11 - .../src/TokenParser/SandboxTokenParser.php | 11 - .../twig/src/TokenParser/SetTokenParser.php | 11 - .../src/TokenParser/SpacelessTokenParser.php | 11 - .../src/TokenParser/TokenParserInterface.php | 11 - .../twig/src/TokenParser/UseTokenParser.php | 11 - .../twig/src/TokenParser/WithTokenParser.php | 11 - .../vendor/twig/twig/src/TokenStream.php | 11 - lib/silex/vendor/twig/twig/src/TwigFilter.php | 11 - .../vendor/twig/twig/src/TwigFunction.php | 11 - lib/silex/vendor/twig/twig/src/TwigTest.php | 11 - .../twig/src/Util/DeprecationCollector.php | 11 - .../twig/src/Util/TemplateDirIterator.php | 11 - .../twig/test/Twig/Tests/AutoloaderTest.php | 24 - .../test/Twig/Tests/Cache/FilesystemTest.php | 193 -- .../twig/test/Twig/Tests/CompilerTest.php | 33 - .../Twig/Tests/ContainerRuntimeLoaderTest.php | 40 - .../test/Twig/Tests/CustomExtensionTest.php | 93 - .../twig/test/Twig/Tests/EnvironmentTest.php | 686 ----- .../twig/twig/test/Twig/Tests/ErrorTest.php | 211 -- .../test/Twig/Tests/ExpressionParserTest.php | 377 --- .../test/Twig/Tests/Extension/CoreTest.php | 355 --- .../test/Twig/Tests/Extension/SandboxTest.php | 304 --- .../Twig/Tests/FactoryRuntimeLoaderTest.php | 32 - .../twig/test/Twig/Tests/FileCachingTest.php | 63 - .../FileExtensionEscapingStrategyTest.php | 51 - .../twig/test/Twig/Tests/FilesystemHelper.php | 30 - .../Twig/Tests/Fixtures/autoescape/block.test | 21 - .../Tests/Fixtures/autoescape/filename.test | 18 - .../Twig/Tests/Fixtures/autoescape/name.test | 22 - .../test/Twig/Tests/Fixtures/errors/base.html | 1 - .../Twig/Tests/Fixtures/errors/index.html | 7 - .../child_contents_outside_blocks.test | 15 - ...ltiline_array_with_undefined_variable.test | 18 - ...e_array_with_undefined_variable_again.test | 18 - ...line_function_with_undefined_variable.test | 12 - ...tiline_function_with_unknown_argument.test | 9 - ...multiline_tag_with_undefined_variable.test | 12 - .../syntax_error_in_reused_template.test | 10 - .../Fixtures/exceptions/unclosed_tag.test | 20 - .../Fixtures/exceptions/undefined_parent.test | 8 - .../undefined_template_in_child_template.test | 15 - .../Fixtures/exceptions/undefined_trait.test | 9 - .../Tests/Fixtures/expressions/_self.test | 8 - .../Tests/Fixtures/expressions/array.test | 61 - .../Fixtures/expressions/array_call.test | 14 - .../Tests/Fixtures/expressions/binary.test | 46 - .../Tests/Fixtures/expressions/bitwise.test | 14 - .../Fixtures/expressions/comparison.test | 14 - .../Fixtures/expressions/divisibleby.test | 17 - .../Tests/Fixtures/expressions/dotdot.test | 20 - .../Tests/Fixtures/expressions/ends_with.test | 26 - .../Tests/Fixtures/expressions/grouping.test | 8 - .../Tests/Fixtures/expressions/literals.test | 22 - .../Fixtures/expressions/magic_call.test | 27 - .../Tests/Fixtures/expressions/matches.test | 12 - .../Fixtures/expressions/method_call.test | 28 - .../expressions/negative_numbers.test | 18 - .../expressions/operators_as_variables.test | 16 - .../Tests/Fixtures/expressions/postfix.test | 22 - .../Tests/Fixtures/expressions/power.test | 20 - .../Tests/Fixtures/expressions/sameas.test | 21 - .../Fixtures/expressions/starts_with.test | 27 - .../Tests/Fixtures/expressions/strings.test | 10 - .../expressions/ternary_operator.test | 18 - .../expressions/ternary_operator_noelse.test | 10 - .../expressions/ternary_operator_nothen.test | 10 - .../two_word_operators_as_variables.test | 8 - .../Tests/Fixtures/expressions/unary.test | 12 - .../expressions/unary_macro_arguments.test | 22 - .../expressions/unary_precedence.test | 14 - .../test/Twig/Tests/Fixtures/filters/abs.test | 30 - .../Twig/Tests/Fixtures/filters/batch.test | 31 - .../Tests/Fixtures/filters/batch_float.test | 29 - .../filters/batch_with_empty_fill.test | 37 - .../filters/batch_with_exact_elements.test | 33 - .../Fixtures/filters/batch_with_fill.test | 37 - .../Fixtures/filters/batch_with_keys.test | 10 - .../filters/batch_with_zero_elements.test | 10 - .../Fixtures/filters/convert_encoding.test | 10 - .../Twig/Tests/Fixtures/filters/date.test | 90 - .../Fixtures/filters/date_default_format.test | 14 - .../filters/date_default_format_interval.test | 16 - .../Fixtures/filters/date_immutable.test | 37 - .../Tests/Fixtures/filters/date_interval.test | 19 - .../Tests/Fixtures/filters/date_modify.test | 14 - .../Fixtures/filters/date_namedargs.test | 13 - .../Twig/Tests/Fixtures/filters/default.test | 150 -- .../Fixtures/filters/dynamic_filter.test | 10 - .../Twig/Tests/Fixtures/filters/escape.test | 8 - .../Fixtures/filters/escape_html_attr.test | 8 - .../Fixtures/filters/escape_javascript.test | 8 - .../filters/escape_non_supported_charset.test | 8 - .../Twig/Tests/Fixtures/filters/first.test | 17 - .../Tests/Fixtures/filters/force_escape.test | 18 - .../Twig/Tests/Fixtures/filters/format.test | 8 - .../Twig/Tests/Fixtures/filters/join.test | 12 - .../Tests/Fixtures/filters/json_encode.test | 12 - .../Twig/Tests/Fixtures/filters/last.test | 17 - .../Twig/Tests/Fixtures/filters/length.test | 31 - .../Tests/Fixtures/filters/length_utf8.test | 12 - .../Twig/Tests/Fixtures/filters/merge.test | 18 - .../Twig/Tests/Fixtures/filters/nl2br.test | 14 - .../Tests/Fixtures/filters/number_format.test | 18 - .../filters/number_format_default.test | 21 - .../Twig/Tests/Fixtures/filters/replace.test | 12 - .../Fixtures/filters/replace_invalid_arg.test | 8 - .../Twig/Tests/Fixtures/filters/reverse.test | 18 - .../Twig/Tests/Fixtures/filters/round.test | 22 - .../Twig/Tests/Fixtures/filters/slice.test | 54 - .../Twig/Tests/Fixtures/filters/sort.test | 12 - .../Tests/Fixtures/filters/special_chars.test | 8 - .../Twig/Tests/Fixtures/filters/split.test | 20 - .../Tests/Fixtures/filters/split_utf8.test | 24 - .../Tests/Fixtures/filters/static_calls.test | 10 - .../Twig/Tests/Fixtures/filters/trim.test | 24 - .../Tests/Fixtures/filters/urlencode.test | 16 - .../filters/urlencode_deprecated.test | 16 - .../Tests/Fixtures/functions/attribute.test | 18 - .../Twig/Tests/Fixtures/functions/block.test | 12 - .../functions/block_with_template.test | 22 - .../functions/block_without_name.test | 12 - .../Tests/Fixtures/functions/constant.test | 10 - .../Twig/Tests/Fixtures/functions/cycle.test | 16 - .../Twig/Tests/Fixtures/functions/date.test | 27 - .../Fixtures/functions/date_namedargs.test | 11 - .../Twig/Tests/Fixtures/functions/dump.test | 16 - .../Tests/Fixtures/functions/dump_array.test | 19 - .../Fixtures/functions/dynamic_function.test | 10 - .../functions/include/assignment.test | 13 - .../functions/include/autoescaping.test | 10 - .../Fixtures/functions/include/basic.test | 17 - .../functions/include/expression.test | 17 - .../functions/include/ignore_missing.test | 10 - .../Fixtures/functions/include/missing.test | 8 - .../functions/include/missing_nested.test | 16 - .../Fixtures/functions/include/sandbox.test | 13 - .../functions/include/sandbox_disabling.test | 16 - .../sandbox_disabling_ignore_missing.test | 13 - .../functions/include/template_instance.test | 10 - .../functions/include/templates_as_array.test | 12 - .../functions/include/with_context.test | 16 - .../functions/include/with_variables.test | 12 - .../Tests/Fixtures/functions/magic_call.test | 8 - .../Fixtures/functions/magic_call53.test | 12 - .../Twig/Tests/Fixtures/functions/max.test | 12 - .../Twig/Tests/Fixtures/functions/min.test | 12 - .../Twig/Tests/Fixtures/functions/range.test | 8 - .../recursive_block_with_inheritance.test | 21 - .../Twig/Tests/Fixtures/functions/source.test | 17 - .../Fixtures/functions/special_chars.test | 8 - .../Fixtures/functions/static_calls.test | 10 - .../functions/template_from_string.test | 15 - .../Tests/Fixtures/macros/default_values.test | 16 - .../Tests/Fixtures/macros/nested_calls.test | 18 - .../Fixtures/macros/reserved_variables.test | 14 - .../Twig/Tests/Fixtures/macros/simple.test | 22 - .../Twig/Tests/Fixtures/macros/varargs.test | 21 - .../Fixtures/macros/varargs_argument.test | 7 - .../Tests/Fixtures/macros/with_filters.test | 14 - .../regression/combined_debug_info.test | 15 - .../Fixtures/regression/empty_token.test | 8 - .../Tests/Fixtures/regression/issue_1143.test | 23 - .../Fixtures/regression/multi_word_tests.test | 10 - .../regression/simple_xml_element.test | 19 - .../regression/strings_like_numbers.test | 8 - .../Tests/Fixtures/tags/autoescape/basic.test | 26 - .../Fixtures/tags/autoescape/blocks.test | 12 - .../tags/autoescape/double_escaping.test | 10 - .../Fixtures/tags/autoescape/functions.test | 83 - .../Fixtures/tags/autoescape/literal.test | 45 - .../Fixtures/tags/autoescape/nested.test | 26 - .../Fixtures/tags/autoescape/objects.test | 26 - .../Tests/Fixtures/tags/autoescape/raw.test | 10 - .../tags/autoescape/strategy.legacy.test | 11 - .../Fixtures/tags/autoescape/strategy.test | 11 - .../Tests/Fixtures/tags/autoescape/type.test | 69 - .../tags/autoescape/with_filters.test | 131 - .../autoescape/with_filters_arguments.test | 23 - .../autoescape/with_pre_escape_filters.test | 68 - .../with_preserves_safety_filters.test | 50 - .../Twig/Tests/Fixtures/tags/block/basic.test | 11 - .../tags/block/block_unique_name.test | 11 - .../Fixtures/tags/block/special_chars.test | 10 - .../Twig/Tests/Fixtures/tags/embed/basic.test | 35 - .../tags/embed/complex_dynamic_parent.test | 35 - .../Fixtures/tags/embed/dynamic_parent.test | 35 - .../Tests/Fixtures/tags/embed/error_line.test | 16 - .../Tests/Fixtures/tags/embed/multiple.test | 50 - .../Tests/Fixtures/tags/embed/nested.test | 42 - .../Fixtures/tags/embed/with_extends.test | 60 - .../Tests/Fixtures/tags/filter/basic.test | 10 - .../Fixtures/tags/filter/json_encode.test | 8 - .../Tests/Fixtures/tags/filter/multiple.test | 10 - .../Tests/Fixtures/tags/filter/nested.test | 16 - .../Fixtures/tags/filter/with_for_tag.test | 13 - .../Fixtures/tags/filter/with_if_tag.test | 29 - .../Tests/Fixtures/tags/for/condition.test | 14 - .../Twig/Tests/Fixtures/tags/for/context.test | 18 - .../Twig/Tests/Fixtures/tags/for/else.test | 23 - .../Fixtures/tags/for/inner_variables.test | 17 - .../Twig/Tests/Fixtures/tags/for/keys.test | 11 - .../Fixtures/tags/for/keys_and_values.test | 11 - .../Tests/Fixtures/tags/for/loop_context.test | 19 - .../Fixtures/tags/for/loop_context_local.test | 10 - .../Fixtures/tags/for/loop_not_defined.test | 10 - .../tags/for/loop_not_defined_cond.test | 9 - .../Tests/Fixtures/tags/for/nested_else.test | 17 - .../Twig/Tests/Fixtures/tags/for/objects.test | 43 - .../Fixtures/tags/for/objects_countable.test | 47 - .../Tests/Fixtures/tags/for/recursive.test | 18 - .../Twig/Tests/Fixtures/tags/for/values.test | 11 - .../test/Twig/Tests/Fixtures/tags/from.test | 14 - .../Twig/Tests/Fixtures/tags/if/basic.test | 22 - .../Tests/Fixtures/tags/if/expression.test | 22 - .../Tests/Fixtures/tags/include/basic.test | 16 - .../Fixtures/tags/include/expression.test | 16 - .../Fixtures/tags/include/ignore_missing.test | 10 - .../Tests/Fixtures/tags/include/missing.test | 8 - .../Fixtures/tags/include/missing_nested.test | 16 - .../Tests/Fixtures/tags/include/only.test | 16 - .../tags/include/template_instance.test | 10 - .../tags/include/templates_as_array.test | 12 - .../Fixtures/tags/include/with_variables.test | 12 - .../Fixtures/tags/inheritance/basic.test | 14 - .../Fixtures/tags/inheritance/block_expr.test | 32 - .../tags/inheritance/block_expr2.test | 34 - .../tags/inheritance/conditional.test | 14 - .../Fixtures/tags/inheritance/dynamic.test | 14 - .../Fixtures/tags/inheritance/empty.test | 10 - .../tags/inheritance/extends_as_array.test | 12 - .../extends_as_array_with_empty_name.test | 12 - .../extends_as_array_with_null_name.test | 12 - .../Fixtures/tags/inheritance/multiple.test | 12 - .../tags/inheritance/multiple_dynamic.test | 22 - .../tags/inheritance/nested_blocks.test | 22 - .../nested_blocks_parent_only.test | 15 - .../tags/inheritance/nested_inheritance.test | 16 - .../Fixtures/tags/inheritance/parent.test | 12 - .../tags/inheritance/parent_change.test | 16 - .../tags/inheritance/parent_in_a_block.test | 8 - .../tags/inheritance/parent_isolation.test | 20 - .../tags/inheritance/parent_nested.test | 28 - .../inheritance/parent_without_extends.test | 8 - .../parent_without_extends_but_traits.test | 14 - .../tags/inheritance/template_instance.test | 14 - .../Tests/Fixtures/tags/inheritance/use.test | 44 - .../Twig/Tests/Fixtures/tags/macro/basic.test | 17 - .../Fixtures/tags/macro/endmacro_name.test | 16 - .../Tests/Fixtures/tags/macro/external.test | 17 - .../Twig/Tests/Fixtures/tags/macro/from.test | 18 - .../tags/macro/from_with_reserved_name.test | 9 - .../Tests/Fixtures/tags/macro/global.test | 14 - .../tags/macro/import_with_reserved_nam.test | 11 - .../Fixtures/tags/macro/reserved_name.test | 10 - .../Fixtures/tags/macro/self_import.test | 17 - .../Fixtures/tags/macro/special_chars.test | 14 - .../Fixtures/tags/macro/super_globals.test | 14 - .../Tests/Fixtures/tags/raw/basic.legacy.test | 10 - .../tags/raw/mixed_usage_with_raw.legacy.test | 10 - .../tags/raw/whitespace_control.legacy.test | 56 - .../Fixtures/tags/sandbox/not_valid1.test | 11 - .../Fixtures/tags/sandbox/not_valid2.test | 14 - .../Tests/Fixtures/tags/sandbox/simple.test | 22 - .../Twig/Tests/Fixtures/tags/set/basic.test | 20 - .../Fixtures/tags/set/capture-empty.test | 9 - .../Twig/Tests/Fixtures/tags/set/capture.test | 10 - .../Tests/Fixtures/tags/set/expression.test | 12 - .../Tests/Fixtures/tags/spaceless/simple.test | 12 - .../Tests/Fixtures/tags/special_chars.test | 8 - .../Twig/Tests/Fixtures/tags/trim_block.test | 74 - .../Twig/Tests/Fixtures/tags/use/aliases.test | 12 - .../Twig/Tests/Fixtures/tags/use/basic.test | 12 - .../Twig/Tests/Fixtures/tags/use/deep.test | 22 - .../Tests/Fixtures/tags/use/deep_empty.test | 10 - .../Tests/Fixtures/tags/use/inheritance.test | 25 - .../Tests/Fixtures/tags/use/inheritance2.test | 24 - .../Tests/Fixtures/tags/use/multiple.test | 21 - .../Fixtures/tags/use/multiple_aliases.test | 23 - .../Tests/Fixtures/tags/use/parent_block.test | 24 - .../Fixtures/tags/use/parent_block2.test | 24 - .../Fixtures/tags/use/parent_block3.test | 38 - .../Fixtures/tags/use/use_with_parent.test | 24 - .../Tests/Fixtures/tags/verbatim/basic.test | 10 - .../tags/verbatim/mixed_usage_with_raw.test | 10 - .../tags/verbatim/whitespace_control.test | 56 - .../Twig/Tests/Fixtures/tags/with/basic.test | 13 - .../Tests/Fixtures/tags/with/expression.test | 10 - .../Twig/Tests/Fixtures/tags/with/nested.test | 15 - .../Fixtures/tags/with/with_no_hash.test | 10 - .../Tests/Fixtures/tags/with/with_only.test | 10 - .../test/Twig/Tests/Fixtures/tests/array.test | 24 - .../Twig/Tests/Fixtures/tests/constant.test | 14 - .../Twig/Tests/Fixtures/tests/defined.test | 129 - .../Fixtures/tests/defined_for_attribute.test | 35 - .../Fixtures/tests/defined_for_blocks.test | 38 - .../defined_for_blocks_with_template.test | 17 - .../Fixtures/tests/defined_for_constants.test | 14 - .../test/Twig/Tests/Fixtures/tests/empty.test | 42 - .../test/Twig/Tests/Fixtures/tests/even.test | 14 - .../test/Twig/Tests/Fixtures/tests/in.test | 128 - .../Tests/Fixtures/tests/in_with_objects.test | 19 - .../Twig/Tests/Fixtures/tests/iterable.test | 19 - .../Tests/Fixtures/tests/null_coalesce.test | 30 - .../test/Twig/Tests/Fixtures/tests/odd.test | 10 - .../twig/test/Twig/Tests/IntegrationTest.php | 309 --- .../autoescape/filename.legacy.test | 18 - .../functions/undefined_block.legacy.test | 12 - .../Tests/LegacyFixtures/test.legacy.test | 8 - .../test/Twig/Tests/LegacyIntegrationTest.php | 54 - .../twig/twig/test/Twig/Tests/LexerTest.php | 347 --- .../twig/test/Twig/Tests/Loader/ArrayTest.php | 137 - .../twig/test/Twig/Tests/Loader/ChainTest.php | 124 - .../test/Twig/Tests/Loader/FilesystemTest.php | 226 -- .../array_inheritance_empty_parent.html.twig | 3 - ...y_inheritance_nonexistent_parent.html.twig | 3 - .../array_inheritance_null_parent.html.twig | 3 - .../array_inheritance_valid_parent.html.twig | 3 - .../Fixtures/inheritance/parent.html.twig | 1 - .../inheritance/spare_parent.html.twig | 1 - .../Tests/Loader/Fixtures/named/index.html | 1 - .../Loader/Fixtures/named_bis/index.html | 1 - .../Loader/Fixtures/named_final/index.html | 1 - .../Fixtures/named_quater/named_absolute.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 - .../Loader/Fixtures/phar/phar-sample.phar | Bin 6786 -> 0 bytes .../Fixtures/themes/theme1/blocks.html.twig | 3 - .../Fixtures/themes/theme2/blocks.html.twig | 3 - .../test/Twig/Tests/NativeExtensionTest.php | 32 - .../test/Twig/Tests/Node/AutoEscapeTest.php | 32 - .../Twig/Tests/Node/BlockReferenceTest.php | 31 - .../twig/test/Twig/Tests/Node/BlockTest.php | 39 - .../twig/twig/test/Twig/Tests/Node/DoTest.php | 32 - .../Twig/Tests/Node/Expression/ArrayTest.php | 37 - .../Tests/Node/Expression/AssignNameTest.php | 29 - .../Tests/Node/Expression/Binary/AddTest.php | 34 - .../Tests/Node/Expression/Binary/AndTest.php | 34 - .../Node/Expression/Binary/ConcatTest.php | 34 - .../Tests/Node/Expression/Binary/DivTest.php | 34 - .../Node/Expression/Binary/FloorDivTest.php | 34 - .../Tests/Node/Expression/Binary/ModTest.php | 34 - .../Tests/Node/Expression/Binary/MulTest.php | 34 - .../Tests/Node/Expression/Binary/OrTest.php | 34 - .../Tests/Node/Expression/Binary/SubTest.php | 34 - .../Twig/Tests/Node/Expression/CallTest.php | 143 - .../Tests/Node/Expression/ConditionalTest.php | 38 - .../Tests/Node/Expression/ConstantTest.php | 30 - .../Twig/Tests/Node/Expression/FilterTest.php | 154 -- .../Tests/Node/Expression/FunctionTest.php | 110 - .../Tests/Node/Expression/GetAttrTest.php | 50 - .../Twig/Tests/Node/Expression/NameTest.php | 43 - .../Node/Expression/NullCoalesceTest.php | 31 - .../Node/Expression/PHP53/FilterInclude.php | 6 - .../Node/Expression/PHP53/FunctionInclude.php | 6 - .../Node/Expression/PHP53/TestInclude.php | 6 - .../Twig/Tests/Node/Expression/ParentTest.php | 28 - .../Twig/Tests/Node/Expression/TestTest.php | 82 - .../Tests/Node/Expression/Unary/NegTest.php | 32 - .../Tests/Node/Expression/Unary/NotTest.php | 31 - .../Tests/Node/Expression/Unary/PosTest.php | 31 - .../twig/test/Twig/Tests/Node/ForTest.php | 191 -- .../twig/twig/test/Twig/Tests/Node/IfTest.php | 88 - .../twig/test/Twig/Tests/Node/ImportTest.php | 40 - .../twig/test/Twig/Tests/Node/IncludeTest.php | 83 - .../twig/test/Twig/Tests/Node/MacroTest.php | 74 - .../twig/test/Twig/Tests/Node/ModuleTest.php | 223 -- .../twig/test/Twig/Tests/Node/PrintTest.php | 29 - .../twig/test/Twig/Tests/Node/SandboxTest.php | 44 - .../Twig/Tests/Node/SandboxedPrintTest.php | 33 - .../twig/test/Twig/Tests/Node/SetTest.php | 69 - .../test/Twig/Tests/Node/SpacelessTest.php | 37 - .../twig/test/Twig/Tests/Node/TextTest.php | 28 - .../Twig/Tests/NodeVisitor/OptimizerTest.php | 124 - .../twig/twig/test/Twig/Tests/ParserTest.php | 198 -- .../Tests/Profiler/Dumper/AbstractTest.php | 101 - .../Tests/Profiler/Dumper/BlackfireTest.php | 32 - .../Twig/Tests/Profiler/Dumper/HtmlTest.php | 30 - .../Twig/Tests/Profiler/Dumper/TextTest.php | 30 - .../test/Twig/Tests/Profiler/ProfileTest.php | 110 - .../twig/test/Twig/Tests/TemplateTest.php | 761 ------ .../test/Twig/Tests/TemplateWrapperTest.php | 64 - .../twig/test/Twig/Tests/TokenStreamTest.php | 82 - .../Tests/Util/DeprecationCollectorTest.php | 42 - .../twig/test/Twig/Tests/escapingTest.php | 320 --- lib/silex/vendor/twig/twig/test/bootstrap.php | 13 - 2337 files changed, 215184 deletions(-) delete mode 100644 lib/silex/composer.json delete mode 100644 lib/silex/composer.lock delete mode 100644 lib/silex/vendor/autoload.php delete mode 100644 lib/silex/vendor/composer/ClassLoader.php delete mode 100644 lib/silex/vendor/composer/LICENSE delete mode 100644 lib/silex/vendor/composer/autoload_classmap.php delete mode 100644 lib/silex/vendor/composer/autoload_files.php delete mode 100644 lib/silex/vendor/composer/autoload_namespaces.php delete mode 100644 lib/silex/vendor/composer/autoload_psr4.php delete mode 100644 lib/silex/vendor/composer/autoload_real.php delete mode 100644 lib/silex/vendor/composer/autoload_static.php delete mode 100644 lib/silex/vendor/composer/installed.json delete mode 100644 lib/silex/vendor/paragonie/random_compat/LICENSE delete mode 100644 lib/silex/vendor/paragonie/random_compat/build-phar.sh delete mode 100644 lib/silex/vendor/paragonie/random_compat/composer.json delete mode 100644 lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey delete mode 100644 lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/byte_safe_strings.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/cast_to_int.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/error_polyfill.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/random.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/lib/random_int.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/other/build_phar.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/psalm-autoload.php delete mode 100644 lib/silex/vendor/paragonie/random_compat/psalm.xml delete mode 100644 lib/silex/vendor/pimple/pimple/.gitignore delete mode 100644 lib/silex/vendor/pimple/pimple/.travis.yml delete mode 100644 lib/silex/vendor/pimple/pimple/CHANGELOG delete mode 100644 lib/silex/vendor/pimple/pimple/LICENSE delete mode 100644 lib/silex/vendor/pimple/pimple/README.rst delete mode 100644 lib/silex/vendor/pimple/pimple/composer.json delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/.gitignore delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/README.md delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/config.m4 delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/config.w32 delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/php_pimple.h delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/pimple.c delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/pimple_compat.h delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/001.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/002.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/003.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/004.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/005.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/006.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/007.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/008.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/009.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/010.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/011.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/012.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/013.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/014.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/015.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/016.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/017.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/018.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/019.phpt delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench.phpb delete mode 100644 lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb delete mode 100644 lib/silex/vendor/pimple/pimple/lib/Pimple.php delete mode 100644 lib/silex/vendor/pimple/pimple/phpunit.xml.dist delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Container.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/Container.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/ServiceIterator.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Invokable.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/NonInvokable.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/PimpleServiceProvider.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Service.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleServiceProviderInterfaceTest.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleTest.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ContainerTest.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ServiceLocatorTest.php delete mode 100644 lib/silex/vendor/pimple/pimple/src/Pimple/Tests/ServiceIteratorTest.php delete mode 100644 lib/silex/vendor/psr/container/.gitignore delete mode 100644 lib/silex/vendor/psr/container/LICENSE delete mode 100644 lib/silex/vendor/psr/container/README.md delete mode 100644 lib/silex/vendor/psr/container/composer.json delete mode 100644 lib/silex/vendor/psr/container/src/ContainerExceptionInterface.php delete mode 100644 lib/silex/vendor/psr/container/src/ContainerInterface.php delete mode 100644 lib/silex/vendor/psr/container/src/NotFoundExceptionInterface.php delete mode 100644 lib/silex/vendor/psr/log/.gitignore delete mode 100644 lib/silex/vendor/psr/log/LICENSE delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/AbstractLogger.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/InvalidArgumentException.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/LogLevel.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/LoggerAwareInterface.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/LoggerAwareTrait.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/LoggerInterface.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/LoggerTrait.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/NullLogger.php delete mode 100644 lib/silex/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php delete mode 100644 lib/silex/vendor/psr/log/README.md delete mode 100644 lib/silex/vendor/psr/log/composer.json delete mode 100644 lib/silex/vendor/silex/silex/.gitignore delete mode 100644 lib/silex/vendor/silex/silex/.travis.yml delete mode 100644 lib/silex/vendor/silex/silex/LICENSE delete mode 100644 lib/silex/vendor/silex/silex/README.rst delete mode 100644 lib/silex/vendor/silex/silex/bin/build delete mode 100644 lib/silex/vendor/silex/silex/bin/compile delete mode 100644 lib/silex/vendor/silex/silex/bin/skeleton/fat_composer.json delete mode 100644 lib/silex/vendor/silex/silex/bin/skeleton/index.php delete mode 100644 lib/silex/vendor/silex/silex/bin/skeleton/slim_composer.json delete mode 100644 lib/silex/vendor/silex/silex/composer.json delete mode 100644 lib/silex/vendor/silex/silex/doc/changelog.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/conf.py delete mode 100644 lib/silex/vendor/silex/silex/doc/contributing.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/assets.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/error_handler.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/form_no_csrf.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/guard_authentication.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/index.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/json_request_body.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/multiple_loggers.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/session_storage.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/sub_requests.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/translating_validation_messages.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/cookbook/validator_yaml.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/index.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/internals.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/intro.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/middlewares.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/organizing_controllers.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/phar.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/asset.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/csrf.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/doctrine.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/form.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/http_cache.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/http_fragment.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/index.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/locale.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/monolog.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/remember_me.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/security.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/serializer.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/service_controller.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/session.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/swiftmailer.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/translation.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/twig.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/url_generator.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/validator.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/providers/var_dumper.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/services.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/testing.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/usage.rst delete mode 100644 lib/silex/vendor/silex/silex/doc/web_servers.rst delete mode 100644 lib/silex/vendor/silex/silex/exclude.txt delete mode 100644 lib/silex/vendor/silex/silex/phpunit.xml.dist delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Api/BootableProviderInterface.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Api/ControllerProviderInterface.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Api/EventListenerProviderInterface.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Api/LICENSE delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Api/composer.json delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/AppArgumentValueResolver.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application/FormTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application/MonologTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application/SecurityTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application/SwiftmailerTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application/TranslationTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application/TwigTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Application/UrlGeneratorTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/CallbackResolver.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ConstraintValidatorFactory.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Controller.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ControllerCollection.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ControllerProviderInterface.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ControllerResolver.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/EventListener/ConverterListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/EventListener/LocaleListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/EventListener/LogListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/EventListener/MiddlewareListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/EventListener/StringToResponseListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Exception/ControllerFrozenException.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ExceptionHandler.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ExceptionListenerWrapper.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/HttpCache.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/LazyUrlMatcher.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/AssetServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/CsrfServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/DoctrineServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/ExceptionHandlerServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Form/SilexFormExtension.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/FormServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCache/HttpCache.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/HttpFragmentServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/HttpKernelServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/LICENSE delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Locale/LocaleListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/LocaleServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/MonologServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/RememberMeServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/LazyRequestMatcher.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/RedirectableUrlMatcher.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/RoutingServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/SerializerServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/ServiceControllerServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Session/SessionListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Session/TestSessionListener.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/SessionServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/SwiftmailerServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/TranslationServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Twig/RuntimeLoader.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/TwigCoreExtension.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/TwigServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/UrlGeneratorServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/Validator/ConstraintValidatorFactory.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/ValidatorServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/VarDumperServiceProvider.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Provider/composer.json delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/RedirectableUrlMatcher.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Route.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Route/SecurityTrait.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ServiceControllerResolver.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ServiceProviderInterface.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Translator.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/Util/Compiler.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/ViewListenerWrapper.php delete mode 100644 lib/silex/vendor/silex/silex/src/Silex/WebTestCase.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormApplication.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologApplication.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityApplication.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerApplication.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationApplication.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigApplication.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorApplication.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/ApplicationTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackResolverTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackServicesTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerCollectionTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerResolverTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/EventListener/LogListenerTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/ExceptionHandlerTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/Php7Controller.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/manifest.json delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/FunctionalTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/JsonTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyDispatcherTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyRequestMatcherTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyUrlMatcherTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/LocaleTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/MiddlewareTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/AssetServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/DoctrineServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest/DisableCsrfExtension.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpCacheServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpFragmentServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/MonologServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RememberMeServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RoutingServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest/TokenAuthenticator.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SerializerServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SessionServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SpoolStub.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SwiftmailerServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TranslationServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TwigServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/UrlGeneratorServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/Custom.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/CustomValidator.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityRoute.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityTraitTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/RouterTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverRouterTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/StreamTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/Silex/Tests/WebTestCaseTest.php delete mode 100644 lib/silex/vendor/silex/silex/tests/bootstrap.php delete mode 100644 lib/silex/vendor/symfony/debug/.gitignore delete mode 100644 lib/silex/vendor/symfony/debug/BufferingLogger.php delete mode 100644 lib/silex/vendor/symfony/debug/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/debug/Debug.php delete mode 100644 lib/silex/vendor/symfony/debug/DebugClassLoader.php delete mode 100644 lib/silex/vendor/symfony/debug/ErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/ClassNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/ContextErrorException.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/FatalErrorException.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/FatalThrowableError.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/FlattenException.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/OutOfMemoryException.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/SilencedErrorContext.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/UndefinedFunctionException.php delete mode 100644 lib/silex/vendor/symfony/debug/Exception/UndefinedMethodException.php delete mode 100644 lib/silex/vendor/symfony/debug/ExceptionHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php delete mode 100644 lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/LICENSE delete mode 100644 lib/silex/vendor/symfony/debug/README.md delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/README.md delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/config.m4 delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/config.w32 delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/php_symfony_debug.h delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/symfony_debug.c delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/tests/001.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/tests/002.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/tests/002_1.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Resources/ext/tests/003.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/.gitignore delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Debug.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalThrowableError.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedMethodException.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/LICENSE delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/README.md delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/README.rst delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.m4 delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.w32 delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/php_symfony_debug.h delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/symfony_debug.c delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/tests/001.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/ClassAlias.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/PEARClass.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/casemismatch.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/notPsr0Bis.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/psr4/Psr4CaseMismatch.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/reallyNotPsr0.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures2/RequiredTwice.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/MockExceptionHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/composer.json delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/exclude.txt delete mode 100644 lib/silex/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/debug/Tests/DebugClassLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/ErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/ExceptionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/AnnotatedClass.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/ClassAlias.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/DeprecatedClass.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/DeprecatedInterface.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/ExtendedFinalMethod.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/FinalClass.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/FinalMethod.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/InternalClass.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/InternalInterface.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/InternalTrait.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/InternalTrait2.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/NonDeprecatedInterface.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/PEARClass.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/Throwing.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/ToStringThrower.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/casemismatch.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/notPsr0Bis.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/psr4/Psr4CaseMismatch.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures/reallyNotPsr0.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/Fixtures2/RequiredTwice.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/HeaderMock.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/MockExceptionHandler.php delete mode 100644 lib/silex/vendor/symfony/debug/Tests/phpt/debug_class_loader.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt delete mode 100644 lib/silex/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt delete mode 100644 lib/silex/vendor/symfony/debug/composer.json delete mode 100644 lib/silex/vendor/symfony/debug/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/.gitignore delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Debug/WrappedListener.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Event.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/EventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/EventDispatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/EventSubscriberInterface.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/GenericEvent.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/LICENSE delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/README.md delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/exclude.txt delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/EventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/EventTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/GenericEventTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/composer.json delete mode 100644 lib/silex/vendor/symfony/event-dispatcher/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/http-foundation/.gitignore delete mode 100644 lib/silex/vendor/symfony/http-foundation/AcceptHeader.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/AcceptHeaderItem.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/ApacheRequest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/BinaryFileResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/http-foundation/Cookie.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Exception/RequestExceptionInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/ExpressionRequestMatcher.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/Exception/FileException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/Exception/UploadException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/File.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/Stream.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/File/UploadedFile.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/FileBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/HeaderBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/IpUtils.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/JsonResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/LICENSE delete mode 100644 lib/silex/vendor/symfony/http-foundation/ParameterBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/README.md delete mode 100644 lib/silex/vendor/symfony/http-foundation/RedirectResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Request.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/RequestMatcher.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/RequestMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/RequestStack.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Response.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/ResponseHeaderBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/ServerBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBagInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Session.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/SessionBagInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/SessionBagProxy.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/SessionInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NullSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Session/Storage/SessionStorageInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/StreamedResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UploadException.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ClockMock.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/directory/.empty delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/other-file.example delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/test delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/test.gif delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/AutoExpireFlashBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/NativeProxyTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/exclude.txt delete mode 100644 lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderItemTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/ApacheRequestTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/CookieTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/ExpressionRequestMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/FakeFile.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/FileTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/test delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/FileBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/HeaderBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/IpUtilsTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/JsonResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/ParameterBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/RedirectResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/RequestMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/RequestStackTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/RequestTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/ResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/ResponseTestCase.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/ServerBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/AttributeBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/AutoExpireFlashBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/FlashBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/SessionTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/common.inc delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.expected delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/read_only.expected delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/read_only.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/regenerate.expected delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/regenerate.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/storage.expected delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/storage.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.expected delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie_and_session.expected delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie_and_session.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MetadataBagTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockArraySessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockFileSessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/NativeSessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/NativeProxyTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/StreamedResponseTest.php delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/schema/http-status-codes.rng delete mode 100644 lib/silex/vendor/symfony/http-foundation/Tests/schema/iana-registry.rng delete mode 100644 lib/silex/vendor/symfony/http-foundation/composer.json delete mode 100644 lib/silex/vendor/symfony/http-foundation/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/http-kernel/.gitignore delete mode 100644 lib/silex/vendor/symfony/http-kernel/Bundle/Bundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Bundle/BundleInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/http-kernel/CacheClearer/CacheClearerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/CacheClearer/ChainCacheClearer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/CacheClearer/Psr6CacheClearer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/CacheWarmer/WarmableInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Client.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Config/EnvParametersResource.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Config/FileLocator.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/DefaultValueResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestValueResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/VariadicValueResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolverInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ArgumentValueResolverInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ControllerReference.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolverInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/TraceableArgumentResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadata.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactory.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/AjaxDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/ConfigDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollectorInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/EventDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/ExceptionDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/LateDataCollectorInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/MemoryDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/RouterDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/TimeDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DataCollector/Util/ValueExporter.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Debug/FileLinkFormatter.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Debug/TraceableEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddClassesToCachePass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/ConfigurableExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/ControllerArgumentValueResolverPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/Extension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/FragmentRendererPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/LoggerPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/ResettableServicePass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/DependencyInjection/ServicesResetter.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/FilterControllerArgumentsEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/FilterControllerEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/FilterResponseEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/FinishRequestEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/GetResponseEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/GetResponseForControllerResultEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/GetResponseForExceptionEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/KernelEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Event/PostResponseEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/AbstractTestSessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/AddRequestFormatsListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/DumpListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/ExceptionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/FragmentListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/LocaleListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/ProfilerListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/ResponseListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/RouterListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/SaveSessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/SessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/StreamedResponseListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/SurrogateListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/TestSessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/TranslatorListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/AccessDeniedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/BadRequestHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/ConflictHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/GoneHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/HttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/HttpExceptionInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/LengthRequiredHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/MethodNotAllowedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/NotAcceptableHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/NotFoundHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/PreconditionFailedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/PreconditionRequiredHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/ServiceUnavailableHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/TooManyRequestsHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/UnauthorizedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/UnprocessableEntityHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Exception/UnsupportedMediaTypeHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/AbstractSurrogateFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/EsiFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/FragmentHandler.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/FragmentRendererInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/HIncludeFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/RoutableFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Fragment/SsiFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/Esi.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/HttpCache.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategyInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/Ssi.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/Store.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/StoreInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpCache/SurrogateInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/HttpKernelInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Kernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/KernelEvents.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/KernelInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/LICENSE delete mode 100644 lib/silex/vendor/symfony/http-kernel/Log/DebugLoggerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Log/Logger.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Profiler/Profile.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Profiler/Profiler.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Profiler/ProfilerStorageInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/README.md delete mode 100644 lib/silex/vendor/symfony/http-kernel/RebootableInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Resources/welcome.html.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/BundleInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/EnvParametersResource.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerReference.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/PostResponseEvent.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DumpListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TranslatorListener.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/SsiFragmentRenderer.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategyInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Ssi.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/LoggerInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/NullLogger.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/BaseBundle/Resources/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/BaseBundle/Resources/hide.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/Resources/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/bar.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle2Bundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ChildBundle/Resources/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ChildBundle/Resources/hide.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/BaseBundle/hide.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/Bundle1Bundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/ChildBundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/FooBundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcacheProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcachedProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/UriSignerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/exclude.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/http-kernel/TerminableInterface.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Bundle/BundleTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/ChainCacheClearerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/Psr6CacheClearerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/ClientTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Config/EnvParametersResourceTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolverTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Controller/ContainerControllerResolverTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Controller/ControllerResolverTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ConfigDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ExceptionDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/LoggerDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/MemoryDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/TimeDataCollectorTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Util/ValueExporterTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/FragmentRendererPassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LoggerPassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ResettableServicePassTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ServicesResetterTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DumpListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/BadRequestHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/ConflictHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/GoneHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/HttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/NotFoundHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/123/Kernel123.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/hide.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/Resources/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/bar.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle2Bundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/hide.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ClearableService.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/BasicTypesController.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingRequest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingSession.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/NullableController.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/VariadicController.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForOverrideName.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelWithoutBundles.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ResettableService.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Resources/BaseBundle/hide.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Resources/Bundle1Bundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Resources/ChildBundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Resources/FooBundle/foo.txt delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/TestClient.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/TestEventDispatcher.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fragment/EsiFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fragment/FragmentHandlerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fragment/RoutableFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Fragment/SsiFragmentRendererTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/EsiTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/ResponseCacheStrategyTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/SsiTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/StoreTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestHttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestMultipleHttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/HttpKernelTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/KernelTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Logger.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Profiler/FileProfilerStorageTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/Profiler/ProfilerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/TestHttpKernel.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/Tests/UriSignerTest.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/UriSigner.php delete mode 100644 lib/silex/vendor/symfony/http-kernel/composer.json delete mode 100644 lib/silex/vendor/symfony/http-kernel/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/polyfill-mbstring/LICENSE delete mode 100644 lib/silex/vendor/symfony/polyfill-mbstring/Mbstring.php delete mode 100644 lib/silex/vendor/symfony/polyfill-mbstring/README.md delete mode 100644 lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php delete mode 100644 lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php delete mode 100644 lib/silex/vendor/symfony/polyfill-mbstring/bootstrap.php delete mode 100644 lib/silex/vendor/symfony/polyfill-mbstring/composer.json delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/LICENSE delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Php70.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/README.md delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/AssertionError.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/Error.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/ParseError.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/TypeError.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/bootstrap.php delete mode 100644 lib/silex/vendor/symfony/polyfill-php70/composer.json delete mode 100644 lib/silex/vendor/symfony/routing/.gitignore delete mode 100644 lib/silex/vendor/symfony/routing/Annotation/Route.php delete mode 100644 lib/silex/vendor/symfony/routing/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/routing/CompiledRoute.php delete mode 100644 lib/silex/vendor/symfony/routing/DependencyInjection/RoutingResolverPass.php delete mode 100644 lib/silex/vendor/symfony/routing/Exception/ExceptionInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Exception/InvalidParameterException.php delete mode 100644 lib/silex/vendor/symfony/routing/Exception/MethodNotAllowedException.php delete mode 100644 lib/silex/vendor/symfony/routing/Exception/MissingMandatoryParametersException.php delete mode 100644 lib/silex/vendor/symfony/routing/Exception/NoConfigurationException.php delete mode 100644 lib/silex/vendor/symfony/routing/Exception/ResourceNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/routing/Exception/RouteNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/routing/Generator/ConfigurableRequirementsInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumperInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Generator/UrlGenerator.php delete mode 100644 lib/silex/vendor/symfony/routing/Generator/UrlGeneratorInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/LICENSE delete mode 100644 lib/silex/vendor/symfony/routing/Loader/AnnotationClassLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/AnnotationDirectoryLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/AnnotationFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/ClosureLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/DirectoryLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/ObjectRouteLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/PhpFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/XmlFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/YamlFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Loader/schema/routing/routing-1.0.xsd delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperCollection.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperRoute.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumperInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/RequestMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/TraceableUrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/UrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Matcher/UrlMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/README.md delete mode 100644 lib/silex/vendor/symfony/routing/RequestContext.php delete mode 100644 lib/silex/vendor/symfony/routing/RequestContextAwareInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Route.php delete mode 100644 lib/silex/vendor/symfony/routing/RouteCollection.php delete mode 100644 lib/silex/vendor/symfony/routing/RouteCollectionBuilder.php delete mode 100644 lib/silex/vendor/symfony/routing/RouteCompiler.php delete mode 100644 lib/silex/vendor/symfony/routing/RouteCompilerInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Router.php delete mode 100644 lib/silex/vendor/symfony/routing/RouterInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/.gitignore delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ExceptionInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/InvalidParameterException.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ResourceNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/RouteNotFoundException.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/LICENSE delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/README.md delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Route.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Router.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouterInterface.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/FooClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/annotated.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/empty.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/foo.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/foo1.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/incomplete.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_path.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid2.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidkeys.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidnode.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/null_values.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/with_define_path_variable.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/withdoctype.xml delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/LegacyApacheUrlMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RequestContextTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/composer.json delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/exclude.txt delete mode 100644 lib/silex/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Annotation/RouteTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/CompiledRouteTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomCompiledRoute.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/annotated.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/bad_format.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/bar.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/empty.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/file_resource.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/foo.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/foo1.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/incomplete.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/list_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/list_null_values.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/map_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/map_null_values.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_id.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_path.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/null_values.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/special_route_name.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.yml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Fixtures/withdoctype.xml delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Loader/YamlFileLoaderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/DumperCollectionTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Matcher/RedirectableUrlMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Matcher/TraceableUrlMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/RequestContextTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/RouteCollectionBuilderTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/RouteCollectionTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/RouteCompilerTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/RouteTest.php delete mode 100644 lib/silex/vendor/symfony/routing/Tests/RouterTest.php delete mode 100644 lib/silex/vendor/symfony/routing/composer.json delete mode 100644 lib/silex/vendor/symfony/routing/phpunit.xml.dist delete mode 100644 lib/silex/vendor/twig/twig/.editorconfig delete mode 100644 lib/silex/vendor/twig/twig/.gitignore delete mode 100644 lib/silex/vendor/twig/twig/.php_cs.dist delete mode 100644 lib/silex/vendor/twig/twig/.travis.yml delete mode 100644 lib/silex/vendor/twig/twig/CHANGELOG delete mode 100644 lib/silex/vendor/twig/twig/LICENSE delete mode 100644 lib/silex/vendor/twig/twig/README.rst delete mode 100644 lib/silex/vendor/twig/twig/composer.json delete mode 100644 lib/silex/vendor/twig/twig/doc/advanced.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/advanced_legacy.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/api.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/coding_standards.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/deprecated.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/abs.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/batch.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/capitalize.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/convert_encoding.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/date.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/date_modify.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/default.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/escape.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/first.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/format.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/index.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/join.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/json_encode.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/keys.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/last.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/length.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/lower.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/merge.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/nl2br.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/number_format.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/raw.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/replace.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/reverse.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/round.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/slice.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/sort.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/split.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/striptags.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/title.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/trim.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/upper.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/filters/url_encode.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/attribute.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/block.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/constant.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/cycle.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/date.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/dump.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/include.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/index.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/max.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/min.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/parent.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/random.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/range.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/source.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/functions/template_from_string.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/index.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/installation.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/internals.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/intro.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/recipes.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/autoescape.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/block.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/do.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/embed.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/extends.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/filter.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/flush.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/for.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/from.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/if.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/import.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/include.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/index.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/macro.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/sandbox.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/set.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/spaceless.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/use.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/verbatim.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tags/with.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/templates.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/constant.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/defined.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/divisibleby.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/empty.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/even.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/index.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/iterable.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/null.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/odd.rst delete mode 100644 lib/silex/vendor/twig/twig/doc/tests/sameas.rst delete mode 100644 lib/silex/vendor/twig/twig/exclude.txt delete mode 100644 lib/silex/vendor/twig/twig/ext/twig/.gitignore delete mode 100644 lib/silex/vendor/twig/twig/ext/twig/config.m4 delete mode 100644 lib/silex/vendor/twig/twig/ext/twig/config.w32 delete mode 100644 lib/silex/vendor/twig/twig/ext/twig/php_twig.h delete mode 100644 lib/silex/vendor/twig/twig/ext/twig/twig.c delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Autoloader.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/BaseNodeVisitor.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Cache/Filesystem.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Cache/Null.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/CacheInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Compiler.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/CompilerInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Environment.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Error.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Error/Loader.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Error/Runtime.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Error/Syntax.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/ExpressionParser.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/Core.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/Debug.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/Escaper.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/Optimizer.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/Profiler.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/Sandbox.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/Staging.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Extension/StringLoader.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/ExtensionInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Filter.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Filter/Function.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Filter/Method.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Filter/Node.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/FilterCallableInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/FilterInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Function.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Function/Function.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Function/Method.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Function/Node.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/FunctionInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Lexer.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/LexerInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Loader/Array.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Loader/Chain.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Loader/Filesystem.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Loader/String.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/LoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Markup.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/AutoEscape.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Block.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/BlockReference.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Body.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Do.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Embed.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Array.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Call.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Constant.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Function.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Name.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/TempName.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Flush.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/For.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/ForLoop.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/If.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Import.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Include.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Macro.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Module.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Print.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Sandbox.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Set.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/SetTemp.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Spaceless.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/Text.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Node/With.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeCaptureInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeOutputInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeTraverser.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Parser.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/ParserInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Base.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Profiler/Profile.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/SimpleFilter.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/SimpleFunction.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/SimpleTest.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Source.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Template.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TemplateInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TemplateWrapper.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Test.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Test/Function.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Test/Method.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Test/Node.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TestCallableInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TestInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Token.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Block.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Do.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Embed.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Extends.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Filter.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Flush.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/For.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/From.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/If.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Import.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Include.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Macro.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Set.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Use.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParser/With.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParserBroker.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenParserInterface.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/TokenStream.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php delete mode 100644 lib/silex/vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php delete mode 100644 lib/silex/vendor/twig/twig/phpunit.xml.dist delete mode 100644 lib/silex/vendor/twig/twig/src/Cache/CacheInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Cache/FilesystemCache.php delete mode 100644 lib/silex/vendor/twig/twig/src/Cache/NullCache.php delete mode 100644 lib/silex/vendor/twig/twig/src/Compiler.php delete mode 100644 lib/silex/vendor/twig/twig/src/Environment.php delete mode 100644 lib/silex/vendor/twig/twig/src/Error/Error.php delete mode 100644 lib/silex/vendor/twig/twig/src/Error/LoaderError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Error/RuntimeError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Error/SyntaxError.php delete mode 100644 lib/silex/vendor/twig/twig/src/ExpressionParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/AbstractExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/CoreExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/DebugExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/EscaperExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/ExtensionInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/GlobalsInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/InitRuntimeInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/OptimizerExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/ProfilerExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/RuntimeExtensionInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/SandboxExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/StagingExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/Extension/StringLoaderExtension.php delete mode 100644 lib/silex/vendor/twig/twig/src/FileExtensionEscapingStrategy.php delete mode 100644 lib/silex/vendor/twig/twig/src/Lexer.php delete mode 100644 lib/silex/vendor/twig/twig/src/Loader/ArrayLoader.php delete mode 100644 lib/silex/vendor/twig/twig/src/Loader/ChainLoader.php delete mode 100644 lib/silex/vendor/twig/twig/src/Loader/ExistsLoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Loader/FilesystemLoader.php delete mode 100644 lib/silex/vendor/twig/twig/src/Loader/LoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Loader/SourceContextLoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Markup.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/AutoEscapeNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/BlockNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/BlockReferenceNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/BodyNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/CheckSecurityNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/DoNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/EmbedNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/AbstractExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/ArrayExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/AssignNameExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/AbstractBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/AddBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/AndBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/BitwiseAndBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/BitwiseOrBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/BitwiseXorBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/ConcatBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/DivBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/EndsWithBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/EqualBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/FloorDivBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/GreaterBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/GreaterEqualBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/InBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/LessBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/LessEqualBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/MatchesBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/ModBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/MulBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/NotEqualBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/NotInBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/OrBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/PowerBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/RangeBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Binary/SubBinary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/BlockReferenceExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/CallExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/ConditionalExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/ConstantExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Filter/DefaultFilter.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/FilterExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/FunctionExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/GetAttrExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/MethodCallExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/NameExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/NullCoalesceExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/ParentExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/TempNameExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Test/ConstantTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Test/DefinedTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Test/DivisiblebyTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Test/EvenTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Test/NullTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Test/OddTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Test/SameasTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/TestExpression.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Unary/AbstractUnary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Unary/NegUnary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Unary/NotUnary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Expression/Unary/PosUnary.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/FlushNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/ForLoopNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/ForNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/IfNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/ImportNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/IncludeNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/MacroNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/ModuleNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/Node.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/NodeCaptureInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/NodeOutputInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/PrintNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/SandboxNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/SandboxedPrintNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/SetNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/SetTempNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/SpacelessNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/TextNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Node/WithNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/NodeTraverser.php delete mode 100644 lib/silex/vendor/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php delete mode 100644 lib/silex/vendor/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php delete mode 100644 lib/silex/vendor/twig/twig/src/NodeVisitor/NodeVisitorInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/NodeVisitor/OptimizerNodeVisitor.php delete mode 100644 lib/silex/vendor/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php delete mode 100644 lib/silex/vendor/twig/twig/src/NodeVisitor/SandboxNodeVisitor.php delete mode 100644 lib/silex/vendor/twig/twig/src/Parser.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/Dumper/BaseDumper.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/Dumper/BlackfireDumper.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/Dumper/HtmlDumper.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/Dumper/TextDumper.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/Node/EnterProfileNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/Node/LeaveProfileNode.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php delete mode 100644 lib/silex/vendor/twig/twig/src/Profiler/Profile.php delete mode 100644 lib/silex/vendor/twig/twig/src/RuntimeLoader/ContainerRuntimeLoader.php delete mode 100644 lib/silex/vendor/twig/twig/src/RuntimeLoader/FactoryRuntimeLoader.php delete mode 100644 lib/silex/vendor/twig/twig/src/RuntimeLoader/RuntimeLoaderInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityNotAllowedFilterError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityNotAllowedFunctionError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityNotAllowedMethodError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityNotAllowedPropertyError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityNotAllowedTagError.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityPolicy.php delete mode 100644 lib/silex/vendor/twig/twig/src/Sandbox/SecurityPolicyInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/Source.php delete mode 100644 lib/silex/vendor/twig/twig/src/Template.php delete mode 100644 lib/silex/vendor/twig/twig/src/TemplateWrapper.php delete mode 100644 lib/silex/vendor/twig/twig/src/Test/IntegrationTestCase.php delete mode 100644 lib/silex/vendor/twig/twig/src/Test/NodeTestCase.php delete mode 100644 lib/silex/vendor/twig/twig/src/Token.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/AbstractTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/AutoEscapeTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/BlockTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/DoTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/EmbedTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/ExtendsTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/FilterTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/FlushTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/ForTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/FromTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/IfTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/ImportTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/IncludeTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/MacroTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/SandboxTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/SetTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/SpacelessTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/TokenParserInterface.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/UseTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenParser/WithTokenParser.php delete mode 100644 lib/silex/vendor/twig/twig/src/TokenStream.php delete mode 100644 lib/silex/vendor/twig/twig/src/TwigFilter.php delete mode 100644 lib/silex/vendor/twig/twig/src/TwigFunction.php delete mode 100644 lib/silex/vendor/twig/twig/src/TwigTest.php delete mode 100644 lib/silex/vendor/twig/twig/src/Util/DeprecationCollector.php delete mode 100644 lib/silex/vendor/twig/twig/src/Util/TemplateDirIterator.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/AutoloaderTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/CompilerTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/ContainerRuntimeLoaderTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/CustomExtensionTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/ErrorTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/FactoryRuntimeLoaderTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/FilesystemHelper.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/block.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/filename.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/child_contents_outside_blocks.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/syntax_error_in_reused_template.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/unclosed_tag.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_parent.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_template_in_child_template.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_trait.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/_self.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array_call.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/binary.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/comparison.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/divisibleby.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/dotdot.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ends_with.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/grouping.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/literals.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/magic_call.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/matches.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/negative_numbers.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/operators_as_variables.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/power.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/sameas.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/starts_with.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/strings.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_noelse.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_nothen.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/two_word_operators_as_variables.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_macro_arguments.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_precedence.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/abs.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_float.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_empty_fill.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_exact_elements.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_fill.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_keys.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_zero_elements.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/convert_encoding.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format_interval.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_immutable.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_namedargs.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/dynamic_filter.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_html_attr.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_javascript.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_non_supported_charset.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/first.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/format.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/json_encode.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/last.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length_utf8.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/nl2br.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format_default.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace_invalid_arg.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/reverse.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/round.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/sort.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/special_chars.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split_utf8.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/static_calls.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/trim.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode_deprecated.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_with_template.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_without_name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/constant.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/cycle.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date_namedargs.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump_array.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dynamic_function.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/assignment.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/autoescaping.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/expression.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/ignore_missing.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing_nested.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/template_instance.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/templates_as_array.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_context.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_variables.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call53.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/max.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/min.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/range.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/source.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/special_chars.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/static_calls.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/default_values.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/simple.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/with_filters.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/combined_debug_info.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/empty_token.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/issue_1143.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/multi_word_tests.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/simple_xml_element.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/strings_like_numbers.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/literal.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/nested.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/objects.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/raw.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_preserves_safety_filters.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/block_unique_name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/special_chars.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/complex_dynamic_parent.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/dynamic_parent.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/error_line.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/multiple.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/with_extends.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/json_encode.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/multiple.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/nested.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/condition.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/context.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/else.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/inner_variables.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys_and_values.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context_local.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined_cond.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/nested_else.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects_countable.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/recursive.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/values.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/from.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/expression.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/expression.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/ignore_missing.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/only.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/template_instance.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/templates_as_array.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/with_variables.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr2.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/conditional.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/empty.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple_dynamic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks_parent_only.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_change.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_in_a_block.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_isolation.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends_but_traits.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/use.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/external.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/global.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/self_import.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/super_globals.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.legacy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.legacy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid1.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid2.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/simple.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture-empty.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/expression.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/spaceless/simple.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/special_chars.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/trim_block.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/aliases.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep_empty.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple_aliases.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block2.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block3.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/use_with_parent.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/whitespace_control.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/basic.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/expression.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/nested.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_no_hash.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_only.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/array.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_attribute.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks_with_template.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_constants.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/even.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/iterable.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/null_coalesce.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/odd.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/autoescape/filename.legacy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/functions/undefined_block.legacy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/LexerTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ArrayTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ChainTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/parent.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/spare_parent.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/phar/phar-sample.phar delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/DoTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NullCoalesceTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/ParserTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/BlackfireTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateWrapperTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/Util/DeprecationCollectorTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/Twig/Tests/escapingTest.php delete mode 100644 lib/silex/vendor/twig/twig/test/bootstrap.php diff --git a/lib/silex/composer.json b/lib/silex/composer.json deleted file mode 100644 index caf83ddd4..000000000 --- a/lib/silex/composer.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "require": { - "silex/silex": "~2.0", - "twig/twig": "1.35" - } -} diff --git a/lib/silex/composer.lock b/lib/silex/composer.lock deleted file mode 100644 index 3a3bcde1b..000000000 --- a/lib/silex/composer.lock +++ /dev/null @@ -1,823 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "content-hash": "d3dddb99878fdc490eef79fde08c0b81", - "packages": [ - { - "name": "paragonie/random_compat", - "version": "v2.0.11", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8", - "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "autoload": { - "files": [ - "lib/random.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "pseudorandom", - "random" - ], - "time": "2017-09-27T21:40:39+00:00" - }, - { - "name": "pimple/pimple", - "version": "v3.2.3", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Pimple.git", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/container": "^1.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "psr-0": { - "Pimple": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Pimple, a simple Dependency Injection Container", - "homepage": "http://pimple.sensiolabs.org", - "keywords": [ - "container", - "dependency injection" - ], - "time": "2018-01-21T07:42:36+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/log", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2016-10-10T12:19:37+00:00" - }, - { - "name": "silex/silex", - "version": "v2.2.2", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Silex.git", - "reference": "3fe50331f194c83ded2f824c47c1c24c20877a8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Silex/zipball/3fe50331f194c83ded2f824c47c1c24c20877a8c", - "reference": "3fe50331f194c83ded2f824c47c1c24c20877a8c", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "pimple/pimple": "~3.0", - "symfony/event-dispatcher": "~2.8|^3.0", - "symfony/http-foundation": "~2.8|^3.0", - "symfony/http-kernel": "~2.8|^3.0", - "symfony/routing": "~2.8|^3.0" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35 || >= 5.0, <5.4.3" - }, - "replace": { - "silex/api": "self.version", - "silex/providers": "self.version" - }, - "require-dev": { - "doctrine/dbal": "~2.2", - "monolog/monolog": "^1.4.1", - "swiftmailer/swiftmailer": "~5", - "symfony/asset": "~2.8|^3.0", - "symfony/browser-kit": "~2.8|^3.0", - "symfony/config": "~2.8|^3.0", - "symfony/css-selector": "~2.8|^3.0", - "symfony/debug": "~2.8|^3.0", - "symfony/doctrine-bridge": "~2.8|^3.0", - "symfony/dom-crawler": "~2.8|^3.0", - "symfony/expression-language": "~2.8|^3.0", - "symfony/finder": "~2.8|^3.0", - "symfony/form": "~2.8|^3.0", - "symfony/intl": "~2.8|^3.0", - "symfony/monolog-bridge": "~2.8|^3.0", - "symfony/options-resolver": "~2.8|^3.0", - "symfony/phpunit-bridge": "^3.2", - "symfony/process": "~2.8|^3.0", - "symfony/security": "~2.8|^3.0", - "symfony/serializer": "~2.8|^3.0", - "symfony/translation": "~2.8|^3.0", - "symfony/twig-bridge": "~2.8|^3.0", - "symfony/validator": "~2.8|^3.0", - "symfony/var-dumper": "~2.8|^3.0", - "symfony/web-link": "^3.3", - "twig/twig": "~1.28|~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Silex\\": "src/Silex" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "The PHP micro-framework based on the Symfony Components", - "homepage": "http://silex.sensiolabs.org", - "keywords": [ - "microframework" - ], - "time": "2018-01-12T07:16:03+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.4.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "53f6af2805daf52a43b393b93d2f24925d35c937" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/53f6af2805daf52a43b393b93d2f24925d35c937", - "reference": "53f6af2805daf52a43b393b93d2f24925d35c937", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2018-01-18T22:16:57+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v3.4.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "26b87b6bca8f8f797331a30b76fdae5342dc26ca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/26b87b6bca8f8f797331a30b76fdae5342dc26ca", - "reference": "26b87b6bca8f8f797331a30b76fdae5342dc26ca", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2018-01-03T07:37:34+00:00" - }, - { - "name": "symfony/http-foundation", - "version": "v3.4.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "8c39071ac9cc7e6d8dab1d556c990dc0d2cc3d30" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8c39071ac9cc7e6d8dab1d556c990dc0d2cc3d30", - "reference": "8c39071ac9cc7e6d8dab1d556c990dc0d2cc3d30", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php70": "~1.6" - }, - "require-dev": { - "symfony/expression-language": "~2.8|~3.0|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com", - "time": "2018-01-29T09:03:43+00:00" - }, - { - "name": "symfony/http-kernel", - "version": "v3.4.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "911d2e5dd4beb63caad9a72e43857de984301907" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/911d2e5dd4beb63caad9a72e43857de984301907", - "reference": "911d2e5dd4beb63caad9a72e43857de984301907", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0", - "symfony/debug": "~2.8|~3.0|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "^3.4.4|^4.0.4" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.4", - "symfony/var-dumper": "<3.3", - "twig/twig": "<1.34|<2.4,>=2" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/cache": "~1.0", - "symfony/browser-kit": "~2.8|~3.0|~4.0", - "symfony/class-loader": "~2.8|~3.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/console": "~2.8|~3.0|~4.0", - "symfony/css-selector": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/dom-crawler": "~2.8|~3.0|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/process": "~2.8|~3.0|~4.0", - "symfony/routing": "~3.4|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/templating": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/var-dumper": "~3.3|~4.0" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpKernel Component", - "homepage": "https://symfony.com", - "time": "2018-01-29T12:29:46+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2017-10-11T12:05:26+00:00" - }, - { - "name": "symfony/polyfill-php70", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", - "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2017-10-11T12:05:26+00:00" - }, - { - "name": "symfony/routing", - "version": "v3.4.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/routing.git", - "reference": "235d01730d553a97732990588407eaf6779bb4b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/235d01730d553a97732990588407eaf6779bb4b2", - "reference": "235d01730d553a97732990588407eaf6779bb4b2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.3", - "symfony/yaml": "<3.4" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/common": "~2.2", - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation loader", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/dependency-injection": "For loading routes from a service", - "symfony/expression-language": "For using expression matching", - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/yaml": "For using the YAML loader" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Routing\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Routing Component", - "homepage": "https://symfony.com", - "keywords": [ - "router", - "routing", - "uri", - "url" - ], - "time": "2018-01-16T18:03:57+00:00" - }, - { - "name": "twig/twig", - "version": "v1.35.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "daa657073e55b0a78cce8fdd22682fddecc6385f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/daa657073e55b0a78cce8fdd22682fddecc6385f", - "reference": "daa657073e55b0a78cce8fdd22682fddecc6385f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/container": "^1.0", - "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~3.3@dev" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.35-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - }, - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "http://twig.sensiolabs.org/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" - ], - "time": "2017-09-27T18:06:46+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [] -} diff --git a/lib/silex/vendor/autoload.php b/lib/silex/vendor/autoload.php deleted file mode 100644 index ac73d8e52..000000000 --- a/lib/silex/vendor/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - private $classMapAuthoritative = false; - private $missingClasses = array(); - private $apcuPrefix; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath.'\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/lib/silex/vendor/composer/LICENSE b/lib/silex/vendor/composer/LICENSE deleted file mode 100644 index f27399a04..000000000 --- a/lib/silex/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/lib/silex/vendor/composer/autoload_classmap.php b/lib/silex/vendor/composer/autoload_classmap.php deleted file mode 100644 index 3a1416586..000000000 --- a/lib/silex/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,16 +0,0 @@ - $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php', - 'AssertionError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php', - 'DivisionByZeroError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', - 'Error' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/Error.php', - 'ParseError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ParseError.php', - 'SessionUpdateTimestampHandlerInterface' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php', - 'TypeError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/TypeError.php', -); diff --git a/lib/silex/vendor/composer/autoload_files.php b/lib/silex/vendor/composer/autoload_files.php deleted file mode 100644 index 776c6b55f..000000000 --- a/lib/silex/vendor/composer/autoload_files.php +++ /dev/null @@ -1,12 +0,0 @@ - $vendorDir . '/paragonie/random_compat/lib/random.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', - '023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php', -); diff --git a/lib/silex/vendor/composer/autoload_namespaces.php b/lib/silex/vendor/composer/autoload_namespaces.php deleted file mode 100644 index 213236c48..000000000 --- a/lib/silex/vendor/composer/autoload_namespaces.php +++ /dev/null @@ -1,11 +0,0 @@ - array($vendorDir . '/twig/twig/lib'), - 'Pimple' => array($vendorDir . '/pimple/pimple/src'), -); diff --git a/lib/silex/vendor/composer/autoload_psr4.php b/lib/silex/vendor/composer/autoload_psr4.php deleted file mode 100644 index dfd2e66ee..000000000 --- a/lib/silex/vendor/composer/autoload_psr4.php +++ /dev/null @@ -1,20 +0,0 @@ - array($vendorDir . '/twig/twig/src'), - 'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'), - 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), - 'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'), - 'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'), - 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), - 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), - 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'), - 'Silex\\' => array($vendorDir . '/silex/silex/src/Silex'), - 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), - 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), -); diff --git a/lib/silex/vendor/composer/autoload_real.php b/lib/silex/vendor/composer/autoload_real.php deleted file mode 100644 index efc522d51..000000000 --- a/lib/silex/vendor/composer/autoload_real.php +++ /dev/null @@ -1,70 +0,0 @@ -= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require_once __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInitc52ed037323c1472e1ed6497110f13b1::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } - - $loader->register(true); - - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitc52ed037323c1472e1ed6497110f13b1::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } - foreach ($includeFiles as $fileIdentifier => $file) { - composerRequirec52ed037323c1472e1ed6497110f13b1($fileIdentifier, $file); - } - - return $loader; - } -} - -function composerRequirec52ed037323c1472e1ed6497110f13b1($fileIdentifier, $file) -{ - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - require $file; - - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - } -} diff --git a/lib/silex/vendor/composer/autoload_static.php b/lib/silex/vendor/composer/autoload_static.php deleted file mode 100644 index 3c1511d96..000000000 --- a/lib/silex/vendor/composer/autoload_static.php +++ /dev/null @@ -1,122 +0,0 @@ - __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', - '023d27dca8066ef29e6739335ea73bad' => __DIR__ . '/..' . '/symfony/polyfill-php70/bootstrap.php', - ); - - public static $prefixLengthsPsr4 = array ( - 'T' => - array ( - 'Twig\\' => 5, - ), - 'S' => - array ( - 'Symfony\\Polyfill\\Php70\\' => 23, - 'Symfony\\Polyfill\\Mbstring\\' => 26, - 'Symfony\\Component\\Routing\\' => 26, - 'Symfony\\Component\\HttpKernel\\' => 29, - 'Symfony\\Component\\HttpFoundation\\' => 33, - 'Symfony\\Component\\EventDispatcher\\' => 34, - 'Symfony\\Component\\Debug\\' => 24, - 'Silex\\' => 6, - ), - 'P' => - array ( - 'Psr\\Log\\' => 8, - 'Psr\\Container\\' => 14, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'Twig\\' => - array ( - 0 => __DIR__ . '/..' . '/twig/twig/src', - ), - 'Symfony\\Polyfill\\Php70\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-php70', - ), - 'Symfony\\Polyfill\\Mbstring\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', - ), - 'Symfony\\Component\\Routing\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/routing', - ), - 'Symfony\\Component\\HttpKernel\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/http-kernel', - ), - 'Symfony\\Component\\HttpFoundation\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/http-foundation', - ), - 'Symfony\\Component\\EventDispatcher\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/event-dispatcher', - ), - 'Symfony\\Component\\Debug\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/debug', - ), - 'Silex\\' => - array ( - 0 => __DIR__ . '/..' . '/silex/silex/src/Silex', - ), - 'Psr\\Log\\' => - array ( - 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', - ), - 'Psr\\Container\\' => - array ( - 0 => __DIR__ . '/..' . '/psr/container/src', - ), - ); - - public static $prefixesPsr0 = array ( - 'T' => - array ( - 'Twig_' => - array ( - 0 => __DIR__ . '/..' . '/twig/twig/lib', - ), - ), - 'P' => - array ( - 'Pimple' => - array ( - 0 => __DIR__ . '/..' . '/pimple/pimple/src', - ), - ), - ); - - public static $classMap = array ( - 'ArithmeticError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php', - 'AssertionError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php', - 'DivisionByZeroError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', - 'Error' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/Error.php', - 'ParseError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ParseError.php', - 'SessionUpdateTimestampHandlerInterface' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php', - 'TypeError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/TypeError.php', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitc52ed037323c1472e1ed6497110f13b1::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitc52ed037323c1472e1ed6497110f13b1::$prefixDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInitc52ed037323c1472e1ed6497110f13b1::$prefixesPsr0; - $loader->classMap = ComposerStaticInitc52ed037323c1472e1ed6497110f13b1::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/lib/silex/vendor/composer/installed.json b/lib/silex/vendor/composer/installed.json deleted file mode 100644 index 6098adaf5..000000000 --- a/lib/silex/vendor/composer/installed.json +++ /dev/null @@ -1,833 +0,0 @@ -[ - { - "name": "paragonie/random_compat", - "version": "v2.0.11", - "version_normalized": "2.0.11.0", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8", - "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "time": "2017-09-27T21:40:39+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "lib/random.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "pseudorandom", - "random" - ] - }, - { - "name": "pimple/pimple", - "version": "v3.2.3", - "version_normalized": "3.2.3.0", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Pimple.git", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/container": "^1.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.2" - }, - "time": "2018-01-21T07:42:36+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Pimple": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Pimple, a simple Dependency Injection Container", - "homepage": "http://pimple.sensiolabs.org", - "keywords": [ - "container", - "dependency injection" - ] - }, - { - "name": "psr/container", - "version": "1.0.0", - "version_normalized": "1.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2017-02-14T16:28:37+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ] - }, - { - "name": "psr/log", - "version": "1.0.2", - "version_normalized": "1.0.2.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2016-10-10T12:19:37+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ] - }, - { - "name": "silex/silex", - "version": "v2.2.2", - "version_normalized": "2.2.2.0", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Silex.git", - "reference": "3fe50331f194c83ded2f824c47c1c24c20877a8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Silex/zipball/3fe50331f194c83ded2f824c47c1c24c20877a8c", - "reference": "3fe50331f194c83ded2f824c47c1c24c20877a8c", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "pimple/pimple": "~3.0", - "symfony/event-dispatcher": "~2.8|^3.0", - "symfony/http-foundation": "~2.8|^3.0", - "symfony/http-kernel": "~2.8|^3.0", - "symfony/routing": "~2.8|^3.0" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35 || >= 5.0, <5.4.3" - }, - "replace": { - "silex/api": "self.version", - "silex/providers": "self.version" - }, - "require-dev": { - "doctrine/dbal": "~2.2", - "monolog/monolog": "^1.4.1", - "swiftmailer/swiftmailer": "~5", - "symfony/asset": "~2.8|^3.0", - "symfony/browser-kit": "~2.8|^3.0", - "symfony/config": "~2.8|^3.0", - "symfony/css-selector": "~2.8|^3.0", - "symfony/debug": "~2.8|^3.0", - "symfony/doctrine-bridge": "~2.8|^3.0", - "symfony/dom-crawler": "~2.8|^3.0", - "symfony/expression-language": "~2.8|^3.0", - "symfony/finder": "~2.8|^3.0", - "symfony/form": "~2.8|^3.0", - "symfony/intl": "~2.8|^3.0", - "symfony/monolog-bridge": "~2.8|^3.0", - "symfony/options-resolver": "~2.8|^3.0", - "symfony/phpunit-bridge": "^3.2", - "symfony/process": "~2.8|^3.0", - "symfony/security": "~2.8|^3.0", - "symfony/serializer": "~2.8|^3.0", - "symfony/translation": "~2.8|^3.0", - "symfony/twig-bridge": "~2.8|^3.0", - "symfony/validator": "~2.8|^3.0", - "symfony/var-dumper": "~2.8|^3.0", - "symfony/web-link": "^3.3", - "twig/twig": "~1.28|~2.0" - }, - "time": "2018-01-12T07:16:03+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Silex\\": "src/Silex" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "The PHP micro-framework based on the Symfony Components", - "homepage": "http://silex.sensiolabs.org", - "keywords": [ - "microframework" - ] - }, - { - "name": "symfony/debug", - "version": "v3.4.4", - "version_normalized": "3.4.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "53f6af2805daf52a43b393b93d2f24925d35c937" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/53f6af2805daf52a43b393b93d2f24925d35c937", - "reference": "53f6af2805daf52a43b393b93d2f24925d35c937", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "time": "2018-01-18T22:16:57+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com" - }, - { - "name": "symfony/event-dispatcher", - "version": "v3.4.4", - "version_normalized": "3.4.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "26b87b6bca8f8f797331a30b76fdae5342dc26ca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/26b87b6bca8f8f797331a30b76fdae5342dc26ca", - "reference": "26b87b6bca8f8f797331a30b76fdae5342dc26ca", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "time": "2018-01-03T07:37:34+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com" - }, - { - "name": "symfony/http-foundation", - "version": "v3.4.4", - "version_normalized": "3.4.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "8c39071ac9cc7e6d8dab1d556c990dc0d2cc3d30" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8c39071ac9cc7e6d8dab1d556c990dc0d2cc3d30", - "reference": "8c39071ac9cc7e6d8dab1d556c990dc0d2cc3d30", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php70": "~1.6" - }, - "require-dev": { - "symfony/expression-language": "~2.8|~3.0|~4.0" - }, - "time": "2018-01-29T09:03:43+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com" - }, - { - "name": "symfony/http-kernel", - "version": "v3.4.4", - "version_normalized": "3.4.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "911d2e5dd4beb63caad9a72e43857de984301907" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/911d2e5dd4beb63caad9a72e43857de984301907", - "reference": "911d2e5dd4beb63caad9a72e43857de984301907", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0", - "symfony/debug": "~2.8|~3.0|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "^3.4.4|^4.0.4" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.4", - "symfony/var-dumper": "<3.3", - "twig/twig": "<1.34|<2.4,>=2" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/cache": "~1.0", - "symfony/browser-kit": "~2.8|~3.0|~4.0", - "symfony/class-loader": "~2.8|~3.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/console": "~2.8|~3.0|~4.0", - "symfony/css-selector": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/dom-crawler": "~2.8|~3.0|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/process": "~2.8|~3.0|~4.0", - "symfony/routing": "~3.4|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/templating": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/var-dumper": "~3.3|~4.0" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "time": "2018-01-29T12:29:46+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpKernel Component", - "homepage": "https://symfony.com" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.6.0", - "version_normalized": "1.6.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "time": "2017-10-11T12:05:26+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ] - }, - { - "name": "symfony/polyfill-php70", - "version": "v1.6.0", - "version_normalized": "1.6.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", - "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0", - "php": ">=5.3.3" - }, - "time": "2017-10-11T12:05:26+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ] - }, - { - "name": "symfony/routing", - "version": "v3.4.4", - "version_normalized": "3.4.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/routing.git", - "reference": "235d01730d553a97732990588407eaf6779bb4b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/235d01730d553a97732990588407eaf6779bb4b2", - "reference": "235d01730d553a97732990588407eaf6779bb4b2", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.3", - "symfony/yaml": "<3.4" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/common": "~2.2", - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation loader", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/dependency-injection": "For loading routes from a service", - "symfony/expression-language": "For using expression matching", - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/yaml": "For using the YAML loader" - }, - "time": "2018-01-16T18:03:57+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Component\\Routing\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Routing Component", - "homepage": "https://symfony.com", - "keywords": [ - "router", - "routing", - "uri", - "url" - ] - }, - { - "name": "twig/twig", - "version": "v1.35.0", - "version_normalized": "1.35.0.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "daa657073e55b0a78cce8fdd22682fddecc6385f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/daa657073e55b0a78cce8fdd22682fddecc6385f", - "reference": "daa657073e55b0a78cce8fdd22682fddecc6385f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/container": "^1.0", - "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~3.3@dev" - }, - "time": "2017-09-27T18:06:46+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.35-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Twig_": "lib/" - }, - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "http://twig.sensiolabs.org/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" - ] - } -] diff --git a/lib/silex/vendor/paragonie/random_compat/LICENSE b/lib/silex/vendor/paragonie/random_compat/LICENSE deleted file mode 100644 index 45c7017df..000000000 --- a/lib/silex/vendor/paragonie/random_compat/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Paragon Initiative Enterprises - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/lib/silex/vendor/paragonie/random_compat/build-phar.sh b/lib/silex/vendor/paragonie/random_compat/build-phar.sh deleted file mode 100644 index b4a5ba31c..000000000 --- a/lib/silex/vendor/paragonie/random_compat/build-phar.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -basedir=$( dirname $( readlink -f ${BASH_SOURCE[0]} ) ) - -php -dphar.readonly=0 "$basedir/other/build_phar.php" $* \ No newline at end of file diff --git a/lib/silex/vendor/paragonie/random_compat/composer.json b/lib/silex/vendor/paragonie/random_compat/composer.json deleted file mode 100644 index 1c5978c6f..000000000 --- a/lib/silex/vendor/paragonie/random_compat/composer.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "paragonie/random_compat", - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "random", - "pseudorandom" - ], - "license": "MIT", - "type": "library", - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "support": { - "issues": "https://github.com/paragonie/random_compat/issues", - "email": "info@paragonie.com", - "source": "https://github.com/paragonie/random_compat" - }, - "require": { - "php": ">=5.2.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "autoload": { - "files": [ - "lib/random.php" - ] - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey b/lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey deleted file mode 100644 index eb50ebfcd..000000000 --- a/lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEEd+wCqJDrx5B4OldM0dQE0ZMX+lx1ZWm -pui0SUqD4G29L3NGsz9UhJ/0HjBdbnkhIK5xviT0X5vtjacF6ajgcCArbTB+ds+p -+h7Q084NuSuIpNb6YPfoUFgC/CL9kAoc ------END PUBLIC KEY----- diff --git a/lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc b/lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc deleted file mode 100644 index 6a1d7f300..000000000 --- a/lib/silex/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc +++ /dev/null @@ -1,11 +0,0 @@ ------BEGIN PGP SIGNATURE----- -Version: GnuPG v2.0.22 (MingW32) - -iQEcBAABAgAGBQJWtW1hAAoJEGuXocKCZATaJf0H+wbZGgskK1dcRTsuVJl9IWip -QwGw/qIKI280SD6/ckoUMxKDCJiFuPR14zmqnS36k7N5UNPnpdTJTS8T11jttSpg -1LCmgpbEIpgaTah+cELDqFCav99fS+bEiAL5lWDAHBTE/XPjGVCqeehyPYref4IW -NDBIEsvnHPHPLsn6X5jq4+Yj5oUixgxaMPiR+bcO4Sh+RzOVB6i2D0upWfRXBFXA -NNnsg9/zjvoC7ZW73y9uSH+dPJTt/Vgfeiv52/v41XliyzbUyLalf02GNPY+9goV -JHG1ulEEBJOCiUD9cE1PUIJwHA/HqyhHIvV350YoEFiHl8iSwm7SiZu5kPjaq74= -=B6+8 ------END PGP SIGNATURE----- diff --git a/lib/silex/vendor/paragonie/random_compat/lib/byte_safe_strings.php b/lib/silex/vendor/paragonie/random_compat/lib/byte_safe_strings.php deleted file mode 100644 index 3de86b223..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/byte_safe_strings.php +++ /dev/null @@ -1,181 +0,0 @@ - RandomCompat_strlen($binary_string)) { - return ''; - } - - return (string) mb_substr($binary_string, $start, $length, '8bit'); - } - - } else { - - /** - * substr() implementation that isn't brittle to mbstring.func_overload - * - * This version just uses the default substr() - * - * @param string $binary_string - * @param int $start - * @param int $length (optional) - * - * @throws TypeError - * - * @return string - */ - function RandomCompat_substr($binary_string, $start, $length = null) - { - if (!is_string($binary_string)) { - throw new TypeError( - 'RandomCompat_substr(): First argument should be a string' - ); - } - - if (!is_int($start)) { - throw new TypeError( - 'RandomCompat_substr(): Second argument should be an integer' - ); - } - - if ($length !== null) { - if (!is_int($length)) { - throw new TypeError( - 'RandomCompat_substr(): Third argument should be an integer, or omitted' - ); - } - - return (string) substr($binary_string, $start, $length); - } - - return (string) substr($binary_string, $start); - } - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/lib/cast_to_int.php b/lib/silex/vendor/paragonie/random_compat/lib/cast_to_int.php deleted file mode 100644 index 9a4fab991..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/cast_to_int.php +++ /dev/null @@ -1,75 +0,0 @@ - operators might accidentally let a float - * through. - * - * @param int|float $number The number we want to convert to an int - * @param bool $fail_open Set to true to not throw an exception - * - * @return float|int - * @psalm-suppress InvalidReturnType - * - * @throws TypeError - */ - function RandomCompat_intval($number, $fail_open = false) - { - if (is_int($number) || is_float($number)) { - $number += 0; - } elseif (is_numeric($number)) { - $number += 0; - } - - if ( - is_float($number) - && - $number > ~PHP_INT_MAX - && - $number < PHP_INT_MAX - ) { - $number = (int) $number; - } - - if (is_int($number)) { - return (int) $number; - } elseif (!$fail_open) { - throw new TypeError( - 'Expected an integer.' - ); - } - return $number; - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/lib/error_polyfill.php b/lib/silex/vendor/paragonie/random_compat/lib/error_polyfill.php deleted file mode 100644 index 6a91990ce..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/error_polyfill.php +++ /dev/null @@ -1,49 +0,0 @@ -= 70000) { - return; -} - -if (!defined('RANDOM_COMPAT_READ_BUFFER')) { - define('RANDOM_COMPAT_READ_BUFFER', 8); -} - -$RandomCompatDIR = dirname(__FILE__); - -require_once $RandomCompatDIR . '/byte_safe_strings.php'; -require_once $RandomCompatDIR . '/cast_to_int.php'; -require_once $RandomCompatDIR . '/error_polyfill.php'; - -if (!is_callable('random_bytes')) { - /** - * PHP 5.2.0 - 5.6.x way to implement random_bytes() - * - * We use conditional statements here to define the function in accordance - * to the operating environment. It's a micro-optimization. - * - * In order of preference: - * 1. Use libsodium if available. - * 2. fread() /dev/urandom if available (never on Windows) - * 3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM) - * 4. COM('CAPICOM.Utilities.1')->GetRandom() - * - * See RATIONALE.md for our reasoning behind this particular order - */ - if (extension_loaded('libsodium')) { - // See random_bytes_libsodium.php - if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { - require_once $RandomCompatDIR . '/random_bytes_libsodium.php'; - } elseif (method_exists('Sodium', 'randombytes_buf')) { - require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php'; - } - } - - /** - * Reading directly from /dev/urandom: - */ - if (DIRECTORY_SEPARATOR === '/') { - // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast - // way to exclude Windows. - $RandomCompatUrandom = true; - $RandomCompat_basedir = ini_get('open_basedir'); - - if (!empty($RandomCompat_basedir)) { - $RandomCompat_open_basedir = explode( - PATH_SEPARATOR, - strtolower($RandomCompat_basedir) - ); - $RandomCompatUrandom = (array() !== array_intersect( - array('/dev', '/dev/', '/dev/urandom'), - $RandomCompat_open_basedir - )); - $RandomCompat_open_basedir = null; - } - - if ( - !is_callable('random_bytes') - && - $RandomCompatUrandom - && - @is_readable('/dev/urandom') - ) { - // Error suppression on is_readable() in case of an open_basedir - // or safe_mode failure. All we care about is whether or not we - // can read it at this point. If the PHP environment is going to - // panic over trying to see if the file can be read in the first - // place, that is not helpful to us here. - - // See random_bytes_dev_urandom.php - require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php'; - } - // Unset variables after use - $RandomCompat_basedir = null; - } else { - $RandomCompatUrandom = false; - } - - /** - * mcrypt_create_iv() - * - * We only want to use mcypt_create_iv() if: - * - * - random_bytes() hasn't already been defined - * - the mcrypt extensions is loaded - * - One of these two conditions is true: - * - We're on Windows (DIRECTORY_SEPARATOR !== '/') - * - We're not on Windows and /dev/urandom is readabale - * (i.e. we're not in a chroot jail) - * - Special case: - * - If we're not on Windows, but the PHP version is between - * 5.6.10 and 5.6.12, we don't want to use mcrypt. It will - * hang indefinitely. This is bad. - * - If we're on Windows, we want to use PHP >= 5.3.7 or else - * we get insufficient entropy errors. - */ - if ( - !is_callable('random_bytes') - && - // Windows on PHP < 5.3.7 is broken, but non-Windows is not known to be. - (DIRECTORY_SEPARATOR === '/' || PHP_VERSION_ID >= 50307) - && - // Prevent this code from hanging indefinitely on non-Windows; - // see https://bugs.php.net/bug.php?id=69833 - ( - DIRECTORY_SEPARATOR !== '/' || - (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) - ) - && - extension_loaded('mcrypt') - ) { - // See random_bytes_mcrypt.php - require_once $RandomCompatDIR . '/random_bytes_mcrypt.php'; - } - $RandomCompatUrandom = null; - - /** - * This is a Windows-specific fallback, for when the mcrypt extension - * isn't loaded. - */ - if ( - !is_callable('random_bytes') - && - extension_loaded('com_dotnet') - && - class_exists('COM') - ) { - $RandomCompat_disabled_classes = preg_split( - '#\s*,\s*#', - strtolower(ini_get('disable_classes')) - ); - - if (!in_array('com', $RandomCompat_disabled_classes)) { - try { - $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); - if (method_exists($RandomCompatCOMtest, 'GetRandom')) { - // See random_bytes_com_dotnet.php - require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php'; - } - } catch (com_exception $e) { - // Don't try to use it. - } - } - $RandomCompat_disabled_classes = null; - $RandomCompatCOMtest = null; - } - - /** - * throw new Exception - */ - if (!is_callable('random_bytes')) { - /** - * We don't have any more options, so let's throw an exception right now - * and hope the developer won't let it fail silently. - * - * @param mixed $length - * @return void - * @throws Exception - */ - function random_bytes($length) - { - unset($length); // Suppress "variable not used" warnings. - throw new Exception( - 'There is no suitable CSPRNG installed on your system' - ); - } - } -} - -if (!is_callable('random_int')) { - require_once $RandomCompatDIR . '/random_int.php'; -} - -$RandomCompatDIR = null; diff --git a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php b/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php deleted file mode 100644 index fc1926e5c..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php +++ /dev/null @@ -1,88 +0,0 @@ -GetRandom($bytes, 0)); - if (RandomCompat_strlen($buf) >= $bytes) { - /** - * Return our random entropy buffer here: - */ - return RandomCompat_substr($buf, 0, $bytes); - } - ++$execCount; - } while ($execCount < $bytes); - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Could not gather sufficient random data' - ); - } -} \ No newline at end of file diff --git a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php b/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php deleted file mode 100644 index df5b91524..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php +++ /dev/null @@ -1,167 +0,0 @@ - 0); - - /** - * Is our result valid? - */ - if (is_string($buf)) { - if (RandomCompat_strlen($buf) === $bytes) { - /** - * Return our random entropy buffer here: - */ - return $buf; - } - } - } - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Error reading from source device' - ); - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php b/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php deleted file mode 100644 index 4af1a2422..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php +++ /dev/null @@ -1,88 +0,0 @@ - 2147483647) { - $buf = ''; - for ($i = 0; $i < $bytes; $i += 1073741824) { - $n = ($bytes - $i) > 1073741824 - ? 1073741824 - : $bytes - $i; - $buf .= \Sodium\randombytes_buf($n); - } - } else { - $buf = \Sodium\randombytes_buf($bytes); - } - - if ($buf !== false) { - if (RandomCompat_strlen($buf) === $bytes) { - return $buf; - } - } - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Could not gather sufficient random data' - ); - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php b/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php deleted file mode 100644 index 705af5262..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php +++ /dev/null @@ -1,92 +0,0 @@ - 2147483647) { - for ($i = 0; $i < $bytes; $i += 1073741824) { - $n = ($bytes - $i) > 1073741824 - ? 1073741824 - : $bytes - $i; - $buf .= Sodium::randombytes_buf((int) $n); - } - } else { - $buf .= Sodium::randombytes_buf((int) $bytes); - } - - if (is_string($buf)) { - if (RandomCompat_strlen($buf) === $bytes) { - return $buf; - } - } - - /** - * If we reach here, PHP has failed us. - */ - throw new Exception( - 'Could not gather sufficient random data' - ); - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php b/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php deleted file mode 100644 index aac9c013d..000000000 --- a/lib/silex/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php +++ /dev/null @@ -1,77 +0,0 @@ - operators might accidentally let a float - * through. - */ - - try { - $min = RandomCompat_intval($min); - } catch (TypeError $ex) { - throw new TypeError( - 'random_int(): $min must be an integer' - ); - } - - try { - $max = RandomCompat_intval($max); - } catch (TypeError $ex) { - throw new TypeError( - 'random_int(): $max must be an integer' - ); - } - - /** - * Now that we've verified our weak typing system has given us an integer, - * let's validate the logic then we can move forward with generating random - * integers along a given range. - */ - if ($min > $max) { - throw new Error( - 'Minimum value must be less than or equal to the maximum value' - ); - } - - if ($max === $min) { - return (int) $min; - } - - /** - * Initialize variables to 0 - * - * We want to store: - * $bytes => the number of random bytes we need - * $mask => an integer bitmask (for use with the &) operator - * so we can minimize the number of discards - */ - $attempts = $bits = $bytes = $mask = $valueShift = 0; - - /** - * At this point, $range is a positive number greater than 0. It might - * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to - * a float and we will lose some precision. - */ - $range = $max - $min; - - /** - * Test for integer overflow: - */ - if (!is_int($range)) { - - /** - * Still safely calculate wider ranges. - * Provided by @CodesInChaos, @oittaa - * - * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435 - * - * We use ~0 as a mask in this case because it generates all 1s - * - * @ref https://eval.in/400356 (32-bit) - * @ref http://3v4l.org/XX9r5 (64-bit) - */ - $bytes = PHP_INT_SIZE; - $mask = ~0; - - } else { - - /** - * $bits is effectively ceil(log($range, 2)) without dealing with - * type juggling - */ - while ($range > 0) { - if ($bits % 8 === 0) { - ++$bytes; - } - ++$bits; - $range >>= 1; - $mask = $mask << 1 | 1; - } - $valueShift = $min; - } - - $val = 0; - /** - * Now that we have our parameters set up, let's begin generating - * random integers until one falls between $min and $max - */ - do { - /** - * The rejection probability is at most 0.5, so this corresponds - * to a failure probability of 2^-128 for a working RNG - */ - if ($attempts > 128) { - throw new Exception( - 'random_int: RNG is broken - too many rejections' - ); - } - - /** - * Let's grab the necessary number of random bytes - */ - $randomByteString = random_bytes($bytes); - - /** - * Let's turn $randomByteString into an integer - * - * This uses bitwise operators (<< and |) to build an integer - * out of the values extracted from ord() - * - * Example: [9F] | [6D] | [32] | [0C] => - * 159 + 27904 + 3276800 + 201326592 => - * 204631455 - */ - $val &= 0; - for ($i = 0; $i < $bytes; ++$i) { - $val |= ord($randomByteString[$i]) << ($i * 8); - } - - /** - * Apply mask - */ - $val &= $mask; - $val += $valueShift; - - ++$attempts; - /** - * If $val overflows to a floating point number, - * ... or is larger than $max, - * ... or smaller than $min, - * then try again. - */ - } while (!is_int($val) || $val > $max || $val < $min); - - return (int) $val; - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/other/build_phar.php b/lib/silex/vendor/paragonie/random_compat/other/build_phar.php deleted file mode 100644 index 70ef4b2ed..000000000 --- a/lib/silex/vendor/paragonie/random_compat/other/build_phar.php +++ /dev/null @@ -1,57 +0,0 @@ -buildFromDirectory(dirname(__DIR__).'/lib'); -rename( - dirname(__DIR__).'/lib/index.php', - dirname(__DIR__).'/lib/random.php' -); - -/** - * If we pass an (optional) path to a private key as a second argument, we will - * sign the Phar with OpenSSL. - * - * If you leave this out, it will produce an unsigned .phar! - */ -if ($argc > 1) { - if (!@is_readable($argv[1])) { - echo 'Could not read the private key file:', $argv[1], "\n"; - exit(255); - } - $pkeyFile = file_get_contents($argv[1]); - - $private = openssl_get_privatekey($pkeyFile); - if ($private !== false) { - $pkey = ''; - openssl_pkey_export($private, $pkey); - $phar->setSignatureAlgorithm(Phar::OPENSSL, $pkey); - - /** - * Save the corresponding public key to the file - */ - if (!@is_readable($dist.'/random_compat.phar.pubkey')) { - $details = openssl_pkey_get_details($private); - file_put_contents( - $dist.'/random_compat.phar.pubkey', - $details['key'] - ); - } - } else { - echo 'An error occurred reading the private key from OpenSSL.', "\n"; - exit(255); - } -} diff --git a/lib/silex/vendor/paragonie/random_compat/psalm-autoload.php b/lib/silex/vendor/paragonie/random_compat/psalm-autoload.php deleted file mode 100644 index d71d1b818..000000000 --- a/lib/silex/vendor/paragonie/random_compat/psalm-autoload.php +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - - - - diff --git a/lib/silex/vendor/pimple/pimple/.gitignore b/lib/silex/vendor/pimple/pimple/.gitignore deleted file mode 100644 index c089b0952..000000000 --- a/lib/silex/vendor/pimple/pimple/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -phpunit.xml -composer.lock -/vendor/ diff --git a/lib/silex/vendor/pimple/pimple/.travis.yml b/lib/silex/vendor/pimple/pimple/.travis.yml deleted file mode 100644 index 196f7fc19..000000000 --- a/lib/silex/vendor/pimple/pimple/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: php - -env: - matrix: - - PIMPLE_EXT=no - - PIMPLE_EXT=yes - global: - - REPORT_EXIT_STATUS=1 - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - -before_script: - - composer self-update - - COMPOSER_ROOT_VERSION=dev-master composer install - - if [ "$PIMPLE_EXT" == "yes" ]; then sh -c "cd ext/pimple && phpize && ./configure && make && sudo make install"; fi - - if [ "$PIMPLE_EXT" == "yes" ]; then echo "extension=pimple.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi - -script: - - cd ext/pimple - - if [ "$PIMPLE_EXT" == "yes" ]; then yes n | make test | tee output ; grep -E 'Tests failed +. +0' output; fi - - if [ "$PIMPLE_EXT" == "yes" ]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi - - cd ../.. - - ./vendor/bin/simple-phpunit - -matrix: - include: - - php: hhvm - dist: trusty - env: PIMPLE_EXT=no - exclude: - - php: 7.0 - env: PIMPLE_EXT=yes - - php: 7.1 - env: PIMPLE_EXT=yes diff --git a/lib/silex/vendor/pimple/pimple/CHANGELOG b/lib/silex/vendor/pimple/pimple/CHANGELOG deleted file mode 100644 index ba56760c1..000000000 --- a/lib/silex/vendor/pimple/pimple/CHANGELOG +++ /dev/null @@ -1,59 +0,0 @@ -* 3.2.3 (2017-XX-XX) - - * n/a - -* 3.2.2 (2017-07-23) - - * reverted extending a protected closure throws an exception (deprecated it instead) - -* 3.2.1 (2017-07-17) - - * fixed PHP error - -* 3.2.0 (2017-07-17) - - * added a PSR-11 service locator - * added a PSR-11 wrapper - * added ServiceIterator - * fixed extending a protected closure (now throws InvalidServiceIdentifierException) - -* 3.1.0 (2017-07-03) - - * deprecated the C extension - * added support for PSR-11 exceptions - -* 3.0.2 (2015-09-11) - - * refactored the C extension - * minor non-significant changes - -* 3.0.1 (2015-07-30) - - * simplified some code - * fixed a segfault in the C extension - -* 3.0.0 (2014-07-24) - - * removed the Pimple class alias (use Pimple\Container instead) - -* 2.1.1 (2014-07-24) - - * fixed compiler warnings for the C extension - * fixed code when dealing with circular references - -* 2.1.0 (2014-06-24) - - * moved the Pimple to Pimple\Container (with a BC layer -- Pimple is now a - deprecated alias which will be removed in Pimple 3.0) - * added Pimple\ServiceProviderInterface (and Pimple::register()) - -* 2.0.0 (2014-02-10) - - * changed extend to automatically re-assign the extended service and keep it as shared or factory - (to keep BC, extend still returns the extended service) - * changed services to be shared by default (use factory() for factory - services) - -* 1.0.0 - - * initial version diff --git a/lib/silex/vendor/pimple/pimple/LICENSE b/lib/silex/vendor/pimple/pimple/LICENSE deleted file mode 100644 index e02dc5a78..000000000 --- a/lib/silex/vendor/pimple/pimple/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2009-2017 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/pimple/pimple/README.rst b/lib/silex/vendor/pimple/pimple/README.rst deleted file mode 100644 index a03b6d3a4..000000000 --- a/lib/silex/vendor/pimple/pimple/README.rst +++ /dev/null @@ -1,326 +0,0 @@ -Pimple -====== - -.. caution:: - - This is the documentation for Pimple 3.x. If you are using Pimple 1.x, read - the `Pimple 1.x documentation`_. Reading the Pimple 1.x code is also a good - way to learn more about how to create a simple Dependency Injection - Container (recent versions of Pimple are more focused on performance). - -Pimple is a small Dependency Injection Container for PHP. - -Installation ------------- - -Before using Pimple in your project, add it to your ``composer.json`` file: - -.. code-block:: bash - - $ ./composer.phar require pimple/pimple "^3.0" - -Usage ------ - -Creating a container is a matter of creating a ``Container`` instance: - -.. code-block:: php - - use Pimple\Container; - - $container = new Container(); - -As many other dependency injection containers, Pimple manages two different -kind of data: **services** and **parameters**. - -Defining Services -~~~~~~~~~~~~~~~~~ - -A service is an object that does something as part of a larger system. Examples -of services: a database connection, a templating engine, or a mailer. Almost -any **global** object can be a service. - -Services are defined by **anonymous functions** that return an instance of an -object: - -.. code-block:: php - - // define some services - $container['session_storage'] = function ($c) { - return new SessionStorage('SESSION_ID'); - }; - - $container['session'] = function ($c) { - return new Session($c['session_storage']); - }; - -Notice that the anonymous function has access to the current container -instance, allowing references to other services or parameters. - -As objects are only created when you get them, the order of the definitions -does not matter. - -Using the defined services is also very easy: - -.. code-block:: php - - // get the session object - $session = $container['session']; - - // the above call is roughly equivalent to the following code: - // $storage = new SessionStorage('SESSION_ID'); - // $session = new Session($storage); - -Defining Factory Services -~~~~~~~~~~~~~~~~~~~~~~~~~ - -By default, each time you get a service, Pimple returns the **same instance** -of it. If you want a different instance to be returned for all calls, wrap your -anonymous function with the ``factory()`` method - -.. code-block:: php - - $container['session'] = $container->factory(function ($c) { - return new Session($c['session_storage']); - }); - -Now, each call to ``$container['session']`` returns a new instance of the -session. - -Defining Parameters -~~~~~~~~~~~~~~~~~~~ - -Defining a parameter allows to ease the configuration of your container from -the outside and to store global values: - -.. code-block:: php - - // define some parameters - $container['cookie_name'] = 'SESSION_ID'; - $container['session_storage_class'] = 'SessionStorage'; - -If you change the ``session_storage`` service definition like below: - -.. code-block:: php - - $container['session_storage'] = function ($c) { - return new $c['session_storage_class']($c['cookie_name']); - }; - -You can now easily change the cookie name by overriding the -``cookie_name`` parameter instead of redefining the service -definition. - -Protecting Parameters -~~~~~~~~~~~~~~~~~~~~~ - -Because Pimple sees anonymous functions as service definitions, you need to -wrap anonymous functions with the ``protect()`` method to store them as -parameters: - -.. code-block:: php - - $container['random_func'] = $container->protect(function () { - return rand(); - }); - -Modifying Services after Definition -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In some cases you may want to modify a service definition after it has been -defined. You can use the ``extend()`` method to define additional code to be -run on your service just after it is created: - -.. code-block:: php - - $container['session_storage'] = function ($c) { - return new $c['session_storage_class']($c['cookie_name']); - }; - - $container->extend('session_storage', function ($storage, $c) { - $storage->...(); - - return $storage; - }); - -The first argument is the name of the service to extend, the second a function -that gets access to the object instance and the container. - -Extending a Container -~~~~~~~~~~~~~~~~~~~~~ - -If you use the same libraries over and over, you might want to reuse some -services from one project to the next one; package your services into a -**provider** by implementing ``Pimple\ServiceProviderInterface``: - -.. code-block:: php - - use Pimple\Container; - - class FooProvider implements Pimple\ServiceProviderInterface - { - public function register(Container $pimple) - { - // register some services and parameters - // on $pimple - } - } - -Then, register the provider on a Container: - -.. code-block:: php - - $pimple->register(new FooProvider()); - -Fetching the Service Creation Function -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -When you access an object, Pimple automatically calls the anonymous function -that you defined, which creates the service object for you. If you want to get -raw access to this function, you can use the ``raw()`` method: - -.. code-block:: php - - $container['session'] = function ($c) { - return new Session($c['session_storage']); - }; - - $sessionFunction = $container->raw('session'); - -PSR-11 compatibility --------------------- - -For historical reasons, the ``Container`` class does not implement the PSR-11 -``ContainerInterface``. However, Pimple provides a helper class that will let -you decouple your code from the Pimple container class. - -The PSR-11 container class -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The ``Pimple\Psr11\Container`` class lets you access the content of an -underlying Pimple container using ``Psr\Container\ContainerInterface`` -methods: - -.. code-block:: php - - use Pimple\Container; - use Pimple\Psr11\Container as PsrContainer; - - $container = new Container(); - $container['service'] = function ($c) { - return new Service(); - }; - $psr11 = new PsrContainer($container); - - $controller = function (PsrContainer $container) { - $service = $container->get('service'); - }; - $controller($psr11); - -Using the PSR-11 ServiceLocator -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Sometimes, a service needs access to several other services without being sure -that all of them will actually be used. In those cases, you may want the -instantiation of the services to be lazy. - -The traditional solution is to inject the entire service container to get only -the services really needed. However, this is not recommended because it gives -services a too broad access to the rest of the application and it hides their -actual dependencies. - -The ``ServiceLocator`` is intended to solve this problem by giving access to a -set of predefined services while instantiating them only when actually needed. - -It also allows you to make your services available under a different name than -the one used to register them. For instance, you may want to use an object -that expects an instance of ``EventDispatcherInterface`` to be available under -the name ``event_dispatcher`` while your event dispatcher has been -registered under the name ``dispatcher``: - -.. code-block:: php - - use Monolog\Logger; - use Pimple\Psr11\ServiceLocator; - use Psr\Container\ContainerInterface; - use Symfony\Component\EventDispatcher\EventDispatcher; - - class MyService - { - /** - * "logger" must be an instance of Psr\Log\LoggerInterface - * "event_dispatcher" must be an instance of Symfony\Component\EventDispatcher\EventDispatcherInterface - */ - private $services; - - public function __construct(ContainerInterface $services) - { - $this->services = $services; - } - } - - $container['logger'] = function ($c) { - return new Monolog\Logger(); - }; - $container['dispatcher'] = function () { - return new EventDispatcher(); - }; - - $container['service'] = function ($c) { - $locator = new ServiceLocator($c, array('logger', 'event_dispatcher' => 'dispatcher')); - - return new MyService($locator); - }; - -Referencing a Collection of Services Lazily -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Passing a collection of services instances in an array may prove inefficient -if the class that consumes the collection only needs to iterate over it at a -later stage, when one of its method is called. It can also lead to problems -if there is a circular dependency between one of the services stored in the -collection and the class that consumes it. - -The ``ServiceIterator`` class helps you solve these issues. It receives a -list of service names during instantiation and will retrieve the services -when iterated over: - -.. code-block:: php - - use Pimple\Container; - use Pimple\ServiceIterator; - - class AuthorizationService - { - private $voters; - - public function __construct($voters) - { - $this->voters = $voters; - } - - public function canAccess($resource) - { - foreach ($this->voters as $voter) { - if (true === $voter->canAccess($resource) { - return true; - } - } - - return false; - } - } - - $container = new Container(); - - $container['voter1'] = function ($c) { - return new SomeVoter(); - } - $container['voter2'] = function ($c) { - return new SomeOtherVoter($c['auth']); - } - $container['auth'] = function ($c) { - return new AuthorizationService(new ServiceIterator($c, array('voter1', 'voter2')); - } - -.. _Pimple 1.x documentation: https://github.com/silexphp/Pimple/tree/1.1 diff --git a/lib/silex/vendor/pimple/pimple/composer.json b/lib/silex/vendor/pimple/pimple/composer.json deleted file mode 100644 index dabf190a9..000000000 --- a/lib/silex/vendor/pimple/pimple/composer.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "pimple/pimple", - "type": "library", - "description": "Pimple, a simple Dependency Injection Container", - "keywords": ["dependency injection", "container"], - "homepage": "http://pimple.sensiolabs.org", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "require": { - "php": ">=5.3.0", - "psr/container": "^1.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.2" - }, - "autoload": { - "psr-0": { "Pimple": "src/" } - }, - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - } -} diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/.gitignore b/lib/silex/vendor/pimple/pimple/ext/pimple/.gitignore deleted file mode 100644 index 1861088ac..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -*.sw* -.deps -Makefile -Makefile.fragments -Makefile.global -Makefile.objects -acinclude.m4 -aclocal.m4 -build/ -config.cache -config.guess -config.h -config.h.in -config.log -config.nice -config.status -config.sub -configure -configure.in -install-sh -libtool -ltmain.sh -missing -mkinstalldirs -run-tests.php -*.loT -.libs/ -modules/ -*.la -*.lo diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/README.md b/lib/silex/vendor/pimple/pimple/ext/pimple/README.md deleted file mode 100644 index 7b39eb292..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/README.md +++ /dev/null @@ -1,12 +0,0 @@ -This is Pimple 2 implemented in C - -* PHP >= 5.3 -* Not tested under Windows, might work - -Install -======= - - > phpize - > ./configure - > make - > make install diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/config.m4 b/lib/silex/vendor/pimple/pimple/ext/pimple/config.m4 deleted file mode 100644 index 3a6e9aaeb..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/config.m4 +++ /dev/null @@ -1,63 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension pimple - -dnl Comments in this file start with the string 'dnl'. -dnl Remove where necessary. This file will not work -dnl without editing. - -dnl If your extension references something external, use with: - -dnl PHP_ARG_WITH(pimple, for pimple support, -dnl Make sure that the comment is aligned: -dnl [ --with-pimple Include pimple support]) - -dnl Otherwise use enable: - -PHP_ARG_ENABLE(pimple, whether to enable pimple support, -dnl Make sure that the comment is aligned: -[ --enable-pimple Enable pimple support]) - -if test "$PHP_PIMPLE" != "no"; then - dnl Write more examples of tests here... - - dnl # --with-pimple -> check with-path - dnl SEARCH_PATH="/usr/local /usr" # you might want to change this - dnl SEARCH_FOR="/include/pimple.h" # you most likely want to change this - dnl if test -r $PHP_PIMPLE/$SEARCH_FOR; then # path given as parameter - dnl PIMPLE_DIR=$PHP_PIMPLE - dnl else # search default path list - dnl AC_MSG_CHECKING([for pimple files in default path]) - dnl for i in $SEARCH_PATH ; do - dnl if test -r $i/$SEARCH_FOR; then - dnl PIMPLE_DIR=$i - dnl AC_MSG_RESULT(found in $i) - dnl fi - dnl done - dnl fi - dnl - dnl if test -z "$PIMPLE_DIR"; then - dnl AC_MSG_RESULT([not found]) - dnl AC_MSG_ERROR([Please reinstall the pimple distribution]) - dnl fi - - dnl # --with-pimple -> add include path - dnl PHP_ADD_INCLUDE($PIMPLE_DIR/include) - - dnl # --with-pimple -> check for lib and symbol presence - dnl LIBNAME=pimple # you may want to change this - dnl LIBSYMBOL=pimple # you most likely want to change this - - dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, - dnl [ - dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PIMPLE_DIR/lib, PIMPLE_SHARED_LIBADD) - dnl AC_DEFINE(HAVE_PIMPLELIB,1,[ ]) - dnl ],[ - dnl AC_MSG_ERROR([wrong pimple lib version or lib not found]) - dnl ],[ - dnl -L$PIMPLE_DIR/lib -lm - dnl ]) - dnl - dnl PHP_SUBST(PIMPLE_SHARED_LIBADD) - - PHP_NEW_EXTENSION(pimple, pimple.c, $ext_shared) -fi diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/config.w32 b/lib/silex/vendor/pimple/pimple/ext/pimple/config.w32 deleted file mode 100644 index 39857b325..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/config.w32 +++ /dev/null @@ -1,13 +0,0 @@ -// $Id$ -// vim:ft=javascript - -// If your extension references something external, use ARG_WITH -// ARG_WITH("pimple", "for pimple support", "no"); - -// Otherwise, use ARG_ENABLE -// ARG_ENABLE("pimple", "enable pimple support", "no"); - -if (PHP_PIMPLE != "no") { - EXTENSION("pimple", "pimple.c"); -} - diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/php_pimple.h b/lib/silex/vendor/pimple/pimple/ext/pimple/php_pimple.h deleted file mode 100644 index eed7c1731..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/php_pimple.h +++ /dev/null @@ -1,137 +0,0 @@ - -/* - * This file is part of Pimple. - * - * Copyright (c) 2014 Fabien Potencier - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished - * to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef PHP_PIMPLE_H -#define PHP_PIMPLE_H - -extern zend_module_entry pimple_module_entry; -#define phpext_pimple_ptr &pimple_module_entry - -#ifdef PHP_WIN32 -# define PHP_PIMPLE_API __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -# define PHP_PIMPLE_API __attribute__ ((visibility("default"))) -#else -# define PHP_PIMPLE_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#define PIMPLE_VERSION "3.2.3-DEV" - -#define PIMPLE_NS "Pimple" -#define PSR_CONTAINER_NS "Psr\\Container" -#define PIMPLE_EXCEPTION_NS "Pimple\\Exception" - -#define PIMPLE_DEFAULT_ZVAL_CACHE_NUM 5 -#define PIMPLE_DEFAULT_ZVAL_VALUES_NUM 10 - -#define PIMPLE_DEPRECATE do { \ - int er = EG(error_reporting); \ - EG(error_reporting) = 0;\ - php_error(E_DEPRECATED, "The Pimple C extension is deprecated since version 3.1 and will be removed in 4.0."); \ - EG(error_reporting) = er; \ -} while (0); - -zend_module_entry *get_module(void); - -PHP_MINIT_FUNCTION(pimple); -PHP_MINFO_FUNCTION(pimple); - -PHP_METHOD(FrozenServiceException, __construct); -PHP_METHOD(InvalidServiceIdentifierException, __construct); -PHP_METHOD(UnknownIdentifierException, __construct); - -PHP_METHOD(Pimple, __construct); -PHP_METHOD(Pimple, factory); -PHP_METHOD(Pimple, protect); -PHP_METHOD(Pimple, raw); -PHP_METHOD(Pimple, extend); -PHP_METHOD(Pimple, keys); -PHP_METHOD(Pimple, register); -PHP_METHOD(Pimple, offsetSet); -PHP_METHOD(Pimple, offsetUnset); -PHP_METHOD(Pimple, offsetGet); -PHP_METHOD(Pimple, offsetExists); - -PHP_METHOD(PimpleClosure, invoker); - -typedef struct _pimple_bucket_value { - zval *value; /* Must be the first element */ - zval *raw; - zend_object_handle handle_num; - enum { - PIMPLE_IS_PARAM = 0, - PIMPLE_IS_SERVICE = 2 - } type; - zend_bool initialized; - zend_fcall_info_cache fcc; -} pimple_bucket_value; - -typedef struct _pimple_object { - zend_object zobj; - HashTable values; - HashTable factories; - HashTable protected; -} pimple_object; - -typedef struct _pimple_closure_object { - zend_object zobj; - zval *callable; - zval *factory; -} pimple_closure_object; - -static const char sensiolabs_logo[] = ""; - -static void pimple_exception_call_parent_constructor(zval *this_ptr, const char *format, const char *arg1 TSRMLS_DC); - -static int pimple_zval_to_pimpleval(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC); -static int pimple_zval_is_valid_callback(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC); - -static void pimple_bucket_dtor(pimple_bucket_value *bucket); -static void pimple_free_bucket(pimple_bucket_value *bucket); - -static zval *pimple_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC); -static void pimple_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC); -static int pimple_object_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC); -static void pimple_object_unset_dimension(zval *object, zval *offset TSRMLS_DC); -static zend_object_value pimple_object_create(zend_class_entry *ce TSRMLS_DC); -static void pimple_free_object_storage(pimple_object *obj TSRMLS_DC); - -static void pimple_closure_free_object_storage(pimple_closure_object *obj TSRMLS_DC); -static zend_object_value pimple_closure_object_create(zend_class_entry *ce TSRMLS_DC); -static zend_function *pimple_closure_get_constructor(zval * TSRMLS_DC); -static int pimple_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC); - -#ifdef ZTS -#define PIMPLE_G(v) TSRMG(pimple_globals_id, zend_pimple_globals *, v) -#else -#define PIMPLE_G(v) (pimple_globals.v) -#endif - -#endif /* PHP_PIMPLE_H */ - diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/pimple.c b/lib/silex/vendor/pimple/pimple/ext/pimple/pimple.c deleted file mode 100644 index c80499b39..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/pimple.c +++ /dev/null @@ -1,1114 +0,0 @@ - -/* - * This file is part of Pimple. - * - * Copyright (c) 2014 Fabien Potencier - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished - * to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_pimple.h" -#include "pimple_compat.h" -#include "zend_interfaces.h" -#include "zend.h" -#include "Zend/zend_closures.h" -#include "ext/spl/spl_exceptions.h" -#include "Zend/zend_exceptions.h" -#include "main/php_output.h" -#include "SAPI.h" - -static zend_class_entry *pimple_ce_PsrContainerInterface; -static zend_class_entry *pimple_ce_PsrContainerExceptionInterface; -static zend_class_entry *pimple_ce_PsrNotFoundExceptionInterface; - -static zend_class_entry *pimple_ce_ExpectedInvokableException; -static zend_class_entry *pimple_ce_FrozenServiceException; -static zend_class_entry *pimple_ce_InvalidServiceIdentifierException; -static zend_class_entry *pimple_ce_UnknownIdentifierException; - -static zend_class_entry *pimple_ce; -static zend_object_handlers pimple_object_handlers; -static zend_class_entry *pimple_closure_ce; -static zend_class_entry *pimple_serviceprovider_ce; -static zend_object_handlers pimple_closure_object_handlers; -static zend_internal_function pimple_closure_invoker_function; - -#define FETCH_DIM_HANDLERS_VARS pimple_object *pimple_obj = NULL; \ - ulong index; \ - pimple_obj = (pimple_object *)zend_object_store_get_object(object TSRMLS_CC); \ - -#define PIMPLE_OBJECT_HANDLE_INHERITANCE_OBJECT_HANDLERS do { \ - if (ce != pimple_ce) { \ - zend_hash_find(&ce->function_table, ZEND_STRS("offsetget"), (void **)&function); \ - if (function->common.scope != ce) { /* if the function is not defined in this actual class */ \ - pimple_object_handlers.read_dimension = pimple_object_read_dimension; /* then overwrite the handler to use custom one */ \ - } \ - zend_hash_find(&ce->function_table, ZEND_STRS("offsetset"), (void **)&function); \ - if (function->common.scope != ce) { \ - pimple_object_handlers.write_dimension = pimple_object_write_dimension; \ - } \ - zend_hash_find(&ce->function_table, ZEND_STRS("offsetexists"), (void **)&function); \ - if (function->common.scope != ce) { \ - pimple_object_handlers.has_dimension = pimple_object_has_dimension; \ - } \ - zend_hash_find(&ce->function_table, ZEND_STRS("offsetunset"), (void **)&function); \ - if (function->common.scope != ce) { \ - pimple_object_handlers.unset_dimension = pimple_object_unset_dimension; \ - } \ - } else { \ - pimple_object_handlers.read_dimension = pimple_object_read_dimension; \ - pimple_object_handlers.write_dimension = pimple_object_write_dimension; \ - pimple_object_handlers.has_dimension = pimple_object_has_dimension; \ - pimple_object_handlers.unset_dimension = pimple_object_unset_dimension; \ - }\ - } while(0); - -#define PIMPLE_CALL_CB do { \ - zend_fcall_info_argn(&fci TSRMLS_CC, 1, &object); \ - fci.size = sizeof(fci); \ - fci.object_ptr = retval->fcc.object_ptr; \ - fci.function_name = retval->value; \ - fci.no_separation = 1; \ - fci.retval_ptr_ptr = &retval_ptr_ptr; \ -\ - zend_call_function(&fci, &retval->fcc TSRMLS_CC); \ - efree(fci.params); \ - if (EG(exception)) { \ - return EG(uninitialized_zval_ptr); \ - } \ - } while(0); - - -/* Psr\Container\ContainerInterface */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_pimple_PsrContainerInterface_get, 0, 0, 1) -ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_pimple_PsrContainerInterface_has, 0, 0, 1) -ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -static const zend_function_entry pimple_ce_PsrContainerInterface_functions[] = { - PHP_ABSTRACT_ME(ContainerInterface, get, arginfo_pimple_PsrContainerInterface_get) - PHP_ABSTRACT_ME(ContainerInterface, has, arginfo_pimple_PsrContainerInterface_has) - PHP_FE_END -}; - -/* Psr\Container\ContainerExceptionInterface */ -static const zend_function_entry pimple_ce_PsrContainerExceptionInterface_functions[] = { - PHP_FE_END -}; - -/* Psr\Container\NotFoundExceptionInterface */ -static const zend_function_entry pimple_ce_PsrNotFoundExceptionInterface_functions[] = { - PHP_FE_END -}; - -/* Pimple\Exception\FrozenServiceException */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_FrozenServiceException___construct, 0, 0, 1) -ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -static const zend_function_entry pimple_ce_FrozenServiceException_functions[] = { - PHP_ME(FrozenServiceException, __construct, arginfo_FrozenServiceException___construct, ZEND_ACC_PUBLIC) - PHP_FE_END -}; - -/* Pimple\Exception\InvalidServiceIdentifierException */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_InvalidServiceIdentifierException___construct, 0, 0, 1) -ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -static const zend_function_entry pimple_ce_InvalidServiceIdentifierException_functions[] = { - PHP_ME(InvalidServiceIdentifierException, __construct, arginfo_InvalidServiceIdentifierException___construct, ZEND_ACC_PUBLIC) - PHP_FE_END -}; - -/* Pimple\Exception\UnknownIdentifierException */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_UnknownIdentifierException___construct, 0, 0, 1) -ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -static const zend_function_entry pimple_ce_UnknownIdentifierException_functions[] = { - PHP_ME(UnknownIdentifierException, __construct, arginfo_UnknownIdentifierException___construct, ZEND_ACC_PUBLIC) - PHP_FE_END -}; - -/* Pimple\Container */ -ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, 0, 0, 0) -ZEND_ARG_ARRAY_INFO(0, value, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetset, 0, 0, 2) -ZEND_ARG_INFO(0, offset) -ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetget, 0, 0, 1) -ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetexists, 0, 0, 1) -ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetunset, 0, 0, 1) -ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_factory, 0, 0, 1) -ZEND_ARG_INFO(0, callable) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_protect, 0, 0, 1) -ZEND_ARG_INFO(0, callable) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_raw, 0, 0, 1) -ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_extend, 0, 0, 2) -ZEND_ARG_INFO(0, id) -ZEND_ARG_INFO(0, callable) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_keys, 0, 0, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_register, 0, 0, 1) -ZEND_ARG_OBJ_INFO(0, provider, Pimple\\ServiceProviderInterface, 0) -ZEND_ARG_ARRAY_INFO(0, values, 1) -ZEND_END_ARG_INFO() - -static const zend_function_entry pimple_ce_functions[] = { - PHP_ME(Pimple, __construct, arginfo___construct, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, factory, arginfo_factory, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, protect, arginfo_protect, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, raw, arginfo_raw, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, extend, arginfo_extend, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, keys, arginfo_keys, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, register, arginfo_register, ZEND_ACC_PUBLIC) - - PHP_ME(Pimple, offsetSet, arginfo_offsetset, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, offsetGet, arginfo_offsetget, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, offsetExists, arginfo_offsetexists, ZEND_ACC_PUBLIC) - PHP_ME(Pimple, offsetUnset, arginfo_offsetunset, ZEND_ACC_PUBLIC) - PHP_FE_END -}; - -/* Pimple\ServiceProviderInterface */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_serviceprovider_register, 0, 0, 1) -ZEND_ARG_OBJ_INFO(0, pimple, Pimple\\Container, 0) -ZEND_END_ARG_INFO() - -static const zend_function_entry pimple_serviceprovider_iface_ce_functions[] = { - PHP_ABSTRACT_ME(ServiceProviderInterface, register, arginfo_serviceprovider_register) - PHP_FE_END -}; - -/* parent::__construct(sprintf("Something with %s", $arg1)) */ -static void pimple_exception_call_parent_constructor(zval *this_ptr, const char *format, const char *arg1 TSRMLS_DC) -{ - zend_class_entry *ce = Z_OBJCE_P(this_ptr); - char *message = NULL; - int message_len; - zval *constructor_arg; - - message_len = spprintf(&message, 0, format, arg1); - ALLOC_INIT_ZVAL(constructor_arg); - ZVAL_STRINGL(constructor_arg, message, message_len, 1); - - zend_call_method_with_1_params(&this_ptr, ce, &ce->parent->constructor, "__construct", NULL, constructor_arg); - - efree(message); - zval_ptr_dtor(&constructor_arg); -} - -/** - * Pass a single string parameter to exception constructor and throw - */ -static void pimple_throw_exception_string(zend_class_entry *ce, const char *message, zend_uint message_len TSRMLS_DC) -{ - zval *exception, *param; - - ALLOC_INIT_ZVAL(exception); - object_init_ex(exception, ce); - - ALLOC_INIT_ZVAL(param); - ZVAL_STRINGL(param, message, message_len, 1); - - zend_call_method_with_1_params(&exception, ce, &ce->constructor, "__construct", NULL, param); - - zend_throw_exception_object(exception TSRMLS_CC); - - zval_ptr_dtor(¶m); -} - -static void pimple_closure_free_object_storage(pimple_closure_object *obj TSRMLS_DC) -{ - zend_object_std_dtor(&obj->zobj TSRMLS_CC); - if (obj->factory) { - zval_ptr_dtor(&obj->factory); - } - if (obj->callable) { - zval_ptr_dtor(&obj->callable); - } - efree(obj); -} - -static void pimple_free_object_storage(pimple_object *obj TSRMLS_DC) -{ - zend_hash_destroy(&obj->factories); - zend_hash_destroy(&obj->protected); - zend_hash_destroy(&obj->values); - zend_object_std_dtor(&obj->zobj TSRMLS_CC); - efree(obj); -} - -static void pimple_free_bucket(pimple_bucket_value *bucket) -{ - if (bucket->raw) { - zval_ptr_dtor(&bucket->raw); - } -} - -static zend_object_value pimple_closure_object_create(zend_class_entry *ce TSRMLS_DC) -{ - zend_object_value retval; - pimple_closure_object *pimple_closure_obj = NULL; - - pimple_closure_obj = ecalloc(1, sizeof(pimple_closure_object)); - ZEND_OBJ_INIT(&pimple_closure_obj->zobj, ce); - - pimple_closure_object_handlers.get_constructor = pimple_closure_get_constructor; - retval.handlers = &pimple_closure_object_handlers; - retval.handle = zend_objects_store_put(pimple_closure_obj, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) pimple_closure_free_object_storage, NULL TSRMLS_CC); - - return retval; -} - -static zend_function *pimple_closure_get_constructor(zval *obj TSRMLS_DC) -{ - zend_error(E_ERROR, "Pimple\\ContainerClosure is an internal class and cannot be instantiated"); - - return NULL; -} - -static int pimple_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC) -{ - *zobj_ptr = obj; - *ce_ptr = Z_OBJCE_P(obj); - *fptr_ptr = (zend_function *)&pimple_closure_invoker_function; - - return SUCCESS; -} - -static zend_object_value pimple_object_create(zend_class_entry *ce TSRMLS_DC) -{ - zend_object_value retval; - pimple_object *pimple_obj = NULL; - zend_function *function = NULL; - - pimple_obj = emalloc(sizeof(pimple_object)); - ZEND_OBJ_INIT(&pimple_obj->zobj, ce); - - PIMPLE_OBJECT_HANDLE_INHERITANCE_OBJECT_HANDLERS - - retval.handlers = &pimple_object_handlers; - retval.handle = zend_objects_store_put(pimple_obj, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) pimple_free_object_storage, NULL TSRMLS_CC); - - zend_hash_init(&pimple_obj->factories, PIMPLE_DEFAULT_ZVAL_CACHE_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0); - zend_hash_init(&pimple_obj->protected, PIMPLE_DEFAULT_ZVAL_CACHE_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0); - zend_hash_init(&pimple_obj->values, PIMPLE_DEFAULT_ZVAL_VALUES_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0); - - return retval; -} - -static void pimple_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) -{ - FETCH_DIM_HANDLERS_VARS - - pimple_bucket_value pimple_value = {0}, *found_value = NULL; - ulong hash; - - pimple_zval_to_pimpleval(value, &pimple_value TSRMLS_CC); - - if (!offset) {/* $p[] = 'foo' when not overloaded */ - zend_hash_next_index_insert(&pimple_obj->values, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL); - Z_ADDREF_P(value); - return; - } - - switch (Z_TYPE_P(offset)) { - case IS_STRING: - hash = zend_hash_func(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); - zend_hash_quick_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hash, (void **)&found_value); - if (found_value && found_value->type == PIMPLE_IS_SERVICE && found_value->initialized == 1) { - pimple_free_bucket(&pimple_value); - pimple_throw_exception_string(pimple_ce_FrozenServiceException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - return; - } - if (zend_hash_quick_update(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hash, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL) == FAILURE) { - pimple_free_bucket(&pimple_value); - return; - } - Z_ADDREF_P(value); - break; - case IS_DOUBLE: - case IS_BOOL: - case IS_LONG: - if (Z_TYPE_P(offset) == IS_DOUBLE) { - index = (ulong)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - zend_hash_index_find(&pimple_obj->values, index, (void **)&found_value); - if (found_value && found_value->type == PIMPLE_IS_SERVICE && found_value->initialized == 1) { - pimple_free_bucket(&pimple_value); - convert_to_string(offset); - pimple_throw_exception_string(pimple_ce_FrozenServiceException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - return; - } - if (zend_hash_index_update(&pimple_obj->values, index, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL) == FAILURE) { - pimple_free_bucket(&pimple_value); - return; - } - Z_ADDREF_P(value); - break; - case IS_NULL: /* $p[] = 'foo' when overloaded */ - zend_hash_next_index_insert(&pimple_obj->values, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL); - Z_ADDREF_P(value); - break; - default: - pimple_free_bucket(&pimple_value); - zend_error(E_WARNING, "Unsupported offset type"); - } -} - -static void pimple_object_unset_dimension(zval *object, zval *offset TSRMLS_DC) -{ - FETCH_DIM_HANDLERS_VARS - - switch (Z_TYPE_P(offset)) { - case IS_STRING: - zend_symtable_del(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); - zend_symtable_del(&pimple_obj->factories, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); - zend_symtable_del(&pimple_obj->protected, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); - break; - case IS_DOUBLE: - case IS_BOOL: - case IS_LONG: - if (Z_TYPE_P(offset) == IS_DOUBLE) { - index = (ulong)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - zend_hash_index_del(&pimple_obj->values, index); - zend_hash_index_del(&pimple_obj->factories, index); - zend_hash_index_del(&pimple_obj->protected, index); - break; - default: - zend_error(E_WARNING, "Unsupported offset type"); - } -} - -static int pimple_object_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC) -{ - FETCH_DIM_HANDLERS_VARS - - pimple_bucket_value *retval = NULL; - - switch (Z_TYPE_P(offset)) { - case IS_STRING: - if (zend_symtable_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **)&retval) == SUCCESS) { - switch (check_empty) { - case 0: /* isset */ - return 1; /* Differs from PHP behavior (Z_TYPE_P(retval->value) != IS_NULL;) */ - case 1: /* empty */ - default: - return zend_is_true(retval->value); - } - } - return 0; - break; - case IS_DOUBLE: - case IS_BOOL: - case IS_LONG: - if (Z_TYPE_P(offset) == IS_DOUBLE) { - index = (ulong)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - if (zend_hash_index_find(&pimple_obj->values, index, (void **)&retval) == SUCCESS) { - switch (check_empty) { - case 0: /* isset */ - return 1; /* Differs from PHP behavior (Z_TYPE_P(retval->value) != IS_NULL;)*/ - case 1: /* empty */ - default: - return zend_is_true(retval->value); - } - } - return 0; - break; - default: - zend_error(E_WARNING, "Unsupported offset type"); - return 0; - } -} - -static zval *pimple_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) -{ - FETCH_DIM_HANDLERS_VARS - - pimple_bucket_value *retval = NULL; - zend_fcall_info fci = {0}; - zval *retval_ptr_ptr = NULL; - - switch (Z_TYPE_P(offset)) { - case IS_STRING: - if (zend_symtable_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **)&retval) == FAILURE) { - pimple_throw_exception_string(pimple_ce_UnknownIdentifierException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - - return EG(uninitialized_zval_ptr); - } - break; - case IS_DOUBLE: - case IS_BOOL: - case IS_LONG: - if (Z_TYPE_P(offset) == IS_DOUBLE) { - index = (ulong)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - if (zend_hash_index_find(&pimple_obj->values, index, (void **)&retval) == FAILURE) { - return EG(uninitialized_zval_ptr); - } - break; - case IS_NULL: /* $p[][3] = 'foo' first dim access */ - return EG(uninitialized_zval_ptr); - break; - default: - zend_error(E_WARNING, "Unsupported offset type"); - return EG(uninitialized_zval_ptr); - } - - if(retval->type == PIMPLE_IS_PARAM) { - return retval->value; - } - - if (zend_hash_index_exists(&pimple_obj->protected, retval->handle_num)) { - /* Service is protected, return the value every time */ - return retval->value; - } - - if (zend_hash_index_exists(&pimple_obj->factories, retval->handle_num)) { - /* Service is a factory, call it every time and never cache its result */ - PIMPLE_CALL_CB - Z_DELREF_P(retval_ptr_ptr); /* fetch dim addr will increment refcount */ - return retval_ptr_ptr; - } - - if (retval->initialized == 1) { - /* Service has already been called, return its cached value */ - return retval->value; - } - - ALLOC_INIT_ZVAL(retval->raw); - MAKE_COPY_ZVAL(&retval->value, retval->raw); - - PIMPLE_CALL_CB - - retval->initialized = 1; - zval_ptr_dtor(&retval->value); - retval->value = retval_ptr_ptr; - - return retval->value; -} - -static int pimple_zval_is_valid_callback(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC) -{ - if (Z_TYPE_P(_zval) != IS_OBJECT) { - return FAILURE; - } - - if (_pimple_bucket_value->fcc.called_scope) { - return SUCCESS; - } - - if (Z_OBJ_HANDLER_P(_zval, get_closure) && Z_OBJ_HANDLER_P(_zval, get_closure)(_zval, &_pimple_bucket_value->fcc.calling_scope, &_pimple_bucket_value->fcc.function_handler, &_pimple_bucket_value->fcc.object_ptr TSRMLS_CC) == SUCCESS) { - _pimple_bucket_value->fcc.called_scope = _pimple_bucket_value->fcc.calling_scope; - return SUCCESS; - } else { - return FAILURE; - } -} - -static int pimple_zval_to_pimpleval(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC) -{ - _pimple_bucket_value->value = _zval; - - if (Z_TYPE_P(_zval) != IS_OBJECT) { - return PIMPLE_IS_PARAM; - } - - if (pimple_zval_is_valid_callback(_zval, _pimple_bucket_value TSRMLS_CC) == SUCCESS) { - _pimple_bucket_value->type = PIMPLE_IS_SERVICE; - _pimple_bucket_value->handle_num = Z_OBJ_HANDLE_P(_zval); - } - - return PIMPLE_IS_SERVICE; -} - -static void pimple_bucket_dtor(pimple_bucket_value *bucket) -{ - zval_ptr_dtor(&bucket->value); - pimple_free_bucket(bucket); -} - -PHP_METHOD(FrozenServiceException, __construct) -{ - char *id = NULL; - int id_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_len) == FAILURE) { - return; - } - pimple_exception_call_parent_constructor(getThis(), "Cannot override frozen service \"%s\".", id TSRMLS_CC); -} - -PHP_METHOD(InvalidServiceIdentifierException, __construct) -{ - char *id = NULL; - int id_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_len) == FAILURE) { - return; - } - pimple_exception_call_parent_constructor(getThis(), "Identifier \"%s\" does not contain an object definition.", id TSRMLS_CC); -} - -PHP_METHOD(UnknownIdentifierException, __construct) -{ - char *id = NULL; - int id_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_len) == FAILURE) { - return; - } - pimple_exception_call_parent_constructor(getThis(), "Identifier \"%s\" is not defined.", id TSRMLS_CC); -} - -PHP_METHOD(Pimple, protect) -{ - zval *protected = NULL; - pimple_object *pobj = NULL; - pimple_bucket_value bucket = {0}; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &protected) == FAILURE) { - return; - } - - if (pimple_zval_is_valid_callback(protected, &bucket TSRMLS_CC) == FAILURE) { - pimple_free_bucket(&bucket); - zend_throw_exception(pimple_ce_ExpectedInvokableException, "Callable is not a Closure or invokable object.", 0 TSRMLS_CC); - return; - } - - pimple_zval_to_pimpleval(protected, &bucket TSRMLS_CC); - pobj = (pimple_object *)zend_object_store_get_object(getThis() TSRMLS_CC); - - if (zend_hash_index_update(&pobj->protected, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL) == SUCCESS) { - Z_ADDREF_P(protected); - RETURN_ZVAL(protected, 1 , 0); - } else { - pimple_free_bucket(&bucket); - } - RETURN_FALSE; -} - -PHP_METHOD(Pimple, raw) -{ - zval *offset = NULL; - pimple_object *pobj = NULL; - pimple_bucket_value *value = NULL; - ulong index; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { - return; - } - - pobj = zend_object_store_get_object(getThis() TSRMLS_CC); - - switch (Z_TYPE_P(offset)) { - case IS_STRING: - if (zend_symtable_find(&pobj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void *)&value) == FAILURE) { - pimple_throw_exception_string(pimple_ce_UnknownIdentifierException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - RETURN_NULL(); - } - break; - case IS_DOUBLE: - case IS_BOOL: - case IS_LONG: - if (Z_TYPE_P(offset) == IS_DOUBLE) { - index = (ulong)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - if (zend_hash_index_find(&pobj->values, index, (void *)&value) == FAILURE) { - RETURN_NULL(); - } - break; - case IS_NULL: - default: - zend_error(E_WARNING, "Unsupported offset type"); - } - - if (value->raw) { - RETVAL_ZVAL(value->raw, 1, 0); - } else { - RETVAL_ZVAL(value->value, 1, 0); - } -} - -PHP_METHOD(Pimple, extend) -{ - zval *offset = NULL, *callable = NULL, *pimple_closure_obj = NULL; - pimple_bucket_value bucket = {0}, *value = NULL; - pimple_object *pobj = NULL; - pimple_closure_object *pcobj = NULL; - ulong index; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &offset, &callable) == FAILURE) { - return; - } - - pobj = zend_object_store_get_object(getThis() TSRMLS_CC); - - switch (Z_TYPE_P(offset)) { - case IS_STRING: - if (zend_symtable_find(&pobj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void *)&value) == FAILURE) { - pimple_throw_exception_string(pimple_ce_UnknownIdentifierException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - RETURN_NULL(); - } - - if (value->type != PIMPLE_IS_SERVICE) { - pimple_throw_exception_string(pimple_ce_InvalidServiceIdentifierException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - RETURN_NULL(); - } - if (zend_hash_index_exists(&pobj->protected, value->handle_num)) { - int er = EG(error_reporting); - EG(error_reporting) = 0; - php_error(E_DEPRECATED, "How Pimple behaves when extending protected closures will be fixed in Pimple 4. Are you sure \"%s\" should be protected?", Z_STRVAL_P(offset)); - EG(error_reporting) = er; - } - break; - case IS_DOUBLE: - case IS_BOOL: - case IS_LONG: - if (Z_TYPE_P(offset) == IS_DOUBLE) { - index = (ulong)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - if (zend_hash_index_find(&pobj->values, index, (void *)&value) == FAILURE) { - convert_to_string(offset); - pimple_throw_exception_string(pimple_ce_UnknownIdentifierException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - RETURN_NULL(); - } - if (value->type != PIMPLE_IS_SERVICE) { - convert_to_string(offset); - pimple_throw_exception_string(pimple_ce_InvalidServiceIdentifierException, Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC); - RETURN_NULL(); - } - if (zend_hash_index_exists(&pobj->protected, value->handle_num)) { - int er = EG(error_reporting); - EG(error_reporting) = 0; - php_error(E_DEPRECATED, "How Pimple behaves when extending protected closures will be fixed in Pimple 4. Are you sure \"%ld\" should be protected?", index); - EG(error_reporting) = er; - } - break; - case IS_NULL: - default: - zend_error(E_WARNING, "Unsupported offset type"); - } - - if (pimple_zval_is_valid_callback(callable, &bucket TSRMLS_CC) == FAILURE) { - pimple_free_bucket(&bucket); - zend_throw_exception(pimple_ce_ExpectedInvokableException, "Extension service definition is not a Closure or invokable object.", 0 TSRMLS_CC); - RETURN_NULL(); - } - pimple_free_bucket(&bucket); - - ALLOC_INIT_ZVAL(pimple_closure_obj); - object_init_ex(pimple_closure_obj, pimple_closure_ce); - - pcobj = zend_object_store_get_object(pimple_closure_obj TSRMLS_CC); - pcobj->callable = callable; - pcobj->factory = value->value; - Z_ADDREF_P(callable); - Z_ADDREF_P(value->value); - - if (zend_hash_index_exists(&pobj->factories, value->handle_num)) { - pimple_zval_to_pimpleval(pimple_closure_obj, &bucket TSRMLS_CC); - zend_hash_index_del(&pobj->factories, value->handle_num); - zend_hash_index_update(&pobj->factories, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL); - Z_ADDREF_P(pimple_closure_obj); - } - - pimple_object_write_dimension(getThis(), offset, pimple_closure_obj TSRMLS_CC); - - RETVAL_ZVAL(pimple_closure_obj, 1, 1); -} - -PHP_METHOD(Pimple, keys) -{ - HashPosition pos; - pimple_object *pobj = NULL; - zval **value = NULL; - zval *endval = NULL; - char *str_index = NULL; - int str_len; - ulong num_index; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - pobj = zend_object_store_get_object(getThis() TSRMLS_CC); - array_init_size(return_value, zend_hash_num_elements(&pobj->values)); - - zend_hash_internal_pointer_reset_ex(&pobj->values, &pos); - - while(zend_hash_get_current_data_ex(&pobj->values, (void **)&value, &pos) == SUCCESS) { - MAKE_STD_ZVAL(endval); - switch (zend_hash_get_current_key_ex(&pobj->values, &str_index, (uint *)&str_len, &num_index, 0, &pos)) { - case HASH_KEY_IS_STRING: - ZVAL_STRINGL(endval, str_index, str_len - 1, 1); - zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &endval, sizeof(zval *), NULL); - break; - case HASH_KEY_IS_LONG: - ZVAL_LONG(endval, num_index); - zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &endval, sizeof(zval *), NULL); - break; - } - zend_hash_move_forward_ex(&pobj->values, &pos); - } -} - -PHP_METHOD(Pimple, factory) -{ - zval *factory = NULL; - pimple_object *pobj = NULL; - pimple_bucket_value bucket = {0}; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &factory) == FAILURE) { - return; - } - - if (pimple_zval_is_valid_callback(factory, &bucket TSRMLS_CC) == FAILURE) { - pimple_free_bucket(&bucket); - zend_throw_exception(pimple_ce_ExpectedInvokableException, "Service definition is not a Closure or invokable object.", 0 TSRMLS_CC); - return; - } - - pimple_zval_to_pimpleval(factory, &bucket TSRMLS_CC); - pobj = (pimple_object *)zend_object_store_get_object(getThis() TSRMLS_CC); - - if (zend_hash_index_update(&pobj->factories, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL) == SUCCESS) { - Z_ADDREF_P(factory); - RETURN_ZVAL(factory, 1 , 0); - } else { - pimple_free_bucket(&bucket); - } - - RETURN_FALSE; -} - -PHP_METHOD(Pimple, offsetSet) -{ - zval *offset = NULL, *value = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &offset, &value) == FAILURE) { - return; - } - - pimple_object_write_dimension(getThis(), offset, value TSRMLS_CC); -} - -PHP_METHOD(Pimple, offsetGet) -{ - zval *offset = NULL, *retval = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { - return; - } - - retval = pimple_object_read_dimension(getThis(), offset, 0 TSRMLS_CC); - - RETVAL_ZVAL(retval, 1, 0); -} - -PHP_METHOD(Pimple, offsetUnset) -{ - zval *offset = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { - return; - } - - pimple_object_unset_dimension(getThis(), offset TSRMLS_CC); -} - -PHP_METHOD(Pimple, offsetExists) -{ - zval *offset = NULL; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { - return; - } - - RETVAL_BOOL(pimple_object_has_dimension(getThis(), offset, 1 TSRMLS_CC)); -} - -PHP_METHOD(Pimple, register) -{ - zval *provider; - zval **data; - zval *retval = NULL; - zval key; - - HashTable *array = NULL; - HashPosition pos; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|h", &provider, pimple_serviceprovider_ce, &array) == FAILURE) { - return; - } - - RETVAL_ZVAL(getThis(), 1, 0); - - zend_call_method_with_1_params(&provider, Z_OBJCE_P(provider), NULL, "register", &retval, getThis()); - - if (retval) { - zval_ptr_dtor(&retval); - } - - if (!array) { - return; - } - - zend_hash_internal_pointer_reset_ex(array, &pos); - - while(zend_hash_get_current_data_ex(array, (void **)&data, &pos) == SUCCESS) { - zend_hash_get_current_key_zval_ex(array, &key, &pos); - pimple_object_write_dimension(getThis(), &key, *data TSRMLS_CC); - zend_hash_move_forward_ex(array, &pos); - } -} - -PHP_METHOD(Pimple, __construct) -{ - zval *values = NULL, **pData = NULL, offset; - HashPosition pos; - char *str_index = NULL; - zend_uint str_length; - ulong num_index; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!", &values) == FAILURE) { - return; - } - - PIMPLE_DEPRECATE - - if (!values) { - return; - } - - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos); - while (zend_hash_has_more_elements_ex(Z_ARRVAL_P(values), &pos) == SUCCESS) { - zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&pData, &pos); - zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &str_index, &str_length, &num_index, 0, &pos); - INIT_ZVAL(offset); - if (zend_hash_get_current_key_type_ex(Z_ARRVAL_P(values), &pos) == HASH_KEY_IS_LONG) { - ZVAL_LONG(&offset, num_index); - } else { - ZVAL_STRINGL(&offset, str_index, (str_length - 1), 0); - } - pimple_object_write_dimension(getThis(), &offset, *pData TSRMLS_CC); - zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos); - } -} - -/* - * This is PHP code snippet handling extend()s calls : - - $extended = function ($c) use ($callable, $factory) { - return $callable($factory($c), $c); - }; - - */ -PHP_METHOD(PimpleClosure, invoker) -{ - pimple_closure_object *pcobj = NULL; - zval *arg = NULL, *retval = NULL, *newretval = NULL; - zend_fcall_info fci = {0}; - zval **args[2]; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { - return; - } - - pcobj = zend_object_store_get_object(getThis() TSRMLS_CC); - - fci.function_name = pcobj->factory; - args[0] = &arg; - zend_fcall_info_argp(&fci TSRMLS_CC, 1, args); - fci.retval_ptr_ptr = &retval; - fci.size = sizeof(fci); - - if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE || EG(exception)) { - efree(fci.params); - return; /* Should here return default zval */ - } - - efree(fci.params); - memset(&fci, 0, sizeof(fci)); - fci.size = sizeof(fci); - - fci.function_name = pcobj->callable; - args[0] = &retval; - args[1] = &arg; - zend_fcall_info_argp(&fci TSRMLS_CC, 2, args); - fci.retval_ptr_ptr = &newretval; - - if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE || EG(exception)) { - efree(fci.params); - zval_ptr_dtor(&retval); - return; - } - - efree(fci.params); - zval_ptr_dtor(&retval); - - RETVAL_ZVAL(newretval, 1 ,1); -} - -PHP_MINIT_FUNCTION(pimple) -{ - zend_class_entry tmp_ce_PsrContainerInterface, tmp_ce_PsrContainerExceptionInterface, tmp_ce_PsrNotFoundExceptionInterface; - zend_class_entry tmp_ce_ExpectedInvokableException, tmp_ce_FrozenServiceException, tmp_ce_InvalidServiceIdentifierException, tmp_ce_UnknownIdentifierException; - zend_class_entry tmp_pimple_ce, tmp_pimple_closure_ce, tmp_pimple_serviceprovider_iface_ce; - - /* Psr\Container namespace */ - INIT_NS_CLASS_ENTRY(tmp_ce_PsrContainerInterface, PSR_CONTAINER_NS, "ContainerInterface", pimple_ce_PsrContainerInterface_functions); - INIT_NS_CLASS_ENTRY(tmp_ce_PsrContainerExceptionInterface, PSR_CONTAINER_NS, "ContainerExceptionInterface", pimple_ce_PsrContainerExceptionInterface_functions); - INIT_NS_CLASS_ENTRY(tmp_ce_PsrNotFoundExceptionInterface, PSR_CONTAINER_NS, "NotFoundExceptionInterface", pimple_ce_PsrNotFoundExceptionInterface_functions); - - pimple_ce_PsrContainerInterface = zend_register_internal_interface(&tmp_ce_PsrContainerInterface TSRMLS_CC); - pimple_ce_PsrContainerExceptionInterface = zend_register_internal_interface(&tmp_ce_PsrContainerExceptionInterface TSRMLS_CC); - pimple_ce_PsrNotFoundExceptionInterface = zend_register_internal_interface(&tmp_ce_PsrNotFoundExceptionInterface TSRMLS_CC); - - zend_class_implements(pimple_ce_PsrNotFoundExceptionInterface TSRMLS_CC, 1, pimple_ce_PsrContainerExceptionInterface); - - /* Pimple\Exception namespace */ - INIT_NS_CLASS_ENTRY(tmp_ce_ExpectedInvokableException, PIMPLE_EXCEPTION_NS, "ExpectedInvokableException", NULL); - INIT_NS_CLASS_ENTRY(tmp_ce_FrozenServiceException, PIMPLE_EXCEPTION_NS, "FrozenServiceException", pimple_ce_FrozenServiceException_functions); - INIT_NS_CLASS_ENTRY(tmp_ce_InvalidServiceIdentifierException, PIMPLE_EXCEPTION_NS, "InvalidServiceIdentifierException", pimple_ce_InvalidServiceIdentifierException_functions); - INIT_NS_CLASS_ENTRY(tmp_ce_UnknownIdentifierException, PIMPLE_EXCEPTION_NS, "UnknownIdentifierException", pimple_ce_UnknownIdentifierException_functions); - - pimple_ce_ExpectedInvokableException = zend_register_internal_class_ex(&tmp_ce_ExpectedInvokableException, spl_ce_InvalidArgumentException, NULL TSRMLS_CC); - pimple_ce_FrozenServiceException = zend_register_internal_class_ex(&tmp_ce_FrozenServiceException, spl_ce_RuntimeException, NULL TSRMLS_CC); - pimple_ce_InvalidServiceIdentifierException = zend_register_internal_class_ex(&tmp_ce_InvalidServiceIdentifierException, spl_ce_InvalidArgumentException, NULL TSRMLS_CC); - pimple_ce_UnknownIdentifierException = zend_register_internal_class_ex(&tmp_ce_UnknownIdentifierException, spl_ce_InvalidArgumentException, NULL TSRMLS_CC); - - zend_class_implements(pimple_ce_ExpectedInvokableException TSRMLS_CC, 1, pimple_ce_PsrContainerExceptionInterface); - zend_class_implements(pimple_ce_FrozenServiceException TSRMLS_CC, 1, pimple_ce_PsrContainerExceptionInterface); - zend_class_implements(pimple_ce_InvalidServiceIdentifierException TSRMLS_CC, 1, pimple_ce_PsrContainerExceptionInterface); - zend_class_implements(pimple_ce_UnknownIdentifierException TSRMLS_CC, 1, pimple_ce_PsrNotFoundExceptionInterface); - - /* Pimple namespace */ - INIT_NS_CLASS_ENTRY(tmp_pimple_ce, PIMPLE_NS, "Container", pimple_ce_functions); - INIT_NS_CLASS_ENTRY(tmp_pimple_closure_ce, PIMPLE_NS, "ContainerClosure", NULL); - INIT_NS_CLASS_ENTRY(tmp_pimple_serviceprovider_iface_ce, PIMPLE_NS, "ServiceProviderInterface", pimple_serviceprovider_iface_ce_functions); - - tmp_pimple_ce.create_object = pimple_object_create; - tmp_pimple_closure_ce.create_object = pimple_closure_object_create; - - pimple_ce = zend_register_internal_class(&tmp_pimple_ce TSRMLS_CC); - zend_class_implements(pimple_ce TSRMLS_CC, 1, zend_ce_arrayaccess); - - pimple_closure_ce = zend_register_internal_class(&tmp_pimple_closure_ce TSRMLS_CC); - pimple_closure_ce->ce_flags |= ZEND_ACC_FINAL_CLASS; - - pimple_serviceprovider_ce = zend_register_internal_interface(&tmp_pimple_serviceprovider_iface_ce TSRMLS_CC); - - memcpy(&pimple_closure_object_handlers, zend_get_std_object_handlers(), sizeof(*zend_get_std_object_handlers())); - pimple_object_handlers = std_object_handlers; - pimple_closure_object_handlers.get_closure = pimple_closure_get_closure; - - pimple_closure_invoker_function.function_name = "Pimple closure internal invoker"; - pimple_closure_invoker_function.fn_flags |= ZEND_ACC_CLOSURE; - pimple_closure_invoker_function.handler = ZEND_MN(PimpleClosure_invoker); - pimple_closure_invoker_function.num_args = 1; - pimple_closure_invoker_function.required_num_args = 1; - pimple_closure_invoker_function.scope = pimple_closure_ce; - pimple_closure_invoker_function.type = ZEND_INTERNAL_FUNCTION; - pimple_closure_invoker_function.module = &pimple_module_entry; - - return SUCCESS; -} - -PHP_MINFO_FUNCTION(pimple) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "SensioLabs Pimple C support", "enabled"); - php_info_print_table_row(2, "Pimple supported version", PIMPLE_VERSION); - php_info_print_table_end(); - - php_info_print_box_start(0); - php_write((void *)ZEND_STRL("SensioLabs Pimple C support developed by Julien Pauli") TSRMLS_CC); - if (!sapi_module.phpinfo_as_text) { - php_write((void *)ZEND_STRL(sensiolabs_logo) TSRMLS_CC); - } - php_info_print_box_end(); -} - -zend_module_entry pimple_module_entry = { - STANDARD_MODULE_HEADER, - "pimple", - NULL, - PHP_MINIT(pimple), - NULL, - NULL, - NULL, - PHP_MINFO(pimple), - PIMPLE_VERSION, - STANDARD_MODULE_PROPERTIES -}; - -#ifdef COMPILE_DL_PIMPLE -ZEND_GET_MODULE(pimple) -#endif diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/pimple_compat.h b/lib/silex/vendor/pimple/pimple/ext/pimple/pimple_compat.h deleted file mode 100644 index d234e174d..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/pimple_compat.h +++ /dev/null @@ -1,81 +0,0 @@ - -/* - * This file is part of Pimple. - * - * Copyright (c) 2014 Fabien Potencier - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished - * to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef PIMPLE_COMPAT_H_ -#define PIMPLE_COMPAT_H_ - -#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */ - -#define PHP_5_0_X_API_NO 220040412 -#define PHP_5_1_X_API_NO 220051025 -#define PHP_5_2_X_API_NO 220060519 -#define PHP_5_3_X_API_NO 220090626 -#define PHP_5_4_X_API_NO 220100525 -#define PHP_5_5_X_API_NO 220121212 -#define PHP_5_6_X_API_NO 220131226 - -#define IS_PHP_56 ZEND_EXTENSION_API_NO == PHP_5_6_X_API_NO -#define IS_AT_LEAST_PHP_56 ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO - -#define IS_PHP_55 ZEND_EXTENSION_API_NO == PHP_5_5_X_API_NO -#define IS_AT_LEAST_PHP_55 ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO - -#define IS_PHP_54 ZEND_EXTENSION_API_NO == PHP_5_4_X_API_NO -#define IS_AT_LEAST_PHP_54 ZEND_EXTENSION_API_NO >= PHP_5_4_X_API_NO - -#define IS_PHP_53 ZEND_EXTENSION_API_NO == PHP_5_3_X_API_NO -#define IS_AT_LEAST_PHP_53 ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO - -#if IS_PHP_53 -#define object_properties_init(obj, ce) do { \ - zend_hash_copy(obj->properties, &ce->default_properties, zval_copy_property_ctor(ce), NULL, sizeof(zval *)); \ - } while (0); -#endif - -#define ZEND_OBJ_INIT(obj, ce) do { \ - zend_object_std_init(obj, ce TSRMLS_CC); \ - object_properties_init((obj), (ce)); \ - } while(0); - -#if IS_PHP_53 || IS_PHP_54 -static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) { - Bucket *p; - - p = pos ? (*pos) : ht->pInternalPointer; - - if (!p) { - Z_TYPE_P(key) = IS_NULL; - } else if (p->nKeyLength) { - Z_TYPE_P(key) = IS_STRING; - Z_STRVAL_P(key) = estrndup(p->arKey, p->nKeyLength - 1); - Z_STRLEN_P(key) = p->nKeyLength - 1; - } else { - Z_TYPE_P(key) = IS_LONG; - Z_LVAL_P(key) = p->h; - } -} -#endif - -#endif /* PIMPLE_COMPAT_H_ */ diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/001.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/001.phpt deleted file mode 100644 index 0809ea232..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/001.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -Test for read_dim/write_dim handlers ---SKIPIF-- - ---FILE-- - - ---EXPECTF-- -foo -42 -foo2 -foo99 -baz -strstr \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/002.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/002.phpt deleted file mode 100644 index 7b56d2c1f..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/002.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Test for constructor ---SKIPIF-- - ---FILE-- -'foo')); -var_dump($p[42]); -?> ---EXPECT-- -NULL -string(3) "foo" diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/003.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/003.phpt deleted file mode 100644 index a22cfa352..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/003.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Test empty dimensions ---SKIPIF-- - ---FILE-- - ---EXPECT-- -int(42) -string(3) "bar" \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/004.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/004.phpt deleted file mode 100644 index 1e1d25136..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/004.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Test has/unset dim handlers ---SKIPIF-- - ---FILE-- - ---EXPECT-- -int(42) -NULL -bool(true) -bool(false) -bool(true) -bool(true) \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/005.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/005.phpt deleted file mode 100644 index 0479ee055..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/005.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Test simple class inheritance ---SKIPIF-- - ---FILE-- -someAttr; -?> ---EXPECT-- -string(3) "hit" -foo -fooAttr \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/006.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/006.phpt deleted file mode 100644 index cfe8a119e..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/006.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -Test complex class inheritance ---SKIPIF-- - ---FILE-- - 'bar', 88 => 'baz'); - -$p = new TestPimple($defaultValues); -$p[42] = 'foo'; -var_dump($p[42]); -var_dump($p[0]); -?> ---EXPECT-- -string(13) "hit offsetset" -string(27) "hit offsetget in TestPimple" -string(25) "hit offsetget in MyPimple" -string(3) "foo" -string(27) "hit offsetget in TestPimple" -string(25) "hit offsetget in MyPimple" -string(3) "baz" \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/007.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/007.phpt deleted file mode 100644 index 5aac68380..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/007.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Test for read_dim/write_dim handlers ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -foo -42 \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/008.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/008.phpt deleted file mode 100644 index db7eeec4a..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/008.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Test frozen services ---SKIPIF-- - ---FILE-- - ---EXPECTF-- diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/009.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/009.phpt deleted file mode 100644 index bb05ea296..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/009.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Test service is called as callback, and only once ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -bool(true) \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/010.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/010.phpt deleted file mode 100644 index badce0146..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/010.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -Test service is called as callback for every callback type ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -callme -called -Foo::bar -array(2) { - [0]=> - string(3) "Foo" - [1]=> - string(3) "bar" -} \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/011.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/011.phpt deleted file mode 100644 index 6682ab8eb..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/011.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -Test service callback throwing an exception ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -all right! \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/012.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/012.phpt deleted file mode 100644 index 4c6ac486d..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/012.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Test service factory ---SKIPIF-- - ---FILE-- -factory($f = function() { var_dump('called-1'); return 'ret-1';}); - -$p[] = $f; - -$p[] = function () { var_dump('called-2'); return 'ret-2'; }; - -var_dump($p[0]); -var_dump($p[0]); -var_dump($p[1]); -var_dump($p[1]); -?> ---EXPECTF-- -string(8) "called-1" -string(5) "ret-1" -string(8) "called-1" -string(5) "ret-1" -string(8) "called-2" -string(5) "ret-2" -string(5) "ret-2" \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/013.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/013.phpt deleted file mode 100644 index f419958c5..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/013.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Test keys() ---SKIPIF-- - ---FILE-- -keys()); - -$p['foo'] = 'bar'; -$p[] = 'foo'; - -var_dump($p->keys()); - -unset($p['foo']); - -var_dump($p->keys()); -?> ---EXPECTF-- -array(0) { -} -array(2) { - [0]=> - string(3) "foo" - [1]=> - int(0) -} -array(1) { - [0]=> - int(0) -} \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/014.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/014.phpt deleted file mode 100644 index ac937213a..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/014.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Test raw() ---SKIPIF-- - ---FILE-- -raw('foo')); -var_dump($p[42]); - -unset($p['foo']); - -try { - $p->raw('foo'); - echo "expected exception"; -} catch (InvalidArgumentException $e) { } ---EXPECTF-- -string(8) "called-2" -string(5) "ret-2" -object(Closure)#%i (0) { -} -string(8) "called-2" -string(5) "ret-2" \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/015.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/015.phpt deleted file mode 100644 index 314f008ac..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/015.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Test protect() ---SKIPIF-- - ---FILE-- -protect($f); - -var_dump($p['foo']); ---EXPECTF-- -object(Closure)#%i (0) { -} \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/016.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/016.phpt deleted file mode 100644 index e55edb0a7..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/016.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Test extend() ---SKIPIF-- - ---FILE-- -extend(12, function ($w) { var_dump($w); return 'bar'; }); /* $callable in code above */ - -var_dump($c('param')); ---EXPECTF-- -string(5) "param" -string(3) "foo" -string(3) "bar" \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/017.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/017.phpt deleted file mode 100644 index bac23ce09..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/017.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Test extend() with exception in service extension ---SKIPIF-- - ---FILE-- -extend(12, function ($w) { throw new BadMethodCallException; }); - -try { - $p[12]; - echo "Exception expected"; -} catch (BadMethodCallException $e) { } ---EXPECTF-- diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt deleted file mode 100644 index 8f881d6eb..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Test extend() with exception in service factory ---SKIPIF-- - ---FILE-- -extend(12, function ($w) { return 'foobar'; }); - -try { - $p[12]; - echo "Exception expected"; -} catch (BadMethodCallException $e) { } ---EXPECTF-- diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/018.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/018.phpt deleted file mode 100644 index 27c12a14e..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/018.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Test register() ---SKIPIF-- - ---FILE-- -register(new Foo, array(42 => 'bar')); - -var_dump($p[42]); ---EXPECTF-- -object(Pimple\Container)#1 (0) { -} -string(3) "bar" \ No newline at end of file diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/019.phpt b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/019.phpt deleted file mode 100644 index 28a9aecac..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/019.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Test register() returns static and is a fluent interface ---SKIPIF-- - ---FILE-- -register(new Foo)); ---EXPECTF-- -bool(true) diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench.phpb b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench.phpb deleted file mode 100644 index 8f983e656..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench.phpb +++ /dev/null @@ -1,51 +0,0 @@ -factory($factory); - -$p['factory'] = $factory; - -echo $p['factory']; -echo $p['factory']; -echo $p['factory']; - -} - -echo microtime(true) - $time; diff --git a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb b/lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb deleted file mode 100644 index aec541f0b..000000000 --- a/lib/silex/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb +++ /dev/null @@ -1,25 +0,0 @@ - diff --git a/lib/silex/vendor/pimple/pimple/lib/Pimple.php b/lib/silex/vendor/pimple/pimple/lib/Pimple.php deleted file mode 100644 index b980522d5..000000000 --- a/lib/silex/vendor/pimple/pimple/lib/Pimple.php +++ /dev/null @@ -1,214 +0,0 @@ -values = $values; - } - - /** - * Sets a parameter or an object. - * - * Objects must be defined as Closures. - * - * Allowing any PHP callable leads to difficult to debug problems - * as function names (strings) are callable (creating a function with - * the same a name as an existing parameter would break your container). - * - * @param string $id The unique identifier for the parameter or object - * @param mixed $value The value of the parameter or a closure to defined an object - */ - public function offsetSet($id, $value) - { - $this->values[$id] = $value; - } - - /** - * Gets a parameter or an object. - * - * @param string $id The unique identifier for the parameter or object - * - * @return mixed The value of the parameter or an object - * - * @throws InvalidArgumentException if the identifier is not defined - */ - public function offsetGet($id) - { - if (!array_key_exists($id, $this->values)) { - throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); - } - - $isFactory = is_object($this->values[$id]) && method_exists($this->values[$id], '__invoke'); - - return $isFactory ? $this->values[$id]($this) : $this->values[$id]; - } - - /** - * Checks if a parameter or an object is set. - * - * @param string $id The unique identifier for the parameter or object - * - * @return Boolean - */ - public function offsetExists($id) - { - return array_key_exists($id, $this->values); - } - - /** - * Unsets a parameter or an object. - * - * @param string $id The unique identifier for the parameter or object - */ - public function offsetUnset($id) - { - unset($this->values[$id]); - } - - /** - * Returns a closure that stores the result of the given service definition - * for uniqueness in the scope of this instance of Pimple. - * - * @param callable $callable A service definition to wrap for uniqueness - * - * @return Closure The wrapped closure - */ - public static function share($callable) - { - if (!is_object($callable) || !method_exists($callable, '__invoke')) { - throw new InvalidArgumentException('Service definition is not a Closure or invokable object.'); - } - - return function ($c) use ($callable) { - static $object; - - if (null === $object) { - $object = $callable($c); - } - - return $object; - }; - } - - /** - * Protects a callable from being interpreted as a service. - * - * This is useful when you want to store a callable as a parameter. - * - * @param callable $callable A callable to protect from being evaluated - * - * @return Closure The protected closure - */ - public static function protect($callable) - { - if (!is_object($callable) || !method_exists($callable, '__invoke')) { - throw new InvalidArgumentException('Callable is not a Closure or invokable object.'); - } - - return function ($c) use ($callable) { - return $callable; - }; - } - - /** - * Gets a parameter or the closure defining an object. - * - * @param string $id The unique identifier for the parameter or object - * - * @return mixed The value of the parameter or the closure defining an object - * - * @throws InvalidArgumentException if the identifier is not defined - */ - public function raw($id) - { - if (!array_key_exists($id, $this->values)) { - throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); - } - - return $this->values[$id]; - } - - /** - * Extends an object definition. - * - * Useful when you want to extend an existing object definition, - * without necessarily loading that object. - * - * @param string $id The unique identifier for the object - * @param callable $callable A service definition to extend the original - * - * @return Closure The wrapped closure - * - * @throws InvalidArgumentException if the identifier is not defined or not a service definition - */ - public function extend($id, $callable) - { - if (!array_key_exists($id, $this->values)) { - throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); - } - - if (!is_object($this->values[$id]) || !method_exists($this->values[$id], '__invoke')) { - throw new InvalidArgumentException(sprintf('Identifier "%s" does not contain an object definition.', $id)); - } - - if (!is_object($callable) || !method_exists($callable, '__invoke')) { - throw new InvalidArgumentException('Extension service definition is not a Closure or invokable object.'); - } - - $factory = $this->values[$id]; - - return $this->values[$id] = function ($c) use ($callable, $factory) { - return $callable($factory($c), $c); - }; - } - - /** - * Returns all defined value names. - * - * @return array An array of value names - */ - public function keys() - { - return array_keys($this->values); - } -} diff --git a/lib/silex/vendor/pimple/pimple/phpunit.xml.dist b/lib/silex/vendor/pimple/pimple/phpunit.xml.dist deleted file mode 100644 index 5c8d487fe..000000000 --- a/lib/silex/vendor/pimple/pimple/phpunit.xml.dist +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - ./src/Pimple/Tests - - - diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Container.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Container.php deleted file mode 100644 index 707b92b82..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Container.php +++ /dev/null @@ -1,298 +0,0 @@ -factories = new \SplObjectStorage(); - $this->protected = new \SplObjectStorage(); - - foreach ($values as $key => $value) { - $this->offsetSet($key, $value); - } - } - - /** - * Sets a parameter or an object. - * - * Objects must be defined as Closures. - * - * Allowing any PHP callable leads to difficult to debug problems - * as function names (strings) are callable (creating a function with - * the same name as an existing parameter would break your container). - * - * @param string $id The unique identifier for the parameter or object - * @param mixed $value The value of the parameter or a closure to define an object - * - * @throws FrozenServiceException Prevent override of a frozen service - */ - public function offsetSet($id, $value) - { - if (isset($this->frozen[$id])) { - throw new FrozenServiceException($id); - } - - $this->values[$id] = $value; - $this->keys[$id] = true; - } - - /** - * Gets a parameter or an object. - * - * @param string $id The unique identifier for the parameter or object - * - * @return mixed The value of the parameter or an object - * - * @throws UnknownIdentifierException If the identifier is not defined - */ - public function offsetGet($id) - { - if (!isset($this->keys[$id])) { - throw new UnknownIdentifierException($id); - } - - if ( - isset($this->raw[$id]) - || !\is_object($this->values[$id]) - || isset($this->protected[$this->values[$id]]) - || !\method_exists($this->values[$id], '__invoke') - ) { - return $this->values[$id]; - } - - if (isset($this->factories[$this->values[$id]])) { - return $this->values[$id]($this); - } - - $raw = $this->values[$id]; - $val = $this->values[$id] = $raw($this); - $this->raw[$id] = $raw; - - $this->frozen[$id] = true; - - return $val; - } - - /** - * Checks if a parameter or an object is set. - * - * @param string $id The unique identifier for the parameter or object - * - * @return bool - */ - public function offsetExists($id) - { - return isset($this->keys[$id]); - } - - /** - * Unsets a parameter or an object. - * - * @param string $id The unique identifier for the parameter or object - */ - public function offsetUnset($id) - { - if (isset($this->keys[$id])) { - if (\is_object($this->values[$id])) { - unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]); - } - - unset($this->values[$id], $this->frozen[$id], $this->raw[$id], $this->keys[$id]); - } - } - - /** - * Marks a callable as being a factory service. - * - * @param callable $callable A service definition to be used as a factory - * - * @return callable The passed callable - * - * @throws ExpectedInvokableException Service definition has to be a closure or an invokable object - */ - public function factory($callable) - { - if (!\method_exists($callable, '__invoke')) { - throw new ExpectedInvokableException('Service definition is not a Closure or invokable object.'); - } - - $this->factories->attach($callable); - - return $callable; - } - - /** - * Protects a callable from being interpreted as a service. - * - * This is useful when you want to store a callable as a parameter. - * - * @param callable $callable A callable to protect from being evaluated - * - * @return callable The passed callable - * - * @throws ExpectedInvokableException Service definition has to be a closure or an invokable object - */ - public function protect($callable) - { - if (!\method_exists($callable, '__invoke')) { - throw new ExpectedInvokableException('Callable is not a Closure or invokable object.'); - } - - $this->protected->attach($callable); - - return $callable; - } - - /** - * Gets a parameter or the closure defining an object. - * - * @param string $id The unique identifier for the parameter or object - * - * @return mixed The value of the parameter or the closure defining an object - * - * @throws UnknownIdentifierException If the identifier is not defined - */ - public function raw($id) - { - if (!isset($this->keys[$id])) { - throw new UnknownIdentifierException($id); - } - - if (isset($this->raw[$id])) { - return $this->raw[$id]; - } - - return $this->values[$id]; - } - - /** - * Extends an object definition. - * - * Useful when you want to extend an existing object definition, - * without necessarily loading that object. - * - * @param string $id The unique identifier for the object - * @param callable $callable A service definition to extend the original - * - * @return callable The wrapped callable - * - * @throws UnknownIdentifierException If the identifier is not defined - * @throws FrozenServiceException If the service is frozen - * @throws InvalidServiceIdentifierException If the identifier belongs to a parameter - * @throws ExpectedInvokableException If the extension callable is not a closure or an invokable object - */ - public function extend($id, $callable) - { - if (!isset($this->keys[$id])) { - throw new UnknownIdentifierException($id); - } - - if (isset($this->frozen[$id])) { - throw new FrozenServiceException($id); - } - - if (!\is_object($this->values[$id]) || !\method_exists($this->values[$id], '__invoke')) { - throw new InvalidServiceIdentifierException($id); - } - - if (isset($this->protected[$this->values[$id]])) { - @\trigger_error(\sprintf('How Pimple behaves when extending protected closures will be fixed in Pimple 4. Are you sure "%s" should be protected?', $id), \E_USER_DEPRECATED); - } - - if (!\is_object($callable) || !\method_exists($callable, '__invoke')) { - throw new ExpectedInvokableException('Extension service definition is not a Closure or invokable object.'); - } - - $factory = $this->values[$id]; - - $extended = function ($c) use ($callable, $factory) { - return $callable($factory($c), $c); - }; - - if (isset($this->factories[$factory])) { - $this->factories->detach($factory); - $this->factories->attach($extended); - } - - return $this[$id] = $extended; - } - - /** - * Returns all defined value names. - * - * @return array An array of value names - */ - public function keys() - { - return \array_keys($this->values); - } - - /** - * Registers a service provider. - * - * @param ServiceProviderInterface $provider A ServiceProviderInterface instance - * @param array $values An array of values that customizes the provider - * - * @return static - */ - public function register(ServiceProviderInterface $provider, array $values = array()) - { - $provider->register($this); - - foreach ($values as $key => $value) { - $this[$key] = $value; - } - - return $this; - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php deleted file mode 100644 index 7228421b1..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ -class ExpectedInvokableException extends \InvalidArgumentException implements ContainerExceptionInterface -{ -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php deleted file mode 100644 index e4d2f6d36..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class FrozenServiceException extends \RuntimeException implements ContainerExceptionInterface -{ - /** - * @param string $id Identifier of the frozen service - */ - public function __construct($id) - { - parent::__construct(\sprintf('Cannot override frozen service "%s".', $id)); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php deleted file mode 100644 index 91e82f98c..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class InvalidServiceIdentifierException extends \InvalidArgumentException implements NotFoundExceptionInterface -{ - /** - * @param string $id The invalid identifier - */ - public function __construct($id) - { - parent::__construct(\sprintf('Identifier "%s" does not contain an object definition.', $id)); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php deleted file mode 100644 index fb6b626e2..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class UnknownIdentifierException extends \InvalidArgumentException implements NotFoundExceptionInterface -{ - /** - * @param string $id The unknown identifier - */ - public function __construct($id) - { - parent::__construct(\sprintf('Identifier "%s" is not defined.', $id)); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/Container.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/Container.php deleted file mode 100644 index cadbfffad..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/Container.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -final class Container implements ContainerInterface -{ - private $pimple; - - public function __construct(PimpleContainer $pimple) - { - $this->pimple = $pimple; - } - - public function get($id) - { - return $this->pimple[$id]; - } - - public function has($id) - { - return isset($this->pimple[$id]); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php deleted file mode 100644 index 3361c6f19..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php +++ /dev/null @@ -1,75 +0,0 @@ - - */ -class ServiceLocator implements ContainerInterface -{ - private $container; - private $aliases = array(); - - /** - * @param PimpleContainer $container The Container instance used to locate services - * @param array $ids Array of service ids that can be located. String keys can be used to define aliases - */ - public function __construct(PimpleContainer $container, array $ids) - { - $this->container = $container; - - foreach ($ids as $key => $id) { - $this->aliases[\is_int($key) ? $id : $key] = $id; - } - } - - /** - * {@inheritdoc} - */ - public function get($id) - { - if (!isset($this->aliases[$id])) { - throw new UnknownIdentifierException($id); - } - - return $this->container[$this->aliases[$id]]; - } - - /** - * {@inheritdoc} - */ - public function has($id) - { - return isset($this->aliases[$id]) && isset($this->container[$this->aliases[$id]]); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/ServiceIterator.php b/lib/silex/vendor/pimple/pimple/src/Pimple/ServiceIterator.php deleted file mode 100644 index 5cde5188f..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/ServiceIterator.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -final class ServiceIterator implements \Iterator -{ - private $container; - private $ids; - - public function __construct(Container $container, array $ids) - { - $this->container = $container; - $this->ids = $ids; - } - - public function rewind() - { - \reset($this->ids); - } - - public function current() - { - return $this->container[\current($this->ids)]; - } - - public function key() - { - return \current($this->ids); - } - - public function next() - { - \next($this->ids); - } - - public function valid() - { - return null !== \key($this->ids); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php b/lib/silex/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php deleted file mode 100644 index c004594ba..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php +++ /dev/null @@ -1,46 +0,0 @@ -value = $value; - - return $service; - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/NonInvokable.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/NonInvokable.php deleted file mode 100644 index 33cd4e548..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/NonInvokable.php +++ /dev/null @@ -1,34 +0,0 @@ -factory(function () { - return new Service(); - }); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Service.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Service.php deleted file mode 100644 index d71b184dd..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Service.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class Service -{ - public $value; -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleServiceProviderInterfaceTest.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleServiceProviderInterfaceTest.php deleted file mode 100644 index 8e5c4c73d..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleServiceProviderInterfaceTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - */ -class PimpleServiceProviderInterfaceTest extends \PHPUnit_Framework_TestCase -{ - public function testProvider() - { - $pimple = new Container(); - - $pimpleServiceProvider = new Fixtures\PimpleServiceProvider(); - $pimpleServiceProvider->register($pimple); - - $this->assertEquals('value', $pimple['param']); - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['service']); - - $serviceOne = $pimple['factory']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne); - - $serviceTwo = $pimple['factory']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo); - - $this->assertNotSame($serviceOne, $serviceTwo); - } - - public function testProviderWithRegisterMethod() - { - $pimple = new Container(); - - $pimple->register(new Fixtures\PimpleServiceProvider(), array( - 'anotherParameter' => 'anotherValue', - )); - - $this->assertEquals('value', $pimple['param']); - $this->assertEquals('anotherValue', $pimple['anotherParameter']); - - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['service']); - - $serviceOne = $pimple['factory']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne); - - $serviceTwo = $pimple['factory']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo); - - $this->assertNotSame($serviceOne, $serviceTwo); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleTest.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleTest.php deleted file mode 100644 index acb66e000..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/PimpleTest.php +++ /dev/null @@ -1,589 +0,0 @@ - - */ -class PimpleTest extends \PHPUnit_Framework_TestCase -{ - public function testWithString() - { - $pimple = new Container(); - $pimple['param'] = 'value'; - - $this->assertEquals('value', $pimple['param']); - } - - public function testWithClosure() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['service']); - } - - public function testServicesShouldBeDifferent() - { - $pimple = new Container(); - $pimple['service'] = $pimple->factory(function () { - return new Fixtures\Service(); - }); - - $serviceOne = $pimple['service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne); - - $serviceTwo = $pimple['service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo); - - $this->assertNotSame($serviceOne, $serviceTwo); - } - - public function testShouldPassContainerAsParameter() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - $pimple['container'] = function ($container) { - return $container; - }; - - $this->assertNotSame($pimple, $pimple['service']); - $this->assertSame($pimple, $pimple['container']); - } - - public function testIsset() - { - $pimple = new Container(); - $pimple['param'] = 'value'; - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - - $pimple['null'] = null; - - $this->assertTrue(isset($pimple['param'])); - $this->assertTrue(isset($pimple['service'])); - $this->assertTrue(isset($pimple['null'])); - $this->assertFalse(isset($pimple['non_existent'])); - } - - public function testConstructorInjection() - { - $params = array('param' => 'value'); - $pimple = new Container($params); - - $this->assertSame($params['param'], $pimple['param']); - } - - /** - * @expectedException \Pimple\Exception\UnknownIdentifierException - * @expectedExceptionMessage Identifier "foo" is not defined. - */ - public function testOffsetGetValidatesKeyIsPresent() - { - $pimple = new Container(); - echo $pimple['foo']; - } - - /** - * @group legacy - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Identifier "foo" is not defined. - */ - public function testLegacyOffsetGetValidatesKeyIsPresent() - { - $pimple = new Container(); - echo $pimple['foo']; - } - - public function testOffsetGetHonorsNullValues() - { - $pimple = new Container(); - $pimple['foo'] = null; - $this->assertNull($pimple['foo']); - } - - public function testUnset() - { - $pimple = new Container(); - $pimple['param'] = 'value'; - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - - unset($pimple['param'], $pimple['service']); - $this->assertFalse(isset($pimple['param'])); - $this->assertFalse(isset($pimple['service'])); - } - - /** - * @dataProvider serviceDefinitionProvider - */ - public function testShare($service) - { - $pimple = new Container(); - $pimple['shared_service'] = $service; - - $serviceOne = $pimple['shared_service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne); - - $serviceTwo = $pimple['shared_service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo); - - $this->assertSame($serviceOne, $serviceTwo); - } - - /** - * @dataProvider serviceDefinitionProvider - */ - public function testProtect($service) - { - $pimple = new Container(); - $pimple['protected'] = $pimple->protect($service); - - $this->assertSame($service, $pimple['protected']); - } - - public function testGlobalFunctionNameAsParameterValue() - { - $pimple = new Container(); - $pimple['global_function'] = 'strlen'; - $this->assertSame('strlen', $pimple['global_function']); - } - - public function testRaw() - { - $pimple = new Container(); - $pimple['service'] = $definition = $pimple->factory(function () { return 'foo'; }); - $this->assertSame($definition, $pimple->raw('service')); - } - - public function testRawHonorsNullValues() - { - $pimple = new Container(); - $pimple['foo'] = null; - $this->assertNull($pimple->raw('foo')); - } - - public function testFluentRegister() - { - $pimple = new Container(); - $this->assertSame($pimple, $pimple->register($this->getMockBuilder('Pimple\ServiceProviderInterface')->getMock())); - } - - /** - * @expectedException \Pimple\Exception\UnknownIdentifierException - * @expectedExceptionMessage Identifier "foo" is not defined. - */ - public function testRawValidatesKeyIsPresent() - { - $pimple = new Container(); - $pimple->raw('foo'); - } - - /** - * @group legacy - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Identifier "foo" is not defined. - */ - public function testLegacyRawValidatesKeyIsPresent() - { - $pimple = new Container(); - $pimple->raw('foo'); - } - - /** - * @dataProvider serviceDefinitionProvider - */ - public function testExtend($service) - { - $pimple = new Container(); - $pimple['shared_service'] = function () { - return new Fixtures\Service(); - }; - $pimple['factory_service'] = $pimple->factory(function () { - return new Fixtures\Service(); - }); - - $pimple->extend('shared_service', $service); - $serviceOne = $pimple['shared_service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne); - $serviceTwo = $pimple['shared_service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo); - $this->assertSame($serviceOne, $serviceTwo); - $this->assertSame($serviceOne->value, $serviceTwo->value); - - $pimple->extend('factory_service', $service); - $serviceOne = $pimple['factory_service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne); - $serviceTwo = $pimple['factory_service']; - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo); - $this->assertNotSame($serviceOne, $serviceTwo); - $this->assertNotSame($serviceOne->value, $serviceTwo->value); - } - - public function testExtendDoesNotLeakWithFactories() - { - if (extension_loaded('pimple')) { - $this->markTestSkipped('Pimple extension does not support this test'); - } - $pimple = new Container(); - - $pimple['foo'] = $pimple->factory(function () { return; }); - $pimple['foo'] = $pimple->extend('foo', function ($foo, $pimple) { return; }); - unset($pimple['foo']); - - $p = new \ReflectionProperty($pimple, 'values'); - $p->setAccessible(true); - $this->assertEmpty($p->getValue($pimple)); - - $p = new \ReflectionProperty($pimple, 'factories'); - $p->setAccessible(true); - $this->assertCount(0, $p->getValue($pimple)); - } - - /** - * @expectedException \Pimple\Exception\UnknownIdentifierException - * @expectedExceptionMessage Identifier "foo" is not defined. - */ - public function testExtendValidatesKeyIsPresent() - { - $pimple = new Container(); - $pimple->extend('foo', function () {}); - } - - /** - * @group legacy - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Identifier "foo" is not defined. - */ - public function testLegacyExtendValidatesKeyIsPresent() - { - $pimple = new Container(); - $pimple->extend('foo', function () {}); - } - - public function testKeys() - { - $pimple = new Container(); - $pimple['foo'] = 123; - $pimple['bar'] = 123; - - $this->assertEquals(array('foo', 'bar'), $pimple->keys()); - } - - /** @test */ - public function settingAnInvokableObjectShouldTreatItAsFactory() - { - $pimple = new Container(); - $pimple['invokable'] = new Fixtures\Invokable(); - - $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['invokable']); - } - - /** @test */ - public function settingNonInvokableObjectShouldTreatItAsParameter() - { - $pimple = new Container(); - $pimple['non_invokable'] = new Fixtures\NonInvokable(); - - $this->assertInstanceOf('Pimple\Tests\Fixtures\NonInvokable', $pimple['non_invokable']); - } - - /** - * @dataProvider badServiceDefinitionProvider - * @expectedException \Pimple\Exception\ExpectedInvokableException - * @expectedExceptionMessage Service definition is not a Closure or invokable object. - */ - public function testFactoryFailsForInvalidServiceDefinitions($service) - { - $pimple = new Container(); - $pimple->factory($service); - } - - /** - * @group legacy - * @dataProvider badServiceDefinitionProvider - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Service definition is not a Closure or invokable object. - */ - public function testLegacyFactoryFailsForInvalidServiceDefinitions($service) - { - $pimple = new Container(); - $pimple->factory($service); - } - - /** - * @dataProvider badServiceDefinitionProvider - * @expectedException \Pimple\Exception\ExpectedInvokableException - * @expectedExceptionMessage Callable is not a Closure or invokable object. - */ - public function testProtectFailsForInvalidServiceDefinitions($service) - { - $pimple = new Container(); - $pimple->protect($service); - } - - /** - * @group legacy - * @dataProvider badServiceDefinitionProvider - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Callable is not a Closure or invokable object. - */ - public function testLegacyProtectFailsForInvalidServiceDefinitions($service) - { - $pimple = new Container(); - $pimple->protect($service); - } - - /** - * @dataProvider badServiceDefinitionProvider - * @expectedException \Pimple\Exception\InvalidServiceIdentifierException - * @expectedExceptionMessage Identifier "foo" does not contain an object definition. - */ - public function testExtendFailsForKeysNotContainingServiceDefinitions($service) - { - $pimple = new Container(); - $pimple['foo'] = $service; - $pimple->extend('foo', function () {}); - } - - /** - * @group legacy - * @dataProvider badServiceDefinitionProvider - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Identifier "foo" does not contain an object definition. - */ - public function testLegacyExtendFailsForKeysNotContainingServiceDefinitions($service) - { - $pimple = new Container(); - $pimple['foo'] = $service; - $pimple->extend('foo', function () {}); - } - - /** - * @group legacy - * @expectedDeprecation How Pimple behaves when extending protected closures will be fixed in Pimple 4. Are you sure "foo" should be protected? - */ - public function testExtendingProtectedClosureDeprecation() - { - $pimple = new Container(); - $pimple['foo'] = $pimple->protect(function () { - return 'bar'; - }); - - $pimple->extend('foo', function ($value) { - return $value.'-baz'; - }); - - $this->assertSame('bar-baz', $pimple['foo']); - } - - /** - * @dataProvider badServiceDefinitionProvider - * @expectedException \Pimple\Exception\ExpectedInvokableException - * @expectedExceptionMessage Extension service definition is not a Closure or invokable object. - */ - public function testExtendFailsForInvalidServiceDefinitions($service) - { - $pimple = new Container(); - $pimple['foo'] = function () {}; - $pimple->extend('foo', $service); - } - - /** - * @group legacy - * @dataProvider badServiceDefinitionProvider - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Extension service definition is not a Closure or invokable object. - */ - public function testLegacyExtendFailsForInvalidServiceDefinitions($service) - { - $pimple = new Container(); - $pimple['foo'] = function () {}; - $pimple->extend('foo', $service); - } - - /** - * @expectedException \Pimple\Exception\FrozenServiceException - * @expectedExceptionMessage Cannot override frozen service "foo". - */ - public function testExtendFailsIfFrozenServiceIsNonInvokable() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return new Fixtures\NonInvokable(); - }; - $foo = $pimple['foo']; - - $pimple->extend('foo', function () {}); - } - - /** - * @expectedException \Pimple\Exception\FrozenServiceException - * @expectedExceptionMessage Cannot override frozen service "foo". - */ - public function testExtendFailsIfFrozenServiceIsInvokable() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return new Fixtures\Invokable(); - }; - $foo = $pimple['foo']; - - $pimple->extend('foo', function () {}); - } - - /** - * Provider for invalid service definitions. - */ - public function badServiceDefinitionProvider() - { - return array( - array(123), - array(new Fixtures\NonInvokable()), - ); - } - - /** - * Provider for service definitions. - */ - public function serviceDefinitionProvider() - { - return array( - array(function ($value) { - $service = new Fixtures\Service(); - $service->value = $value; - - return $service; - }), - array(new Fixtures\Invokable()), - ); - } - - public function testDefiningNewServiceAfterFreeze() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return 'foo'; - }; - $foo = $pimple['foo']; - - $pimple['bar'] = function () { - return 'bar'; - }; - $this->assertSame('bar', $pimple['bar']); - } - - /** - * @expectedException \Pimple\Exception\FrozenServiceException - * @expectedExceptionMessage Cannot override frozen service "foo". - */ - public function testOverridingServiceAfterFreeze() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return 'foo'; - }; - $foo = $pimple['foo']; - - $pimple['foo'] = function () { - return 'bar'; - }; - } - - /** - * @group legacy - * @expectedException \RuntimeException - * @expectedExceptionMessage Cannot override frozen service "foo". - */ - public function testLegacyOverridingServiceAfterFreeze() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return 'foo'; - }; - $foo = $pimple['foo']; - - $pimple['foo'] = function () { - return 'bar'; - }; - } - - public function testRemovingServiceAfterFreeze() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return 'foo'; - }; - $foo = $pimple['foo']; - - unset($pimple['foo']); - $pimple['foo'] = function () { - return 'bar'; - }; - $this->assertSame('bar', $pimple['foo']); - } - - public function testExtendingService() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return 'foo'; - }; - $pimple['foo'] = $pimple->extend('foo', function ($foo, $app) { - return "$foo.bar"; - }); - $pimple['foo'] = $pimple->extend('foo', function ($foo, $app) { - return "$foo.baz"; - }); - $this->assertSame('foo.bar.baz', $pimple['foo']); - } - - public function testExtendingServiceAfterOtherServiceFreeze() - { - $pimple = new Container(); - $pimple['foo'] = function () { - return 'foo'; - }; - $pimple['bar'] = function () { - return 'bar'; - }; - $foo = $pimple['foo']; - - $pimple['bar'] = $pimple->extend('bar', function ($bar, $app) { - return "$bar.baz"; - }); - $this->assertSame('bar.baz', $pimple['bar']); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ContainerTest.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ContainerTest.php deleted file mode 100644 index 7ca2d7fff..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ContainerTest.php +++ /dev/null @@ -1,77 +0,0 @@ -assertSame($pimple['service'], $psr->get('service')); - } - - /** - * @expectedException \Psr\Container\NotFoundExceptionInterface - * @expectedExceptionMessage Identifier "service" is not defined. - */ - public function testGetThrowsExceptionIfServiceIsNotFound() - { - $pimple = new Container(); - $psr = new PsrContainer($pimple); - - $psr->get('service'); - } - - public function testHasReturnsTrueIfServiceExists() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Service(); - }; - $psr = new PsrContainer($pimple); - - $this->assertTrue($psr->has('service')); - } - - public function testHasReturnsFalseIfServiceDoesNotExist() - { - $pimple = new Container(); - $psr = new PsrContainer($pimple); - - $this->assertFalse($psr->has('service')); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ServiceLocatorTest.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ServiceLocatorTest.php deleted file mode 100644 index c9a081259..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ServiceLocatorTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - */ -class ServiceLocatorTest extends TestCase -{ - public function testCanAccessServices() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - $locator = new ServiceLocator($pimple, array('service')); - - $this->assertSame($pimple['service'], $locator->get('service')); - } - - public function testCanAccessAliasedServices() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - $locator = new ServiceLocator($pimple, array('alias' => 'service')); - - $this->assertSame($pimple['service'], $locator->get('alias')); - } - - /** - * @expectedException \Pimple\Exception\UnknownIdentifierException - * @expectedExceptionMessage Identifier "service" is not defined. - */ - public function testCannotAccessAliasedServiceUsingRealIdentifier() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - $locator = new ServiceLocator($pimple, array('alias' => 'service')); - - $service = $locator->get('service'); - } - - /** - * @expectedException \Pimple\Exception\UnknownIdentifierException - * @expectedExceptionMessage Identifier "foo" is not defined. - */ - public function testGetValidatesServiceCanBeLocated() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - $locator = new ServiceLocator($pimple, array('alias' => 'service')); - - $service = $locator->get('foo'); - } - - /** - * @expectedException \Pimple\Exception\UnknownIdentifierException - * @expectedExceptionMessage Identifier "invalid" is not defined. - */ - public function testGetValidatesTargetServiceExists() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - $locator = new ServiceLocator($pimple, array('alias' => 'invalid')); - - $service = $locator->get('alias'); - } - - public function testHasValidatesServiceCanBeLocated() - { - $pimple = new Container(); - $pimple['service1'] = function () { - return new Fixtures\Service(); - }; - $pimple['service2'] = function () { - return new Fixtures\Service(); - }; - $locator = new ServiceLocator($pimple, array('service1')); - - $this->assertTrue($locator->has('service1')); - $this->assertFalse($locator->has('service2')); - } - - public function testHasChecksIfTargetServiceExists() - { - $pimple = new Container(); - $pimple['service'] = function () { - return new Fixtures\Service(); - }; - $locator = new ServiceLocator($pimple, array('foo' => 'service', 'bar' => 'invalid')); - - $this->assertTrue($locator->has('foo')); - $this->assertFalse($locator->has('bar')); - } -} diff --git a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/ServiceIteratorTest.php b/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/ServiceIteratorTest.php deleted file mode 100644 index 5dd52f0d9..000000000 --- a/lib/silex/vendor/pimple/pimple/src/Pimple/Tests/ServiceIteratorTest.php +++ /dev/null @@ -1,52 +0,0 @@ -assertSame(array('service1' => $pimple['service1'], 'service2' => $pimple['service2']), iterator_to_array($iterator)); - } -} diff --git a/lib/silex/vendor/psr/container/.gitignore b/lib/silex/vendor/psr/container/.gitignore deleted file mode 100644 index b2395aa05..000000000 --- a/lib/silex/vendor/psr/container/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -composer.lock -composer.phar -/vendor/ diff --git a/lib/silex/vendor/psr/container/LICENSE b/lib/silex/vendor/psr/container/LICENSE deleted file mode 100644 index 2877a4894..000000000 --- a/lib/silex/vendor/psr/container/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013-2016 container-interop -Copyright (c) 2016 PHP Framework Interoperability Group - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/silex/vendor/psr/container/README.md b/lib/silex/vendor/psr/container/README.md deleted file mode 100644 index 084f6df51..000000000 --- a/lib/silex/vendor/psr/container/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# PSR Container - -This repository holds all interfaces/classes/traits related to [PSR-11](https://github.com/container-interop/fig-standards/blob/master/proposed/container.md). - -Note that this is not a container implementation of its own. See the specification for more details. diff --git a/lib/silex/vendor/psr/container/composer.json b/lib/silex/vendor/psr/container/composer.json deleted file mode 100644 index b8ee01265..000000000 --- a/lib/silex/vendor/psr/container/composer.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "psr/container", - "type": "library", - "description": "Common Container Interface (PHP FIG PSR-11)", - "keywords": ["psr", "psr-11", "container", "container-interop", "container-interface"], - "homepage": "https://github.com/php-fig/container", - "license": "MIT", - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "require": { - "php": ">=5.3.0" - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - } -} diff --git a/lib/silex/vendor/psr/container/src/ContainerExceptionInterface.php b/lib/silex/vendor/psr/container/src/ContainerExceptionInterface.php deleted file mode 100644 index d35c6b4d8..000000000 --- a/lib/silex/vendor/psr/container/src/ContainerExceptionInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } -} diff --git a/lib/silex/vendor/psr/log/Psr/Log/InvalidArgumentException.php b/lib/silex/vendor/psr/log/Psr/Log/InvalidArgumentException.php deleted file mode 100644 index 67f852d1d..000000000 --- a/lib/silex/vendor/psr/log/Psr/Log/InvalidArgumentException.php +++ /dev/null @@ -1,7 +0,0 @@ -logger = $logger; - } -} diff --git a/lib/silex/vendor/psr/log/Psr/Log/LoggerInterface.php b/lib/silex/vendor/psr/log/Psr/Log/LoggerInterface.php deleted file mode 100644 index 5ea72438b..000000000 --- a/lib/silex/vendor/psr/log/Psr/Log/LoggerInterface.php +++ /dev/null @@ -1,123 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } - - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - * - * @return void - */ - abstract public function log($level, $message, array $context = array()); -} diff --git a/lib/silex/vendor/psr/log/Psr/Log/NullLogger.php b/lib/silex/vendor/psr/log/Psr/Log/NullLogger.php deleted file mode 100644 index d8cd682c8..000000000 --- a/lib/silex/vendor/psr/log/Psr/Log/NullLogger.php +++ /dev/null @@ -1,28 +0,0 @@ -logger) { }` - * blocks. - */ -class NullLogger extends AbstractLogger -{ - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - * - * @return void - */ - public function log($level, $message, array $context = array()) - { - // noop - } -} diff --git a/lib/silex/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php b/lib/silex/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php deleted file mode 100644 index a0391a52b..000000000 --- a/lib/silex/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php +++ /dev/null @@ -1,140 +0,0 @@ - ". - * - * Example ->error('Foo') would yield "error Foo". - * - * @return string[] - */ - abstract public function getLogs(); - - public function testImplements() - { - $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); - } - - /** - * @dataProvider provideLevelsAndMessages - */ - public function testLogsAtAllLevels($level, $message) - { - $logger = $this->getLogger(); - $logger->{$level}($message, array('user' => 'Bob')); - $logger->log($level, $message, array('user' => 'Bob')); - - $expected = array( - $level.' message of level '.$level.' with context: Bob', - $level.' message of level '.$level.' with context: Bob', - ); - $this->assertEquals($expected, $this->getLogs()); - } - - public function provideLevelsAndMessages() - { - return array( - LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), - LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), - LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), - LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), - LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), - LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), - LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), - LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), - ); - } - - /** - * @expectedException \Psr\Log\InvalidArgumentException - */ - public function testThrowsOnInvalidLevel() - { - $logger = $this->getLogger(); - $logger->log('invalid level', 'Foo'); - } - - public function testContextReplacement() - { - $logger = $this->getLogger(); - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); - - $expected = array('info {Message {nothing} Bob Bar a}'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testObjectCastToString() - { - if (method_exists($this, 'createPartialMock')) { - $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString')); - } else { - $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString')); - } - $dummy->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('DUMMY')); - - $this->getLogger()->warning($dummy); - - $expected = array('warning DUMMY'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextCanContainAnything() - { - $context = array( - 'bool' => true, - 'null' => null, - 'string' => 'Foo', - 'int' => 0, - 'float' => 0.5, - 'nested' => array('with object' => new DummyTest), - 'object' => new \DateTime, - 'resource' => fopen('php://memory', 'r'), - ); - - $this->getLogger()->warning('Crazy context data', $context); - - $expected = array('warning Crazy context data'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextExceptionKeyCanBeExceptionOrOtherValues() - { - $logger = $this->getLogger(); - $logger->warning('Random message', array('exception' => 'oops')); - $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); - - $expected = array( - 'warning Random message', - 'critical Uncaught Exception!' - ); - $this->assertEquals($expected, $this->getLogs()); - } -} - -class DummyTest -{ - public function __toString() - { - } -} diff --git a/lib/silex/vendor/psr/log/README.md b/lib/silex/vendor/psr/log/README.md deleted file mode 100644 index 574bc1cb2..000000000 --- a/lib/silex/vendor/psr/log/README.md +++ /dev/null @@ -1,45 +0,0 @@ -PSR Log -======= - -This repository holds all interfaces/classes/traits related to -[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md). - -Note that this is not a logger of its own. It is merely an interface that -describes a logger. See the specification for more details. - -Usage ------ - -If you need a logger, you can use the interface like this: - -```php -logger = $logger; - } - - public function doSomething() - { - if ($this->logger) { - $this->logger->info('Doing work'); - } - - // do something useful - } -} -``` - -You can then pick one of the implementations of the interface to get a logger. - -If you want to implement the interface, you can require this package and -implement `Psr\Log\LoggerInterface` in your code. Please read the -[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) -for details. diff --git a/lib/silex/vendor/psr/log/composer.json b/lib/silex/vendor/psr/log/composer.json deleted file mode 100644 index 87934d707..000000000 --- a/lib/silex/vendor/psr/log/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "psr/log", - "description": "Common interface for logging libraries", - "keywords": ["psr", "psr-3", "log"], - "homepage": "https://github.com/php-fig/log", - "license": "MIT", - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "require": { - "php": ">=5.3.0" - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - } -} diff --git a/lib/silex/vendor/silex/silex/.gitignore b/lib/silex/vendor/silex/silex/.gitignore deleted file mode 100644 index 3d4ff050e..000000000 --- a/lib/silex/vendor/silex/silex/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/phpunit.xml -/vendor -/build -/composer.lock - diff --git a/lib/silex/vendor/silex/silex/.travis.yml b/lib/silex/vendor/silex/silex/.travis.yml deleted file mode 100644 index f54aba1b7..000000000 --- a/lib/silex/vendor/silex/silex/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: php - -sudo: false - -env: - global: - - SYMFONY_DEPRECATIONS_HELPER=weak - -cache: - directories: - - $HOME/.composer/cache/files - - .phpunit - -before_install: - - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi - -before_script: - # Twig 1.x - - if [[ $TWIG_VERSION != 2.0 ]]; then sed -i 's/~1.8|~2.0/~1.8/g' composer.json; fi - - # Symfony 2.8 - - if [[ $SYMFONY_DEPS_VERSION = 2.8 ]]; then sed -i 's/~2\.8|^3\.0/2.8.*@dev/g' composer.json; fi - # Symfony 3.0 - - if [[ $SYMFONY_DEPS_VERSION = 3.0 ]]; then sed -i 's/~2\.8|^3\.0/3.0.*@dev/g' composer.json; fi - # Symfony 3.1 - - if [[ $SYMFONY_DEPS_VERSION = 3.1 ]]; then sed -i 's/~2\.8|^3\.0/3.1.*@dev/g' composer.json; fi - # Symfony 3.2 - - if [[ $SYMFONY_DEPS_VERSION = 3.2 ]]; then sed -i 's/~2\.8|^3\.0/3.2.*@dev/g' composer.json; fi - # Symfony 3.3 - - | - if [[ $SYMFONY_DEPS_VERSION = 3.3 ]]; then - sed -i 's/~2\.8|^3\.0/3.3.*@dev/g' composer.json; - composer require --dev --no-update symfony/web-link:3.3.* - fi - - - composer update --no-suggest - -script: ./vendor/bin/simple-phpunit - -matrix: - include: - - php: 5.5 - - php: 5.6 - env: TWIG_VERSION=2.0 - - php: 5.6 - env: SYMFONY_DEPS_VERSION=2.8 - - php: 5.6 - env: SYMFONY_DEPS_VERSION=3.0 - - php: 5.6 - env: SYMFONY_DEPS_VERSION=3.1 - - php: 5.6 - env: SYMFONY_DEPS_VERSION=3.2 - - php: 5.6 - env: SYMFONY_DEPS_VERSION=3.3 - - php: 5.6 - - php: 7.0 - - php: 7.1 - - php: 7.2 - - php: hhvm - dist: trusty diff --git a/lib/silex/vendor/silex/silex/LICENSE b/lib/silex/vendor/silex/silex/LICENSE deleted file mode 100644 index b420d7195..000000000 --- a/lib/silex/vendor/silex/silex/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2017 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/silex/silex/README.rst b/lib/silex/vendor/silex/silex/README.rst deleted file mode 100644 index b79e47b6d..000000000 --- a/lib/silex/vendor/silex/silex/README.rst +++ /dev/null @@ -1,64 +0,0 @@ -Silex, a simple Web Framework -============================= - -Silex is a PHP micro-framework to develop websites based on `Symfony -components`_: - -.. code-block:: php - - get('/hello/{name}', function ($name) use ($app) { - return 'Hello '.$app->escape($name); - }); - - $app->run(); - -Silex works with PHP 5.5.9 or later. - -Installation ------------- - -The recommended way to install Silex is through `Composer`_: - -.. code-block:: bash - - composer require silex/silex "~2.0" - -Alternatively, you can download the `silex.zip`_ file and extract it. - -More Information ----------------- - -Read the `documentation`_ for more information and `changelog -`_ for upgrading information. - -Tests ------ - -To run the test suite, you need `Composer`_ and `PHPUnit`_: - -.. code-block:: bash - - composer install - phpunit - -Community ---------- - -Check out #silex-php on irc.freenode.net. - -License -------- - -Silex is licensed under the MIT license. - -.. _Symfony components: http://symfony.com -.. _Composer: http://getcomposer.org -.. _PHPUnit: https://phpunit.de -.. _silex.zip: http://silex.sensiolabs.org/download -.. _documentation: http://silex.sensiolabs.org/documentation diff --git a/lib/silex/vendor/silex/silex/bin/build b/lib/silex/vendor/silex/silex/bin/build deleted file mode 100644 index e72700373..000000000 --- a/lib/silex/vendor/silex/silex/bin/build +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -PHP=`which php` -GIT=`which git` -DIR=`$PHP -r "echo dirname(dirname(realpath('$0')));"` - -if [ ! -d "$DIR/build" ]; then - mkdir -p $DIR/build -fi - -cd $DIR/build - -if [ ! -f "composer.phar" ]; then - curl -s http://getcomposer.org/installer 2>/dev/null | $PHP >/dev/null 2>/dev/null -else - $PHP composer.phar self-update >/dev/null 2>/dev/null -fi - -for TYPE in slim fat -do - if [ -d "$DIR/build/skeleton" ]; then - rm -rf $DIR/build/skeleton - fi - mkdir -p $DIR/build/skeleton - - cd "$DIR/build/skeleton" - - mkdir -p web/ - COMPOSER=$TYPE"_composer.json" - cp $DIR/bin/skeleton/$COMPOSER composer.json - cp $DIR/bin/skeleton/index.php web/index.php - - $PHP ../composer.phar install -q - - if [ -d "$DIR/build/tmp/silex" ]; then - rm -rf $DIR/build/tmp/silex - fi - mkdir -p $DIR/build/tmp/silex - - cd "$DIR/build/tmp/silex" - cp -r ../../skeleton/* . - - find . -name .DS_Store | xargs rm -rf - - find . -name .git | xargs rm -rf - - find . -name phpunit.xml.* | xargs rm -rf - - find . -type d -name Tests | xargs rm -rf - - find . -type d -name test* | xargs rm -rf - - find . -type d -name doc | xargs rm -rf - - find . -type d -name ext | xargs rm -rf - - - export COPY_EXTENDED_ATTRIBUTES_DISABLE=true - export COPYFILE_DISABLE=true - - cd "$DIR/build/tmp" - - if [ "slim" = "$TYPE" ]; then - NAME="silex" - else - NAME="silex_fat" - fi - - rm -f "$DIR/build/$NAME.*" - tar zcpf "$DIR/build/$NAME.tgz" silex - zip -rq "$DIR/build/$NAME.zip" silex - rm -rf "$DIR/build/tmp" - rm -rf "$DIR/build/skeleton" -done diff --git a/lib/silex/vendor/silex/silex/bin/compile b/lib/silex/vendor/silex/silex/bin/compile deleted file mode 100644 index f0986edc9..000000000 --- a/lib/silex/vendor/silex/silex/bin/compile +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env php -compile(); diff --git a/lib/silex/vendor/silex/silex/bin/skeleton/fat_composer.json b/lib/silex/vendor/silex/silex/bin/skeleton/fat_composer.json deleted file mode 100644 index 4495d4f2c..000000000 --- a/lib/silex/vendor/silex/silex/bin/skeleton/fat_composer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "require": { - "silex/silex": "~1.1", - "symfony/browser-kit": "~2.3", - "symfony/console": "~2.3", - "symfony/config": "~2.3", - "symfony/css-selector": "~2.3", - "symfony/dom-crawler": "~2.3", - "symfony/filesystem": "~2.3", - "symfony/finder": "~2.3", - "symfony/form": "~2.3", - "symfony/locale": "~2.3", - "symfony/process": "~2.3", - "symfony/security": "~2.3", - "symfony/serializer": "~2.3", - "symfony/translation": "~2.3", - "symfony/validator": "~2.3", - "symfony/monolog-bridge": "~2.3", - "symfony/twig-bridge": "~2.3", - "doctrine/dbal": ">=2.2.0,<2.4.0-dev", - "swiftmailer/swiftmailer": "5.*" - } -} diff --git a/lib/silex/vendor/silex/silex/bin/skeleton/index.php b/lib/silex/vendor/silex/silex/bin/skeleton/index.php deleted file mode 100644 index 683c610e1..000000000 --- a/lib/silex/vendor/silex/silex/bin/skeleton/index.php +++ /dev/null @@ -1,11 +0,0 @@ -get('/hello', function () { - return 'Hello!'; -}); - -$app->run(); diff --git a/lib/silex/vendor/silex/silex/bin/skeleton/slim_composer.json b/lib/silex/vendor/silex/silex/bin/skeleton/slim_composer.json deleted file mode 100644 index df5ed0000..000000000 --- a/lib/silex/vendor/silex/silex/bin/skeleton/slim_composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "silex/silex": "~1.1" - } -} diff --git a/lib/silex/vendor/silex/silex/composer.json b/lib/silex/vendor/silex/silex/composer.json deleted file mode 100644 index 935c51812..000000000 --- a/lib/silex/vendor/silex/silex/composer.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "silex/silex", - "description": "The PHP micro-framework based on the Symfony Components", - "keywords": ["microframework"], - "homepage": "http://silex.sensiolabs.org", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "require": { - "php": ">=5.5.9", - "pimple/pimple": "~3.0", - "symfony/event-dispatcher": "~2.8|^3.0", - "symfony/http-foundation": "~2.8|^3.0", - "symfony/http-kernel": "~2.8|^3.0", - "symfony/routing": "~2.8|^3.0" - }, - "require-dev": { - "symfony/asset": "~2.8|^3.0", - "symfony/expression-language": "~2.8|^3.0", - "symfony/security": "~2.8|^3.0", - "symfony/config": "~2.8|^3.0", - "symfony/form": "~2.8|^3.0", - "symfony/browser-kit": "~2.8|^3.0", - "symfony/css-selector": "~2.8|^3.0", - "symfony/debug": "~2.8|^3.0", - "symfony/dom-crawler": "~2.8|^3.0", - "symfony/finder": "~2.8|^3.0", - "symfony/intl": "~2.8|^3.0", - "symfony/monolog-bridge": "~2.8|^3.0", - "symfony/doctrine-bridge": "~2.8|^3.0", - "symfony/options-resolver": "~2.8|^3.0", - "symfony/phpunit-bridge": "^3.2", - "symfony/process": "~2.8|^3.0", - "symfony/serializer": "~2.8|^3.0", - "symfony/translation": "~2.8|^3.0", - "symfony/twig-bridge": "~2.8|^3.0", - "symfony/validator": "~2.8|^3.0", - "symfony/var-dumper": "~2.8|^3.0", - "twig/twig": "~1.28|~2.0", - "doctrine/dbal": "~2.2", - "swiftmailer/swiftmailer": "~5", - "monolog/monolog": "^1.4.1", - "symfony/web-link": "^3.3" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35 || >= 5.0, <5.4.3" - }, - "replace": { - "silex/api": "self.version", - "silex/providers": "self.version" - }, - "autoload": { - "psr-4": { "Silex\\": "src/Silex" } - }, - "autoload-dev" : { - "psr-4": { "Silex\\Tests\\" : "tests/Silex/Tests" } - }, - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "minimum-stability": "dev" -} diff --git a/lib/silex/vendor/silex/silex/doc/changelog.rst b/lib/silex/vendor/silex/silex/doc/changelog.rst deleted file mode 100644 index 01a2cb86d..000000000 --- a/lib/silex/vendor/silex/silex/doc/changelog.rst +++ /dev/null @@ -1,398 +0,0 @@ -Changelog -========= - -2.2.2 (2018-01-12) ------------------- - -* [SECURITY] fixed before handlers not executed under mounts - -2.2.1 (2017-12-14) ------------------- - -* added support for Swiftmailer SSL stream_context_options option -* fixed usage of namespaces for Twig paths - -2.2.0 (2017-07-23) ------------------- - -* added json manifest version strategy support -* fixed EsiFragment constructor -* fixed RedirectableUrlMatcher compatibility with Symfony -* fixed compatibility with Pimple 3.2 -* fixed WebTestCase compatibility with PHPUnit 6+ - -2.1.0 (2017-05-03) ------------------- - -* added more options to security.firewalls -* added WebLink component integration -* added parameters to configure the Twig core extension behavior -* fixed deprecation notices with symfony/twig-bridge 3.2+ in TwigServiceProvider -* added FormRegistry as a service to enable the extension point -* removed the build scripts -* fixed some deprecation warnings -* added support for registering Swiftmailer plugins - -2.0.4 (2016-11-06) ------------------- - -* fixed twig.app_variable definition -* added support for latest versions of Twig 1.x and 2.0 (Twig runtime loaders) -* added support for Symfony 2.3 - -2.0.3 (2016-08-22) ------------------- - -* fixed lazy evaluation of 'monolog.use_error_handler' -* fixed PHP7 type hint on controllers - -2.0.2 (2016-06-14) ------------------- - -* fixed Symfony 3.1 deprecations - -2.0.1 (2016-05-27) ------------------- - -* fixed the silex form extension registration to allow overriding default ones -* removed support for the obsolete Locale Symfony component (uses the Intl one now) -* added support for Symfony 3.1 - -2.0.0 (2016-05-18) ------------------- - -* decoupled the exception handler from HttpKernelServiceProvider -* Switched to BCrypt as the default encoder in the security provider -* added full support for RequestMatcher -* added support for Symfony Guard -* added support for callables in CallbackResolver -* added FormTrait::namedForm() -* added support for delivery_addresses, delivery_whitelist, and sender_address -* added support to register form types / form types extensions / form types guessers as services -* added support for callable in mounts (allow nested route collection to be built easily) -* added support for conditions on routes -* added support for the Symfony VarDumper Component -* added a global Twig variable (an AppVariable instance) -* [BC BREAK] CSRF has been moved to a standalone provider (``form.secret`` is not available anymore) -* added support for the Symfony HttpFoundation Twig bridge extension -* added support for the Symfony Asset Component -* bumped minimum version of Symfony to 2.8 -* bumped minimum version of PHP to 5.5.0 -* Updated Pimple to 3.0 -* Updated session listeners to extends HttpKernel ones -* [BC BREAK] Locale management has been moved to LocaleServiceProvider which must be registered - if you want Silex to manage your locale (must also be registered for the translation service provider) -* [BC BREAK] Provider interfaces moved to Silex\Api namespace, published as - separate package via subtree split -* [BC BREAK] ServiceProviderInterface split in to EventListenerProviderInterface - and BootableProviderInterface -* [BC BREAK] Service Provider support files moved under Silex\Provider - namespace, allowing publishing as separate package via sub-tree split -* ``monolog.exception.logger_filter`` option added to Monolog service provider -* [BC BREAK] ``$app['request']`` service removed, use ``$app['request_stack']`` instead - -1.3.6 (2016-XX-XX) ------------------- - -* n/a - -1.3.5 (2016-01-06) ------------------- - -* fixed typo in SecurityServiceProvider - -1.3.4 (2015-09-15) ------------------- - -* fixed some new deprecations -* fixed translation registration for the validators - -1.3.3 (2015-09-08) ------------------- - -* added support for Symfony 3.0 and Twig 2.0 -* fixed some Form deprecations -* removed deprecated method call in the exception handler -* fixed Swiftmailer spool flushing when spool is not enabled - -1.3.2 (2015-08-24) ------------------- - -* no changes - -1.3.1 (2015-08-04) ------------------- - -* added missing support for the Expression constraint -* fixed the possibility to override translations for validator error messages -* fixed sub-mounts with same name clash -* fixed session logout handler when a firewall is stateless - -1.3.0 (2015-06-05) ------------------- - -* added a `$app['user']` to get the current user (security provider) -* added view handlers -* added support for the OPTIONS HTTP method -* added caching for the Translator provider -* deprecated `$app['exception_handler']->disable()` in favor of `unset($app['exception_handler'])` -* made Silex compatible with Symfony 2.7 an 2.8 (and keep compatibility with Symfony 2.3, 2.5, and 2.6) -* removed deprecated TwigCoreExtension class (register the new HttpFragmentServiceProvider instead) -* bumped minimum version of PHP to 5.3.9 - -1.2.5 (2015-06-04) ------------------- - -* no code changes (last version of the 1.2 branch) - -1.2.4 (2015-04-11) ------------------- - -* fixed the exception message when mounting a collection that doesn't return a ControllerCollection -* fixed Symfony dependencies (Silex 1.2 is not compatible with Symfony 2.7) - -1.2.3 (2015-01-20) ------------------- - -* fixed remember me listener -* fixed translation files loading when they do not exist -* allowed global after middlewares to return responses like route specific ones - -1.2.2 (2014-09-26) ------------------- - -* fixed Translator locale management -* added support for the $app argument in application middlewares (to make it consistent with route middlewares) -* added form.types to the Form provider - -1.2.1 (2014-07-01) ------------------- - -* added support permissions in the Monolog provider -* fixed Switfmailer spool where the event dispatcher is different from the other ones -* fixed locale when changing it on the translator itself - -1.2.0 (2014-03-29) ------------------- - -* Allowed disabling the boot logic of MonologServiceProvider -* Reverted "convert attributes on the request that actually exist" -* [BC BREAK] Routes are now always added in the order of their registration (even for mounted routes) -* Added run() on Route to be able to define the controller code -* Deprecated TwigCoreExtension (register the new HttpFragmentServiceProvider instead) -* Added HttpFragmentServiceProvider -* Allowed a callback to be a method call on a service (before, after, finish, error, on Application; convert, before, after on Controller) - -1.1.3 (2013-XX-XX) ------------------- - -* Fixed translator locale management - -1.1.2 (2013-10-30) ------------------- - -* Added missing "security.hide_user_not_found" support in SecurityServiceProvider -* Fixed event listeners that are registered after the boot via the on() method - -1.0.2 (2013-10-30) ------------------- - -* Fixed SecurityServiceProvider to use null as a fake controller so that routes can be dumped - -1.1.1 (2013-10-11) ------------------- - -* Removed or replaced deprecated Symfony code -* Updated code to take advantages of 2.3 new features -* Only convert attributes on the request that actually exist. - -1.1.0 (2013-07-04) ------------------- - -* Support for any ``Psr\Log\LoggerInterface`` as opposed to the monolog-bridge - one. -* Made dispatcher proxy methods ``on``, ``before``, ``after`` and ``error`` - lazy, so that they will not instantiate the dispatcher early. -* Dropped support for 2.1 and 2.2 versions of Symfony. - -1.0.1 (2013-07-04) ------------------- - -* Fixed RedirectableUrlMatcher::redirect() when Silex is configured to use a logger -* Make ``DoctrineServiceProvider`` multi-db support lazy. - -1.0.0 (2013-05-03) ------------------- - -* **2013-04-12**: Added support for validators as services. - -* **2013-04-01**: Added support for host matching with symfony 2.2:: - - $app->match('/', function() { - // app-specific action - })->host('example.com'); - - $app->match('/', function ($user) { - // user-specific action - })->host('{user}.example.com'); - -* **2013-03-08**: Added support for form type extensions and guessers as - services. - -* **2013-03-08**: Added support for remember-me via the - ``RememberMeServiceProvider``. - -* **2013-02-07**: Added ``Application::sendFile()`` to ease sending - ``BinaryFileResponse``. - -* **2012-11-05**: Filters have been renamed to application middlewares in the - documentation. - -* **2012-11-05**: The ``before()``, ``after()``, ``error()``, and ``finish()`` - listener priorities now set the priority of the underlying Symfony event - instead of a custom one before. - -* **2012-11-05**: Removing the default exception handler should now be done - via its ``disable()`` method: - - Before: - - unset($app['exception_handler']); - - After: - - $app['exception_handler']->disable(); - -* **2012-07-15**: removed the ``monolog.configure`` service. Use the - ``extend`` method instead: - - Before:: - - $app['monolog.configure'] = $app->protect(function ($monolog) use ($app) { - // do something - }); - - After:: - - $app['monolog'] = $app->share($app->extend('monolog', function($monolog, $app) { - // do something - - return $monolog; - })); - - -* **2012-06-17**: ``ControllerCollection`` now takes a required route instance - as a constructor argument. - - Before:: - - $controllers = new ControllerCollection(); - - After:: - - $controllers = new ControllerCollection(new Route()); - - // or even better - $controllers = $app['controllers_factory']; - -* **2012-06-17**: added application traits for PHP 5.4 - -* **2012-06-16**: renamed ``request.default_locale`` to ``locale`` - -* **2012-06-16**: Removed the ``translator.loader`` service. See documentation - for how to use XLIFF or YAML-based translation files. - -* **2012-06-15**: removed the ``twig.configure`` service. Use the ``extend`` - method instead: - - Before:: - - $app['twig.configure'] = $app->protect(function ($twig) use ($app) { - // do something - }); - - After:: - - $app['twig'] = $app->share($app->extend('twig', function($twig, $app) { - // do something - - return $twig; - })); - -* **2012-06-13**: Added a route ``before`` middleware - -* **2012-06-13**: Renamed the route ``middleware`` to ``before`` - -* **2012-06-13**: Added an extension for the Symfony Security component - -* **2012-05-31**: Made the ``BrowserKit``, ``CssSelector``, ``DomCrawler``, - ``Finder`` and ``Process`` components optional dependencies. Projects that - depend on them (e.g. through functional tests) should add those dependencies - to their ``composer.json``. - -* **2012-05-26**: added ``boot()`` to ``ServiceProviderInterface``. - -* **2012-05-26**: Removed ``SymfonyBridgesServiceProvider``. It is now implicit - by checking the existence of the bridge. - -* **2012-05-26**: Removed the ``translator.messages`` parameter (use - ``translator.domains`` instead). - -* **2012-05-24**: Removed the ``autoloader`` service (use composer instead). - The ``*.class_path`` settings on all the built-in providers have also been - removed in favor of Composer. - -* **2012-05-21**: Changed error() to allow handling specific exceptions. - -* **2012-05-20**: Added a way to define settings on a controller collection. - -* **2012-05-20**: The Request instance is not available anymore from the - Application after it has been handled. - -* **2012-04-01**: Added ``finish`` filters. - -* **2012-03-20**: Added ``json`` helper:: - - $data = array('some' => 'data'); - $response = $app->json($data); - -* **2012-03-11**: Added route middlewares. - -* **2012-03-02**: Switched to use Composer for dependency management. - -* **2012-02-27**: Updated to Symfony 2.1 session handling. - -* **2012-01-02**: Introduced support for streaming responses. - -* **2011-09-22**: ``ExtensionInterface`` has been renamed to - ``ServiceProviderInterface``. All built-in extensions have been renamed - accordingly (for instance, ``Silex\Extension\TwigExtension`` has been - renamed to ``Silex\Provider\TwigServiceProvider``). - -* **2011-09-22**: The way reusable applications work has changed. The - ``mount()`` method now takes an instance of ``ControllerCollection`` instead - of an ``Application`` one. - - Before:: - - $app = new Application(); - $app->get('/bar', function() { return 'foo'; }); - - return $app; - - After:: - - $app = new ControllerCollection(); - $app->get('/bar', function() { return 'foo'; }); - - return $app; - -* **2011-08-08**: The controller method configuration is now done on the Controller itself - - Before:: - - $app->match('/', function () { echo 'foo'; }, 'GET|POST'); - - After:: - - $app->match('/', function () { echo 'foo'; })->method('GET|POST'); diff --git a/lib/silex/vendor/silex/silex/doc/conf.py b/lib/silex/vendor/silex/silex/doc/conf.py deleted file mode 100644 index dfe355c77..000000000 --- a/lib/silex/vendor/silex/silex/doc/conf.py +++ /dev/null @@ -1,17 +0,0 @@ -import sys, os -from sphinx.highlighting import lexers -from pygments.lexers.web import PhpLexer - -sys.path.append(os.path.abspath('_exts')) - -extensions = [] -master_doc = 'index' -highlight_language = 'php' - -project = u'Silex' -copyright = u'2010 Fabien Potencier' - -version = '0' -release = '0.0.0' - -lexers['php'] = PhpLexer(startinline=True) diff --git a/lib/silex/vendor/silex/silex/doc/contributing.rst b/lib/silex/vendor/silex/silex/doc/contributing.rst deleted file mode 100644 index 34a339d86..000000000 --- a/lib/silex/vendor/silex/silex/doc/contributing.rst +++ /dev/null @@ -1,34 +0,0 @@ -Contributing -============ - -We are open to contributions to the Silex code. If you find a bug or want to -contribute a provider, just follow these steps: - -* Fork `the Silex repository `_; - -* Make your feature addition or bug fix; - -* Add tests for it; - -* Optionally, add some documentation; - -* `Send a pull request - `_, to the correct - target branch (1.3 for bug fixes, master for new features). - -.. note:: - - Any code you contribute must be licensed under the MIT - License. - -Writing Documentation -===================== - -The documentation is written in `reStructuredText -`_ and can be generated using `sphinx -`_. - -.. code-block:: bash - - $ cd doc - $ sphinx-build -b html . build diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/assets.rst b/lib/silex/vendor/silex/silex/doc/cookbook/assets.rst deleted file mode 100644 index 41c75793c..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/assets.rst +++ /dev/null @@ -1,66 +0,0 @@ -Managing Assets in Templates -============================ - -A Silex application is not always hosted at the web root directory. To avoid -repeating the base path whenever you link to another page, it is highly -recommended to use the :doc:`URL generator service provider -`. - -But what about images, stylesheets, or JavaScript files? Their URLs are not -managed by the Silex router, but nonetheless, they need to get prefixed by the -base path. Fortunately, the Request object contain the application base path -that needs to be prepended:: - - // generate a link to the stylesheets in /css/styles.css - $request->getBasePath().'/css/styles.css'; - -And doing the same in a Twig template is as easy as it can get: - -.. code-block:: jinja - - {{ app.request.basepath }}/css/styles.css - -If your assets are hosted under a different host, you might want to abstract -the path by defining a Silex parameter:: - - $app['asset_path'] = 'http://assets.examples.com'; - -Using it in a template is as easy as before: - -.. code-block:: jinja - - {{ app.asset_path }}/css/styles.css - -If you need to implement some logic independently of the asset, define a -service instead:: - - $app['asset_path'] = $app->share(function () { - // implement whatever logic you need to determine the asset path - - return 'http://assets.examples.com'; - }); - -Usage is exactly the same as before: - -.. code-block:: jinja - - {{ app.asset_path }}/css/styles.css - -If the asset location depends on the asset type or path, you will need more -abstraction; here is one way to do that with a Twig function:: - - $app['twig'] = $app->share($app->extend('twig', function($twig, $app) { - $twig->addFunction(new \Twig_SimpleFunction('asset', function ($asset) { - // implement whatever logic you need to determine the asset path - - return sprintf('http://assets.examples.com/%s', ltrim($asset, '/')); - })); - - return $twig; - })); - -The ``asset`` function can then be used in your templates: - -.. code-block:: jinja - - {{ asset('/css/styles.css') }} diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/error_handler.rst b/lib/silex/vendor/silex/silex/doc/cookbook/error_handler.rst deleted file mode 100644 index 235c263a7..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/error_handler.rst +++ /dev/null @@ -1,38 +0,0 @@ -Converting Errors to Exceptions -=============================== - -Silex catches exceptions that are thrown from within a request/response cycle. -However, it does *not* catch PHP errors and notices. This recipe tells you how -to catch them by converting them to exceptions. - -Registering the ErrorHandler ----------------------------- - -The ``Symfony/Debug`` package has an ``ErrorHandler`` class that solves this -problem. It converts all errors to exceptions, and exceptions are then caught -by Silex. - -Register it by calling the static ``register`` method:: - - use Symfony\Component\Debug\ErrorHandler; - - ErrorHandler::register(); - -It is recommended that you do this as early as possible. - -Handling fatal errors ---------------------- - -To handle fatal errors, you can additionally register a global -``ExceptionHandler``:: - - use Symfony\Component\Debug\ExceptionHandler; - - ExceptionHandler::register(); - -In production you may want to disable the debug output by passing ``false`` as -the ``$debug`` argument:: - - use Symfony\Component\Debug\ExceptionHandler; - - ExceptionHandler::register(false); diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/form_no_csrf.rst b/lib/silex/vendor/silex/silex/doc/cookbook/form_no_csrf.rst deleted file mode 100644 index e9bf595e4..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/form_no_csrf.rst +++ /dev/null @@ -1,36 +0,0 @@ -Disabling CSRF Protection on a Form using the FormExtension -=========================================================== - -The *FormExtension* provides a service for building form in your application -with the Symfony Form component. When the :doc:`CSRF Service Provider -` is registered, the *FormExtension* uses the CSRF Protection -avoiding Cross-site request forgery, a method by which a malicious user -attempts to make your legitimate users unknowingly submit data that they don't -intend to submit. - -You can find more details about CSRF Protection and CSRF token in the -`Symfony Book -`_. - -In some cases (for example, when embedding a form in an html email) you might -want not to use this protection. The easiest way to avoid this is to -understand that it is possible to give specific options to your form builder -through the ``createBuilder()`` function. - -Example -------- - -.. code-block:: php - - $form = $app['form.factory']->createBuilder('form', null, array('csrf_protection' => false)); - -That's it, your form could be submitted from everywhere without CSRF Protection. - -Going further -------------- - -This specific example showed how to change the ``csrf_protection`` in the -``$options`` parameter of the ``createBuilder()`` function. More of them could -be passed through this parameter, it is as simple as using the Symfony -``getDefaultOptions()`` method in your form classes. `See more here -`_. diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/guard_authentication.rst b/lib/silex/vendor/silex/silex/doc/cookbook/guard_authentication.rst deleted file mode 100644 index 8774f6863..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/guard_authentication.rst +++ /dev/null @@ -1,183 +0,0 @@ -How to Create a Custom Authentication System with Guard -======================================================= - -Whether you need to build a traditional login form, an API token -authentication system or you need to integrate with some proprietary -single-sign-on system, the Guard component can make it easy... and fun! - -In this example, you'll build an API token authentication system and -learn how to work with Guard. - -Step 1) Create the Authenticator Class --------------------------------------- - -Suppose you have an API where your clients will send an X-AUTH-TOKEN -header on each request. This token is composed of the username followed -by a password, separated by a colon (e.g. ``X-AUTH-TOKEN: coolguy:awesomepassword``). -Your job is to read this, find the associated user (if any) and check -the password. - -To create a custom authentication system, just create a class and make -it implement GuardAuthenticatorInterface. Or, extend the simpler -AbstractGuardAuthenticator. This requires you to implement six methods: - -.. code-block:: php - - encoderFactory = $encoderFactory; - } - - public function getCredentials(Request $request) - { - // Checks if the credential header is provided - if (!$token = $request->headers->get('X-AUTH-TOKEN')) { - return; - } - - // Parse the header or ignore it if the format is incorrect. - if (false === strpos($token, ':')) { - return; - } - list($username, $secret) = explode(':', $token, 2); - - return array( - 'username' => $username, - 'secret' => $secret, - ); - } - - public function getUser($credentials, UserProviderInterface $userProvider) - { - return $userProvider->loadUserByUsername($credentials['username']); - } - - public function checkCredentials($credentials, UserInterface $user) - { - // check credentials - e.g. make sure the password is valid - // return true to cause authentication success - - $encoder = $this->encoderFactory->getEncoder($user); - - return $encoder->isPasswordValid( - $user->getPassword(), - $credentials['secret'], - $user->getSalt() - ); - } - - public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) - { - // on success, let the request continue - return; - } - - public function onAuthenticationFailure(Request $request, AuthenticationException $exception) - { - $data = array( - 'message' => strtr($exception->getMessageKey(), $exception->getMessageData()), - - // or to translate this message - // $this->translator->trans($exception->getMessageKey(), $exception->getMessageData()) - ); - - return new JsonResponse($data, 403); - } - - /** - * Called when authentication is needed, but it's not sent - */ - public function start(Request $request, AuthenticationException $authException = null) - { - $data = array( - // you might translate this message - 'message' => 'Authentication Required', - ); - - return new JsonResponse($data, 401); - } - - public function supportsRememberMe() - { - return false; - } - } - - -Step 2) Configure the Authenticator ------------------------------------ - -To finish this, register the class as a service: - -.. code-block:: php - - $app['app.token_authenticator'] = function ($app) { - return new App\Security\TokenAuthenticator($app['security.encoder_factory']); - }; - - -Finally, configure your `security.firewalls` key to use this authenticator: - -.. code-block:: php - - $app['security.firewalls'] = array( - 'main' => array( - 'guard' => array( - 'authenticators' => array( - 'app.token_authenticator' - ), - - // Using more than 1 authenticator, you must specify - // which one is used as entry point. - // 'entry_point' => 'app.token_authenticator', - ), - // configure where your users come from. Hardcode them, or load them from somewhere - // http://silex.sensiolabs.org/doc/providers/security.html#defining-a-custom-user-provider - 'users' => array( - //raw password = foo - 'victoria' => array('ROLE_USER', '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a'), - ), - // 'anonymous' => true - ), - ); - -.. note:: - You can use many authenticators, they are executed by the order - they are configured. - -You did it! You now have a fully-working API token authentication -system. If your homepage required ROLE_USER, then you could test it -under different conditions: - -.. code-block:: bash - - # test with no token - curl http://localhost:8000/ - # {"message":"Authentication Required"} - - # test with a bad token - curl -H "X-AUTH-TOKEN: alan" http://localhost:8000/ - # {"message":"Username could not be found."} - - # test with a working token - curl -H "X-AUTH-TOKEN: victoria:foo" http://localhost:8000/ - # the homepage controller is executed: the page loads normally - -For more details read the Symfony cookbook entry on -`How to Create a Custom Authentication System with Guard `_. diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/index.rst b/lib/silex/vendor/silex/silex/doc/cookbook/index.rst deleted file mode 100644 index 53b10fe2c..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/index.rst +++ /dev/null @@ -1,40 +0,0 @@ -Cookbook -======== - -The cookbook section contains recipes for solving specific problems. - -.. toctree:: - :maxdepth: 1 - :hidden: - - json_request_body - session_storage - form_no_csrf - validator_yaml - sub_requests - error_handler - multiple_loggers - guard_authentication - -Recipes -------- - -* :doc:`Accepting a JSON Request Body ` A common need when - building a restful API is the ability to accept a JSON encoded entity from - the request body. - -* :doc:`Using PdoSessionStorage to store Sessions in the Database - `. - -* :doc:`Disabling the CSRF Protection on a Form using the FormExtension - `. - -* :doc:`Using YAML to configure Validation `. - -* :doc:`Making sub-Requests `. - -* :doc:`Converting Errors to Exceptions `. - -* :doc:`Using multiple Monolog Loggers `. - -* :doc:`How to Create a Custom Authentication System with Guard `. diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/json_request_body.rst b/lib/silex/vendor/silex/silex/doc/cookbook/json_request_body.rst deleted file mode 100644 index 471590082..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/json_request_body.rst +++ /dev/null @@ -1,95 +0,0 @@ -Accepting a JSON Request Body -============================= - -A common need when building a restful API is the ability to accept a JSON -encoded entity from the request body. - -An example for such an API could be a blog post creation. - -Example API ------------ - -In this example we will create an API for creating a blog post. The following -is a spec of how we want it to work. - -Request -~~~~~~~ - -In the request we send the data for the blog post as a JSON object. We also -indicate that using the ``Content-Type`` header: - -.. code-block:: text - - POST /blog/posts - Accept: application/json - Content-Type: application/json - Content-Length: 57 - - {"title":"Hello World!","body":"This is my first post!"} - -Response -~~~~~~~~ - -The server responds with a 201 status code, telling us that the post was -created. It tells us the ``Content-Type`` of the response, which is also -JSON: - -.. code-block:: text - - HTTP/1.1 201 Created - Content-Type: application/json - Content-Length: 65 - Connection: close - - {"id":"1","title":"Hello World!","body":"This is my first post!"} - -Parsing the request body ------------------------- - -The request body should only be parsed as JSON if the ``Content-Type`` header -begins with ``application/json``. Since we want to do this for every request, -the easiest solution is to use an application before middleware. - -We simply use ``json_decode`` to parse the content of the request and then -replace the request data on the ``$request`` object:: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpFoundation\ParameterBag; - - $app->before(function (Request $request) { - if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) { - $data = json_decode($request->getContent(), true); - $request->request->replace(is_array($data) ? $data : array()); - } - }); - -Controller implementation -------------------------- - -Our controller will create a new blog post from the data provided and will -return the post object, including its ``id``, as JSON:: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpFoundation\Response; - - $app->post('/blog/posts', function (Request $request) use ($app) { - $post = array( - 'title' => $request->request->get('title'), - 'body' => $request->request->get('body'), - ); - - $post['id'] = createPost($post); - - return $app->json($post, 201); - }); - -Manual testing --------------- - -In order to manually test our API, we can use the ``curl`` command line -utility, which allows sending HTTP requests: - -.. code-block:: bash - - $ curl http://blog.lo/blog/posts -d '{"title":"Hello World!","body":"This is my first post!"}' -H 'Content-Type: application/json' - {"id":"1","title":"Hello World!","body":"This is my first post!"} diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/multiple_loggers.rst b/lib/silex/vendor/silex/silex/doc/cookbook/multiple_loggers.rst deleted file mode 100644 index cb1039530..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/multiple_loggers.rst +++ /dev/null @@ -1,69 +0,0 @@ -Using multiple Monolog Loggers -============================== - -Having separate instances of Monolog for different parts of your system is -often desirable and allows you to configure them independently, allowing for fine -grained control of where your logging goes and in what detail. - -This simple example allows you to quickly configure several monolog instances, -using the bundled handler, but each with a different channel. - -.. code-block:: php - - $app['monolog.factory'] = $app->protect(function ($name) use ($app) { - $log = new $app['monolog.logger.class']($name); - $log->pushHandler($app['monolog.handler']); - - return $log; - }); - - foreach (array('auth', 'payments', 'stats') as $channel) { - $app['monolog.'.$channel] = function ($app) use ($channel) { - return $app['monolog.factory']($channel); - }; - } - -As your application grows, or your logging needs for certain areas of the -system become apparent, it should be straightforward to then configure that -particular service separately, including your customizations. - -.. code-block:: php - - use Monolog\Handler\StreamHandler; - - $app['monolog.payments'] = function ($app) { - $log = new $app['monolog.logger.class']('payments'); - $handler = new StreamHandler($app['monolog.payments.logfile'], $app['monolog.payment.level']); - $log->pushHandler($handler); - - return $log; - }; - -Alternatively, you could attempt to make the factory more complicated, and rely -on some conventions, such as checking for an array of handlers registered with -the container with the channel name, defaulting to the bundled handler. - -.. code-block:: php - - use Monolog\Handler\StreamHandler; - use Monolog\Logger; - - $app['monolog.factory'] = $app->protect(function ($name) use ($app) { - $log = new $app['monolog.logger.class']($name); - - $handlers = isset($app['monolog.'.$name.'.handlers']) - ? $app['monolog.'.$name.'.handlers'] - : array($app['monolog.handler']); - - foreach ($handlers as $handler) { - $log->pushHandler($handler); - } - - return $log; - }); - - $app['monolog.payments.handlers'] = function ($app) { - return array( - new StreamHandler(__DIR__.'/../payments.log', Logger::DEBUG), - ); - }; diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/session_storage.rst b/lib/silex/vendor/silex/silex/doc/cookbook/session_storage.rst deleted file mode 100644 index 29328b490..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/session_storage.rst +++ /dev/null @@ -1,89 +0,0 @@ -Using PdoSessionStorage to store Sessions in the Database -========================================================= - -By default, the :doc:`SessionServiceProvider ` writes -session information in files using Symfony NativeFileSessionStorage. Most -medium to large websites use a database to store sessions instead of files, -because databases are easier to use and scale in a multi-webserver environment. - -Symfony's `NativeSessionStorage -`_ -has multiple storage handlers and one of them uses PDO to store sessions, -`PdoSessionHandler -`_. -To use it, replace the ``session.storage.handler`` service in your application -like explained below. - -With a dedicated PDO service ----------------------------- - -.. code-block:: php - - use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - - $app->register(new Silex\Provider\SessionServiceProvider()); - - $app['pdo.dsn'] = 'mysql:dbname=mydatabase'; - $app['pdo.user'] = 'myuser'; - $app['pdo.password'] = 'mypassword'; - - $app['session.db_options'] = array( - 'db_table' => 'session', - 'db_id_col' => 'session_id', - 'db_data_col' => 'session_value', - 'db_time_col' => 'session_time', - ); - - $app['pdo'] = function () use ($app) { - return new PDO( - $app['pdo.dsn'], - $app['pdo.user'], - $app['pdo.password'] - ); - }; - - $app['session.storage.handler'] = function () use ($app) { - return new PdoSessionHandler( - $app['pdo'], - $app['session.db_options'] - ); - }; - -Using the DoctrineServiceProvider ---------------------------------- - -When using the :doc:`DoctrineServiceProvider ` You don't -have to make another database connection, simply pass the getWrappedConnection method. - -.. code-block:: php - - use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - - $app->register(new Silex\Provider\SessionServiceProvider()); - - $app['session.storage.handler'] = function () use ($app) { - return new PdoSessionHandler( - $app['db']->getWrappedConnection(), - array( - 'db_table' => 'session', - 'db_id_col' => 'session_id', - 'db_data_col' => 'session_value', - 'db_lifetime_col' => 'session_lifetime', - 'db_time_col' => 'session_time', - ) - ); - }; - -Database structure ------------------- - -PdoSessionStorage needs a database table with 3 columns: - -* ``session_id``: ID column (VARCHAR(255) or larger) -* ``session_value``: Value column (TEXT or CLOB) -* ``session_lifetime``: Lifetime column (INTEGER) -* ``session_time``: Time column (INTEGER) - -You can find examples of SQL statements to create the session table in the -`Symfony cookbook -`_ diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/sub_requests.rst b/lib/silex/vendor/silex/silex/doc/cookbook/sub_requests.rst deleted file mode 100644 index 95d391362..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/sub_requests.rst +++ /dev/null @@ -1,137 +0,0 @@ -Making sub-Requests -=================== - -Since Silex is based on the ``HttpKernelInterface``, it allows you to simulate -requests against your application. This means that you can embed a page within -another, it also allows you to forward a request which is essentially an -internal redirect that does not change the URL. - -Basics ------- - -You can make a sub-request by calling the ``handle`` method on the -``Application``. This method takes three arguments: - -* ``$request``: An instance of the ``Request`` class which represents the - HTTP request. - -* ``$type``: Must be either ``HttpKernelInterface::MASTER_REQUEST`` or - ``HttpKernelInterface::SUB_REQUEST``. Certain listeners are only executed for - the master request, so it's important that this is set to ``SUB_REQUEST``. - -* ``$catch``: Catches exceptions and turns them into a response with status code - ``500``. This argument defaults to ``true``. For sub-requests you will most - likely want to set it to ``false``. - -By calling ``handle``, you can make a sub-request manually. Here's an example:: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpKernel\HttpKernelInterface; - - $subRequest = Request::create('/'); - $response = $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false); - -There's some more things that you need to keep in mind though. In most cases -you will want to forward some parts of the current master request to the -sub-request like cookies, server information, or the session. - -Here is a more advanced example that forwards said information (``$request`` -holds the master request):: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpKernel\HttpKernelInterface; - - $subRequest = Request::create('/', 'GET', array(), $request->cookies->all(), array(), $request->server->all()); - if ($request->getSession()) { - $subRequest->setSession($request->getSession()); - } - - $response = $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false); - -To forward this response to the client, you can simply return it from a -controller:: - - use Silex\Application; - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpKernel\HttpKernelInterface; - - $app->get('/foo', function (Application $app, Request $request) { - $subRequest = Request::create('/', ...); - $response = $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false); - - return $response; - }); - -If you want to embed the response as part of a larger page you can call -``Response::getContent``:: - - $header = ...; - $footer = ...; - $body = $response->getContent(); - - return $header.$body.$footer; - -Rendering pages in Twig templates ---------------------------------- - -The :doc:`TwigServiceProvider ` provides a ``render`` -function that you can use in Twig templates. It gives you a convenient way to -embed pages. - -.. code-block:: jinja - - {{ render('/sidebar') }} - -For details, refer to the :doc:`TwigServiceProvider ` docs. - -Edge Side Includes ------------------- - -You can use ESI either through the :doc:`HttpCacheServiceProvider -` or a reverse proxy cache such as Varnish. This also -allows you to embed pages, however it also gives you the benefit of caching -parts of the page. - -Here is an example of how you would embed a page via ESI: - -.. code-block:: jinja - - - -For details, refer to the :doc:`HttpCacheServiceProvider -` docs. - -Dealing with the request base URL ---------------------------------- - -One thing to watch out for is the base URL. If your application is not -hosted at the webroot of your web server, then you may have an URL like -``http://example.org/foo/index.php/articles/42``. - -In this case, ``/foo/index.php`` is your request base path. Silex accounts for -this path prefix in the routing process, it reads it from -``$request->server``. In the context of sub-requests this can lead to issues, -because if you do not prepend the base path the request could mistake a part -of the path you want to match as the base path and cut it off. - -You can prevent that from happening by always prepending the base path when -constructing a request:: - - $url = $request->getUriForPath('/'); - $subRequest = Request::create($url, 'GET', array(), $request->cookies->all(), array(), $request->server->all()); - -This is something to be aware of when making sub-requests by hand. - -Services depending on the Request ---------------------------------- - -The container is a concept that is global to a Silex application, since the -application object **is** the container. Any request that is run against an -application will re-use the same set of services. Since these services are -mutable, code in a master request can affect the sub-requests and vice versa. -Any services depending on the ``request`` service will store the first request -that they get (could be master or sub-request), and keep using it, even if -that request is already over. - -Instead of injecting the ``request`` service, you should always inject the -``request_stack`` one instead. diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/translating_validation_messages.rst b/lib/silex/vendor/silex/silex/doc/cookbook/translating_validation_messages.rst deleted file mode 100644 index 745055fb1..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/translating_validation_messages.rst +++ /dev/null @@ -1,20 +0,0 @@ -Translating Validation Messages -=============================== - -When working with Symfony2 validator, a common task would be to show localized -validation messages. - -In order to do that, you will need to register translator and point to -translated resources:: - - $app->register(new Silex\Provider\TranslationServiceProvider(), array( - 'locale' => 'sr_Latn', - 'translator.domains' => array(), - )); - - $app->before(function () use ($app) { - $app['translator']->addLoader('xlf', new Symfony\Component\Translation\Loader\XliffFileLoader()); - $app['translator']->addResource('xlf', __DIR__.'/vendor/symfony/validator/Symfony/Component/Validator/Resources/translations/validators/validators.sr_Latn.xlf', 'sr_Latn', 'validators'); - }); - -And that's all you need to load translations from Symfony2 ``xlf`` files. diff --git a/lib/silex/vendor/silex/silex/doc/cookbook/validator_yaml.rst b/lib/silex/vendor/silex/silex/doc/cookbook/validator_yaml.rst deleted file mode 100644 index 10a41fcfa..000000000 --- a/lib/silex/vendor/silex/silex/doc/cookbook/validator_yaml.rst +++ /dev/null @@ -1,35 +0,0 @@ -Using YAML to configure Validation -================================== - -Simplicity is at the heart of Silex so there is no out of the box solution to -use YAML files for validation. But this doesn't mean that this is not -possible. Let's see how to do it. - -First, you need to install the YAML Component: - -.. code-block:: bash - - composer require symfony/yaml - -Next, you need to tell the Validation Service that you are not using -``StaticMethodLoader`` to load your class metadata but a YAML file:: - - $app->register(new ValidatorServiceProvider()); - - $app['validator.mapping.class_metadata_factory'] = new Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory( - new Symfony\Component\Validator\Mapping\Loader\YamlFileLoader(__DIR__.'/validation.yml') - ); - -Now, we can replace the usage of the static method and move all the validation -rules to ``validation.yml``: - -.. code-block:: yaml - - # validation.yml - Post: - properties: - title: - - NotNull: ~ - - NotBlank: ~ - body: - - Min: 100 diff --git a/lib/silex/vendor/silex/silex/doc/index.rst b/lib/silex/vendor/silex/silex/doc/index.rst deleted file mode 100644 index d1a851d0a..000000000 --- a/lib/silex/vendor/silex/silex/doc/index.rst +++ /dev/null @@ -1,19 +0,0 @@ -The Book -======== - -.. toctree:: - :maxdepth: 1 - - intro - usage - middlewares - organizing_controllers - services - providers - testing - cookbook/index - internals - contributing - providers/index - web_servers - changelog diff --git a/lib/silex/vendor/silex/silex/doc/internals.rst b/lib/silex/vendor/silex/silex/doc/internals.rst deleted file mode 100644 index c7ffac8ce..000000000 --- a/lib/silex/vendor/silex/silex/doc/internals.rst +++ /dev/null @@ -1,84 +0,0 @@ -Internals -========= - -This chapter will tell you how Silex works internally. - -Silex ------ - -Application -~~~~~~~~~~~ - -The application is the main interface to Silex. It implements Symfony's -`HttpKernelInterface -`_, -so you can pass a `Request -`_ -to the ``handle`` method and it will return a `Response -`_. - -It extends the ``Pimple`` service container, allowing for flexibility on the -outside as well as the inside. You could replace any service, and you are also -able to read them. - -The application makes strong use of the `EventDispatcher -`_ to hook into the Symfony `HttpKernel -`_ -events. This allows fetching the ``Request``, converting string responses into -``Response`` objects and handling Exceptions. We also use it to dispatch some -custom events like before/after middlewares and errors. - -Controller -~~~~~~~~~~ - -The Symfony `Route -`_ is -actually quite powerful. Routes can be named, which allows for URL generation. -They can also have requirements for the variable parts. In order to allow -setting these through a nice interface, the ``match`` method (which is used by -``get``, ``post``, etc.) returns an instance of the ``Controller``, which -wraps a route. - -ControllerCollection -~~~~~~~~~~~~~~~~~~~~ - -One of the goals of exposing the `RouteCollection -`_ -was to make it mutable, so providers could add stuff to it. The challenge here -is the fact that routes know nothing about their name. The name only has -meaning in context of the ``RouteCollection`` and cannot be changed. - -To solve this challenge we came up with a staging area for routes. The -``ControllerCollection`` holds the controllers until ``flush`` is called, at -which point the routes are added to the ``RouteCollection``. Also, the -controllers are then frozen. This means that they can no longer be modified -and will throw an Exception if you try to do so. - -Unfortunately no good way for flushing implicitly could be found, which is why -flushing is now always explicit. The Application will flush, but if you want -to read the ``ControllerCollection`` before the request takes place, you will -have to call flush yourself. - -The ``Application`` provides a shortcut ``flush`` method for flushing the -``ControllerCollection``. - -.. tip:: - - Instead of creating an instance of ``RouteCollection`` yourself, use the - ``$app['controllers_factory']`` factory instead. - -Symfony -------- - -Following Symfony components are used by Silex: - -* **HttpFoundation**: For ``Request`` and ``Response``. - -* **HttpKernel**: Because we need a heart. - -* **Routing**: For matching defined routes. - -* **EventDispatcher**: For hooking into the HttpKernel. - -For more information, `check out the Symfony website `_. diff --git a/lib/silex/vendor/silex/silex/doc/intro.rst b/lib/silex/vendor/silex/silex/doc/intro.rst deleted file mode 100644 index 2ab2bc300..000000000 --- a/lib/silex/vendor/silex/silex/doc/intro.rst +++ /dev/null @@ -1,50 +0,0 @@ -Introduction -============ - -Silex is a PHP microframework. It is built on the shoulders of `Symfony`_ and -`Pimple`_ and also inspired by `Sinatra`_. - -Silex aims to be: - -* *Concise*: Silex exposes an intuitive and concise API. - -* *Extensible*: Silex has an extension system based around the Pimple - service-container that makes it easy to tie in third party libraries. - -* *Testable*: Silex uses Symfony's HttpKernel which abstracts request and - response. This makes it very easy to test apps and the framework itself. It - also respects the HTTP specification and encourages its proper use. - -In a nutshell, you define controllers and map them to routes, all in one step. - -Usage ------ - -.. code-block:: php - - get('/hello/{name}', function ($name) use ($app) { - return 'Hello '.$app->escape($name); - }); - - $app->run(); - -All that is needed to get access to the Framework is to include the -autoloader. - -Next, a route for ``/hello/{name}`` that matches for ``GET`` requests is -defined. When the route matches, the function is executed and the return value -is sent back to the client. - -Finally, the app is run. Visit ``/hello/world`` to see the result. It's really -that easy! - -.. _Symfony: http://symfony.com/ -.. _Pimple: http://pimple.sensiolabs.org/ -.. _Sinatra: http://www.sinatrarb.com/ diff --git a/lib/silex/vendor/silex/silex/doc/middlewares.rst b/lib/silex/vendor/silex/silex/doc/middlewares.rst deleted file mode 100644 index c5c17cf0d..000000000 --- a/lib/silex/vendor/silex/silex/doc/middlewares.rst +++ /dev/null @@ -1,162 +0,0 @@ -Middleware -========== - -Silex allows you to run code, that changes the default Silex behavior, at -different stages during the handling of a request through *middleware*: - -* *Application middleware* is triggered independently of the current handled - request; - -* *Route middleware* is triggered when its associated route is matched. - -Application Middleware ----------------------- - -Application middleware is only run for the "master" Request. - -Before Middleware -~~~~~~~~~~~~~~~~~ - -A *before* application middleware allows you to tweak the Request before the -controller is executed:: - - $app->before(function (Request $request, Application $app) { - // ... - }); - -By default, the middleware is run after the routing and the security. - -If you want your middleware to be run even if an exception is thrown early on -(on a 404 or 403 error for instance), then, you need to register it as an -early event:: - - $app->before(function (Request $request, Application $app) { - // ... - }, Application::EARLY_EVENT); - -In this case, the routing and the security won't have been executed, and so you -won't have access to the locale, the current route, or the security user. - -.. note:: - - The before middleware is an event registered on the Symfony *request* - event. - -After Middleware -~~~~~~~~~~~~~~~~ - -An *after* application middleware allows you to tweak the Response before it -is sent to the client:: - - $app->after(function (Request $request, Response $response) { - // ... - }); - -.. note:: - - The after middleware is an event registered on the Symfony *response* - event. - -Finish Middleware -~~~~~~~~~~~~~~~~~ - -A *finish* application middleware allows you to execute tasks after the -Response has been sent to the client (like sending emails or logging):: - - $app->finish(function (Request $request, Response $response) { - // ... - // Warning: modifications to the Request or Response will be ignored - }); - -.. note:: - - The finish middleware is an event registered on the Symfony *terminate* - event. - -Route Middleware ----------------- - -Route middleware is added to routes or route collections and it is only -triggered when the corresponding route is matched. You can also stack them:: - - $app->get('/somewhere', function () { - // ... - }) - ->before($before1) - ->before($before2) - ->after($after1) - ->after($after2) - ; - -Before Middleware -~~~~~~~~~~~~~~~~~ - -A *before* route middleware is fired just before the route callback, but after -the *before* application middleware:: - - $before = function (Request $request, Application $app) { - // ... - }; - - $app->get('/somewhere', function () { - // ... - }) - ->before($before); - -After Middleware -~~~~~~~~~~~~~~~~ - -An *after* route middleware is fired just after the route callback, but before -the application *after* application middleware:: - - $after = function (Request $request, Response $response, Application $app) { - // ... - }; - - $app->get('/somewhere', function () { - // ... - }) - ->after($after); - -Middleware Priority -------------------- - -You can add as much middleware as you want, in which case they are triggered -in the same order as you added them. - -You can explicitly control the priority of your middleware by passing an -additional argument to the registration methods:: - - $app->before(function (Request $request) { - // ... - }, 32); - -As a convenience, two constants allow you to register an event as early as -possible or as late as possible:: - - $app->before(function (Request $request) { - // ... - }, Application::EARLY_EVENT); - - $app->before(function (Request $request) { - // ... - }, Application::LATE_EVENT); - -Short-circuiting the Controller -------------------------------- - -If a *before* middleware returns a ``Response`` object, the request handling is -short-circuited (the next middleware won't be run, nor the route -callback), and the Response is passed to the *after* middleware right away:: - - $app->before(function (Request $request) { - // redirect the user to the login screen if access to the Resource is protected - if (...) { - return new RedirectResponse('/login'); - } - }); - -.. note:: - - A ``RuntimeException`` is thrown if a before middleware does not return a - Response or ``null``. diff --git a/lib/silex/vendor/silex/silex/doc/organizing_controllers.rst b/lib/silex/vendor/silex/silex/doc/organizing_controllers.rst deleted file mode 100644 index 89fc68674..000000000 --- a/lib/silex/vendor/silex/silex/doc/organizing_controllers.rst +++ /dev/null @@ -1,84 +0,0 @@ -Organizing Controllers -====================== - -When your application starts to define too many controllers, you might want to -group them logically:: - - // define controllers for a blog - $blog = $app['controllers_factory']; - $blog->get('/', function () { - return 'Blog home page'; - }); - // ... - - // define controllers for a forum - $forum = $app['controllers_factory']; - $forum->get('/', function () { - return 'Forum home page'; - }); - - // define "global" controllers - $app->get('/', function () { - return 'Main home page'; - }); - - $app->mount('/blog', $blog); - $app->mount('/forum', $forum); - - // define controllers for an admin - $app->mount('/admin', function ($admin) { - // recursively mount - $admin->mount('/blog', function ($user) { - $user->get('/', function () { - return 'Admin Blog home page'; - }); - }); - }); - -.. note:: - - ``$app['controllers_factory']`` is a factory that returns a new instance - of ``ControllerCollection`` when used. - -``mount()`` prefixes all routes with the given prefix and merges them into the -main Application. So, ``/`` will map to the main home page, ``/blog/`` to the -blog home page, ``/forum/`` to the forum home page, and ``/admin/blog/`` to the -admin blog home page. - -.. caution:: - - When mounting a route collection under ``/blog``, it is not possible to - define a route for the ``/blog`` URL. The shortest possible URL is - ``/blog/``. - -.. note:: - - When calling ``get()``, ``match()``, or any other HTTP methods on the - Application, you are in fact calling them on a default instance of - ``ControllerCollection`` (stored in ``$app['controllers']``). - -Another benefit is the ability to apply settings on a set of controllers very -easily. Building on the example from the middleware section, here is how you -would secure all controllers for the backend collection:: - - $backend = $app['controllers_factory']; - - // ensure that all controllers require logged-in users - $backend->before($mustBeLogged); - -.. tip:: - - For a better readability, you can split each controller collection into a - separate file:: - - // blog.php - $blog = $app['controllers_factory']; - $blog->get('/', function () { return 'Blog home page'; }); - - return $blog; - - // app.php - $app->mount('/blog', include 'blog.php'); - - Instead of requiring a file, you can also create a :ref:`Controller - provider `. diff --git a/lib/silex/vendor/silex/silex/doc/phar.rst b/lib/silex/vendor/silex/silex/doc/phar.rst deleted file mode 100644 index c1b607dfd..000000000 --- a/lib/silex/vendor/silex/silex/doc/phar.rst +++ /dev/null @@ -1,109 +0,0 @@ -Phar File -========= - -.. caution:: - - Using the Silex ``phar`` file is deprecated. You should use Composer - instead to install Silex and its dependencies or download one of the - archives. - -Installing ----------- - -Installing Silex is as easy as downloading the `phar -`_ and storing it somewhere on -the disk. Then, require it in your script:: - - get('/hello/{name}', function ($name) use ($app) { - return 'Hello '.$app->escape($name); - }); - - $app->run(); - -Console -------- - -Silex includes a lightweight console for updating to the latest version. - -To find out which version of Silex you are using, invoke ``silex.phar`` on the -command-line with ``version`` as an argument: - -.. code-block:: text - - $ php silex.phar version - Silex version 0a243d3 2011-04-17 14:49:31 +0200 - -To check that your are using the latest version, run the ``check`` command: - -.. code-block:: text - - $ php silex.phar check - -To update ``silex.phar`` to the latest version, invoke the ``update`` -command: - -.. code-block:: text - - $ php silex.phar update - -This will automatically download a new ``silex.phar`` from -``silex.sensiolabs.org`` and replace the existing one. - -Pitfalls --------- - -There are some things that can go wrong. Here we will try and outline the -most frequent ones. - -PHP configuration -~~~~~~~~~~~~~~~~~ - -Certain PHP distributions have restrictive default Phar settings. Setting -the following may help. - -.. code-block:: ini - - detect_unicode = Off - phar.readonly = Off - phar.require_hash = Off - -If you are on Suhosin you will also have to set this: - -.. code-block:: ini - - suhosin.executor.include.whitelist = phar - -.. note:: - - Ubuntu's PHP ships with Suhosin, so if you are using Ubuntu, you will need - this change. - -Phar-Stub bug -~~~~~~~~~~~~~ - -Some PHP installations have a bug that throws a ``PharException`` when trying -to include the Phar. It will also tell you that ``Silex\Application`` could not -be found. A workaround is using the following include line:: - - require_once 'phar://'.__DIR__.'/silex.phar/autoload.php'; - -The exact cause of this issue could not be determined yet. - -ioncube loader bug -~~~~~~~~~~~~~~~~~~ - -Ioncube loader is an extension that can decode PHP encoded file. -Unfortunately, old versions (prior to version 4.0.9) are not working well -with phar archives. -You must either upgrade Ioncube loader to version 4.0.9 or newer or disable it -by commenting or removing this line in your php.ini file: - -.. code-block:: ini - - zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so diff --git a/lib/silex/vendor/silex/silex/doc/providers.rst b/lib/silex/vendor/silex/silex/doc/providers.rst deleted file mode 100644 index c3d049db7..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers.rst +++ /dev/null @@ -1,262 +0,0 @@ -Providers -========= - -Providers allow the developer to reuse parts of an application into another -one. Silex provides two types of providers defined by two interfaces: -``ServiceProviderInterface`` for services and ``ControllerProviderInterface`` -for controllers. - -Service Providers ------------------ - -Loading providers -~~~~~~~~~~~~~~~~~ - -In order to load and use a service provider, you must register it on the -application:: - - $app = new Silex\Application(); - - $app->register(new Acme\DatabaseServiceProvider()); - -You can also provide some parameters as a second argument. These will be set -**after** the provider is registered, but **before** it is booted:: - - $app->register(new Acme\DatabaseServiceProvider(), array( - 'database.dsn' => 'mysql:host=localhost;dbname=myapp', - 'database.user' => 'root', - 'database.password' => 'secret_root_password', - )); - -Conventions -~~~~~~~~~~~ - -You need to watch out in what order you do certain things when interacting -with providers. Just keep these rules in mind: - -* Overriding existing services must occur **after** the provider is - registered. - - *Reason: If the service already exists, the provider will overwrite it.* - -* You can set parameters any time **after** the provider is registered, but - **before** the service is accessed. - - *Reason: Providers can set default values for parameters. Just like with - services, the provider will overwrite existing values.* - -Included providers -~~~~~~~~~~~~~~~~~~ - -There are a few providers that you get out of the box. All of these are within -the ``Silex\Provider`` namespace: - -* :doc:`AssetServiceProvider ` -* :doc:`CsrfServiceProvider ` -* :doc:`DoctrineServiceProvider ` -* :doc:`FormServiceProvider ` -* :doc:`HttpCacheServiceProvider ` -* :doc:`HttpFragmentServiceProvider ` -* :doc:`LocaleServiceProvider ` -* :doc:`MonologServiceProvider ` -* :doc:`RememberMeServiceProvider ` -* :doc:`SecurityServiceProvider ` -* :doc:`SerializerServiceProvider ` -* :doc:`ServiceControllerServiceProvider ` -* :doc:`SessionServiceProvider ` -* :doc:`SwiftmailerServiceProvider ` -* :doc:`TranslationServiceProvider ` -* :doc:`TwigServiceProvider ` -* :doc:`ValidatorServiceProvider ` -* :doc:`VarDumperServiceProvider ` - -.. note:: - - The Silex core team maintains a `WebProfiler - `_ provider that helps debug - code in the development environment thanks to the Symfony web debug toolbar - and the Symfony profiler. - -Third party providers -~~~~~~~~~~~~~~~~~~~~~ - -Some service providers are developed by the community. Those third-party -providers are listed on `Silex' repository wiki -`_. - -You are encouraged to share yours. - -Creating a provider -~~~~~~~~~~~~~~~~~~~ - -Providers must implement the ``Pimple\ServiceProviderInterface``:: - - interface ServiceProviderInterface - { - public function register(Container $container); - } - -This is very straight forward, just create a new class that implements the -register method. In the ``register()`` method, you can define services on the -application which then may make use of other services and parameters. - -.. tip:: - - The ``Pimple\ServiceProviderInterface`` belongs to the Pimple package, so - take care to only use the API of ``Pimple\Container`` within your - ``register`` method. Not only is this a good practice due to the way Pimple - and Silex work, but may allow your provider to be used outside of Silex. - -Optionally, your service provider can implement the -``Silex\Api\BootableProviderInterface``. A bootable provider must -implement the ``boot()`` method, with which you can configure the application, just -before it handles a request:: - - interface BootableProviderInterface - { - function boot(Application $app); - } - -Another optional interface, is the ``Silex\Api\EventListenerProviderInterface``. -This interface contains the ``subscribe()`` method, which allows your provider to -subscribe event listener with Silex's EventDispatcher, just before it handles a -request:: - - interface EventListenerProviderInterface - { - function subscribe(Container $app, EventDispatcherInterface $dispatcher); - } - -Here is an example of such a provider:: - - namespace Acme; - - use Pimple\Container; - use Pimple\ServiceProviderInterface; - use Silex\Application; - use Silex\Api\BootableProviderInterface; - use Silex\Api\EventListenerProviderInterface; - use Symfony\Component\EventDispatcher\EventDispatcherInterface; - use Symfony\Component\HttpKernel\KernelEvents; - use Symfony\Component\HttpKernel\Event\FilterResponseEvent; - - class HelloServiceProvider implements ServiceProviderInterface, BootableProviderInterface, EventListenerProviderInterface - { - public function register(Container $app) - { - $app['hello'] = $app->protect(function ($name) use ($app) { - $default = $app['hello.default_name'] ? $app['hello.default_name'] : ''; - $name = $name ?: $default; - - return 'Hello '.$app->escape($name); - }); - } - - public function boot(Application $app) - { - // do something - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addListener(KernelEvents::REQUEST, function(FilterResponseEvent $event) use ($app) { - // do something - }); - } - } - -This class provides a ``hello`` service which is a protected closure. It takes -a ``name`` argument and will return ``hello.default_name`` if no name is -given. If the default is also missing, it will use an empty string. - -You can now use this provider as follows:: - - use Symfony\Component\HttpFoundation\Request; - - $app = new Silex\Application(); - - $app->register(new Acme\HelloServiceProvider(), array( - 'hello.default_name' => 'Igor', - )); - - $app->get('/hello', function (Request $request) use ($app) { - $name = $request->get('name'); - - return $app['hello']($name); - }); - -In this example we are getting the ``name`` parameter from the query string, -so the request path would have to be ``/hello?name=Fabien``. - -.. _controller-providers: - -Controller Providers --------------------- - -Loading providers -~~~~~~~~~~~~~~~~~ - -In order to load and use a controller provider, you must "mount" its -controllers under a path:: - - $app = new Silex\Application(); - - $app->mount('/blog', new Acme\BlogControllerProvider()); - -All controllers defined by the provider will now be available under the -``/blog`` path. - -Creating a provider -~~~~~~~~~~~~~~~~~~~ - -Providers must implement the ``Silex\Api\ControllerProviderInterface``:: - - interface ControllerProviderInterface - { - public function connect(Application $app); - } - -Here is an example of such a provider:: - - namespace Acme; - - use Silex\Application; - use Silex\Api\ControllerProviderInterface; - - class HelloControllerProvider implements ControllerProviderInterface - { - public function connect(Application $app) - { - // creates a new controller based on the default route - $controllers = $app['controllers_factory']; - - $controllers->get('/', function (Application $app) { - return $app->redirect('/hello'); - }); - - return $controllers; - } - } - -The ``connect`` method must return an instance of ``ControllerCollection``. -``ControllerCollection`` is the class where all controller related methods are -defined (like ``get``, ``post``, ``match``, ...). - -.. tip:: - - The ``Application`` class acts in fact as a proxy for these methods. - -You can use this provider as follows:: - - $app = new Silex\Application(); - - $app->mount('/blog', new Acme\HelloControllerProvider()); - -In this example, the ``/blog/`` path now references the controller defined in -the provider. - -.. tip:: - - You can also define a provider that implements both the service and the - controller provider interface and package in the same class the services - needed to make your controllers work. diff --git a/lib/silex/vendor/silex/silex/doc/providers/asset.rst b/lib/silex/vendor/silex/silex/doc/providers/asset.rst deleted file mode 100644 index 72b184da7..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/asset.rst +++ /dev/null @@ -1,69 +0,0 @@ -Asset -===== - -The *AssetServiceProvider* provides a way to manage URL generation and -versioning of web assets such as CSS stylesheets, JavaScript files and image -files. - -Parameters ----------- - -* **assets.version**: Default version for assets. - -* **assets.format_version** (optional): Default format for assets. - -* **assets.base_path**: Default path to prepend to all assets without a package. - -* **assets.named_packages** (optional): Named packages. Keys are the package - names and values the configuration (supported keys are ``version``, - ``version_format``, ``base_urls``, and ``base_path``). - -Services --------- - -* **assets.packages**: The asset service. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\AssetServiceProvider(), array( - 'assets.version' => 'v1', - 'assets.version_format' => '%s?version=%s', - 'assets.named_packages' => array( - 'css' => array('version' => 'css2', 'base_path' => '/whatever-makes-sense'), - 'images' => array('base_urls' => array('https://img.example.com')), - ), - )); - -.. note:: - - Add the Symfony Asset Component as a dependency: - - .. code-block:: bash - - composer require symfony/asset - - If you want to use assets in your Twig templates, you must also install the - Symfony Twig Bridge: - - .. code-block:: bash - - composer require symfony/twig-bridge - -Usage ------ - -The AssetServiceProvider is mostly useful with the Twig provider: - -.. code-block:: jinja - - {{ asset('/css/foo.png') }} - {{ asset('/css/foo.css', 'css') }} - {{ asset('/img/foo.png', 'images') }} - - {{ asset_version('/css/foo.png') }} - -For more information, check out the `Asset Component documentation -`_. diff --git a/lib/silex/vendor/silex/silex/doc/providers/csrf.rst b/lib/silex/vendor/silex/silex/doc/providers/csrf.rst deleted file mode 100644 index a055c112e..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/csrf.rst +++ /dev/null @@ -1,53 +0,0 @@ -CSRF -==== - -The *CsrfServiceProvider* provides a service for building forms in your -application with the Symfony Form component. - -Parameters ----------- - -* none - -Services --------- - -* **csrf.token_manager**: An instance of an implementation of the - `CsrfTokenManagerInterface - `_, - -Registering ------------ - -.. code-block:: php - - use Silex\Provider\CsrfServiceProvider; - - $app->register(new CsrfServiceProvider()); - -.. note:: - - Add the Symfony's `Security CSRF Component - `_ as a - dependency: - - .. code-block:: bash - - composer require symfony/security-csrf - -Usage ------ - -When the CSRF Service Provider is registered, all forms created via the Form -Service Provider are protected against CSRF by default. - -You can also use the CSRF protection without using the Symfony Form component. -If, for example, you're doing a DELETE action, create a CSRF token to use in -your code:: - - use Symfony\Component\Security\Csrf\CsrfToken; - $csrfToken = $app['csrf.token_manager']->getToken('token_id'); //'TOKEN' - -Then check it:: - - $app['csrf.token_manager']->isTokenValid(new CsrfToken('token_id', 'TOKEN')); diff --git a/lib/silex/vendor/silex/silex/doc/providers/doctrine.rst b/lib/silex/vendor/silex/silex/doc/providers/doctrine.rst deleted file mode 100644 index 0ef167b78..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/doctrine.rst +++ /dev/null @@ -1,137 +0,0 @@ -Doctrine -======== - -The *DoctrineServiceProvider* provides integration with the `Doctrine DBAL -`_ for easy database access -(Doctrine ORM integration is **not** supplied). - -Parameters ----------- - -* **db.options**: Array of Doctrine DBAL options. - - These options are available: - - * **driver**: The database driver to use, defaults to ``pdo_mysql``. - Can be any of: ``pdo_mysql``, ``pdo_sqlite``, ``pdo_pgsql``, - ``pdo_oci``, ``oci8``, ``ibm_db2``, ``pdo_ibm``, ``pdo_sqlsrv``. - - * **dbname**: The name of the database to connect to. - - * **host**: The host of the database to connect to. Defaults to - localhost. - - * **user**: The user of the database to connect to. Defaults to - root. - - * **password**: The password of the database to connect to. - - * **charset**: Only relevant for ``pdo_mysql``, and ``pdo_oci/oci8``, - specifies the charset used when connecting to the database. - - * **path**: Only relevant for ``pdo_sqlite``, specifies the path to - the SQLite database. - - * **port**: Only relevant for ``pdo_mysql``, ``pdo_pgsql``, and ``pdo_oci/oci8``, - specifies the port of the database to connect to. - - These and additional options are described in detail in the `Doctrine DBAL - configuration documentation `_. - -Services --------- - -* **db**: The database connection, instance of - ``Doctrine\DBAL\Connection``. - -* **db.config**: Configuration object for Doctrine. Defaults to - an empty ``Doctrine\DBAL\Configuration``. - -* **db.event_manager**: Event Manager for Doctrine. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\DoctrineServiceProvider(), array( - 'db.options' => array( - 'driver' => 'pdo_sqlite', - 'path' => __DIR__.'/app.db', - ), - )); - -.. note:: - - Add the Doctrine DBAL as a dependency: - - .. code-block:: bash - - composer require "doctrine/dbal:~2.2" - -Usage ------ - -The Doctrine provider provides a ``db`` service. Here is a usage -example:: - - $app->get('/blog/{id}', function ($id) use ($app) { - $sql = "SELECT * FROM posts WHERE id = ?"; - $post = $app['db']->fetchAssoc($sql, array((int) $id)); - - return "

{$post['title']}

". - "

{$post['body']}

"; - }); - -Using multiple databases ------------------------- - -The Doctrine provider can allow access to multiple databases. In order to -configure the data sources, replace the **db.options** with **dbs.options**. -**dbs.options** is an array of configurations where keys are connection names -and values are options:: - - $app->register(new Silex\Provider\DoctrineServiceProvider(), array( - 'dbs.options' => array ( - 'mysql_read' => array( - 'driver' => 'pdo_mysql', - 'host' => 'mysql_read.someplace.tld', - 'dbname' => 'my_database', - 'user' => 'my_username', - 'password' => 'my_password', - 'charset' => 'utf8mb4', - ), - 'mysql_write' => array( - 'driver' => 'pdo_mysql', - 'host' => 'mysql_write.someplace.tld', - 'dbname' => 'my_database', - 'user' => 'my_username', - 'password' => 'my_password', - 'charset' => 'utf8mb4', - ), - ), - )); - -The first registered connection is the default and can simply be accessed as -you would if there was only one connection. Given the above configuration, -these two lines are equivalent:: - - $app['db']->fetchAll('SELECT * FROM table'); - - $app['dbs']['mysql_read']->fetchAll('SELECT * FROM table'); - -Using multiple connections:: - - $app->get('/blog/{id}', function ($id) use ($app) { - $sql = "SELECT * FROM posts WHERE id = ?"; - $post = $app['dbs']['mysql_read']->fetchAssoc($sql, array((int) $id)); - - $sql = "UPDATE posts SET value = ? WHERE id = ?"; - $app['dbs']['mysql_write']->executeUpdate($sql, array('newValue', (int) $id)); - - return "

{$post['title']}

". - "

{$post['body']}

"; - }); - -For more information, consult the `Doctrine DBAL documentation -`_. diff --git a/lib/silex/vendor/silex/silex/doc/providers/form.rst b/lib/silex/vendor/silex/silex/doc/providers/form.rst deleted file mode 100644 index 6818b8582..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/form.rst +++ /dev/null @@ -1,216 +0,0 @@ -Form -==== - -The *FormServiceProvider* provides a service for building forms in -your application with the Symfony Form component. - -Parameters ----------- - -* none - -Services --------- - -* **form.factory**: An instance of `FormFactory - `_, - that is used to build a form. - -Registering ------------ - -.. code-block:: php - - use Silex\Provider\FormServiceProvider; - - $app->register(new FormServiceProvider()); - -.. note:: - - If you don't want to create your own form layout, it's fine: a default one - will be used. But you will have to register the :doc:`translation provider - ` as the default form layout requires it:: - - $app->register(new Silex\Provider\TranslationServiceProvider(), array( - 'translator.domains' => array(), - )); - - If you want to use validation with forms, do not forget to register the - :doc:`Validator provider `. - -.. note:: - - Add the Symfony Form Component as a dependency: - - .. code-block:: bash - - composer require symfony/form - - If you are going to use the validation extension with forms, you must also - add a dependency to the ``symfony/validator`` and ``symfony/config`` - components: - - .. code-block:: bash - - composer require symfony/validator symfony/config - - If you want to use forms in your Twig templates, you can also install the - Symfony Twig Bridge. Make sure to install, if you didn't do that already, - the Translation component in order for the bridge to work: - - .. code-block:: bash - - composer require symfony/twig-bridge - -Usage ------ - -The FormServiceProvider provides a ``form.factory`` service. Here is a usage -example:: - - use Symfony\Component\Form\Extension\Core\Type\ChoiceType; - use Symfony\Component\Form\Extension\Core\Type\FormType; - use Symfony\Component\Form\Extension\Core\Type\SubmitType; - - $app->match('/form', function (Request $request) use ($app) { - // some default data for when the form is displayed the first time - $data = array( - 'name' => 'Your name', - 'email' => 'Your email', - ); - - $form = $app['form.factory']->createBuilder(FormType::class, $data) - ->add('name') - ->add('email') - ->add('billing_plan', ChoiceType::class, array( - 'choices' => array('free' => 1, 'small business' => 2, 'corporate' => 3), - 'expanded' => true, - )) - ->add('submit', SubmitType::class, [ - 'label' => 'Save', - ]) - ->getForm(); - - $form->handleRequest($request); - - if ($form->isValid()) { - $data = $form->getData(); - - // do something with the data - - // redirect somewhere - return $app->redirect('...'); - } - - // display the form - return $app['twig']->render('index.twig', array('form' => $form->createView())); - }); - -And here is the ``index.twig`` form template (requires ``symfony/twig-bridge``): - -.. code-block:: jinja - -
- {{ form_widget(form) }} - - -
- -If you are using the validator provider, you can also add validation to your -form by adding constraints on the fields:: - - use Symfony\Component\Form\Extension\Core\Type\ChoiceType; - use Symfony\Component\Form\Extension\Core\Type\FormType; - use Symfony\Component\Form\Extension\Core\Type\SubmitType; - use Symfony\Component\Form\Extension\Core\Type\TextType; - use Symfony\Component\Validator\Constraints as Assert; - - $app->register(new Silex\Provider\ValidatorServiceProvider()); - $app->register(new Silex\Provider\TranslationServiceProvider(), array( - 'translator.domains' => array(), - )); - - $form = $app['form.factory']->createBuilder(FormType::class) - ->add('name', TextType::class, array( - 'constraints' => array(new Assert\NotBlank(), new Assert\Length(array('min' => 5))) - )) - ->add('email', TextType::class, array( - 'constraints' => new Assert\Email() - )) - ->add('billing_plan', ChoiceType::class, array( - 'choices' => array('free' => 1, 'small business' => 2, 'corporate' => 3), - 'expanded' => true, - 'constraints' => new Assert\Choice(array(1, 2, 3)), - )) - ->add('submit', SubmitType::class, [ - 'label' => 'Save', - ]) - ->getForm(); - -You can register form types by extending ``form.types``:: - - $app['your.type.service'] = function ($app) { - return new YourServiceFormType(); - }; - $app->extend('form.types', function ($types) use ($app) { - $types[] = new YourFormType(); - $types[] = 'your.type.service'; - - return $types; - })); - -You can register form extensions by extending ``form.extensions``:: - - $app->extend('form.extensions', function ($extensions) use ($app) { - $extensions[] = new YourTopFormExtension(); - - return $extensions; - }); - - -You can register form type extensions by extending ``form.type.extensions``:: - - $app['your.type.extension.service'] = function ($app) { - return new YourServiceFormTypeExtension(); - }; - $app->extend('form.type.extensions', function ($extensions) use ($app) { - $extensions[] = new YourFormTypeExtension(); - $extensions[] = 'your.type.extension.service'; - - return $extensions; - }); - -You can register form type guessers by extending ``form.type.guessers``:: - - $app['your.type.guesser.service'] = function ($app) { - return new YourServiceFormTypeGuesser(); - }; - $app->extend('form.type.guessers', function ($guessers) use ($app) { - $guessers[] = new YourFormTypeGuesser(); - $guessers[] = 'your.type.guesser.service'; - - return $guessers; - }); - -.. warning:: - - CSRF protection is only available and automatically enabled when the - :doc:`CSRF Service Provider
` is registered. - -Traits ------- - -``Silex\Application\FormTrait`` adds the following shortcuts: - -* **form**: Creates a FormBuilderInterface instance. - -* **namedForm**: Creates a FormBuilderInterface instance (named). - -.. code-block:: php - - $app->form($data); - - $app->namedForm($name, $data, $options, $type); - -For more information, consult the `Symfony Forms documentation -`_. diff --git a/lib/silex/vendor/silex/silex/doc/providers/http_cache.rst b/lib/silex/vendor/silex/silex/doc/providers/http_cache.rst deleted file mode 100644 index 8bc98f67a..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/http_cache.rst +++ /dev/null @@ -1,128 +0,0 @@ -HTTP Cache -========== - -The *HttpCacheServiceProvider* provides support for the Symfony Reverse -Proxy. - -Parameters ----------- - -* **http_cache.cache_dir**: The cache directory to store the HTTP cache data. - -* **http_cache.options** (optional): An array of options for the `HttpCache - `_ - constructor. - -Services --------- - -* **http_cache**: An instance of `HttpCache - `_. - -* **http_cache.esi**: An instance of `Esi - `_, - that implements the ESI capabilities to Request and Response instances. - -* **http_cache.store**: An instance of `Store - `_, - that implements all the logic for storing cache metadata (Request and Response - headers). - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\HttpCacheServiceProvider(), array( - 'http_cache.cache_dir' => __DIR__.'/cache/', - )); - -Usage ------ - -Silex already supports any reverse proxy like Varnish out of the box by -setting Response HTTP cache headers:: - - use Symfony\Component\HttpFoundation\Response; - - $app->get('/', function() { - return new Response('Foo', 200, array( - 'Cache-Control' => 's-maxage=5', - )); - }); - -.. tip:: - - If you want Silex to trust the ``X-Forwarded-For*`` headers from your - reverse proxy at address $ip, you will need to whitelist it as documented - in `Trusting Proxies - `_. - - If you would be running Varnish in front of your application on the same machine:: - - use Symfony\Component\HttpFoundation\Request; - - Request::setTrustedProxies(array('127.0.0.1', '::1')); - $app->run(); - -This provider allows you to use the Symfony reverse proxy natively with -Silex applications by using the ``http_cache`` service. The Symfony reverse proxy -acts much like any other proxy would, so you will want to whitelist it:: - - use Symfony\Component\HttpFoundation\Request; - - Request::setTrustedProxies(array('127.0.0.1')); - $app['http_cache']->run(); - -The provider also provides ESI support:: - - $app->get('/', function() { - $response = new Response(<< - - Hello - - - - - EOF - , 200, array( - 'Surrogate-Control' => 'content="ESI/1.0"', - )); - - $response->setTtl(20); - - return $response; - }); - - $app->get('/included', function() { - $response = new Response('Foo'); - $response->setTtl(5); - - return $response; - }); - - $app['http_cache']->run(); - -If your application doesn't use ESI, you can disable it to slightly improve the -overall performance:: - - $app->register(new Silex\Provider\HttpCacheServiceProvider(), array( - 'http_cache.cache_dir' => __DIR__.'/cache/', - 'http_cache.esi' => null, - )); - -.. tip:: - - To help you debug caching issues, set your application ``debug`` to true. - Symfony automatically adds a ``X-Symfony-Cache`` header to each response - with useful information about cache hits and misses. - - If you are *not* using the Symfony Session provider, you might want to set - the PHP ``session.cache_limiter`` setting to an empty value to avoid the - default PHP behavior. - - Finally, check that your Web server does not override your caching strategy. - -For more information, consult the `Symfony HTTP Cache documentation -`_. diff --git a/lib/silex/vendor/silex/silex/doc/providers/http_fragment.rst b/lib/silex/vendor/silex/silex/doc/providers/http_fragment.rst deleted file mode 100644 index 8e681853a..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/http_fragment.rst +++ /dev/null @@ -1,70 +0,0 @@ -HTTP Fragment -============= - -The *HttpFragmentServiceProvider* provides support for the Symfony fragment -sub-framework, which allows you to embed fragments of HTML in a template. - -Parameters ----------- - -* **fragment.path**: The path to use for the URL generated for ESI and - HInclude URLs (``/_fragment`` by default). - -* **uri_signer.secret**: The secret to use for the URI signer service (used - for the HInclude renderer). - -* **fragment.renderers.hinclude.global_template**: The content or Twig - template to use for the default content when using the HInclude renderer. - -Services --------- - -* **fragment.handler**: An instance of `FragmentHandler - `_. - -* **fragment.renderers**: An array of fragment renderers (by default, the - inline, ESI, and HInclude renderers are pre-configured). - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\HttpFragmentServiceProvider()); - -Usage ------ - -.. note:: - - This section assumes that you are using Twig for your templates. - -Instead of building a page out of a single request/controller/template, the -fragment framework allows you to build a page from several -controllers/sub-requests/sub-templates by using **fragments**. - -Including "sub-pages" in the main page can be done with the Twig ``render()`` -function: - -.. code-block:: jinja - - The main page content. - - {{ render('/foo') }} - - The main page content resumes here. - -The ``render()`` call is replaced by the content of the ``/foo`` URL -(internally, a sub-request is handled by Silex to render the sub-page). - -Instead of making internal sub-requests, you can also use the ESI (the -sub-request is handled by a reverse proxy) or the HInclude strategies (the -sub-request is handled by a web browser): - -.. code-block:: jinja - - {{ render(url('route_name')) }} - - {{ render_esi(url('route_name')) }} - - {{ render_hinclude(url('route_name')) }} diff --git a/lib/silex/vendor/silex/silex/doc/providers/index.rst b/lib/silex/vendor/silex/silex/doc/providers/index.rst deleted file mode 100644 index 8c5a17547..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -Built-in Service Providers -========================== - -.. toctree:: - :maxdepth: 1 - - twig - asset - monolog - session - swiftmailer - locale - translation - validator - form - csrf - http_cache - http_fragment - security - remember_me - serializer - service_controller - var_dumper - doctrine diff --git a/lib/silex/vendor/silex/silex/doc/providers/locale.rst b/lib/silex/vendor/silex/silex/doc/providers/locale.rst deleted file mode 100644 index 8f6cd675f..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/locale.rst +++ /dev/null @@ -1,24 +0,0 @@ -Locale -====== - -The *LocaleServiceProvider* manages the locale of an application. - -Parameters ----------- - -* **locale**: The locale of the user. When set before any request handling, it - defines the default locale (``en`` by default). When a request is being - handled, it is automatically set according to the ``_locale`` request - attribute of the current route. - -Services --------- - -* n/a - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\LocaleServiceProvider()); diff --git a/lib/silex/vendor/silex/silex/doc/providers/monolog.rst b/lib/silex/vendor/silex/silex/doc/providers/monolog.rst deleted file mode 100644 index 645b71061..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/monolog.rst +++ /dev/null @@ -1,115 +0,0 @@ -Monolog -======= - -The *MonologServiceProvider* provides a default logging mechanism through -Jordi Boggiano's `Monolog `_ library. - -It will log requests and errors and allow you to add logging to your -application. This allows you to debug and monitor the behaviour, -even in production. - -Parameters ----------- - -* **monolog.logfile**: File where logs are written to. -* **monolog.bubble**: (optional) Whether the messages that are handled can bubble up the stack or not. -* **monolog.permission**: (optional) File permissions default (null), nothing change. - -* **monolog.level** (optional): Level of logging, defaults - to ``DEBUG``. Must be one of ``Logger::DEBUG``, ``Logger::INFO``, - ``Logger::WARNING``, ``Logger::ERROR``. ``DEBUG`` will log - everything, ``INFO`` will log everything except ``DEBUG``, - etc. - - In addition to the ``Logger::`` constants, it is also possible to supply the - level in string form, for example: ``"DEBUG"``, ``"INFO"``, ``"WARNING"``, - ``"ERROR"``. - -* **monolog.name** (optional): Name of the monolog channel, - defaults to ``myapp``. - -* **monolog.exception.logger_filter** (optional): An anonymous function that - returns an error level for on uncaught exception that should be logged. - -* **monolog.use_error_handler** (optional): Whether errors and uncaught exceptions - should be handled by the Monolog ``ErrorHandler`` class and added to the log. - By default the error handler is enabled unless the application ``debug`` parameter - is set to true. - - Please note that enabling the error handler may silence some errors, - ignoring the PHP ``display_errors`` configuration setting. - -Services --------- - -* **monolog**: The monolog logger instance. - - Example usage:: - - $app['monolog']->debug('Testing the Monolog logging.'); - -* **monolog.listener**: An event listener to log requests, responses and errors. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\MonologServiceProvider(), array( - 'monolog.logfile' => __DIR__.'/development.log', - )); - -.. note:: - - Add Monolog as a dependency: - - .. code-block:: bash - - composer require monolog/monolog - -Usage ------ - -The MonologServiceProvider provides a ``monolog`` service. You can use it to -add log entries for any logging level through ``debug()``, ``info()``, -``warning()`` and ``error()``:: - - use Symfony\Component\HttpFoundation\Response; - - $app->post('/user', function () use ($app) { - // ... - - $app['monolog']->info(sprintf("User '%s' registered.", $username)); - - return new Response('', 201); - }); - -Customization -------------- - -You can configure Monolog (like adding or changing the handlers) before using -it by extending the ``monolog`` service:: - - $app->extend('monolog', function($monolog, $app) { - $monolog->pushHandler(...); - - return $monolog; - }); - -By default, all requests, responses and errors are logged by an event listener -registered as a service called `monolog.listener`. You can replace or remove -this service if you want to modify or disable the logged information. - -Traits ------- - -``Silex\Application\MonologTrait`` adds the following shortcuts: - -* **log**: Logs a message. - -.. code-block:: php - - $app->log(sprintf("User '%s' registered.", $username)); - -For more information, check out the `Monolog documentation -`_. diff --git a/lib/silex/vendor/silex/silex/doc/providers/remember_me.rst b/lib/silex/vendor/silex/silex/doc/providers/remember_me.rst deleted file mode 100644 index 7fdaaabad..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/remember_me.rst +++ /dev/null @@ -1,69 +0,0 @@ -Remember Me -=========== - -The *RememberMeServiceProvider* adds "Remember-Me" authentication to the -*SecurityServiceProvider*. - -Parameters ----------- - -n/a - -Services --------- - -n/a - -.. note:: - - The service provider defines many other services that are used internally - but rarely need to be customized. - -Registering ------------ - -Before registering this service provider, you must register the -*SecurityServiceProvider*:: - - $app->register(new Silex\Provider\SecurityServiceProvider()); - $app->register(new Silex\Provider\RememberMeServiceProvider()); - - $app['security.firewalls'] = array( - 'my-firewall' => array( - 'pattern' => '^/secure$', - 'form' => true, - 'logout' => true, - 'remember_me' => array( - 'key' => 'Choose_A_Unique_Random_Key', - 'always_remember_me' => true, - /* Other options */ - ), - 'users' => array( /* ... */ ), - ), - ); - -Options -------- - -* **key**: A secret key to generate tokens (you should generate a random - string). - -* **name**: Cookie name (default: ``REMEMBERME``). - -* **lifetime**: Cookie lifetime (default: ``31536000`` ~ 1 year). - -* **path**: Cookie path (default: ``/``). - -* **domain**: Cookie domain (default: ``null`` = request domain). - -* **secure**: Cookie is secure (default: ``false``). - -* **httponly**: Cookie is HTTP only (default: ``true``). - -* **always_remember_me**: Enable remember me (default: ``false``). - -* **remember_me_parameter**: Name of the request parameter enabling remember_me - on login. To add the checkbox to the login form. You can find more - information in the `Symfony cookbook - `_ - (default: ``_remember_me``). diff --git a/lib/silex/vendor/silex/silex/doc/providers/security.rst b/lib/silex/vendor/silex/silex/doc/providers/security.rst deleted file mode 100644 index 37ae0504e..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/security.rst +++ /dev/null @@ -1,709 +0,0 @@ -Security -======== - -The *SecurityServiceProvider* manages authentication and authorization for -your applications. - -Parameters ----------- - -* **security.hide_user_not_found** (optional): Defines whether to hide user not - found exception or not. Defaults to ``true``. - -* **security.encoder.bcrypt.cost** (optional): Defines BCrypt password encoder cost. Defaults to 13. - -Services --------- - -* **security.token_storage**: Gives access to the user token. - -* **security.authorization_checker**: Allows to check authorizations for the - users. - -* **security.authentication_manager**: An instance of - `AuthenticationProviderManager - `_, - responsible for authentication. - -* **security.access_manager**: An instance of `AccessDecisionManager - `_, - responsible for authorization. - -* **security.session_strategy**: Define the session strategy used for - authentication (default to a migration strategy). - -* **security.user_checker**: Checks user flags after authentication. - -* **security.last_error**: Returns the last authentication errors when given a - Request object. - -* **security.encoder_factory**: Defines the encoding strategies for user - passwords (uses ``security.default_encoder``). - -* **security.default_encoder**: The encoder to use by default for all users (BCrypt). - -* **security.encoder.digest**: Digest password encoder. - -* **security.encoder.bcrypt**: BCrypt password encoder. - -* **security.encoder.pbkdf2**: Pbkdf2 password encoder. - -* **user**: Returns the current user - -.. note:: - - The service provider defines many other services that are used internally - but rarely need to be customized. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\SecurityServiceProvider(), array( - 'security.firewalls' => // see below - )); - -.. note:: - - Add the Symfony Security Component as a dependency: - - .. code-block:: bash - - composer require symfony/security - -.. caution:: - - If you're using a form to authenticate users, you need to enable - ``SessionServiceProvider``. - -.. caution:: - - The security features are only available after the Application has been - booted. So, if you want to use it outside of the handling of a request, - don't forget to call ``boot()`` first:: - - $app->boot(); - -Usage ------ - -The Symfony Security component is powerful. To learn more about it, read the -`Symfony Security documentation -`_. - -.. tip:: - - When a security configuration does not behave as expected, enable logging - (with the Monolog extension for instance) as the Security Component logs a - lot of interesting information about what it does and why. - -Below is a list of recipes that cover some common use cases. - -Accessing the current User -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The current user information is stored in a token that is accessible via the -``security`` service:: - - $token = $app['security.token_storage']->getToken(); - -If there is no information about the user, the token is ``null``. If the user -is known, you can get it with a call to ``getUser()``:: - - if (null !== $token) { - $user = $token->getUser(); - } - -The user can be a string, an object with a ``__toString()`` method, or an -instance of `UserInterface -`_. - -Securing a Path with HTTP Authentication -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The following configuration uses HTTP basic authentication to secure URLs -under ``/admin/``:: - - $app['security.firewalls'] = array( - 'admin' => array( - 'pattern' => '^/admin', - 'http' => true, - 'users' => array( - // raw password is foo - 'admin' => array('ROLE_ADMIN', '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a'), - ), - ), - ); - -The ``pattern`` is a regular expression on the URL path; the ``http`` setting -tells the security layer to use HTTP basic authentication and the ``users`` -entry defines valid users. - -If you want to restrict the firewall by more than the URL pattern (like the -HTTP method, the client IP, the hostname, or any Request attributes), use an -instance of a `RequestMatcher -`_ -for the ``pattern`` option:: - - use Symfony\Component\HttpFoundation\RequestMatcher; - - $app['security.firewalls'] = array( - 'admin' => array( - 'pattern' => new RequestMatcher('^/admin', 'example.com', 'POST'), - // ... - ), - ); - -Each user is defined with the following information: - -* The role or an array of roles for the user (roles are strings beginning with - ``ROLE_`` and ending with anything you want); - -* The user encoded password. - -.. caution:: - - All users must at least have one role associated with them. - -The default configuration of the extension enforces encoded passwords. To -generate a valid encoded password from a raw password, use the -``security.encoder_factory`` service:: - - // find the encoder for a UserInterface instance - $encoder = $app['security.encoder_factory']->getEncoder($user); - - // compute the encoded password for foo - $password = $encoder->encodePassword('foo', $user->getSalt()); - -When the user is authenticated, the user stored in the token is an instance of -`User -`_ - -.. caution:: - - If you are using php-cgi under Apache, you need to add this configuration - to make things work correctly: - - .. code-block:: apache - - RewriteEngine On - RewriteCond %{HTTP:Authorization} ^(.+)$ - RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ app.php [QSA,L] - -Securing a Path with a Form -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Using a form to authenticate users is very similar to the above configuration. -Instead of using the ``http`` setting, use the ``form`` one and define these -two parameters: - -* **login_path**: The login path where the user is redirected when they are - accessing a secured area without being authenticated so that they can enter - their credentials; - -* **check_path**: The check URL used by Symfony to validate the credentials of - the user. - -Here is how to secure all URLs under ``/admin/`` with a form:: - - $app['security.firewalls'] = array( - 'admin' => array( - 'pattern' => '^/admin/', - 'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), - 'users' => array( - 'admin' => array('ROLE_ADMIN', '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a'), - ), - ), - ); - -Always keep in mind the following two golden rules: - -* The ``login_path`` path must always be defined **outside** the secured area - (or if it is in the secured area, the ``anonymous`` authentication mechanism - must be enabled -- see below); - -* The ``check_path`` path must always be defined **inside** the secured area. - -For the login form to work, create a controller like the following:: - - use Symfony\Component\HttpFoundation\Request; - - $app->get('/login', function(Request $request) use ($app) { - return $app['twig']->render('login.html', array( - 'error' => $app['security.last_error']($request), - 'last_username' => $app['session']->get('_security.last_username'), - )); - }); - -The ``error`` and ``last_username`` variables contain the last authentication -error and the last username entered by the user in case of an authentication -error. - -Create the associated template: - -.. code-block:: jinja - -
- {{ error }} - - - -
- -.. note:: - - The ``admin_login_check`` route is automatically defined by Silex and its - name is derived from the ``check_path`` value (all ``/`` are replaced with - ``_`` and the leading ``/`` is stripped). - -Defining more than one Firewall -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You are not limited to define one firewall per project. - -Configuring several firewalls is useful when you want to secure different -parts of your website with different authentication strategies or for -different users (like using an HTTP basic authentication for the website API -and a form to secure your website administration area). - -It's also useful when you want to secure all URLs except the login form:: - - $app['security.firewalls'] = array( - 'login' => array( - 'pattern' => '^/login$', - ), - 'secured' => array( - 'pattern' => '^.*$', - 'form' => array('login_path' => '/login', 'check_path' => '/login_check'), - 'users' => array( - 'admin' => array('ROLE_ADMIN', '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a'), - ), - ), - ); - -The order of the firewall configurations is significant as the first one to -match wins. The above configuration first ensures that the ``/login`` URL is -not secured (no authentication settings), and then it secures all other URLs. - -.. tip:: - - You can toggle all registered authentication mechanisms for a particular - area on and off with the ``security`` flag:: - - $app['security.firewalls'] = array( - 'api' => array( - 'pattern' => '^/api', - 'security' => $app['debug'] ? false : true, - 'wsse' => true, - - // ... - ), - ); - -Adding a Logout -~~~~~~~~~~~~~~~ - -When using a form for authentication, you can let users log out if you add the -``logout`` setting, where ``logout_path`` must match the main firewall -pattern:: - - $app['security.firewalls'] = array( - 'secured' => array( - 'pattern' => '^/admin/', - 'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), - 'logout' => array('logout_path' => '/admin/logout', 'invalidate_session' => true), - - // ... - ), - ); - -A route is automatically generated, based on the configured path (all ``/`` -are replaced with ``_`` and the leading ``/`` is stripped): - -.. code-block:: jinja - - Logout - -Allowing Anonymous Users -~~~~~~~~~~~~~~~~~~~~~~~~ - -When securing only some parts of your website, the user information are not -available in non-secured areas. To make the user accessible in such areas, -enabled the ``anonymous`` authentication mechanism:: - - $app['security.firewalls'] = array( - 'unsecured' => array( - 'anonymous' => true, - - // ... - ), - ); - -When enabling the anonymous setting, a user will always be accessible from the -security context; if the user is not authenticated, it returns the ``anon.`` -string. - -Checking User Roles -~~~~~~~~~~~~~~~~~~~ - -To check if a user is granted some role, use the ``isGranted()`` method on the -security context:: - - if ($app['security.authorization_checker']->isGranted('ROLE_ADMIN')) { - // ... - } - -You can check roles in Twig templates too: - -.. code-block:: jinja - - {% if is_granted('ROLE_ADMIN') %} - Switch to Fabien - {% endif %} - -You can check if a user is "fully authenticated" (not an anonymous user for -instance) with the special ``IS_AUTHENTICATED_FULLY`` role: - -.. code-block:: jinja - - {% if is_granted('IS_AUTHENTICATED_FULLY') %} - Logout - {% else %} - Login - {% endif %} - -Of course you will need to define a ``login`` route for this to work. - -.. tip:: - - Don't use the ``getRoles()`` method to check user roles. - -.. caution:: - - ``isGranted()`` throws an exception when no authentication information is - available (which is the case on non-secured area). - -Impersonating a User -~~~~~~~~~~~~~~~~~~~~ - -If you want to be able to switch to another user (without knowing the user -credentials), enable the ``switch_user`` authentication strategy:: - - $app['security.firewalls'] = array( - 'unsecured' => array( - 'switch_user' => array('parameter' => '_switch_user', 'role' => 'ROLE_ALLOWED_TO_SWITCH'), - - // ... - ), - ); - -Switching to another user is now a matter of adding the ``_switch_user`` query -parameter to any URL when logged in as a user who has the -``ROLE_ALLOWED_TO_SWITCH`` role: - -.. code-block:: jinja - - {% if is_granted('ROLE_ALLOWED_TO_SWITCH') %} - Switch to user Fabien - {% endif %} - -You can check that you are impersonating a user by checking the special -``ROLE_PREVIOUS_ADMIN``. This is useful for instance to allow the user to -switch back to their primary account: - -.. code-block:: jinja - - {% if is_granted('ROLE_PREVIOUS_ADMIN') %} - You are an admin but you've switched to another user, - exit the switch. - {% endif %} - -Defining a Role Hierarchy -~~~~~~~~~~~~~~~~~~~~~~~~~ - -Defining a role hierarchy allows to automatically grant users some additional -roles:: - - $app['security.role_hierarchy'] = array( - 'ROLE_ADMIN' => array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'), - ); - -With this configuration, all users with the ``ROLE_ADMIN`` role also -automatically have the ``ROLE_USER`` and ``ROLE_ALLOWED_TO_SWITCH`` roles. - -Defining Access Rules -~~~~~~~~~~~~~~~~~~~~~ - -Roles are a great way to adapt the behavior of your website depending on -groups of users, but they can also be used to further secure some areas by -defining access rules:: - - $app['security.access_rules'] = array( - array('^/admin', 'ROLE_ADMIN', 'https'), - array('^.*$', 'ROLE_USER'), - ); - -With the above configuration, users must have the ``ROLE_ADMIN`` to access the -``/admin`` section of the website, and ``ROLE_USER`` for everything else. -Furthermore, the admin section can only be accessible via HTTPS (if that's not -the case, the user will be automatically redirected). - -.. note:: - - The first argument can also be a `RequestMatcher - `_ - instance. - -Defining a custom User Provider -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Using an array of users is simple and useful when securing an admin section of -a personal website, but you can override this default mechanism with you own. - -The ``users`` setting can be defined as a service that returns an instance of -`UserProviderInterface -`_:: - - 'users' => function () use ($app) { - return new UserProvider($app['db']); - }, - -Here is a simple example of a user provider, where Doctrine DBAL is used to -store the users:: - - use Symfony\Component\Security\Core\User\UserProviderInterface; - use Symfony\Component\Security\Core\User\UserInterface; - use Symfony\Component\Security\Core\User\User; - use Symfony\Component\Security\Core\Exception\UnsupportedUserException; - use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; - use Doctrine\DBAL\Connection; - - class UserProvider implements UserProviderInterface - { - private $conn; - - public function __construct(Connection $conn) - { - $this->conn = $conn; - } - - public function loadUserByUsername($username) - { - $stmt = $this->conn->executeQuery('SELECT * FROM users WHERE username = ?', array(strtolower($username))); - - if (!$user = $stmt->fetch()) { - throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); - } - - return new User($user['username'], $user['password'], explode(',', $user['roles']), true, true, true, true); - } - - public function refreshUser(UserInterface $user) - { - if (!$user instanceof User) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); - } - - return $this->loadUserByUsername($user->getUsername()); - } - - public function supportsClass($class) - { - return $class === 'Symfony\Component\Security\Core\User\User'; - } - } - -In this example, instances of the default ``User`` class are created for the -users, but you can define your own class; the only requirement is that the -class must implement `UserInterface -`_ - -And here is the code that you can use to create the database schema and some -sample users:: - - use Doctrine\DBAL\Schema\Table; - - $schema = $app['db']->getSchemaManager(); - if (!$schema->tablesExist('users')) { - $users = new Table('users'); - $users->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true)); - $users->setPrimaryKey(array('id')); - $users->addColumn('username', 'string', array('length' => 32)); - $users->addUniqueIndex(array('username')); - $users->addColumn('password', 'string', array('length' => 255)); - $users->addColumn('roles', 'string', array('length' => 255)); - - $schema->createTable($users); - - $app['db']->insert('users', array( - 'username' => 'fabien', - 'password' => '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a', - 'roles' => 'ROLE_USER' - )); - - $app['db']->insert('users', array( - 'username' => 'admin', - 'password' => '$2y$10$3i9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a', - 'roles' => 'ROLE_ADMIN' - )); - } - -.. tip:: - - If you are using the Doctrine ORM, the Symfony bridge for Doctrine - provides a user provider class that is able to load users from your - entities. - -Defining a custom Encoder -~~~~~~~~~~~~~~~~~~~~~~~~~ - -By default, Silex uses the ``BCrypt`` algorithm to encode passwords. -Additionally, the password is encoded multiple times. -You can change these defaults by overriding ``security.default_encoder`` -service to return one of the predefined encoders: - -* **security.encoder.digest**: Digest password encoder. - -* **security.encoder.bcrypt**: BCrypt password encoder. - -* **security.encoder.pbkdf2**: Pbkdf2 password encoder. - -.. code-block:: php - - $app['security.default_encoder'] = function ($app) { - return $app['security.encoder.pbkdf2']; - }; - -Or you can define you own, fully customizable encoder:: - - use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder; - - $app['security.default_encoder'] = function ($app) { - // Plain text (e.g. for debugging) - return new PlaintextPasswordEncoder(); - }; - -.. tip:: - - You can change the default BCrypt encoding cost by overriding ``security.encoder.bcrypt.cost`` - -Defining a custom Authentication Provider -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The Symfony Security component provides a lot of ready-to-use authentication -providers (form, HTTP, X509, remember me, ...), but you can add new ones -easily. To register a new authentication provider, create a service named -``security.authentication_listener.factory.XXX`` where ``XXX`` is the name you want to -use in your configuration:: - - $app['security.authentication_listener.factory.wsse'] = $app->protect(function ($name, $options) use ($app) { - // define the authentication provider object - $app['security.authentication_provider.'.$name.'.wsse'] = function () use ($app) { - return new WsseProvider($app['security.user_provider.default'], __DIR__.'/security_cache'); - }; - - // define the authentication listener object - $app['security.authentication_listener.'.$name.'.wsse'] = function () use ($app) { - return new WsseListener($app['security.token_storage'], $app['security.authentication_manager']); - }; - - return array( - // the authentication provider id - 'security.authentication_provider.'.$name.'.wsse', - // the authentication listener id - 'security.authentication_listener.'.$name.'.wsse', - // the entry point id - null, - // the position of the listener in the stack - 'pre_auth' - ); - }); - -You can now use it in your configuration like any other built-in -authentication provider:: - - $app->register(new Silex\Provider\SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'wsse' => true, - - // ... - ), - ), - )); - -Instead of ``true``, you can also define an array of options that customize -the behavior of your authentication factory; it will be passed as the second -argument of your authentication factory (see above). - -This example uses the authentication provider classes as described in the -Symfony `cookbook`_. - - -.. note:: - - The Guard component simplifies the creation of custom authentication - providers. :doc:`How to Create a Custom Authentication System with Guard - ` - -Stateless Authentication -~~~~~~~~~~~~~~~~~~~~~~~~ - -By default, a session cookie is created to persist the security context of -the user. However, if you use certificates, HTTP authentication, WSSE and so -on, the credentials are sent for each request. In that case, you can turn off -persistence by activating the ``stateless`` authentication flag:: - - $app['security.firewalls'] = array( - 'default' => array( - 'stateless' => true, - 'wsse' => true, - - // ... - ), - ); - -Traits ------- - -``Silex\Application\SecurityTrait`` adds the following shortcuts: - -* **encodePassword**: Encode a given password. - -.. code-block:: php - - $encoded = $app->encodePassword($app['user'], 'foo'); - -``Silex\Route\SecurityTrait`` adds the following methods to the controllers: - -* **secure**: Secures a controller for the given roles. - -.. code-block:: php - - $app->get('/', function () { - // do something but only for admins - })->secure('ROLE_ADMIN'); - -.. caution:: - - The ``Silex\Route\SecurityTrait`` must be used with a user defined - ``Route`` class, not the application. - - .. code-block:: php - - use Silex\Route; - - class MyRoute extends Route - { - use Route\SecurityTrait; - } - - .. code-block:: php - - $app['route_class'] = 'MyRoute'; - - -.. _cookbook: http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html diff --git a/lib/silex/vendor/silex/silex/doc/providers/serializer.rst b/lib/silex/vendor/silex/silex/doc/providers/serializer.rst deleted file mode 100644 index be5847de2..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/serializer.rst +++ /dev/null @@ -1,85 +0,0 @@ -Serializer -========== - -The *SerializerServiceProvider* provides a service for serializing objects. - -Parameters ----------- - -None. - -Services --------- - -* **serializer**: An instance of `Symfony\\Component\\Serializer\\Serializer - `_. - -* **serializer.encoders**: `Symfony\\Component\\Serializer\\Encoder\\JsonEncoder - `_ - and `Symfony\\Component\\Serializer\\Encoder\\XmlEncoder - `_. - -* **serializer.normalizers**: `Symfony\\Component\\Serializer\\Normalizer\\CustomNormalizer - `_ - and `Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer - `_. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\SerializerServiceProvider()); - -.. note:: - - Add the Symfony's `Serializer Component - `_ as a - dependency: - - .. code-block:: bash - - composer require symfony/serializer - -Usage ------ - -The ``SerializerServiceProvider`` provider provides a ``serializer`` service:: - - use Silex\Application; - use Silex\Provider\SerializerServiceProvider; - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpFoundation\Response; - - $app = new Application(); - - $app->register(new SerializerServiceProvider()); - - // only accept content types supported by the serializer via the assert method. - $app->get("/pages/{id}.{_format}", function (Request $request, $id) use ($app) { - // assume a page_repository service exists that returns Page objects. The - // object returned has getters and setters exposing the state. - $page = $app['page_repository']->find($id); - $format = $request->getRequestFormat(); - - if (!$page instanceof Page) { - $app->abort("No page found for id: $id"); - } - - return new Response($app['serializer']->serialize($page, $format), 200, array( - "Content-Type" => $request->getMimeType($format) - )); - })->assert("_format", "xml|json") - ->assert("id", "\d+"); - -Using a Cache -------------- - -To use a cache, register a class implementing ``Doctrine\Common\Cache\Cache``:: - - $app->register(new Silex\Provider\SerializerServiceProvider()); - $app['serializer.normalizers'] = function () use ($app) { - return [new \Symfony\Component\Serializer\Normalizer\CustomNormalizer(), - new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $app['my_custom_cache'])) - ]; - }; diff --git a/lib/silex/vendor/silex/silex/doc/providers/service_controller.rst b/lib/silex/vendor/silex/silex/doc/providers/service_controller.rst deleted file mode 100644 index 15bca28d1..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/service_controller.rst +++ /dev/null @@ -1,142 +0,0 @@ -Service Controllers -=================== - -As your Silex application grows, you may wish to begin organizing your -controllers in a more formal fashion. Silex can use controller classes out of -the box, but with a bit of work, your controllers can be created as services, -giving you the full power of dependency injection and lazy loading. - -.. ::todo Link above to controller classes cookbook - -Why would I want to do this? ----------------------------- - -- Dependency Injection over Service Location - - Using this method, you can inject the actual dependencies required by your - controller and gain total inversion of control, while still maintaining the - lazy loading of your controllers and its dependencies. Because your - dependencies are clearly defined, they are easily mocked, allowing you to test - your controllers in isolation. - -- Framework Independence - - Using this method, your controllers start to become more independent of the - framework you are using. Carefully crafted, your controllers will become - reusable with multiple frameworks. By keeping careful control of your - dependencies, your controllers could easily become compatible with Silex, - Symfony (full stack) and Drupal, to name just a few. - -Parameters ----------- - -There are currently no parameters for the ``ServiceControllerServiceProvider``. - -Services --------- - -There are no extra services provided, the ``ServiceControllerServiceProvider`` -simply extends the existing **resolver** service. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\ServiceControllerServiceProvider()); - -Usage ------ - -In this slightly contrived example of a blog API, we're going to change the -``/posts.json`` route to use a controller, that is defined as a service. - -.. code-block:: php - - use Silex\Application; - use Demo\Repository\PostRepository; - - $app = new Application(); - - $app['posts.repository'] = function() { - return new PostRepository; - }; - - $app->get('/posts.json', function() use ($app) { - return $app->json($app['posts.repository']->findAll()); - }); - -Rewriting your controller as a service is pretty simple, create a Plain Ol' PHP -Object with your ``PostRepository`` as a dependency, along with an -``indexJsonAction`` method to handle the request. Although not shown in the -example below, you can use type hinting and parameter naming to get the -parameters you need, just like with standard Silex routes. - -If you are a TDD/BDD fan (and you should be), you may notice that this -controller has well defined responsibilities and dependencies, and is easily -tested/specced. You may also notice that the only external dependency is on -``Symfony\Component\HttpFoundation\JsonResponse``, meaning this controller could -easily be used in a Symfony (full stack) application, or potentially with other -applications or frameworks that know how to handle a `Symfony/HttpFoundation -`_ -``Response`` object. - -.. code-block:: php - - namespace Demo\Controller; - - use Demo\Repository\PostRepository; - use Symfony\Component\HttpFoundation\JsonResponse; - - class PostController - { - protected $repo; - - public function __construct(PostRepository $repo) - { - $this->repo = $repo; - } - - public function indexJsonAction() - { - return new JsonResponse($this->repo->findAll()); - } - } - -And lastly, define your controller as a service in the application, along with -your route. The syntax in the route definition is the name of the service, -followed by a single colon (:), followed by the method name. - -.. code-block:: php - - $app['posts.controller'] = function() use ($app) { - return new PostController($app['posts.repository']); - }; - - $app->get('/posts.json', "posts.controller:indexJsonAction"); - -In addition to using classes for service controllers, you can define any -callable as a service in the application to be used for a route. - -.. code-block:: php - - namespace Demo\Controller; - - use Demo\Repository\PostRepository; - use Symfony\Component\HttpFoundation\JsonResponse; - - function postIndexJson(PostRepository $repo) { - return function() use ($repo) { - return new JsonResponse($repo->findAll()); - }; - } - -And when defining your route, the code would look like the following: - -.. code-block:: php - - $app['posts.controller'] = function($app) { - return Demo\Controller\postIndexJson($app['posts.repository']); - }; - - $app->get('/posts.json', 'posts.controller'); diff --git a/lib/silex/vendor/silex/silex/doc/providers/session.rst b/lib/silex/vendor/silex/silex/doc/providers/session.rst deleted file mode 100644 index 011b69feb..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/session.rst +++ /dev/null @@ -1,120 +0,0 @@ -Session -======= - -The *SessionServiceProvider* provides a service for storing data persistently -between requests. - -Parameters ----------- - -* **session.storage.save_path** (optional): The path for the - ``NativeFileSessionHandler``, defaults to the value of - ``sys_get_temp_dir()``. - -* **session.storage.options**: An array of options that is passed to the - constructor of the ``session.storage`` service. - - In case of the default `NativeSessionStorage - `_, - the most useful options are: - - * **name**: The cookie name (_SESS by default) - * **id**: The session id (null by default) - * **cookie_lifetime**: Cookie lifetime - * **cookie_path**: Cookie path - * **cookie_domain**: Cookie domain - * **cookie_secure**: Cookie secure (HTTPS) - * **cookie_httponly**: Whether the cookie is http only - - However, all of these are optional. Default Sessions life time is 1800 - seconds (30 minutes). To override this, set the ``lifetime`` option. - - For a full list of available options, read the `PHP - `_ official documentation. - -* **session.test**: Whether to simulate sessions or not (useful when writing - functional tests). - -Services --------- - -* **session**: An instance of Symfony's `Session - `_. - -* **session.storage**: A service that is used for persistence of the session - data. - -* **session.storage.handler**: A service that is used by the - ``session.storage`` for data access. Defaults to a `NativeFileSessionHandler - `_ - storage handler. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\SessionServiceProvider()); - -Using Handlers --------------- - -The default session handler is ``NativeFileSessionHandler``. However, there are -multiple handlers available for use by setting ``session.storage.handler`` to -an instance of one of the following handler objects: - -* `LegacyPdoSessionHandler `_ -* `MemcacheSessionHandler `_ -* `MemcachedSessionHandler `_ -* `MongoDbSessionHandler `_ -* `NativeFileSessionHandler `_ -* `NativeSessionHandler `_ -* `NullSessionHandler `_ -* `PdoSessionHandler `_ -* `WriteCheckSessionHandler `_ - -Usage ------ - -The Session provider provides a ``session`` service. Here is an example that -authenticates a user and creates a session for them:: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpFoundation\Response; - - $app->get('/login', function (Request $request) use ($app) { - $username = $request->server->get('PHP_AUTH_USER', false); - $password = $request->server->get('PHP_AUTH_PW'); - - if ('igor' === $username && 'password' === $password) { - $app['session']->set('user', array('username' => $username)); - return $app->redirect('/account'); - } - - $response = new Response(); - $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', 'site_login')); - $response->setStatusCode(401, 'Please sign in.'); - return $response; - }); - - $app->get('/account', function () use ($app) { - if (null === $user = $app['session']->get('user')) { - return $app->redirect('/login'); - } - - return "Welcome {$user['username']}!"; - }); - - -Custom Session Configurations ------------------------------ - -If your system is using a custom session configuration (such as a redis handler -from a PHP extension) then you need to disable the NativeFileSessionHandler by -setting ``session.storage.handler`` to null. You will have to configure the -``session.save_path`` ini setting yourself in that case. - -.. code-block:: php - - $app['session.storage.handler'] = null; - diff --git a/lib/silex/vendor/silex/silex/doc/providers/swiftmailer.rst b/lib/silex/vendor/silex/silex/doc/providers/swiftmailer.rst deleted file mode 100644 index 9297d665b..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/swiftmailer.rst +++ /dev/null @@ -1,156 +0,0 @@ -Swiftmailer -=========== - -The *SwiftmailerServiceProvider* provides a service for sending email through -the `Swift Mailer `_ library. - -You can use the ``mailer`` service to send messages easily. By default, it -will attempt to send emails through SMTP. - -Parameters ----------- - -* **swiftmailer.use_spool**: A boolean to specify whether or not to use the - memory spool, defaults to true. - -* **swiftmailer.options**: An array of options for the default SMTP-based - configuration. - - The following options can be set: - - * **host**: SMTP hostname, defaults to 'localhost'. - * **port**: SMTP port, defaults to 25. - * **username**: SMTP username, defaults to an empty string. - * **password**: SMTP password, defaults to an empty string. - * **encryption**: SMTP encryption, defaults to null. Valid values are 'tls', 'ssl', or null (indicating no encryption). - * **auth_mode**: SMTP authentication mode, defaults to null. Valid values are 'plain', 'login', 'cram-md5', or null. - - Example usage:: - - $app['swiftmailer.options'] = array( - 'host' => 'host', - 'port' => '25', - 'username' => 'username', - 'password' => 'password', - 'encryption' => null, - 'auth_mode' => null - ); - -* **swiftmailer.sender_address**: If set, all messages will be delivered with - this address as the "return path" address. - -* **swiftmailer.delivery_addresses**: If not empty, all email messages will be - sent to those addresses instead of being sent to their actual recipients. This - is often useful when developing. - -* **swiftmailer.delivery_whitelist**: Used in combination with - ``delivery_addresses``. If set, emails matching any of these patterns will be - delivered like normal, as well as being sent to ``delivery_addresses``. - -* **swiftmailer.plugins**: Array of SwiftMailer plugins. - - Example usage:: - - $app['swiftmailer.plugins'] = function ($app) { - return array( - new \Swift_Plugins_PopBeforeSmtpPlugin('pop3.example.com'), - ); - }; - -Services --------- - -* **mailer**: The mailer instance. - - Example usage:: - - $message = \Swift_Message::newInstance(); - - // ... - - $app['mailer']->send($message); - -* **swiftmailer.transport**: The transport used for e-mail - delivery. Defaults to a ``Swift_Transport_EsmtpTransport``. - -* **swiftmailer.transport.buffer**: StreamBuffer used by - the transport. - -* **swiftmailer.transport.authhandler**: Authentication - handler used by the transport. Will try the following - by default: CRAM-MD5, login, plaintext. - -* **swiftmailer.transport.eventdispatcher**: Internal event - dispatcher used by Swiftmailer. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\SwiftmailerServiceProvider()); - -.. note:: - - Add SwiftMailer as a dependency: - - .. code-block:: bash - - composer require swiftmailer/swiftmailer - -Usage ------ - -The Swiftmailer provider provides a ``mailer`` service:: - - use Symfony\Component\HttpFoundation\Request; - - $app->post('/feedback', function (Request $request) use ($app) { - $message = \Swift_Message::newInstance() - ->setSubject('[YourSite] Feedback') - ->setFrom(array('noreply@yoursite.com')) - ->setTo(array('feedback@yoursite.com')) - ->setBody($request->get('message')); - - $app['mailer']->send($message); - - return new Response('Thank you for your feedback!', 201); - }); - -Usage in commands -~~~~~~~~~~~~~~~~~ - -By default, the Swiftmailer provider sends the emails using the ``KernelEvents::TERMINATE`` -event, which is fired after the response has been sent. However, as this event -isn't fired for console commands, your emails won't be sent. - -For that reason, if you send emails using a command console, it is recommended -that you disable the use of the memory spool (before accessing ``$app['mailer']``):: - - $app['swiftmailer.use_spool'] = false; - -Alternatively, you can just make sure to flush the message spool by hand before -ending the command execution. To do so, use the following code:: - - $app['swiftmailer.spooltransport'] - ->getSpool() - ->flushQueue($app['swiftmailer.transport']) - ; - -Traits ------- - -``Silex\Application\SwiftmailerTrait`` adds the following shortcuts: - -* **mail**: Sends an email. - -.. code-block:: php - - $app->mail(\Swift_Message::newInstance() - ->setSubject('[YourSite] Feedback') - ->setFrom(array('noreply@yoursite.com')) - ->setTo(array('feedback@yoursite.com')) - ->setBody($request->get('message'))); - -For more information, check out the `Swift Mailer documentation -`_. diff --git a/lib/silex/vendor/silex/silex/doc/providers/translation.rst b/lib/silex/vendor/silex/silex/doc/providers/translation.rst deleted file mode 100644 index 145fc18c6..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/translation.rst +++ /dev/null @@ -1,193 +0,0 @@ -Translation -=========== - -The *TranslationServiceProvider* provides a service for translating your -application into different languages. - -Parameters ----------- - -* **translator.domains** (optional): A mapping of domains/locales/messages. - This parameter contains the translation data for all languages and domains. - -* **locale** (optional): The locale for the translator. You will most likely - want to set this based on some request parameter. Defaults to ``en``. - -* **locale_fallbacks** (optional): Fallback locales for the translator. It will - be used when the current locale has no messages set. Defaults to ``en``. - -Services --------- - -* **translator**: An instance of `Translator - `_, - that is used for translation. - -* **translator.loader**: An instance of an implementation of the translation - `LoaderInterface - `_, - defaults to an `ArrayLoader - `_. - -* **translator.message_selector**: An instance of `MessageSelector - `_. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\LocaleServiceProvider()); - $app->register(new Silex\Provider\TranslationServiceProvider(), array( - 'locale_fallbacks' => array('en'), - )); - -.. note:: - - Add the Symfony Translation Component as a dependency: - - .. code-block:: bash - - composer require symfony/translation - -Usage ------ - -The Translation provider provides a ``translator`` service and makes use of -the ``translator.domains`` parameter:: - - $app['translator.domains'] = array( - 'messages' => array( - 'en' => array( - 'hello' => 'Hello %name%', - 'goodbye' => 'Goodbye %name%', - ), - 'de' => array( - 'hello' => 'Hallo %name%', - 'goodbye' => 'Tschüss %name%', - ), - 'fr' => array( - 'hello' => 'Bonjour %name%', - 'goodbye' => 'Au revoir %name%', - ), - ), - 'validators' => array( - 'fr' => array( - 'This value should be a valid number.' => 'Cette valeur doit être un nombre.', - ), - ), - ); - - $app->get('/{_locale}/{message}/{name}', function ($message, $name) use ($app) { - return $app['translator']->trans($message, array('%name%' => $name)); - }); - -The above example will result in following routes: - -* ``/en/hello/igor`` will return ``Hello igor``. - -* ``/de/hello/igor`` will return ``Hallo igor``. - -* ``/fr/hello/igor`` will return ``Bonjour igor``. - -* ``/it/hello/igor`` will return ``Hello igor`` (because of the fallback). - -Using Resources ---------------- - -When translations are stored in a file, you can load them as follows:: - - $app = new Application(); - - $app->register(new TranslationServiceProvider()); - $app->extend('translator.resources', function ($resources, $app) { - $resources = array_merge($resources, array( - array('array', array('This value should be a valid number.' => 'Cette valeur doit être un nombre.'), 'fr', 'validators'), - )); - - return $resources; - }); - -Traits ------- - -``Silex\Application\TranslationTrait`` adds the following shortcuts: - -* **trans**: Translates the given message. - -* **transChoice**: Translates the given choice message by choosing a - translation according to a number. - -.. code-block:: php - - $app->trans('Hello World'); - - $app->transChoice('Hello World'); - -Recipes -------- - -YAML-based language files -~~~~~~~~~~~~~~~~~~~~~~~~~ - -Having your translations in PHP files can be inconvenient. This recipe will -show you how to load translations from external YAML files. - -First, add the Symfony ``Config`` and ``Yaml`` components as dependencies: - -.. code-block:: bash - - composer require symfony/config symfony/yaml - -Next, you have to create the language mappings in YAML files. A naming you can -use is ``locales/en.yml``. Just do the mapping in this file as follows: - -.. code-block:: yaml - - hello: Hello %name% - goodbye: Goodbye %name% - -Then, register the ``YamlFileLoader`` on the ``translator`` and add all your -translation files:: - - use Symfony\Component\Translation\Loader\YamlFileLoader; - - $app->extend('translator', function($translator, $app) { - $translator->addLoader('yaml', new YamlFileLoader()); - - $translator->addResource('yaml', __DIR__.'/locales/en.yml', 'en'); - $translator->addResource('yaml', __DIR__.'/locales/de.yml', 'de'); - $translator->addResource('yaml', __DIR__.'/locales/fr.yml', 'fr'); - - return $translator; - }); - -XLIFF-based language files -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Just as you would do with YAML translation files, you first need to add the -Symfony ``Config`` component as a dependency (see above for details). - -Then, similarly, create XLIFF files in your locales directory and add them to -the translator:: - - $translator->addResource('xliff', __DIR__.'/locales/en.xlf', 'en'); - $translator->addResource('xliff', __DIR__.'/locales/de.xlf', 'de'); - $translator->addResource('xliff', __DIR__.'/locales/fr.xlf', 'fr'); - -.. note:: - - The XLIFF loader is already pre-configured by the extension. - -Accessing translations in Twig templates -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Once loaded, the translation service provider is available from within Twig -templates when using the Twig bridge provided by Symfony (see -:doc:`TwigServiceProvider
`): - -.. code-block:: jinja - - {{ 'translation_key'|trans }} - {{ 'translation_key'|transchoice }} - {% trans %}translation_key{% endtrans %} diff --git a/lib/silex/vendor/silex/silex/doc/providers/twig.rst b/lib/silex/vendor/silex/silex/doc/providers/twig.rst deleted file mode 100644 index b713e1a35..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/twig.rst +++ /dev/null @@ -1,237 +0,0 @@ -Twig -==== - -The *TwigServiceProvider* provides integration with the `Twig -`_ template engine. - -Parameters ----------- - -* **twig.path** (optional): Path to the directory containing twig template - files (it can also be an array of paths). - -* **twig.templates** (optional): An associative array of template names to - template contents. Use this if you want to define your templates inline. - -* **twig.options** (optional): An associative array of twig - options. Check out the `twig documentation `_ - for more information. - -* **twig.form.templates** (optional): An array of templates used to render - forms (only available when the ``FormServiceProvider`` is enabled). The - default theme is ``form_div_layout.html.twig``, but you can use the other - built-in themes: ``form_table_layout.html.twig``, - ``bootstrap_3_layout.html.twig``, and - ``bootstrap_3_horizontal_layout.html.twig``. - -* **twig.date.format** (optional): Default format used by the ``date`` - filter. The format string must conform to the format accepted by - `date() `_. - -* **twig.date.interval_format** (optional): Default format used by the - ``date`` filter when the filtered data is of type `DateInterval `_. - The format string must conform to the format accepted by - `DateInterval::format() `_. - -* **twig.date.timezone** (optional): Default timezone used when formatting - dates. If set to ``null`` the timezone returned by `date_default_timezone_get() `_ - is used. - -* **twig.number_format.decimals** (optional): Default number of decimals - displayed by the ``number_format`` filter. - -* **twig.number_format.decimal_point** (optional): Default separator for - the decimal point used by the ``number_format`` filter. - -* **twig.number_format.thousands_separator** (optional): Default thousands - separator used by the ``number_format`` filter. - -Services --------- - -* **twig**: The ``Twig_Environment`` instance. The main way of - interacting with Twig. - -* **twig.loader**: The loader for Twig templates which uses the ``twig.path`` - and the ``twig.templates`` options. You can also replace the loader - completely. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\TwigServiceProvider(), array( - 'twig.path' => __DIR__.'/views', - )); - -.. note:: - - Add Twig as a dependency: - - .. code-block:: bash - - composer require twig/twig - -Usage ------ - -The Twig provider provides a ``twig`` service that can render templates:: - - $app->get('/hello/{name}', function ($name) use ($app) { - return $app['twig']->render('hello.twig', array( - 'name' => $name, - )); - }); - -Symfony Components Integration ------------------------------- - -Symfony provides a Twig bridge that provides additional integration between -some Symfony components and Twig. Add it as a dependency: - -.. code-block:: bash - - composer require symfony/twig-bridge - -When present, the ``TwigServiceProvider`` will provide you with the following -additional capabilities. - -* Access to the ``path()`` and ``url()`` functions. You can find more - information in the `Symfony Routing documentation - `_: - - .. code-block:: jinja - - {{ path('homepage') }} - {{ url('homepage') }} {# generates the absolute url http://example.org/ #} - {{ path('hello', {name: 'Fabien'}) }} - {{ url('hello', {name: 'Fabien'}) }} {# generates the absolute url http://example.org/hello/Fabien #} - -* Access to the ``absolute_url()`` and ``relative_path()`` Twig functions. - -Translations Support -~~~~~~~~~~~~~~~~~~~~ - -If you are using the ``TranslationServiceProvider``, you will get the -``trans()`` and ``transchoice()`` functions for translation in Twig templates. -You can find more information in the `Symfony Translation documentation -`_. - -Form Support -~~~~~~~~~~~~ - -If you are using the ``FormServiceProvider``, you will get a set of helpers for -working with forms in templates. You can find more information in the `Symfony -Forms reference -`_. - -Security Support -~~~~~~~~~~~~~~~~ - -If you are using the ``SecurityServiceProvider``, you will have access to the -``is_granted()`` function in templates. You can find more information in the -`Symfony Security documentation -`_. - -Web Link Support -~~~~~~~~~~~~~~~~ - -If you are using the ``symfony/web-link`` component, you will have access to the -``preload()``, ``prefetch()``, ``prerender()``, ``dns_prefetch()``, -``preconnect()`` and ``link()`` functions in templates. You can find more -information in the `Symfony WebLink documentation -`_. - -Global Variable -~~~~~~~~~~~~~~~ - -When the Twig bridge is available, the ``global`` variable refers to an -instance of `AppVariable `_. -It gives access to the following methods: - -.. code-block:: jinja - - {# The current Request #} - {{ global.request }} - - {# The current User (when security is enabled) #} - {{ global.user }} - - {# The current Session #} - {{ global.session }} - - {# The debug flag #} - {{ global.debug }} - -Rendering a Controller -~~~~~~~~~~~~~~~~~~~~~~ - -A ``render`` function is also registered to help you render another controller -from a template (available when the :doc:`HttpFragment Service Provider -
` is registered): - -.. code-block:: jinja - - {{ render(url('sidebar')) }} - - {# or you can reference a controller directly without defining a route for it #} - {{ render(controller(controller)) }} - -.. note:: - - You must prepend the ``app.request.baseUrl`` to render calls to ensure - that the render works when deployed into a sub-directory of the docroot. - -.. note:: - - Read the Twig `reference`_ for Symfony document to learn more about the - various Twig functions. - -Traits ------- - -``Silex\Application\TwigTrait`` adds the following shortcuts: - -* **render**: Renders a view with the given parameters and returns a Response - object. - -.. code-block:: php - - return $app->render('index.html', ['name' => 'Fabien']); - - $response = new Response(); - $response->setTtl(10); - - return $app->render('index.html', ['name' => 'Fabien'], $response); - -.. code-block:: php - - // stream a view - use Symfony\Component\HttpFoundation\StreamedResponse; - - return $app->render('index.html', ['name' => 'Fabien'], new StreamedResponse()); - -* **renderView**: Renders a view with the given parameters and returns a string. - -.. code-block:: php - - $content = $app->renderView('index.html', ['name' => 'Fabien']); - -Customization -------------- - -You can configure the Twig environment before using it by extending the -``twig`` service:: - - $app->extend('twig', function($twig, $app) { - $twig->addGlobal('pi', 3.14); - $twig->addFilter('levenshtein', new \Twig_Filter_Function('levenshtein')); - - return $twig; - }); - -For more information, check out the `official Twig documentation -`_. - -.. _reference: https://symfony.com/doc/current/reference/twig_reference.html#controller diff --git a/lib/silex/vendor/silex/silex/doc/providers/url_generator.rst b/lib/silex/vendor/silex/silex/doc/providers/url_generator.rst deleted file mode 100644 index c3d5847d0..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/url_generator.rst +++ /dev/null @@ -1,79 +0,0 @@ -UrlGeneratorServiceProvider -=========================== - -The *UrlGeneratorServiceProvider* provides a service for generating URLs for -named routes. - -Parameters ----------- - -None. - -Services --------- - -* **url_generator**: An instance of `UrlGenerator - `_, - using the `RouteCollection - `_ - that is provided through the ``routes`` service. It has a ``generate`` - method, which takes the route name as an argument, followed by an array of - route parameters. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\UrlGeneratorServiceProvider()); - -Usage ------ - -The UrlGenerator provider provides a ``url_generator`` service:: - - $app->get('/', function () { - return 'welcome to the homepage'; - }) - ->bind('homepage'); - - $app->get('/hello/{name}', function ($name) { - return "Hello $name!"; - }) - ->bind('hello'); - - $app->get('/navigation', function () use ($app) { - return 'Home'. - ' | '. - 'Hello Igor'; - }); - -When using Twig, the service can be used like this: - -.. code-block:: jinja - - {{ app.url_generator.generate('homepage') }} - -Moreover, if you have ``twig-bridge`` as a Composer dep, you will have access -to the ``path()`` and ``url()`` functions: - -.. code-block:: jinja - - {{ path('homepage') }} - {{ url('homepage') }} {# generates the absolute url http://example.org/ #} - {{ path('hello', {name: 'Fabien'}) }} - {{ url('hello', {name: 'Fabien'}) }} {# generates the absolute url http://example.org/hello/Fabien #} - -Traits ------- - -``Silex\Application\UrlGeneratorTrait`` adds the following shortcuts: - -* **path**: Generates a path. - -* **url**: Generates an absolute URL. - -.. code-block:: php - - $app->path('homepage'); - $app->url('homepage'); diff --git a/lib/silex/vendor/silex/silex/doc/providers/validator.rst b/lib/silex/vendor/silex/silex/doc/providers/validator.rst deleted file mode 100644 index bd4e99858..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/validator.rst +++ /dev/null @@ -1,217 +0,0 @@ -Validator -========= - -The *ValidatorServiceProvider* provides a service for validating data. It is -most useful when used with the *FormServiceProvider*, but can also be used -standalone. - -Parameters ----------- - -* **validator.validator_service_ids**: An array of service names representing - validators. - -Services --------- - -* **validator**: An instance of `Validator - `_. - -* **validator.mapping.class_metadata_factory**: Factory for metadata loaders, - which can read validation constraint information from classes. Defaults to - StaticMethodLoader--ClassMetadataFactory. - - This means you can define a static ``loadValidatorMetadata`` method on your - data class, which takes a ClassMetadata argument. Then you can set - constraints on this ClassMetadata instance. - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\ValidatorServiceProvider()); - -.. note:: - - Add the Symfony Validator Component as a dependency: - - .. code-block:: bash - - composer require symfony/validator - -Usage ------ - -The Validator provider provides a ``validator`` service. - -Validating Values -~~~~~~~~~~~~~~~~~ - -You can validate values directly using the ``validate`` validator -method:: - - use Symfony\Component\Validator\Constraints as Assert; - - $app->get('/validate/{email}', function ($email) use ($app) { - $errors = $app['validator']->validate($email, new Assert\Email()); - - if (count($errors) > 0) { - return (string) $errors; - } else { - return 'The email is valid'; - } - }); - -Validating Associative Arrays -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Validating associative arrays is like validating simple values, with a -collection of constraints:: - - use Symfony\Component\Validator\Constraints as Assert; - - $book = array( - 'title' => 'My Book', - 'author' => array( - 'first_name' => 'Fabien', - 'last_name' => 'Potencier', - ), - ); - - $constraint = new Assert\Collection(array( - 'title' => new Assert\Length(array('min' => 10)), - 'author' => new Assert\Collection(array( - 'first_name' => array(new Assert\NotBlank(), new Assert\Length(array('min' => 10))), - 'last_name' => new Assert\Length(array('min' => 10)), - )), - )); - $errors = $app['validator']->validate($book, $constraint); - - if (count($errors) > 0) { - foreach ($errors as $error) { - echo $error->getPropertyPath().' '.$error->getMessage()."\n"; - } - } else { - echo 'The book is valid'; - } - -Validating Objects -~~~~~~~~~~~~~~~~~~ - -If you want to add validations to a class, you can define the constraint for -the class properties and getters, and then call the ``validate`` method:: - - use Symfony\Component\Validator\Constraints as Assert; - - class Book - { - public $title; - public $author; - } - - class Author - { - public $first_name; - public $last_name; - } - - $author = new Author(); - $author->first_name = 'Fabien'; - $author->last_name = 'Potencier'; - - $book = new Book(); - $book->title = 'My Book'; - $book->author = $author; - - $metadata = $app['validator.mapping.class_metadata_factory']->getMetadataFor('Author'); - $metadata->addPropertyConstraint('first_name', new Assert\NotBlank()); - $metadata->addPropertyConstraint('first_name', new Assert\Length(array('min' => 10))); - $metadata->addPropertyConstraint('last_name', new Assert\Length(array('min' => 10))); - - $metadata = $app['validator.mapping.class_metadata_factory']->getMetadataFor('Book'); - $metadata->addPropertyConstraint('title', new Assert\Length(array('min' => 10))); - $metadata->addPropertyConstraint('author', new Assert\Valid()); - - $errors = $app['validator']->validate($book); - - if (count($errors) > 0) { - foreach ($errors as $error) { - echo $error->getPropertyPath().' '.$error->getMessage()."\n"; - } - } else { - echo 'The author is valid'; - } - -You can also declare the class constraint by adding a static -``loadValidatorMetadata`` method to your classes:: - - use Symfony\Component\Validator\Mapping\ClassMetadata; - use Symfony\Component\Validator\Constraints as Assert; - - class Book - { - public $title; - public $author; - - static public function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addPropertyConstraint('title', new Assert\Length(array('min' => 10))); - $metadata->addPropertyConstraint('author', new Assert\Valid()); - } - } - - class Author - { - public $first_name; - public $last_name; - - static public function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addPropertyConstraint('first_name', new Assert\NotBlank()); - $metadata->addPropertyConstraint('first_name', new Assert\Length(array('min' => 10))); - $metadata->addPropertyConstraint('last_name', new Assert\Length(array('min' => 10))); - } - } - - $app->get('/validate/{email}', function ($email) use ($app) { - $author = new Author(); - $author->first_name = 'Fabien'; - $author->last_name = 'Potencier'; - - $book = new Book(); - $book->title = 'My Book'; - $book->author = $author; - - $errors = $app['validator']->validate($book); - - if (count($errors) > 0) { - foreach ($errors as $error) { - echo $error->getPropertyPath().' '.$error->getMessage()."\n"; - } - } else { - echo 'The author is valid'; - } - }); - -.. note:: - - Use ``addGetterConstraint()`` to add constraints on getter methods and - ``addConstraint()`` to add constraints on the class itself. - -Translation -~~~~~~~~~~~ - -To be able to translate the error messages, you can use the translator -provider and register the messages under the ``validators`` domain:: - - $app['translator.domains'] = array( - 'validators' => array( - 'fr' => array( - 'This value should be a valid number.' => 'Cette valeur doit être un nombre.', - ), - ), - ); - -For more information, consult the `Symfony Validation documentation -`_. diff --git a/lib/silex/vendor/silex/silex/doc/providers/var_dumper.rst b/lib/silex/vendor/silex/silex/doc/providers/var_dumper.rst deleted file mode 100644 index ea4dd19a4..000000000 --- a/lib/silex/vendor/silex/silex/doc/providers/var_dumper.rst +++ /dev/null @@ -1,44 +0,0 @@ -Var Dumper -========== - -The *VarDumperServiceProvider* provides a mechanism that allows exploring then -dumping any PHP variable. - -Parameters ----------- - -* **var_dumper.dump_destination**: A stream URL where dumps should be written - to (defaults to ``null``). - -Services --------- - -* n/a - -Registering ------------ - -.. code-block:: php - - $app->register(new Silex\Provider\VarDumperServiceProvider()); - -.. note:: - - Add the Symfony VarDumper Component as a dependency: - - .. code-block:: bash - - composer require symfony/var-dumper - -Usage ------ - -Adding the VarDumper component as a Composer dependency gives you access to the -``dump()`` PHP function anywhere in your code. - -If you are using Twig, it also provides a ``dump()`` Twig function and a -``dump`` Twig tag. - -The VarDumperServiceProvider is also useful when used with the Silex -WebProfiler as the dumps are made available in the web debug toolbar and in the -web profiler. diff --git a/lib/silex/vendor/silex/silex/doc/services.rst b/lib/silex/vendor/silex/silex/doc/services.rst deleted file mode 100644 index 0b34ad35e..000000000 --- a/lib/silex/vendor/silex/silex/doc/services.rst +++ /dev/null @@ -1,269 +0,0 @@ -Services -======== - -Silex is not only a framework, it is also a service container. It does this by -extending `Pimple `_ which provides a very simple -service container. - -Dependency Injection --------------------- - -.. note:: - - You can skip this if you already know what Dependency Injection is. - -Dependency Injection is a design pattern where you pass dependencies to -services instead of creating them from within the service or relying on -globals. This generally leads to code that is decoupled, re-usable, flexible -and testable. - -Here is an example of a class that takes a ``User`` object and stores it as a -file in JSON format:: - - class JsonUserPersister - { - private $basePath; - - public function __construct($basePath) - { - $this->basePath = $basePath; - } - - public function persist(User $user) - { - $data = $user->getAttributes(); - $json = json_encode($data); - $filename = $this->basePath.'/'.$user->id.'.json'; - file_put_contents($filename, $json, LOCK_EX); - } - } - -In this simple example the dependency is the ``basePath`` property. It is -passed to the constructor. This means you can create several independent -instances with different base paths. Of course dependencies do not have to be -simple strings. More often they are in fact other services. - -A service container is responsible for creating and storing services. It can -recursively create dependencies of the requested services and inject them. It -does so lazily, which means a service is only created when you actually need it. - -Pimple ------- - -Pimple makes strong use of closures and implements the ArrayAccess interface. - -We will start off by creating a new instance of Pimple -- and because -``Silex\Application`` extends ``Pimple\Container`` all of this applies to Silex -as well:: - - $container = new Pimple\Container(); - -or:: - - $app = new Silex\Application(); - -Parameters -~~~~~~~~~~ - -You can set parameters (which are usually strings) by setting an array key on -the container:: - - $app['some_parameter'] = 'value'; - -The array key can be any value. By convention dots are used for namespacing:: - - $app['asset.host'] = 'http://cdn.mysite.com/'; - -Reading parameter values is possible with the same syntax:: - - echo $app['some_parameter']; - -Service definitions -~~~~~~~~~~~~~~~~~~~ - -Defining services is no different than defining parameters. You just set an -array key on the container to be a closure. However, when you retrieve the -service, the closure is executed. This allows for lazy service creation:: - - $app['some_service'] = function () { - return new Service(); - }; - -And to retrieve the service, use:: - - $service = $app['some_service']; - -On first invocation, this will create the service; the same instance will then -be returned on any subsequent access. - -Factory services -~~~~~~~~~~~~~~~~ - -If you want a different instance to be returned for each service access, wrap -the service definition with the ``factory()`` method:: - - $app['some_service'] = $app->factory(function () { - return new Service(); - }); - -Every time you call ``$app['some_service']``, a new instance of the service is -created. - -Access container from closure -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In many cases you will want to access the service container from within a -service definition closure. For example when fetching services the current -service depends on. - -Because of this, the container is passed to the closure as an argument:: - - $app['some_service'] = function ($app) { - return new Service($app['some_other_service'], $app['some_service.config']); - }; - -Here you can see an example of Dependency Injection. ``some_service`` depends -on ``some_other_service`` and takes ``some_service.config`` as configuration -options. The dependency is only created when ``some_service`` is accessed, and -it is possible to replace either of the dependencies by simply overriding -those definitions. - -Going back to our initial example, here's how we could use the container -to manage its dependencies:: - - $app['user.persist_path'] = '/tmp/users'; - $app['user.persister'] = function ($app) { - return new JsonUserPersister($app['user.persist_path']); - }; - - -Protected closures -~~~~~~~~~~~~~~~~~~ - -Because the container sees closures as factories for services, it will always -execute them when reading them. - -In some cases you will however want to store a closure as a parameter, so that -you can fetch it and execute it yourself -- with your own arguments. - -This is why Pimple allows you to protect your closures from being executed, by -using the ``protect`` method:: - - $app['closure_parameter'] = $app->protect(function ($a, $b) { - return $a + $b; - }); - - // will not execute the closure - $add = $app['closure_parameter']; - - // calling it now - echo $add(2, 3); - -Note that the container is not provided as an argument to protected closures. -However, you can inject it via `use($app)`:: - - $app['closure_parameter'] = $app->protect(function ($a, $b) use ($app) { - // ... - }); - -Core services -------------- - -Silex defines a range of services. - -* **request_stack**: Controls the lifecycle of requests, an instance of - `RequestStack `_. - It gives you access to ``GET``, ``POST`` parameters and lots more! - - Example usage:: - - $id = $app['request_stack']->getCurrentRequest()->get('id'); - - A request is only available when a request is being served; you can only - access it from within a controller, an application before/after middlewares, - or an error handler. - -* **routes**: The `RouteCollection - `_ - that is used internally. You can add, modify, read routes. - -* **url_generator**: An instance of `UrlGenerator - `_, - using the `RouteCollection - `_ - that is provided through the ``routes`` service. It has a ``generate`` - method, which takes the route name as an argument, followed by an array of - route parameters. - -* **controllers**: The ``Silex\ControllerCollection`` that is used internally. - Check the :doc:`Internals chapter ` for more information. - -* **dispatcher**: The `EventDispatcher - `_ - that is used internally. It is the core of the Symfony system and is used - quite a bit by Silex. - -* **resolver**: The `ControllerResolver - `_ - that is used internally. It takes care of executing the controller with the - right arguments. - -* **kernel**: The `HttpKernel - `_ - that is used internally. The HttpKernel is the heart of Symfony, it takes a - Request as input and returns a Response as output. - -* **request_context**: The request context is a simplified representation of - the request that is used by the router and the URL generator. - -* **exception_handler**: The Exception handler is the default handler that is - used when you don't register one via the ``error()`` method or if your - handler does not return a Response. Disable it with - ``unset($app['exception_handler'])``. - -* **logger**: A `LoggerInterface `_ instance. By default, logging is - disabled as the value is set to ``null``. To enable logging you can either use - the :doc:`MonologServiceProvider ` or define your own ``logger`` service that - conforms to the PSR logger interface. - -Core traits ------------ - -* ``Silex\Application\UrlGeneratorTrait`` adds the following shortcuts: - - * **path**: Generates a path. - - * **url**: Generates an absolute URL. - - .. code-block:: php - - $app->path('homepage'); - $app->url('homepage'); - -Core parameters ---------------- - -* **request.http_port** (optional): Allows you to override the default port - for non-HTTPS URLs. If the current request is HTTP, it will always use the - current port. - - Defaults to 80. - - This parameter can be used when generating URLs. - -* **request.https_port** (optional): Allows you to override the default port - for HTTPS URLs. If the current request is HTTPS, it will always use the - current port. - - Defaults to 443. - - This parameter can be used when generating URLs. - -* **debug** (optional): Returns whether or not the application is running in - debug mode. - - Defaults to false. - -* **charset** (optional): The charset to use for Responses. - - Defaults to UTF-8. diff --git a/lib/silex/vendor/silex/silex/doc/testing.rst b/lib/silex/vendor/silex/silex/doc/testing.rst deleted file mode 100644 index 17f5f571c..000000000 --- a/lib/silex/vendor/silex/silex/doc/testing.rst +++ /dev/null @@ -1,222 +0,0 @@ -Testing -======= - -Because Silex is built on top of Symfony, it is very easy to write functional -tests for your application. Functional tests are automated software tests that -ensure that your code is working correctly. They go through the user interface, -using a fake browser, and mimic the actions a user would do. - -Why ---- - -If you are not familiar with software tests, you may be wondering why you would -need this. Every time you make a change to your application, you have to test -it. This means going through all the pages and making sure they are still -working. Functional tests save you a lot of time, because they enable you to -test your application in usually under a second by running a single command. - -For more information on functional testing, unit testing, and automated -software tests in general, check out `PHPUnit -`_ and `Bulat Shakirzyanov's talk -on Clean Code `_. - -PHPUnit -------- - -`PHPUnit `_ is the de-facto -standard testing framework for PHP. It was built for writing unit tests, but it -can be used for functional tests too. You write tests by creating a new class, -that extends the ``PHPUnit_Framework_TestCase``. Your test cases are methods -prefixed with ``test``:: - - class ContactFormTest extends \PHPUnit_Framework_TestCase - { - public function testInitialPage() - { - ... - } - } - -In your test cases, you do assertions on the state of what you are testing. In -this case we are testing a contact form, so we would want to assert that the -page loaded correctly and contains our form:: - - public function testInitialPage() - { - $statusCode = ... - $pageContent = ... - - $this->assertEquals(200, $statusCode); - $this->assertContains('Contact us', $pageContent); - $this->assertContains('`_ -section of the PHPUnit documentation. - -WebTestCase ------------ - -Symfony provides a WebTestCase class that can be used to write functional -tests. The Silex version of this class is ``Silex\WebTestCase``, and you can -use it by making your test extend it:: - - use Silex\WebTestCase; - - class ContactFormTest extends WebTestCase - { - ... - } - -.. caution:: - - If you need to override the ``setUp()`` method, don't forget to call the - parent (``parent::setUp()``) to call the Silex default setup. - -.. note:: - - If you want to use the Symfony ``WebTestCase`` class you will need to - explicitly install its dependencies for your project: - - .. code-block:: bash - - composer require --dev symfony/browser-kit symfony/css-selector - -For your WebTestCase, you will have to implement a ``createApplication`` -method, which returns your application instance:: - - public function createApplication() - { - // app.php must return an Application instance - return require __DIR__.'/path/to/app.php'; - } - -Make sure you do **not** use ``require_once`` here, as this method will be -executed before every test. - -.. tip:: - - By default, the application behaves in the same way as when using it from a - browser. But when an error occurs, it is sometimes easier to get raw - exceptions instead of HTML pages. It is rather simple if you tweak the - application configuration in the ``createApplication()`` method like - follows:: - - public function createApplication() - { - $app = require __DIR__.'/path/to/app.php'; - $app['debug'] = true; - unset($app['exception_handler']); - - return $app; - } - -.. tip:: - - If your application use sessions, set ``session.test`` to ``true`` to - simulate sessions:: - - public function createApplication() - { - // ... - - $app['session.test'] = true; - - // ... - } - -The WebTestCase provides a ``createClient`` method. A client acts as a browser, -and allows you to interact with your application. Here's how it works:: - - public function testInitialPage() - { - $client = $this->createClient(); - $crawler = $client->request('GET', '/'); - - $this->assertTrue($client->getResponse()->isOk()); - $this->assertCount(1, $crawler->filter('h1:contains("Contact us")')); - $this->assertCount(1, $crawler->filter('form')); - ... - } - -There are several things going on here. You have both a ``Client`` and a -``Crawler``. - -You can also access the application through ``$this->app``. - -Client -~~~~~~ - -The client represents a browser. It holds your browsing history, cookies and -more. The ``request`` method allows you to make a request to a page on your -application. - -.. note:: - - You can find some documentation for it in `the client section of the - testing chapter of the Symfony documentation - `_. - -Crawler -~~~~~~~ - -The crawler allows you to inspect the content of a page. You can filter it -using CSS expressions and lots more. - -.. note:: - - You can find some documentation for it in `the crawler section of the testing - chapter of the Symfony documentation - `_. - -Configuration -------------- - -The suggested way to configure PHPUnit is to create a ``phpunit.xml.dist`` -file, a ``tests`` folder and your tests in -``tests/YourApp/Tests/YourTest.php``. The ``phpunit.xml.dist`` file should -look like this: - -.. code-block:: xml - - - - - - ./tests/ - - - - -Your ``tests/YourApp/Tests/YourTest.php`` should look like this:: - - namespace YourApp\Tests; - - use Silex\WebTestCase; - - class YourTest extends WebTestCase - { - public function createApplication() - { - return require __DIR__.'/../../../app.php'; - } - - public function testFooBar() - { - ... - } - } - -Now, when running ``phpunit`` on the command line, tests should run. diff --git a/lib/silex/vendor/silex/silex/doc/usage.rst b/lib/silex/vendor/silex/silex/doc/usage.rst deleted file mode 100644 index 724254cef..000000000 --- a/lib/silex/vendor/silex/silex/doc/usage.rst +++ /dev/null @@ -1,799 +0,0 @@ -Usage -===== - -Installation ------------- - -If you want to get started fast, use the `Silex Skeleton`_: - -.. code-block:: bash - - composer create-project fabpot/silex-skeleton path/to/install "~2.0" - -If you want more flexibility, use Composer_ instead: - -.. code-block:: bash - - composer require silex/silex:~2.0 - -Web Server ----------- - -All examples in the documentation rely on a well-configured web server; read -the :doc:`webserver documentation` to check yours. - -Bootstrap ---------- - -To bootstrap Silex, all you need to do is require the ``vendor/autoload.php`` -file and create an instance of ``Silex\Application``. After your controller -definitions, call the ``run`` method on your application:: - - // web/index.php - require_once __DIR__.'/../vendor/autoload.php'; - - $app = new Silex\Application(); - - // ... definitions - - $app->run(); - -.. tip:: - - When developing a website, you might want to turn on the debug mode to - ease debugging:: - - $app['debug'] = true; - -.. tip:: - - If your application is hosted behind a reverse proxy at address ``$ip``, - and you want Silex to trust the ``X-Forwarded-For*`` headers, you will - need to run your application like this:: - - use Symfony\Component\HttpFoundation\Request; - - Request::setTrustedProxies(array($ip)); - $app->run(); - -Routing -------- - -In Silex you define a route and the controller that is called when that -route is matched. A route pattern consists of: - -* *Pattern*: The route pattern defines a path that points to a resource. The - pattern can include variable parts and you are able to set RegExp - requirements for them. - -* *Method*: One of the following HTTP methods: ``GET``, ``POST``, ``PUT``, - ``DELETE``, ``PATCH``, or ``OPTIONS``. This describes the interaction with - the resource. - -The controller is defined using a closure like this:: - - function () { - // ... do something - } - -The return value of the closure becomes the content of the page. - -Example GET Route -~~~~~~~~~~~~~~~~~ - -Here is an example definition of a ``GET`` route:: - - $blogPosts = array( - 1 => array( - 'date' => '2011-03-29', - 'author' => 'igorw', - 'title' => 'Using Silex', - 'body' => '...', - ), - ); - - $app->get('/blog', function () use ($blogPosts) { - $output = ''; - foreach ($blogPosts as $post) { - $output .= $post['title']; - $output .= '
'; - } - - return $output; - }); - -Visiting ``/blog`` will return a list of blog post titles. The ``use`` -statement means something different in this context. It tells the closure to -import the ``$blogPosts`` variable from the outer scope. This allows you to use -it from within the closure. - -Dynamic Routing -~~~~~~~~~~~~~~~ - -Now, you can create another controller for viewing individual blog posts:: - - $app->get('/blog/{id}', function (Silex\Application $app, $id) use ($blogPosts) { - if (!isset($blogPosts[$id])) { - $app->abort(404, "Post $id does not exist."); - } - - $post = $blogPosts[$id]; - - return "

{$post['title']}

". - "

{$post['body']}

"; - }); - -This route definition has a variable ``{id}`` part which is passed to the -closure. - -The current ``Application`` is automatically injected by Silex to the Closure -thanks to the type hinting. - -When the post does not exist, you are using ``abort()`` to stop the request -early. It actually throws an exception, which you will see how to handle later -on. - -Example POST Route -~~~~~~~~~~~~~~~~~~ - -POST routes signify the creation of a resource. An example for this is a -feedback form. You will use the ``mail`` function to send an e-mail:: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpFoundation\Response; - - $app->post('/feedback', function (Request $request) { - $message = $request->get('message'); - mail('feedback@yoursite.com', '[YourSite] Feedback', $message); - - return new Response('Thank you for your feedback!', 201); - }); - -It is pretty straightforward. - -.. note:: - - There is a :doc:`SwiftmailerServiceProvider ` - included that you can use instead of ``mail()``. - -The current ``request`` is automatically injected by Silex to the Closure -thanks to the type hinting. It is an instance of -Request_, so you can fetch variables using the request ``get`` method. - -Instead of returning a string you are returning an instance of Response_. -This allows setting an HTTP status code, in this case it is set to -``201 Created``. - -.. note:: - - Silex always uses a ``Response`` internally, it converts strings to - responses with status code ``200``. - -Other methods -~~~~~~~~~~~~~ - -You can create controllers for most HTTP methods. Just call one of these -methods on your application: ``get``, ``post``, ``put``, ``delete``, ``patch``, ``options``:: - - $app->put('/blog/{id}', function ($id) { - // ... - }); - - $app->delete('/blog/{id}', function ($id) { - // ... - }); - - $app->patch('/blog/{id}', function ($id) { - // ... - }); - -.. tip:: - - Forms in most web browsers do not directly support the use of other HTTP - methods. To use methods other than GET and POST you can utilize a special - form field with a name of ``_method``. The form's ``method`` attribute must - be set to POST when using this field: - - .. code-block:: html - -
- - -
- - You need to explicitly enable this method override:: - - use Symfony\Component\HttpFoundation\Request; - - Request::enableHttpMethodParameterOverride(); - $app->run(); - -You can also call ``match``, which will match all methods. This can be -restricted via the ``method`` method:: - - $app->match('/blog', function () { - // ... - }); - - $app->match('/blog', function () { - // ... - }) - ->method('PATCH'); - - $app->match('/blog', function () { - // ... - }) - ->method('PUT|POST'); - -.. note:: - - The order in which the routes are defined is significant. The first - matching route will be used, so place more generic routes at the bottom. - -Route Variables -~~~~~~~~~~~~~~~ - -As it has been shown before you can define variable parts in a route like -this:: - - $app->get('/blog/{id}', function ($id) { - // ... - }); - -It is also possible to have more than one variable part, just make sure the -closure arguments match the names of the variable parts:: - - $app->get('/blog/{postId}/{commentId}', function ($postId, $commentId) { - // ... - }); - -While it's not recommended, you could also do this (note the switched -arguments):: - - $app->get('/blog/{postId}/{commentId}', function ($commentId, $postId) { - // ... - }); - -You can also ask for the current Request and Application objects:: - - $app->get('/blog/{id}', function (Application $app, Request $request, $id) { - // ... - }); - -.. note:: - - Note for the Application and Request objects, Silex does the injection - based on the type hinting and not on the variable name:: - - $app->get('/blog/{id}', function (Application $foo, Request $bar, $id) { - // ... - }); - -Route Variable Converters -~~~~~~~~~~~~~~~~~~~~~~~~~ - -Before injecting the route variables into the controller, you can apply some -converters:: - - $app->get('/user/{id}', function ($id) { - // ... - })->convert('id', function ($id) { return (int) $id; }); - -This is useful when you want to convert route variables to objects as it -allows to reuse the conversion code across different controllers:: - - $userProvider = function ($id) { - return new User($id); - }; - - $app->get('/user/{user}', function (User $user) { - // ... - })->convert('user', $userProvider); - - $app->get('/user/{user}/edit', function (User $user) { - // ... - })->convert('user', $userProvider); - -The converter callback also receives the ``Request`` as its second argument:: - - $callback = function ($post, Request $request) { - return new Post($request->attributes->get('slug')); - }; - - $app->get('/blog/{id}/{slug}', function (Post $post) { - // ... - })->convert('post', $callback); - -A converter can also be defined as a service. For example, here is a user -converter based on Doctrine ObjectManager:: - - use Doctrine\Common\Persistence\ObjectManager; - use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - - class UserConverter - { - private $om; - - public function __construct(ObjectManager $om) - { - $this->om = $om; - } - - public function convert($id) - { - if (null === $user = $this->om->find('User', (int) $id)) { - throw new NotFoundHttpException(sprintf('User %d does not exist', $id)); - } - - return $user; - } - } - -The service will now be registered in the application, and the -``convert()`` method will be used as converter (using the syntax -``service_name:method_name``):: - - $app['converter.user'] = function () { - return new UserConverter(); - }; - - $app->get('/user/{user}', function (User $user) { - // ... - })->convert('user', 'converter.user:convert'); - -Requirements -~~~~~~~~~~~~ - -In some cases you may want to only match certain expressions. You can define -requirements using regular expressions by calling ``assert`` on the -``Controller`` object, which is returned by the routing methods. - -The following will make sure the ``id`` argument is a positive integer, since -``\d+`` matches any amount of digits:: - - $app->get('/blog/{id}', function ($id) { - // ... - }) - ->assert('id', '\d+'); - -You can also chain these calls:: - - $app->get('/blog/{postId}/{commentId}', function ($postId, $commentId) { - // ... - }) - ->assert('postId', '\d+') - ->assert('commentId', '\d+'); - -Conditions -~~~~~~~~~~ - -Besides restricting route matching based on the HTTP method or parameter -requirements, you can set conditions on any part of the request by calling -``when`` on the ``Controller`` object, which is returned by the routing -methods:: - - $app->get('/blog/{id}', function ($id) { - // ... - }) - ->when("request.headers.get('User-Agent') matches '/firefox/i'"); - -The ``when`` argument is a Symfony Expression_ , which means that you need to -add ``symfony/expression-language`` as a dependency of your project. - -Default Values -~~~~~~~~~~~~~~ - -You can define a default value for any route variable by calling ``value`` on -the ``Controller`` object:: - - $app->get('/{pageName}', function ($pageName) { - // ... - }) - ->value('pageName', 'index'); - -This will allow matching ``/``, in which case the ``pageName`` variable will -have the value ``index``. - -Named Routes -~~~~~~~~~~~~ - -Some providers can make use of named routes. By default Silex will generate an -internal route name for you but you can give an explicit route name by calling -``bind``:: - - $app->get('/', function () { - // ... - }) - ->bind('homepage'); - - $app->get('/blog/{id}', function ($id) { - // ... - }) - ->bind('blog_post'); - -Controllers as Classes -~~~~~~~~~~~~~~~~~~~~~~ - -Instead of anonymous functions, you can also define your controllers as -methods. By using the ``ControllerClass::methodName`` syntax, you can tell -Silex to lazily create the controller object for you:: - - $app->get('/', 'Acme\\Foo::bar'); - - use Silex\Application; - use Symfony\Component\HttpFoundation\Request; - - namespace Acme - { - class Foo - { - public function bar(Request $request, Application $app) - { - // ... - } - } - } - -This will load the ``Acme\Foo`` class on demand, create an instance and call -the ``bar`` method to get the response. You can use ``Request`` and -``Silex\Application`` type hints to get ``$request`` and ``$app`` injected. - -It is also possible to :doc:`define your controllers as services -`. - -Global Configuration --------------------- - -If a controller setting must be applied to **all** controllers (a converter, a -middleware, a requirement, or a default value), configure it on -``$app['controllers']``, which holds all application controllers:: - - $app['controllers'] - ->value('id', '1') - ->assert('id', '\d+') - ->requireHttps() - ->method('get') - ->convert('id', function () { /* ... */ }) - ->before(function () { /* ... */ }) - ->when('request.isSecure() == true') - ; - -These settings are applied to already registered controllers and they become -the defaults for new controllers. - -.. note:: - - The global configuration does not apply to controller providers you might - mount as they have their own global configuration (read the - :doc:`dedicated chapter` for more information). - -Error Handlers --------------- - -When an exception is thrown, error handlers allow you to display a custom -error page to the user. They can also be used to do additional things, such as -logging. - -To register an error handler, pass a closure to the ``error`` method which -takes an ``Exception`` argument and returns a response:: - - use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\HttpFoundation\Request; - - $app->error(function (\Exception $e, Request $request, $code) { - return new Response('We are sorry, but something went terribly wrong.'); - }); - -You can also check for specific errors by using the ``$code`` argument, and -handle them differently:: - - use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\HttpFoundation\Request; - - $app->error(function (\Exception $e, Request $request, $code) { - switch ($code) { - case 404: - $message = 'The requested page could not be found.'; - break; - default: - $message = 'We are sorry, but something went terribly wrong.'; - } - - return new Response($message); - }); - -You can restrict an error handler to only handle some Exception classes by -setting a more specific type hint for the Closure argument:: - - use Symfony\Component\HttpFoundation\Request; - - $app->error(function (\LogicException $e, Request $request, $code) { - // this handler will only handle \LogicException exceptions - // and exceptions that extend \LogicException - }); - -.. note:: - - As Silex ensures that the Response status code is set to the most - appropriate one depending on the exception, setting the status on the - response won't work. If you want to overwrite the status code, set the - ``X-Status-Code`` header:: - - return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200)); - -If you want to use a separate error handler for logging, make sure you register -it with a higher priority than response error handlers, because once a response -is returned, the following handlers are ignored. - -.. note:: - - Silex ships with a provider for Monolog_ which handles logging of errors. - Check out the *Providers* :doc:`chapter ` for details. - -.. tip:: - - Silex comes with a default error handler that displays a detailed error - message with the stack trace when **debug** is true, and a simple error - message otherwise. Error handlers registered via the ``error()`` method - always take precedence but you can keep the nice error messages when debug - is turned on like this:: - - use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\HttpFoundation\Request; - - $app->error(function (\Exception $e, Request $request, $code) use ($app) { - if ($app['debug']) { - return; - } - - // ... logic to handle the error and return a Response - }); - -The error handlers are also called when you use ``abort`` to abort a request -early:: - - $app->get('/blog/{id}', function (Silex\Application $app, $id) use ($blogPosts) { - if (!isset($blogPosts[$id])) { - $app->abort(404, "Post $id does not exist."); - } - - return new Response(...); - }); - -You can convert errors to ``Exceptions``, check out the cookbook :doc:`chapter ` for details. - -View Handlers -------------- - -View Handlers allow you to intercept a controller result that is not a -``Response`` and transform it before it gets returned to the kernel. - -To register a view handler, pass a callable (or string that can be resolved to a -callable) to the ``view()`` method. The callable should accept some sort of result -from the controller:: - - $app->view(function (array $controllerResult) use ($app) { - return $app->json($controllerResult); - }); - -View Handlers also receive the ``Request`` as their second argument, -making them a good candidate for basic content negotiation:: - - $app->view(function (array $controllerResult, Request $request) use ($app) { - $acceptHeader = $request->headers->get('Accept'); - $bestFormat = $app['negotiator']->getBestFormat($acceptHeader, array('json', 'xml')); - - if ('json' === $bestFormat) { - return new JsonResponse($controllerResult); - } - - if ('xml' === $bestFormat) { - return $app['serializer.xml']->renderResponse($controllerResult); - } - - return $controllerResult; - }); - -View Handlers will be examined in the order they are added to the application -and Silex will use type hints to determine if a view handler should be used for -the current result, continuously using the return value of the last view handler -as the input for the next. - -.. note:: - - You must ensure that Silex receives a ``Response`` or a string as the result of - the last view handler (or controller) to be run. - -Redirects ---------- - -You can redirect to another page by returning a ``RedirectResponse`` response, -which you can create by calling the ``redirect`` method:: - - $app->get('/', function () use ($app) { - return $app->redirect('/hello'); - }); - -This will redirect from ``/`` to ``/hello``. - -Forwards --------- - -When you want to delegate the rendering to another controller, without a -round-trip to the browser (as for a redirect), use an internal sub-request:: - - use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpKernel\HttpKernelInterface; - - $app->get('/', function () use ($app) { - // forward to /hello - $subRequest = Request::create('/hello', 'GET'); - - return $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST); - }); - -.. tip:: - - You can also generate the URI via the built-in URL generator:: - - $request = Request::create($app['url_generator']->generate('hello'), 'GET'); - -There's some more things that you need to keep in mind though. In most cases you -will want to forward some parts of the current master request to the sub-request. -That includes: Cookies, server information, session. -Read more on :doc:`how to make sub-requests `. - -JSON ----- - -If you want to return JSON data, you can use the ``json`` helper method. -Simply pass it your data, status code and headers, and it will create a JSON -response for you:: - - $app->get('/users/{id}', function ($id) use ($app) { - $user = getUser($id); - - if (!$user) { - $error = array('message' => 'The user was not found.'); - - return $app->json($error, 404); - } - - return $app->json($user); - }); - -Streaming ---------- - -It's possible to stream a response, which is important in cases when you don't -want to buffer the data being sent:: - - $app->get('/images/{file}', function ($file) use ($app) { - if (!file_exists(__DIR__.'/images/'.$file)) { - return $app->abort(404, 'The image was not found.'); - } - - $stream = function () use ($file) { - readfile($file); - }; - - return $app->stream($stream, 200, array('Content-Type' => 'image/png')); - }); - -If you need to send chunks, make sure you call ``ob_flush`` and ``flush`` -after every chunk:: - - $stream = function () { - $fh = fopen('http://www.example.com/', 'rb'); - while (!feof($fh)) { - echo fread($fh, 1024); - ob_flush(); - flush(); - } - fclose($fh); - }; - -Sending a file --------------- - -If you want to return a file, you can use the ``sendFile`` helper method. -It eases returning files that would otherwise not be publicly available. Simply -pass it your file path, status code, headers and the content disposition and it -will create a ``BinaryFileResponse`` response for you:: - - $app->get('/files/{path}', function ($path) use ($app) { - if (!file_exists('/base/path/' . $path)) { - $app->abort(404); - } - - return $app->sendFile('/base/path/' . $path); - }); - -To further customize the response before returning it, check the API doc for -`Symfony\Component\HttpFoundation\BinaryFileResponse -`_:: - - return $app - ->sendFile('/base/path/' . $path) - ->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'pic.jpg') - ; - -Traits ------- - -Silex comes with PHP traits that define shortcut methods. - -Almost all built-in service providers have some corresponding PHP traits. To -use them, define your own Application class and include the traits you want:: - - use Silex\Application; - - class MyApplication extends Application - { - use Application\TwigTrait; - use Application\SecurityTrait; - use Application\FormTrait; - use Application\UrlGeneratorTrait; - use Application\SwiftmailerTrait; - use Application\MonologTrait; - use Application\TranslationTrait; - } - -You can also define your own Route class and use some traits:: - - use Silex\Route; - - class MyRoute extends Route - { - use Route\SecurityTrait; - } - -To use your newly defined route, override the ``$app['route_class']`` -setting:: - - $app['route_class'] = 'MyRoute'; - -Read each provider chapter to learn more about the added methods. - -Security --------- - -Make sure to protect your application against attacks. - -Escaping -~~~~~~~~ - -When outputting any user input, make sure to escape it correctly to prevent -Cross-Site-Scripting attacks. - -* **Escaping HTML**: PHP provides the ``htmlspecialchars`` function for this. - Silex provides a shortcut ``escape`` method:: - - use Symfony\Component\HttpFoundation\Request; - - $app->get('/name', function (Request $request, Silex\Application $app) { - $name = $request->get('name'); - - return "You provided the name {$app->escape($name)}."; - }); - - If you use the Twig template engine, you should use its escaping or even - auto-escaping mechanisms. Check out the *Providers* :doc:`chapter ` for details. - -* **Escaping JSON**: If you want to provide data in JSON format you should - use the Silex ``json`` function:: - - use Symfony\Component\HttpFoundation\Request; - - $app->get('/name.json', function (Request $request, Silex\Application $app) { - $name = $request->get('name'); - - return $app->json(array('name' => $name)); - }); - -.. _Silex Skeleton: http://github.com/silexphp/Silex-Skeleton -.. _Composer: http://getcomposer.org/ -.. _Request: http://api.symfony.com/master/Symfony/Component/HttpFoundation/Request.html -.. _Response: http://api.symfony.com/master/Symfony/Component/HttpFoundation/Response.html -.. _Monolog: https://github.com/Seldaek/monolog -.. _Expression: https://symfony.com/doc/current/book/routing.html#completely-customized-route-matching-with-conditions diff --git a/lib/silex/vendor/silex/silex/doc/web_servers.rst b/lib/silex/vendor/silex/silex/doc/web_servers.rst deleted file mode 100644 index 18f5531d4..000000000 --- a/lib/silex/vendor/silex/silex/doc/web_servers.rst +++ /dev/null @@ -1,184 +0,0 @@ -Webserver Configuration -======================= - -Apache ------- - -If you are using Apache, make sure ``mod_rewrite`` is enabled and use the -following ``.htaccess`` file: - -.. code-block:: apache - - - Options -MultiViews - - RewriteEngine On - #RewriteBase /path/to/app - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [QSA,L] - - -.. note:: - - If your site is not at the webroot level you will have to uncomment the - ``RewriteBase`` statement and adjust the path to point to your directory, - relative from the webroot. - -Alternatively, if you use Apache 2.2.16 or higher, you can use the -`FallbackResource directive`_ to make your .htaccess even easier: - -.. code-block:: apache - - FallbackResource index.php - -.. note:: - - If your site is not at the webroot level you will have to adjust the path to - point to your directory, relative from the webroot. - -Or if you're using a VirtualHost, you can add the same directive to the VirtualHost's Directory entry: - -.. code-block:: apache - - - # other directives - - Alias /app/ /path/to/app/ - - # other directives - - FallbackResource /app/index.php - - - -.. note:: - - Note that you need the leading forward slash there, unlike with the .htaccess version - -nginx ------ - -The **minimum configuration** to get your application running under Nginx is: - -.. code-block:: nginx - - server { - server_name domain.tld www.domain.tld; - root /var/www/project/web; - - location / { - # try to serve file directly, fallback to front controller - try_files $uri /index.php$is_args$args; - } - - # If you have 2 front controllers for dev|prod use the following line instead - # location ~ ^/(index|index_dev)\.php(/|$) { - location ~ ^/index\.php(/|$) { - # the ubuntu default - fastcgi_pass unix:/var/run/php/phpX.X-fpm.sock; - # for running on centos - #fastcgi_pass unix:/var/run/php-fpm/www.sock; - - fastcgi_split_path_info ^(.+\.php)(/.*)$; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param HTTPS off; - - # Prevents URIs that include the front controller. This will 404: - # http://domain.tld/index.php/some-path - # Enable the internal directive to disable URIs like this - # internal; - } - - #return 404 for all php files as we do have a front controller - location ~ \.php$ { - return 404; - } - - error_log /var/log/nginx/project_error.log; - access_log /var/log/nginx/project_access.log; - } - -IIS ---- - -If you are using the Internet Information Services from Windows, you can use -this sample ``web.config`` file: - -.. code-block:: xml - - - - - - - - - - - - - - - - - - - - - - - - -Lighttpd --------- - -If you are using lighttpd, use this sample ``simple-vhost`` as a starting -point: - -.. code-block:: lighttpd - - server.document-root = "/path/to/app" - - url.rewrite-once = ( - # configure some static files - "^/assets/.+" => "$0", - "^/favicon\.ico$" => "$0", - - "^(/[^\?]*)(\?.*)?" => "/index.php$1$2" - ) - -.. _FallbackResource directive: http://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/ - -PHP ---- - -PHP ships with a built-in webserver for development. This server allows you to -run silex without any configuration. However, in order to serve static files, -you'll have to make sure your front controller returns false in that case:: - - // web/index.php - - $filename = __DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']); - if (php_sapi_name() === 'cli-server' && is_file($filename)) { - return false; - } - - $app = require __DIR__.'/../src/app.php'; - $app->run(); - - -Assuming your front controller is at ``web/index.php``, you can start the -server from the command-line with this command: - -.. code-block:: text - - $ php -S localhost:8080 -t web web/index.php - -Now the application should be running at ``http://localhost:8080``. - -.. note:: - - This server is for development only. It is **not** recommended to use it - in production. diff --git a/lib/silex/vendor/silex/silex/exclude.txt b/lib/silex/vendor/silex/silex/exclude.txt deleted file mode 100644 index 2fb875b0c..000000000 --- a/lib/silex/vendor/silex/silex/exclude.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -# The following source files are not re-distributed with the "build" of the application -# since they are used solely for constructing other files during the build process -# -tests \ No newline at end of file diff --git a/lib/silex/vendor/silex/silex/phpunit.xml.dist b/lib/silex/vendor/silex/silex/phpunit.xml.dist deleted file mode 100644 index 799f16c90..000000000 --- a/lib/silex/vendor/silex/silex/phpunit.xml.dist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - ./tests/Silex/ - - - - - ./src - - - diff --git a/lib/silex/vendor/silex/silex/src/Silex/Api/BootableProviderInterface.php b/lib/silex/vendor/silex/silex/src/Silex/Api/BootableProviderInterface.php deleted file mode 100644 index 739e04d56..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Api/BootableProviderInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Api; - -use Silex\Application; - -/** - * Interface for bootable service providers. - * - * @author Fabien Potencier - */ -interface BootableProviderInterface -{ - /** - * Bootstraps the application. - * - * This method is called after all services are registered - * and should be used for "dynamic" configuration (whenever - * a service must be requested). - * - * @param Application $app - */ - public function boot(Application $app); -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Api/ControllerProviderInterface.php b/lib/silex/vendor/silex/silex/src/Silex/Api/ControllerProviderInterface.php deleted file mode 100644 index 28d9d0e5e..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Api/ControllerProviderInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Api; - -use Silex\Application; -use Silex\ControllerCollection; - -/** - * Interface for controller providers. - * - * @author Fabien Potencier - */ -interface ControllerProviderInterface -{ - /** - * Returns routes to connect to the given application. - * - * @param Application $app An Application instance - * - * @return ControllerCollection A ControllerCollection instance - */ - public function connect(Application $app); -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Api/EventListenerProviderInterface.php b/lib/silex/vendor/silex/silex/src/Silex/Api/EventListenerProviderInterface.php deleted file mode 100644 index f3e625557..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Api/EventListenerProviderInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Api; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Pimple\Container; - -/** - * Interface for event listener providers. - * - * @author Fabien Potencier - */ -interface EventListenerProviderInterface -{ - public function subscribe(Container $app, EventDispatcherInterface $dispatcher); -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Api/LICENSE b/lib/silex/vendor/silex/silex/src/Silex/Api/LICENSE deleted file mode 100644 index bc6ad0497..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Api/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/silex/silex/src/Silex/Api/composer.json b/lib/silex/vendor/silex/silex/src/Silex/Api/composer.json deleted file mode 100644 index 7290988a3..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Api/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "minimum-stability": "dev", - "name": "silex/api", - "description": "The Silex interfaces", - "keywords": ["microframework"], - "homepage": "http://silex.sensiolabs.org", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "require": { - "php": ">=5.5.9", - "pimple/pimple": "~3.0" - }, - "suggest": { - "symfony/event-dispatcher": "For EventListenerProviderInterface", - "silex/silex": "For BootableProviderInterface and ControllerProviderInterface" - }, - "autoload": { - "psr-4": { "Silex\\Api\\": "" } - }, - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/AppArgumentValueResolver.php b/lib/silex/vendor/silex/silex/src/Silex/AppArgumentValueResolver.php deleted file mode 100644 index cc2197ab8..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/AppArgumentValueResolver.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * HttpKernel Argument Resolver for Silex. - * - * @author Romain Neutron - */ -class AppArgumentValueResolver implements ArgumentValueResolverInterface -{ - private $app; - - public function __construct(Application $app) - { - $this->app = $app; - } - - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - return null !== $argument->getType() && ($argument->getType() === Application::class || is_subclass_of($argument->getType(), Application::class)); - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - yield $this->app; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application.php b/lib/silex/vendor/silex/silex/src/Silex/Application.php deleted file mode 100644 index a5e5431d8..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application.php +++ /dev/null @@ -1,506 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\BinaryFileResponse; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\TerminableInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpKernel\Exception\HttpException; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpFoundation\JsonResponse; -use Silex\Api\BootableProviderInterface; -use Silex\Api\EventListenerProviderInterface; -use Silex\Api\ControllerProviderInterface; -use Silex\Provider\ExceptionHandlerServiceProvider; -use Silex\Provider\RoutingServiceProvider; -use Silex\Provider\HttpKernelServiceProvider; - -/** - * The Silex framework class. - * - * @author Fabien Potencier - */ -class Application extends Container implements HttpKernelInterface, TerminableInterface -{ - const VERSION = '2.2.2'; - - const EARLY_EVENT = 512; - const LATE_EVENT = -512; - - protected $providers = array(); - protected $booted = false; - - /** - * Instantiate a new Application. - * - * Objects and parameters can be passed as argument to the constructor. - * - * @param array $values The parameters or objects. - */ - public function __construct(array $values = array()) - { - parent::__construct(); - - $this['request.http_port'] = 80; - $this['request.https_port'] = 443; - $this['debug'] = false; - $this['charset'] = 'UTF-8'; - $this['logger'] = null; - - $this->register(new HttpKernelServiceProvider()); - $this->register(new RoutingServiceProvider()); - $this->register(new ExceptionHandlerServiceProvider()); - - foreach ($values as $key => $value) { - $this[$key] = $value; - } - } - - /** - * Registers a service provider. - * - * @param ServiceProviderInterface $provider A ServiceProviderInterface instance - * @param array $values An array of values that customizes the provider - * - * @return Application - */ - public function register(ServiceProviderInterface $provider, array $values = array()) - { - $this->providers[] = $provider; - - parent::register($provider, $values); - - return $this; - } - - /** - * Boots all service providers. - * - * This method is automatically called by handle(), but you can use it - * to boot all service providers when not handling a request. - */ - public function boot() - { - if ($this->booted) { - return; - } - - $this->booted = true; - - foreach ($this->providers as $provider) { - if ($provider instanceof EventListenerProviderInterface) { - $provider->subscribe($this, $this['dispatcher']); - } - - if ($provider instanceof BootableProviderInterface) { - $provider->boot($this); - } - } - } - - /** - * Maps a pattern to a callable. - * - * You can optionally specify HTTP methods that should be matched. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function match($pattern, $to = null) - { - return $this['controllers']->match($pattern, $to); - } - - /** - * Maps a GET request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function get($pattern, $to = null) - { - return $this['controllers']->get($pattern, $to); - } - - /** - * Maps a POST request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function post($pattern, $to = null) - { - return $this['controllers']->post($pattern, $to); - } - - /** - * Maps a PUT request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function put($pattern, $to = null) - { - return $this['controllers']->put($pattern, $to); - } - - /** - * Maps a DELETE request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function delete($pattern, $to = null) - { - return $this['controllers']->delete($pattern, $to); - } - - /** - * Maps an OPTIONS request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function options($pattern, $to = null) - { - return $this['controllers']->options($pattern, $to); - } - - /** - * Maps a PATCH request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function patch($pattern, $to = null) - { - return $this['controllers']->patch($pattern, $to); - } - - /** - * Adds an event listener that listens on the specified events. - * - * @param string $eventName The event to listen on - * @param callable $callback The listener - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - */ - public function on($eventName, $callback, $priority = 0) - { - if ($this->booted) { - $this['dispatcher']->addListener($eventName, $this['callback_resolver']->resolveCallback($callback), $priority); - - return; - } - - $this->extend('dispatcher', function (EventDispatcherInterface $dispatcher, $app) use ($callback, $priority, $eventName) { - $dispatcher->addListener($eventName, $app['callback_resolver']->resolveCallback($callback), $priority); - - return $dispatcher; - }); - } - - /** - * Registers a before filter. - * - * Before filters are run before any route has been matched. - * - * @param mixed $callback Before filter callback - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - */ - public function before($callback, $priority = 0) - { - $app = $this; - - $this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($callback, $app) { - if (!$event->isMasterRequest()) { - return; - } - - $ret = call_user_func($app['callback_resolver']->resolveCallback($callback), $event->getRequest(), $app); - - if ($ret instanceof Response) { - $event->setResponse($ret); - } - }, $priority); - } - - /** - * Registers an after filter. - * - * After filters are run after the controller has been executed. - * - * @param mixed $callback After filter callback - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - */ - public function after($callback, $priority = 0) - { - $app = $this; - - $this->on(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use ($callback, $app) { - if (!$event->isMasterRequest()) { - return; - } - - $response = call_user_func($app['callback_resolver']->resolveCallback($callback), $event->getRequest(), $event->getResponse(), $app); - if ($response instanceof Response) { - $event->setResponse($response); - } elseif (null !== $response) { - throw new \RuntimeException('An after middleware returned an invalid response value. Must return null or an instance of Response.'); - } - }, $priority); - } - - /** - * Registers a finish filter. - * - * Finish filters are run after the response has been sent. - * - * @param mixed $callback Finish filter callback - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - */ - public function finish($callback, $priority = 0) - { - $app = $this; - - $this->on(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($callback, $app) { - call_user_func($app['callback_resolver']->resolveCallback($callback), $event->getRequest(), $event->getResponse(), $app); - }, $priority); - } - - /** - * Aborts the current request by sending a proper HTTP error. - * - * @param int $statusCode The HTTP status code - * @param string $message The status message - * @param array $headers An array of HTTP headers - */ - public function abort($statusCode, $message = '', array $headers = array()) - { - throw new HttpException($statusCode, $message, null, $headers); - } - - /** - * Registers an error handler. - * - * Error handlers are simple callables which take a single Exception - * as an argument. If a controller throws an exception, an error handler - * can return a specific response. - * - * When an exception occurs, all handlers will be called, until one returns - * something (a string or a Response object), at which point that will be - * returned to the client. - * - * For this reason you should add logging handlers before output handlers. - * - * @param mixed $callback Error handler callback, takes an Exception argument - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to -8) - */ - public function error($callback, $priority = -8) - { - $this->on(KernelEvents::EXCEPTION, new ExceptionListenerWrapper($this, $callback), $priority); - } - - /** - * Registers a view handler. - * - * View handlers are simple callables which take a controller result and the - * request as arguments, whenever a controller returns a value that is not - * an instance of Response. When this occurs, all suitable handlers will be - * called, until one returns a Response object. - * - * @param mixed $callback View handler callback - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - */ - public function view($callback, $priority = 0) - { - $this->on(KernelEvents::VIEW, new ViewListenerWrapper($this, $callback), $priority); - } - - /** - * Flushes the controller collection. - */ - public function flush() - { - $this['routes']->addCollection($this['controllers']->flush()); - } - - /** - * Redirects the user to another URL. - * - * @param string $url The URL to redirect to - * @param int $status The status code (302 by default) - * - * @return RedirectResponse - */ - public function redirect($url, $status = 302) - { - return new RedirectResponse($url, $status); - } - - /** - * Creates a streaming response. - * - * @param mixed $callback A valid PHP callback - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return StreamedResponse - */ - public function stream($callback = null, $status = 200, array $headers = array()) - { - return new StreamedResponse($callback, $status, $headers); - } - - /** - * Escapes a text for HTML. - * - * @param string $text The input text to be escaped - * @param int $flags The flags (@see htmlspecialchars) - * @param string $charset The charset - * @param bool $doubleEncode Whether to try to avoid double escaping or not - * - * @return string Escaped text - */ - public function escape($text, $flags = ENT_COMPAT, $charset = null, $doubleEncode = true) - { - return htmlspecialchars($text, $flags, $charset ?: $this['charset'], $doubleEncode); - } - - /** - * Convert some data into a JSON response. - * - * @param mixed $data The response data - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return JsonResponse - */ - public function json($data = array(), $status = 200, array $headers = array()) - { - return new JsonResponse($data, $status, $headers); - } - - /** - * Sends a file. - * - * @param \SplFileInfo|string $file The file to stream - * @param int $status The response status code - * @param array $headers An array of response headers - * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename - * - * @return BinaryFileResponse - */ - public function sendFile($file, $status = 200, array $headers = array(), $contentDisposition = null) - { - return new BinaryFileResponse($file, $status, $headers, true, $contentDisposition); - } - - /** - * Mounts controllers under the given route prefix. - * - * @param string $prefix The route prefix - * @param ControllerCollection|callable|ControllerProviderInterface $controllers A ControllerCollection, a callable, or a ControllerProviderInterface instance - * - * @return Application - * - * @throws \LogicException - */ - public function mount($prefix, $controllers) - { - if ($controllers instanceof ControllerProviderInterface) { - $connectedControllers = $controllers->connect($this); - - if (!$connectedControllers instanceof ControllerCollection) { - throw new \LogicException(sprintf('The method "%s::connect" must return a "ControllerCollection" instance. Got: "%s"', get_class($controllers), is_object($connectedControllers) ? get_class($connectedControllers) : gettype($connectedControllers))); - } - - $controllers = $connectedControllers; - } elseif (!$controllers instanceof ControllerCollection && !is_callable($controllers)) { - throw new \LogicException('The "mount" method takes either a "ControllerCollection" instance, "ControllerProviderInterface" instance, or a callable.'); - } - - $this['controllers']->mount($prefix, $controllers); - - return $this; - } - - /** - * Handles the request and delivers the response. - * - * @param Request|null $request Request to process - */ - public function run(Request $request = null) - { - if (null === $request) { - $request = Request::createFromGlobals(); - } - - $response = $this->handle($request); - $response->send(); - $this->terminate($request, $response); - } - - /** - * {@inheritdoc} - * - * If you call this method directly instead of run(), you must call the - * terminate() method yourself if you want the finish filters to be run. - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - if (!$this->booted) { - $this->boot(); - } - - $this->flush(); - - return $this['kernel']->handle($request, $type, $catch); - } - - /** - * {@inheritdoc} - */ - public function terminate(Request $request, Response $response) - { - $this['kernel']->terminate($request, $response); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application/FormTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Application/FormTrait.php deleted file mode 100644 index 9106e7de1..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application/FormTrait.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Application; - -use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormTypeInterface; - -/** - * Form trait. - * - * @author Fabien Potencier - * @author David Berlioz - */ -trait FormTrait -{ - /** - * Creates and returns a form builder instance. - * - * @param mixed $data The initial data for the form - * @param array $options Options for the form - * @param string|FormTypeInterface $type Type of the form - * - * @return FormBuilder - */ - public function form($data = null, array $options = array(), $type = null) - { - return $this['form.factory']->createBuilder($type ?: FormType::class, $data, $options); - } - - /** - * Creates and returns a named form builder instance. - * - * @param string $name - * @param mixed $data The initial data for the form - * @param array $options Options for the form - * @param string|FormTypeInterface $type Type of the form - * - * @return FormBuilder - */ - public function namedForm($name, $data = null, array $options = array(), $type = null) - { - return $this['form.factory']->createNamedBuilder($name, $type ?: FormType::class, $data, $options); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application/MonologTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Application/MonologTrait.php deleted file mode 100644 index 18cb54c6d..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application/MonologTrait.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Application; - -use Monolog\Logger; - -/** - * Monolog trait. - * - * @author Fabien Potencier - */ -trait MonologTrait -{ - /** - * Adds a log record. - * - * @param string $message The log message - * @param array $context The log context - * @param int $level The logging level - * - * @return bool Whether the record has been processed - */ - public function log($message, array $context = array(), $level = Logger::INFO) - { - return $this['monolog']->addRecord($level, $message, $context); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application/SecurityTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Application/SecurityTrait.php deleted file mode 100644 index 43ce55522..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application/SecurityTrait.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Application; - -use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException; -use Symfony\Component\Security\Core\User\UserInterface; - -/** - * Security trait. - * - * @author Fabien Potencier - */ -trait SecurityTrait -{ - /** - * Encodes the raw password. - * - * @param UserInterface $user A UserInterface instance - * @param string $password The password to encode - * - * @return string The encoded password - * - * @throws \RuntimeException when no password encoder could be found for the user - */ - public function encodePassword(UserInterface $user, $password) - { - return $this['security.encoder_factory']->getEncoder($user)->encodePassword($password, $user->getSalt()); - } - - /** - * Checks if the attributes are granted against the current authentication token and optionally supplied object. - * - * @param mixed $attributes - * @param mixed $object - * - * @return bool - * - * @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token. - */ - public function isGranted($attributes, $object = null) - { - return $this['security.authorization_checker']->isGranted($attributes, $object); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application/SwiftmailerTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Application/SwiftmailerTrait.php deleted file mode 100644 index 157f94d8b..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application/SwiftmailerTrait.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Application; - -/** - * Swiftmailer trait. - * - * @author Fabien Potencier - */ -trait SwiftmailerTrait -{ - /** - * Sends an email. - * - * @param \Swift_Message $message A \Swift_Message instance - * @param array $failedRecipients An array of failures by-reference - * - * @return int The number of sent messages - */ - public function mail(\Swift_Message $message, &$failedRecipients = null) - { - return $this['mailer']->send($message, $failedRecipients); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application/TranslationTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Application/TranslationTrait.php deleted file mode 100644 index 8b6e818e8..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application/TranslationTrait.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Application; - -/** - * Translation trait. - * - * @author Fabien Potencier - */ -trait TranslationTrait -{ - /** - * Translates the given message. - * - * @param string $id The message id - * @param array $parameters An array of parameters for the message - * @param string $domain The domain for the message - * @param string $locale The locale - * - * @return string The translated string - */ - public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null) - { - return $this['translator']->trans($id, $parameters, $domain, $locale); - } - - /** - * Translates the given choice message by choosing a translation according to a number. - * - * @param string $id The message id - * @param int $number The number to use to find the indice of the message - * @param array $parameters An array of parameters for the message - * @param string $domain The domain for the message - * @param string $locale The locale - * - * @return string The translated string - */ - public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) - { - return $this['translator']->transChoice($id, $number, $parameters, $domain, $locale); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application/TwigTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Application/TwigTrait.php deleted file mode 100644 index cb4127d7e..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application/TwigTrait.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Application; - -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; - -/** - * Twig trait. - * - * @author Fabien Potencier - */ -trait TwigTrait -{ - /** - * Renders a view and returns a Response. - * - * To stream a view, pass an instance of StreamedResponse as a third argument. - * - * @param string $view The view name - * @param array $parameters An array of parameters to pass to the view - * @param Response $response A Response instance - * - * @return Response A Response instance - */ - public function render($view, array $parameters = array(), Response $response = null) - { - $twig = $this['twig']; - - if ($response instanceof StreamedResponse) { - $response->setCallback(function () use ($twig, $view, $parameters) { - $twig->display($view, $parameters); - }); - } else { - if (null === $response) { - $response = new Response(); - } - $response->setContent($twig->render($view, $parameters)); - } - - return $response; - } - - /** - * Renders a view. - * - * @param string $view The view name - * @param array $parameters An array of parameters to pass to the view - * - * @return string The rendered view - */ - public function renderView($view, array $parameters = array()) - { - return $this['twig']->render($view, $parameters); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Application/UrlGeneratorTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Application/UrlGeneratorTrait.php deleted file mode 100644 index 7ccdf8ac5..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Application/UrlGeneratorTrait.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Application; - -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * UrlGenerator trait. - * - * @author Fabien Potencier - */ -trait UrlGeneratorTrait -{ - /** - * Generates a path from the given parameters. - * - * @param string $route The name of the route - * @param mixed $parameters An array of parameters - * - * @return string The generated path - */ - public function path($route, $parameters = array()) - { - return $this['url_generator']->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_PATH); - } - - /** - * Generates an absolute URL from the given parameters. - * - * @param string $route The name of the route - * @param mixed $parameters An array of parameters - * - * @return string The generated URL - */ - public function url($route, $parameters = array()) - { - return $this['url_generator']->generate($route, $parameters, UrlGeneratorInterface::ABSOLUTE_URL); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/CallbackResolver.php b/lib/silex/vendor/silex/silex/src/Silex/CallbackResolver.php deleted file mode 100644 index 692901c29..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/CallbackResolver.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Pimple\Container; - -class CallbackResolver -{ - const SERVICE_PATTERN = "/[A-Za-z0-9\._\-]+:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/"; - - private $app; - - public function __construct(Container $app) - { - $this->app = $app; - } - - /** - * Returns true if the string is a valid service method representation. - * - * @param string $name - * - * @return bool - */ - public function isValid($name) - { - return is_string($name) && (preg_match(static::SERVICE_PATTERN, $name) || isset($this->app[$name])); - } - - /** - * Returns a callable given its string representation. - * - * @param string $name - * - * @return callable - * - * @throws \InvalidArgumentException In case the method does not exist. - */ - public function convertCallback($name) - { - if (preg_match(static::SERVICE_PATTERN, $name)) { - list($service, $method) = explode(':', $name, 2); - $callback = array($this->app[$service], $method); - } else { - $service = $name; - $callback = $this->app[$name]; - } - - if (!is_callable($callback)) { - throw new \InvalidArgumentException(sprintf('Service "%s" is not callable.', $service)); - } - - return $callback; - } - - /** - * Returns a callable given its string representation if it is a valid service method. - * - * @param string $name - * - * @return string|callable A callable value or the string passed in - * - * @throws \InvalidArgumentException In case the method does not exist. - */ - public function resolveCallback($name) - { - return $this->isValid($name) ? $this->convertCallback($name) : $name; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ConstraintValidatorFactory.php b/lib/silex/vendor/silex/silex/src/Silex/ConstraintValidatorFactory.php deleted file mode 100644 index 1daf43667..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ConstraintValidatorFactory.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; -use Symfony\Component\Validator\ConstraintValidator; - -/** - * Uses a service container to create constraint validators with dependencies. - * - * @author Kris Wallsmith - * @author Alex Kalyvitis - */ -class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface -{ - /** - * @var \Pimple - */ - protected $container; - - /** - * @var array - */ - protected $serviceNames; - - /** - * @var array - */ - protected $validators; - - /** - * Constructor - * - * @param \Pimple $container DI container - * @param array $serviceNames Validator service names - */ - public function __construct(\Pimple $container, array $serviceNames = array()) - { - $this->container = $container; - $this->serviceNames = $serviceNames; - $this->validators = array(); - } - - /** - * Returns the validator for the supplied constraint. - * - * @param Constraint $constraint A constraint - * @return ConstraintValidator A validator for the supplied constraint - */ - public function getInstance(Constraint $constraint) - { - $name = $constraint->validatedBy(); - - if (isset($this->validators[$name])) { - return $this->validators[$name]; - } - - $this->validators[$name] = $this->createValidator($name); - - return $this->validators[$name]; - } - - /** - * Returns the validator instance - * - * @param string $name - * @return ConstraintValidator - */ - private function createValidator($name) - { - if (isset($this->serviceNames[$name])) { - return $this->container[$this->serviceNames[$name]]; - } - - return new $name(); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Controller.php b/lib/silex/vendor/silex/silex/src/Silex/Controller.php deleted file mode 100644 index 9a8075591..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Controller.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Silex\Exception\ControllerFrozenException; - -/** - * A wrapper for a controller, mapped to a route. - * - * __call() forwards method-calls to Route, but returns instance of Controller - * listing Route's methods below, so that IDEs know they are valid - * - * @method Controller assert(string $variable, string $regexp) - * @method Controller value(string $variable, mixed $default) - * @method Controller convert(string $variable, mixed $callback) - * @method Controller method(string $method) - * @method Controller requireHttp() - * @method Controller requireHttps() - * @method Controller before(mixed $callback) - * @method Controller after(mixed $callback) - * @method Controller when(string $condition) - * - * @author Igor Wiedler - */ -class Controller -{ - private $route; - private $routeName; - private $isFrozen = false; - - /** - * Constructor. - * - * @param Route $route - */ - public function __construct(Route $route) - { - $this->route = $route; - } - - /** - * Gets the controller's route. - * - * @return Route - */ - public function getRoute() - { - return $this->route; - } - - /** - * Gets the controller's route name. - * - * @return string - */ - public function getRouteName() - { - return $this->routeName; - } - - /** - * Sets the controller's route. - * - * @param string $routeName - * - * @return Controller $this The current Controller instance - */ - public function bind($routeName) - { - if ($this->isFrozen) { - throw new ControllerFrozenException(sprintf('Calling %s on frozen %s instance.', __METHOD__, __CLASS__)); - } - - $this->routeName = $routeName; - - return $this; - } - - public function __call($method, $arguments) - { - if (!method_exists($this->route, $method)) { - throw new \BadMethodCallException(sprintf('Method "%s::%s" does not exist.', get_class($this->route), $method)); - } - - call_user_func_array(array($this->route, $method), $arguments); - - return $this; - } - - /** - * Freezes the controller. - * - * Once the controller is frozen, you can no longer change the route name - */ - public function freeze() - { - $this->isFrozen = true; - } - - public function generateRouteName($prefix) - { - $methods = implode('_', $this->route->getMethods()).'_'; - - $routeName = $methods.$prefix.$this->route->getPath(); - $routeName = str_replace(array('/', ':', '|', '-'), '_', $routeName); - $routeName = preg_replace('/[^a-z0-9A-Z_.]+/', '', $routeName); - - // Collapse consecutive underscores down into a single underscore. - $routeName = preg_replace('/_+/', '_', $routeName); - - return $routeName; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ControllerCollection.php b/lib/silex/vendor/silex/silex/src/Silex/ControllerCollection.php deleted file mode 100644 index 32f4a1917..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ControllerCollection.php +++ /dev/null @@ -1,240 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\HttpFoundation\Request; - -/** - * Builds Silex controllers. - * - * It acts as a staging area for routes. You are able to set the route name - * until flush() is called, at which point all controllers are frozen and - * converted to a RouteCollection. - * - * __call() forwards method-calls to Route, but returns instance of ControllerCollection - * listing Route's methods below, so that IDEs know they are valid - * - * @method ControllerCollection assert(string $variable, string $regexp) - * @method ControllerCollection value(string $variable, mixed $default) - * @method ControllerCollection convert(string $variable, mixed $callback) - * @method ControllerCollection method(string $method) - * @method ControllerCollection requireHttp() - * @method ControllerCollection requireHttps() - * @method ControllerCollection before(mixed $callback) - * @method ControllerCollection after(mixed $callback) - * @method ControllerCollection when(string $condition) - * - * @author Igor Wiedler - * @author Fabien Potencier - */ -class ControllerCollection -{ - protected $controllers = array(); - protected $defaultRoute; - protected $defaultController; - protected $prefix; - protected $routesFactory; - protected $controllersFactory; - - public function __construct(Route $defaultRoute, RouteCollection $routesFactory = null, $controllersFactory = null) - { - $this->defaultRoute = $defaultRoute; - $this->routesFactory = $routesFactory; - $this->controllersFactory = $controllersFactory; - $this->defaultController = function (Request $request) { - throw new \LogicException(sprintf('The "%s" route must have code to run when it matches.', $request->attributes->get('_route'))); - }; - } - - /** - * Mounts controllers under the given route prefix. - * - * @param string $prefix The route prefix - * @param ControllerCollection|callable $controllers A ControllerCollection instance or a callable for defining routes - * - * @throws \LogicException - */ - public function mount($prefix, $controllers) - { - if (is_callable($controllers)) { - $collection = $this->controllersFactory ? call_user_func($this->controllersFactory) : new static(new Route(), new RouteCollection()); - $collection->defaultRoute = clone $this->defaultRoute; - call_user_func($controllers, $collection); - $controllers = $collection; - } elseif (!$controllers instanceof self) { - throw new \LogicException('The "mount" method takes either a "ControllerCollection" instance or callable.'); - } - - $controllers->prefix = $prefix; - - $this->controllers[] = $controllers; - } - - /** - * Maps a pattern to a callable. - * - * You can optionally specify HTTP methods that should be matched. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function match($pattern, $to = null) - { - $route = clone $this->defaultRoute; - $route->setPath($pattern); - $this->controllers[] = $controller = new Controller($route); - $route->setDefault('_controller', null === $to ? $this->defaultController : $to); - - return $controller; - } - - /** - * Maps a GET request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function get($pattern, $to = null) - { - return $this->match($pattern, $to)->method('GET'); - } - - /** - * Maps a POST request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function post($pattern, $to = null) - { - return $this->match($pattern, $to)->method('POST'); - } - - /** - * Maps a PUT request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function put($pattern, $to = null) - { - return $this->match($pattern, $to)->method('PUT'); - } - - /** - * Maps a DELETE request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function delete($pattern, $to = null) - { - return $this->match($pattern, $to)->method('DELETE'); - } - - /** - * Maps an OPTIONS request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function options($pattern, $to = null) - { - return $this->match($pattern, $to)->method('OPTIONS'); - } - - /** - * Maps a PATCH request to a callable. - * - * @param string $pattern Matched route pattern - * @param mixed $to Callback that returns the response when matched - * - * @return Controller - */ - public function patch($pattern, $to = null) - { - return $this->match($pattern, $to)->method('PATCH'); - } - - public function __call($method, $arguments) - { - if (!method_exists($this->defaultRoute, $method)) { - throw new \BadMethodCallException(sprintf('Method "%s::%s" does not exist.', get_class($this->defaultRoute), $method)); - } - - call_user_func_array(array($this->defaultRoute, $method), $arguments); - - foreach ($this->controllers as $controller) { - call_user_func_array(array($controller, $method), $arguments); - } - - return $this; - } - - /** - * Persists and freezes staged controllers. - * - * @return RouteCollection A RouteCollection instance - */ - public function flush() - { - if (null === $this->routesFactory) { - $routes = new RouteCollection(); - } else { - $routes = $this->routesFactory; - } - - return $this->doFlush('', $routes); - } - - private function doFlush($prefix, RouteCollection $routes) - { - if ($prefix !== '') { - $prefix = '/'.trim(trim($prefix), '/'); - } - - foreach ($this->controllers as $controller) { - if ($controller instanceof Controller) { - $controller->getRoute()->setPath($prefix.$controller->getRoute()->getPath()); - if (!$name = $controller->getRouteName()) { - $name = $base = $controller->generateRouteName(''); - $i = 0; - while ($routes->get($name)) { - $name = $base.'_'.++$i; - } - $controller->bind($name); - } - $routes->add($name, $controller->getRoute()); - $controller->freeze(); - } else { - $controller->doFlush($prefix.$controller->prefix, $routes); - } - } - - $this->controllers = array(); - - return $routes; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ControllerProviderInterface.php b/lib/silex/vendor/silex/silex/src/Silex/ControllerProviderInterface.php deleted file mode 100644 index 2e1f7e6aa..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ControllerProviderInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -/** - * Interface for controller providers. - * - * @author Fabien Potencier - */ -interface ControllerProviderInterface -{ - /** - * Returns routes to connect to the given application. - * - * @param Application $app An Application instance - * - * @return ControllerCollection A ControllerCollection instance - */ - public function connect(Application $app); -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ControllerResolver.php b/lib/silex/vendor/silex/silex/src/Silex/ControllerResolver.php deleted file mode 100644 index 0a95e15f2..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ControllerResolver.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver; -use Symfony\Component\HttpFoundation\Request; - -/** - * Adds Application as a valid argument for controllers. - * - * @author Fabien Potencier - * - * @deprecated This class can be dropped once Symfony 3.0 is not supported anymore. - */ -class ControllerResolver extends BaseControllerResolver -{ - protected $app; - - /** - * Constructor. - * - * @param Application $app An Application instance - * @param LoggerInterface $logger A LoggerInterface instance - */ - public function __construct(Application $app, LoggerInterface $logger = null) - { - $this->app = $app; - - parent::__construct($logger); - } - - protected function doGetArguments(Request $request, $controller, array $parameters) - { - foreach ($parameters as $param) { - if ($param->getClass() && $param->getClass()->isInstance($this->app)) { - $request->attributes->set($param->getName(), $this->app); - - break; - } - } - - return parent::doGetArguments($request, $controller, $parameters); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/EventListener/ConverterListener.php b/lib/silex/vendor/silex/silex/src/Silex/EventListener/ConverterListener.php deleted file mode 100644 index 2fa93c199..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/EventListener/ConverterListener.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\EventListener; - -use Silex\CallbackResolver; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Routing\RouteCollection; - -/** - * Handles converters. - * - * @author Fabien Potencier - */ -class ConverterListener implements EventSubscriberInterface -{ - protected $routes; - protected $callbackResolver; - - /** - * Constructor. - * - * @param RouteCollection $routes A RouteCollection instance - * @param CallbackResolver $callbackResolver A CallbackResolver instance - */ - public function __construct(RouteCollection $routes, CallbackResolver $callbackResolver) - { - $this->routes = $routes; - $this->callbackResolver = $callbackResolver; - } - - /** - * Handles converters. - * - * @param FilterControllerEvent $event The event to handle - */ - public function onKernelController(FilterControllerEvent $event) - { - $request = $event->getRequest(); - $route = $this->routes->get($request->attributes->get('_route')); - if ($route && $converters = $route->getOption('_converters')) { - foreach ($converters as $name => $callback) { - $callback = $this->callbackResolver->resolveCallback($callback); - - $request->attributes->set($name, call_user_func($callback, $request->attributes->get($name), $request)); - } - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::CONTROLLER => 'onKernelController', - ); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/EventListener/LocaleListener.php b/lib/silex/vendor/silex/silex/src/Silex/EventListener/LocaleListener.php deleted file mode 100644 index 60dd624c0..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/EventListener/LocaleListener.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\EventListener; - -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\EventListener\LocaleListener as BaseLocaleListener; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Routing\RequestContextAwareInterface; -use Silex\Application; - -/** - * Initializes the locale based on the current request. - * - * @author Fabien Potencier - */ -class LocaleListener extends BaseLocaleListener -{ - protected $app; - - public function __construct(Application $app, RequestContextAwareInterface $router = null, RequestStack $requestStack = null) - { - parent::__construct($app['locale'], $router, $requestStack); - - $this->app = $app; - } - - public function onKernelRequest(GetResponseEvent $event) - { - parent::onKernelRequest($event); - - $this->app['locale'] = $event->getRequest()->getLocale(); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/EventListener/LogListener.php b/lib/silex/vendor/silex/silex/src/Silex/EventListener/LogListener.php deleted file mode 100644 index 5f3cc9045..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/EventListener/LogListener.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\EventListener; - -use Psr\Log\LoggerInterface; -use Psr\Log\LogLevel; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; - -/** - * Logs request, response, and exceptions. - */ -class LogListener implements EventSubscriberInterface -{ - protected $logger; - protected $exceptionLogFilter; - - public function __construct(LoggerInterface $logger, $exceptionLogFilter = null) - { - $this->logger = $logger; - if (null === $exceptionLogFilter) { - $exceptionLogFilter = function (\Exception $e) { - if ($e instanceof HttpExceptionInterface && $e->getStatusCode() < 500) { - return LogLevel::ERROR; - } - - return LogLevel::CRITICAL; - }; - } - - $this->exceptionLogFilter = $exceptionLogFilter; - } - - /** - * Logs master requests on event KernelEvents::REQUEST. - * - * @param GetResponseEvent $event - */ - public function onKernelRequest(GetResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $this->logRequest($event->getRequest()); - } - - /** - * Logs master response on event KernelEvents::RESPONSE. - * - * @param FilterResponseEvent $event - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $this->logResponse($event->getResponse()); - } - - /** - * Logs uncaught exceptions on event KernelEvents::EXCEPTION. - * - * @param GetResponseForExceptionEvent $event - */ - public function onKernelException(GetResponseForExceptionEvent $event) - { - $this->logException($event->getException()); - } - - /** - * Logs a request. - * - * @param Request $request - */ - protected function logRequest(Request $request) - { - $this->logger->log(LogLevel::DEBUG, '> '.$request->getMethod().' '.$request->getRequestUri()); - } - - /** - * Logs a response. - * - * @param Response $response - */ - protected function logResponse(Response $response) - { - $message = '< '.$response->getStatusCode(); - - if ($response instanceof RedirectResponse) { - $message .= ' '.$response->getTargetUrl(); - } - - $this->logger->log(LogLevel::DEBUG, $message); - } - - /** - * Logs an exception. - */ - protected function logException(\Exception $e) - { - $this->logger->log(call_user_func($this->exceptionLogFilter, $e), sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), array('exception' => $e)); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 0), - KernelEvents::RESPONSE => array('onKernelResponse', 0), - /* - * Priority -4 is used to come after those from SecurityServiceProvider (0) - * but before the error handlers added with Silex\Application::error (defaults to -8) - */ - KernelEvents::EXCEPTION => array('onKernelException', -4), - ); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/EventListener/MiddlewareListener.php b/lib/silex/vendor/silex/silex/src/Silex/EventListener/MiddlewareListener.php deleted file mode 100644 index 9b28ff1ac..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/EventListener/MiddlewareListener.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\EventListener; - -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Silex\Application; - -/** - * Manages the route middlewares. - * - * @author Fabien Potencier - */ -class MiddlewareListener implements EventSubscriberInterface -{ - protected $app; - - /** - * Constructor. - * - * @param Application $app An Application instance - */ - public function __construct(Application $app) - { - $this->app = $app; - } - - /** - * Runs before filters. - * - * @param GetResponseEvent $event The event to handle - */ - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - $routeName = $request->attributes->get('_route'); - if (!$route = $this->app['routes']->get($routeName)) { - return; - } - - foreach ((array) $route->getOption('_before_middlewares') as $callback) { - $ret = call_user_func($this->app['callback_resolver']->resolveCallback($callback), $request, $this->app); - if ($ret instanceof Response) { - $event->setResponse($ret); - - return; - } elseif (null !== $ret) { - throw new \RuntimeException(sprintf('A before middleware for route "%s" returned an invalid response value. Must return null or an instance of Response.', $routeName)); - } - } - } - - /** - * Runs after filters. - * - * @param FilterResponseEvent $event The event to handle - */ - public function onKernelResponse(FilterResponseEvent $event) - { - $request = $event->getRequest(); - $routeName = $request->attributes->get('_route'); - if (!$route = $this->app['routes']->get($routeName)) { - return; - } - - foreach ((array) $route->getOption('_after_middlewares') as $callback) { - $response = call_user_func($this->app['callback_resolver']->resolveCallback($callback), $request, $event->getResponse(), $this->app); - if ($response instanceof Response) { - $event->setResponse($response); - } elseif (null !== $response) { - throw new \RuntimeException(sprintf('An after middleware for route "%s" returned an invalid response value. Must return null or an instance of Response.', $routeName)); - } - } - } - - public static function getSubscribedEvents() - { - return array( - // this must be executed after the late events defined with before() (and their priority is -512) - KernelEvents::REQUEST => array('onKernelRequest', -1024), - KernelEvents::RESPONSE => array('onKernelResponse', 128), - ); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/EventListener/StringToResponseListener.php b/lib/silex/vendor/silex/silex/src/Silex/EventListener/StringToResponseListener.php deleted file mode 100644 index 9fdba5fe6..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/EventListener/StringToResponseListener.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\EventListener; - -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Response; - -/** - * Converts string responses to proper Response instances. - * - * @author Fabien Potencier - */ -class StringToResponseListener implements EventSubscriberInterface -{ - /** - * Handles string responses. - * - * @param GetResponseForControllerResultEvent $event The event to handle - */ - public function onKernelView(GetResponseForControllerResultEvent $event) - { - $response = $event->getControllerResult(); - - if (!( - null === $response - || is_array($response) - || $response instanceof Response - || (is_object($response) && !method_exists($response, '__toString')) - )) { - $event->setResponse(new Response((string) $response)); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::VIEW => array('onKernelView', -10), - ); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Exception/ControllerFrozenException.php b/lib/silex/vendor/silex/silex/src/Silex/Exception/ControllerFrozenException.php deleted file mode 100644 index 7f0d65f14..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Exception/ControllerFrozenException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Exception; - -/** - * Exception, is thrown when a frozen controller is modified. - * - * @author Igor Wiedler - */ -class ControllerFrozenException extends \RuntimeException -{ -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ExceptionHandler.php b/lib/silex/vendor/silex/silex/src/Silex/ExceptionHandler.php deleted file mode 100644 index 34eb8937c..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ExceptionHandler.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\Debug\ExceptionHandler as DebugExceptionHandler; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Default exception handler. - * - * @author Fabien Potencier - */ -class ExceptionHandler implements EventSubscriberInterface -{ - protected $debug; - - public function __construct($debug) - { - $this->debug = $debug; - } - - public function onSilexError(GetResponseForExceptionEvent $event) - { - $handler = new DebugExceptionHandler($this->debug); - - $exception = $event->getException(); - if (!$exception instanceof FlattenException) { - $exception = FlattenException::create($exception); - } - - $response = Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset(ini_get('default_charset')); - - $event->setResponse($response); - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return array(KernelEvents::EXCEPTION => array('onSilexError', -255)); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ExceptionListenerWrapper.php b/lib/silex/vendor/silex/silex/src/Silex/ExceptionListenerWrapper.php deleted file mode 100644 index e0d527b00..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ExceptionListenerWrapper.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; - -/** - * Wraps exception listeners. - * - * @author Fabien Potencier - */ -class ExceptionListenerWrapper -{ - protected $app; - protected $callback; - - /** - * Constructor. - * - * @param Application $app An Application instance - * @param callable $callback - */ - public function __construct(Application $app, $callback) - { - $this->app = $app; - $this->callback = $callback; - } - - public function __invoke(GetResponseForExceptionEvent $event) - { - $exception = $event->getException(); - $this->callback = $this->app['callback_resolver']->resolveCallback($this->callback); - - if (!$this->shouldRun($exception)) { - return; - } - - $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500; - - $response = call_user_func($this->callback, $exception, $event->getRequest(), $code); - - $this->ensureResponse($response, $event); - } - - protected function shouldRun(\Exception $exception) - { - if (is_array($this->callback)) { - $callbackReflection = new \ReflectionMethod($this->callback[0], $this->callback[1]); - } elseif (is_object($this->callback) && !$this->callback instanceof \Closure) { - $callbackReflection = new \ReflectionObject($this->callback); - $callbackReflection = $callbackReflection->getMethod('__invoke'); - } else { - $callbackReflection = new \ReflectionFunction($this->callback); - } - - if ($callbackReflection->getNumberOfParameters() > 0) { - $parameters = $callbackReflection->getParameters(); - $expectedException = $parameters[0]; - if ($expectedException->getClass() && !$expectedException->getClass()->isInstance($exception)) { - return false; - } - } - - return true; - } - - protected function ensureResponse($response, GetResponseForExceptionEvent $event) - { - if ($response instanceof Response) { - $event->setResponse($response); - } else { - $viewEvent = new GetResponseForControllerResultEvent($this->app['kernel'], $event->getRequest(), $event->getRequestType(), $response); - $this->app['dispatcher']->dispatch(KernelEvents::VIEW, $viewEvent); - - if ($viewEvent->hasResponse()) { - $event->setResponse($viewEvent->getResponse()); - } - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/HttpCache.php b/lib/silex/vendor/silex/silex/src/Silex/HttpCache.php deleted file mode 100644 index ebd65dd92..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/HttpCache.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache; -use Symfony\Component\HttpFoundation\Request; - -/** - * HTTP Cache extension to allow using the run() shortcut. - * - * @author Fabien Potencier - */ -class HttpCache extends BaseHttpCache -{ - /** - * Handles the Request and delivers the Response. - * - * @param Request $request The Request object - */ - public function run(Request $request = null) - { - if (null === $request) { - $request = Request::createFromGlobals(); - } - - $response = $this->handle($request); - $response->send(); - $this->terminate($request, $response); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/LazyUrlMatcher.php b/lib/silex/vendor/silex/silex/src/Silex/LazyUrlMatcher.php deleted file mode 100644 index 9cdd3bdd5..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/LazyUrlMatcher.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\Routing\RequestContext as SymfonyRequestContext; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; - -/** - * Implements a lazy UrlMatcher. - * - * @author Igor Wiedler - */ -class LazyUrlMatcher implements UrlMatcherInterface -{ - private $factory; - - public function __construct(\Closure $factory) - { - $this->factory = $factory; - } - - /** - * Returns the corresponding UrlMatcherInterface instance. - * - * @return UrlMatcherInterface - */ - public function getUrlMatcher() - { - $urlMatcher = call_user_func($this->factory); - if (!$urlMatcher instanceof UrlMatcherInterface) { - throw new \LogicException("Factory supplied to LazyUrlMatcher must return implementation of UrlMatcherInterface."); - } - - return $urlMatcher; - } - - /** - * {@inheritdoc} - */ - public function match($pathinfo) - { - return $this->getUrlMatcher()->match($pathinfo); - } - - /** - * {@inheritdoc} - */ - public function setContext(SymfonyRequestContext $context) - { - $this->getUrlMatcher()->setContext($context); - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - return $this->getUrlMatcher()->getContext(); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/AssetServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/AssetServiceProvider.php deleted file mode 100644 index fa6033066..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/AssetServiceProvider.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Symfony\Component\Asset\Packages; -use Symfony\Component\Asset\Package; -use Symfony\Component\Asset\PathPackage; -use Symfony\Component\Asset\UrlPackage; -use Symfony\Component\Asset\Context\RequestStackContext; -use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; -use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy; -use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; - -/** - * Symfony Asset component Provider. - * - * @author Fabien Potencier - */ -class AssetServiceProvider implements ServiceProviderInterface -{ - public function register(Container $app) - { - $app['assets.packages'] = function ($app) { - $packages = array(); - foreach ($app['assets.named_packages'] as $name => $package) { - $version = $app['assets.strategy_factory'](isset($package['version']) ? $package['version'] : null, isset($package['version_format']) ? $package['version_format'] : null, isset($package['json_manifest_path']) ? $package['json_manifest_path'] : null, $name); - - $packages[$name] = $app['assets.package_factory'](isset($package['base_path']) ? $package['base_path'] : '', isset($package['base_urls']) ? $package['base_urls'] : array(), $version, $name); - } - - return new Packages($app['assets.default_package'], $packages); - }; - - $app['assets.default_package'] = function ($app) { - $version = $app['assets.strategy_factory']($app['assets.version'], $app['assets.version_format'], $app['assets.json_manifest_path'], 'default'); - - return $app['assets.package_factory']($app['assets.base_path'], $app['assets.base_urls'], $version, 'default'); - }; - - $app['assets.context'] = function ($app) { - return new RequestStackContext($app['request_stack']); - }; - - $app['assets.base_path'] = ''; - $app['assets.base_urls'] = array(); - $app['assets.version'] = null; - $app['assets.version_format'] = null; - $app['assets.json_manifest_path'] = null; - - $app['assets.named_packages'] = array(); - - // prototypes - - $app['assets.strategy_factory'] = $app->protect(function ($version, $format, $jsonManifestPath, $name) use ($app) { - if ($version && $jsonManifestPath) { - throw new \LogicException(sprintf('Asset package "%s" cannot have version and manifest.', $name)); - } - - if ($version) { - return new StaticVersionStrategy($version, $format); - } - - if ($jsonManifestPath) { - if (!class_exists('Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy')) { - throw new \RuntimeException('You must require symfony/asset >= 3.3 to use JSON manifest version strategy.'); - } - - return new JsonManifestVersionStrategy($jsonManifestPath); - } - - return new EmptyVersionStrategy(); - }); - - $app['assets.package_factory'] = $app->protect(function ($basePath, $baseUrls, $version, $name) use ($app) { - if ($basePath && $baseUrls) { - throw new \LogicException(sprintf('Asset package "%s" cannot have base URLs and base paths.', $name)); - } - - if (!$baseUrls) { - return new PathPackage($basePath, $version, $app['assets.context']); - } - - return new UrlPackage($baseUrls, $version, $app['assets.context']); - }); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/CsrfServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/CsrfServiceProvider.php deleted file mode 100644 index eb6e882df..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/CsrfServiceProvider.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Symfony\Component\Security\Csrf\CsrfTokenManager; -use Symfony\Component\Security\Csrf\TokenGenerator\UriSafeTokenGenerator; -use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage; -use Symfony\Component\Security\Csrf\TokenStorage\NativeSessionTokenStorage; - -/** - * Symfony CSRF Security component Provider. - * - * @author Fabien Potencier - */ -class CsrfServiceProvider implements ServiceProviderInterface -{ - public function register(Container $app) - { - $app['csrf.token_manager'] = function ($app) { - return new CsrfTokenManager($app['csrf.token_generator'], $app['csrf.token_storage']); - }; - - $app['csrf.token_storage'] = function ($app) { - if (isset($app['session'])) { - return new SessionTokenStorage($app['session'], $app['csrf.session_namespace']); - } - - return new NativeSessionTokenStorage($app['csrf.session_namespace']); - }; - - $app['csrf.token_generator'] = function ($app) { - return new UriSafeTokenGenerator(); - }; - - $app['csrf.session_namespace'] = '_csrf'; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/DoctrineServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/DoctrineServiceProvider.php deleted file mode 100644 index 9c71d5b79..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/DoctrineServiceProvider.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Configuration; -use Doctrine\Common\EventManager; -use Symfony\Bridge\Doctrine\Logger\DbalLogger; - -/** - * Doctrine DBAL Provider. - * - * @author Fabien Potencier - */ -class DoctrineServiceProvider implements ServiceProviderInterface -{ - public function register(Container $app) - { - $app['db.default_options'] = array( - 'driver' => 'pdo_mysql', - 'dbname' => null, - 'host' => 'localhost', - 'user' => 'root', - 'password' => null, - ); - - $app['dbs.options.initializer'] = $app->protect(function () use ($app) { - static $initialized = false; - - if ($initialized) { - return; - } - - $initialized = true; - - if (!isset($app['dbs.options'])) { - $app['dbs.options'] = array('default' => isset($app['db.options']) ? $app['db.options'] : array()); - } - - $tmp = $app['dbs.options']; - foreach ($tmp as $name => &$options) { - $options = array_replace($app['db.default_options'], $options); - - if (!isset($app['dbs.default'])) { - $app['dbs.default'] = $name; - } - } - $app['dbs.options'] = $tmp; - }); - - $app['dbs'] = function ($app) { - $app['dbs.options.initializer'](); - - $dbs = new Container(); - foreach ($app['dbs.options'] as $name => $options) { - if ($app['dbs.default'] === $name) { - // we use shortcuts here in case the default has been overridden - $config = $app['db.config']; - $manager = $app['db.event_manager']; - } else { - $config = $app['dbs.config'][$name]; - $manager = $app['dbs.event_manager'][$name]; - } - - $dbs[$name] = function ($dbs) use ($options, $config, $manager) { - return DriverManager::getConnection($options, $config, $manager); - }; - } - - return $dbs; - }; - - $app['dbs.config'] = function ($app) { - $app['dbs.options.initializer'](); - - $configs = new Container(); - $addLogger = isset($app['logger']) && null !== $app['logger'] && class_exists('Symfony\Bridge\Doctrine\Logger\DbalLogger'); - foreach ($app['dbs.options'] as $name => $options) { - $configs[$name] = new Configuration(); - if ($addLogger) { - $configs[$name]->setSQLLogger(new DbalLogger($app['logger'], isset($app['stopwatch']) ? $app['stopwatch'] : null)); - } - } - - return $configs; - }; - - $app['dbs.event_manager'] = function ($app) { - $app['dbs.options.initializer'](); - - $managers = new Container(); - foreach ($app['dbs.options'] as $name => $options) { - $managers[$name] = new EventManager(); - } - - return $managers; - }; - - // shortcuts for the "first" DB - $app['db'] = function ($app) { - $dbs = $app['dbs']; - - return $dbs[$app['dbs.default']]; - }; - - $app['db.config'] = function ($app) { - $dbs = $app['dbs.config']; - - return $dbs[$app['dbs.default']]; - }; - - $app['db.event_manager'] = function ($app) { - $dbs = $app['dbs.event_manager']; - - return $dbs[$app['dbs.default']]; - }; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/ExceptionHandlerServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/ExceptionHandlerServiceProvider.php deleted file mode 100644 index 1c6f20286..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/ExceptionHandlerServiceProvider.php +++ /dev/null @@ -1,32 +0,0 @@ -addSubscriber($app['exception_handler']); - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Form/SilexFormExtension.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Form/SilexFormExtension.php deleted file mode 100644 index 12efbdf23..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Form/SilexFormExtension.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Form; - -use Pimple\Container; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\FormExtensionInterface; -use Symfony\Component\Form\FormTypeGuesserChain; - -class SilexFormExtension implements FormExtensionInterface -{ - private $app; - private $types; - private $typeExtensions; - private $guessers; - private $guesserLoaded = false; - private $guesser; - - public function __construct(Container $app, array $types, array $typeExtensions, array $guessers) - { - $this->app = $app; - $this->setTypes($types); - $this->setTypeExtensions($typeExtensions); - $this->setGuessers($guessers); - } - - public function getType($name) - { - if (!isset($this->types[$name])) { - throw new InvalidArgumentException(sprintf('The type "%s" is not the name of a registered form type.', $name)); - } - if (!is_object($this->types[$name])) { - $this->types[$name] = $this->app[$this->types[$name]]; - } - - return $this->types[$name]; - } - - public function hasType($name) - { - return isset($this->types[$name]); - } - - public function getTypeExtensions($name) - { - return isset($this->typeExtensions[$name]) ? $this->typeExtensions[$name] : []; - } - - public function hasTypeExtensions($name) - { - return isset($this->typeExtensions[$name]); - } - - public function getTypeGuesser() - { - if (!$this->guesserLoaded) { - $this->guesserLoaded = true; - - if ($this->guessers) { - $guessers = []; - foreach ($this->guessers as $guesser) { - if (!is_object($guesser)) { - $guesser = $this->app[$guesser]; - } - $guessers[] = $guesser; - } - $this->guesser = new FormTypeGuesserChain($guessers); - } - } - - return $this->guesser; - } - - private function setTypes(array $types) - { - $this->types = []; - foreach ($types as $type) { - if (!is_object($type)) { - if (!isset($this->app[$type])) { - throw new InvalidArgumentException(sprintf('Invalid form type. The silex service "%s" does not exist.', $type)); - } - $this->types[$type] = $type; - } else { - $this->types[get_class($type)] = $type; - } - } - } - - private function setTypeExtensions(array $typeExtensions) - { - $this->typeExtensions = []; - foreach ($typeExtensions as $extension) { - if (!is_object($extension)) { - if (!isset($this->app[$extension])) { - throw new InvalidArgumentException(sprintf('Invalid form type extension. The silex service "%s" does not exist.', $extension)); - } - $extension = $this->app[$extension]; - } - $this->typeExtensions[$extension->getExtendedType()][] = $extension; - } - } - - private function setGuessers(array $guessers) - { - $this->guessers = []; - foreach ($guessers as $guesser) { - if (!is_object($guesser) && !isset($this->app[$guesser])) { - throw new InvalidArgumentException(sprintf('Invalid form type guesser. The silex service "%s" does not exist.', $guesser)); - } - $this->guessers[] = $guesser; - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/FormServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/FormServiceProvider.php deleted file mode 100644 index 00841d0bf..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/FormServiceProvider.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Symfony\Component\Form\Extension\Csrf\CsrfExtension; -use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension; -use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidatorExtension; -use Symfony\Component\Form\FormFactory; -use Symfony\Component\Form\FormRegistry; -use Symfony\Component\Form\ResolvedFormTypeFactory; - -/** - * Symfony Form component Provider. - * - * @author Fabien Potencier - */ -class FormServiceProvider implements ServiceProviderInterface -{ - public function register(Container $app) - { - if (!class_exists('Locale')) { - throw new \RuntimeException('You must either install the PHP intl extension or the Symfony Intl Component to use the Form extension.'); - } - - $app['form.types'] = function ($app) { - return array(); - }; - - $app['form.type.extensions'] = function ($app) { - return array(); - }; - - $app['form.type.guessers'] = function ($app) { - return array(); - }; - - $app['form.extension.csrf'] = function ($app) { - if (isset($app['translator'])) { - return new CsrfExtension($app['csrf.token_manager'], $app['translator']); - } - - return new CsrfExtension($app['csrf.token_manager']); - }; - - $app['form.extension.silex'] = function ($app) { - return new Form\SilexFormExtension($app, $app['form.types'], $app['form.type.extensions'], $app['form.type.guessers']); - }; - - $app['form.extensions'] = function ($app) { - $extensions = array( - new HttpFoundationExtension(), - ); - - if (isset($app['csrf.token_manager'])) { - $extensions[] = $app['form.extension.csrf']; - } - - if (isset($app['validator'])) { - $extensions[] = new FormValidatorExtension($app['validator']); - } - $extensions[] = $app['form.extension.silex']; - - return $extensions; - }; - - $app['form.factory'] = function ($app) { - return new FormFactory($app['form.registry'], $app['form.resolved_type_factory']); - }; - - $app['form.registry'] = function ($app) { - return new FormRegistry($app['form.extensions'], $app['form.resolved_type_factory']); - }; - - $app['form.resolved_type_factory'] = function ($app) { - return new ResolvedFormTypeFactory(); - }; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCache/HttpCache.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCache/HttpCache.php deleted file mode 100644 index b0ebb5ccb..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCache/HttpCache.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\HttpCache; - -use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache; -use Symfony\Component\HttpFoundation\Request; - -/** - * HTTP Cache extension to allow using the run() shortcut. - * - * @author Fabien Potencier - */ -class HttpCache extends BaseHttpCache -{ - /** - * Handles the Request and delivers the Response. - * - * @param Request $request The Request object - */ - public function run(Request $request = null) - { - if (null === $request) { - $request = Request::createFromGlobals(); - } - - $response = $this->handle($request); - $response->send(); - $this->terminate($request, $response); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php deleted file mode 100644 index 8b3f37ee6..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Provider\HttpCache\HttpCache; -use Silex\Api\EventListenerProviderInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\HttpCache\Store; -use Symfony\Component\HttpKernel\EventListener\SurrogateListener; - -/** - * Symfony HttpKernel component Provider for HTTP cache. - * - * @author Fabien Potencier - */ -class HttpCacheServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['http_cache'] = function ($app) { - $app['http_cache.options'] = array_replace( - array( - 'debug' => $app['debug'], - ), $app['http_cache.options'] - ); - - return new HttpCache($app, $app['http_cache.store'], $app['http_cache.esi'], $app['http_cache.options']); - }; - - $app['http_cache.esi'] = function ($app) { - return new Esi(); - }; - - $app['http_cache.store'] = function ($app) { - return new Store($app['http_cache.cache_dir']); - }; - - $app['http_cache.esi_listener'] = function ($app) { - return new SurrogateListener($app['http_cache.esi']); - }; - - $app['http_cache.options'] = array(); - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber($app['http_cache.esi_listener']); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpFragmentServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpFragmentServiceProvider.php deleted file mode 100644 index fb1f4990a..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpFragmentServiceProvider.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Api\EventListenerProviderInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\Fragment\FragmentHandler; -use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer; -use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; -use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; -use Symfony\Component\HttpKernel\EventListener\FragmentListener; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\UriSigner; - -/** - * HttpKernel Fragment integration for Silex. - * - * @author Fabien Potencier - */ -class HttpFragmentServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['fragment.handler'] = function ($app) { - return new FragmentHandler($app['request_stack'], $app['fragment.renderers'], $app['debug']); - }; - - $app['fragment.renderer.inline'] = function ($app) { - $renderer = new InlineFragmentRenderer($app['kernel'], $app['dispatcher']); - $renderer->setFragmentPath($app['fragment.path']); - - return $renderer; - }; - - $app['fragment.renderer.hinclude'] = function ($app) { - $renderer = new HIncludeFragmentRenderer(null, $app['uri_signer'], $app['fragment.renderer.hinclude.global_template'], $app['charset']); - $renderer->setFragmentPath($app['fragment.path']); - - return $renderer; - }; - - $app['fragment.renderer.esi'] = function ($app) { - $renderer = new EsiFragmentRenderer($app['http_cache.esi'], $app['fragment.renderer.inline'], $app['uri_signer']); - $renderer->setFragmentPath($app['fragment.path']); - - return $renderer; - }; - - $app['fragment.listener'] = function ($app) { - return new FragmentListener($app['uri_signer'], $app['fragment.path']); - }; - - $app['uri_signer'] = function ($app) { - return new UriSigner($app['uri_signer.secret']); - }; - - $app['uri_signer.secret'] = md5(__DIR__); - $app['fragment.path'] = '/_fragment'; - $app['fragment.renderer.hinclude.global_template'] = null; - $app['fragment.renderers'] = function ($app) { - $renderers = array($app['fragment.renderer.inline'], $app['fragment.renderer.hinclude']); - - if (isset($app['http_cache.esi'])) { - $renderers[] = $app['fragment.renderer.esi']; - } - - return $renderers; - }; - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber($app['fragment.listener']); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpKernelServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpKernelServiceProvider.php deleted file mode 100644 index 86f155fe6..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/HttpKernelServiceProvider.php +++ /dev/null @@ -1,101 +0,0 @@ -= 30100) { - return new SfControllerResolver($app['logger']); - } - - return new ControllerResolver($app, $app['logger']); - }; - - if (Kernel::VERSION_ID >= 30100) { - $app['argument_metadata_factory'] = function ($app) { - return new ArgumentMetadataFactory(); - }; - $app['argument_value_resolvers'] = function ($app) { - if (Kernel::VERSION_ID < 30200) { - return array( - new AppArgumentValueResolver($app), - new RequestAttributeValueResolver(), - new RequestValueResolver(), - new DefaultValueResolver(), - new VariadicValueResolver(), - ); - } - - return array_merge(array(new AppArgumentValueResolver($app)), ArgumentResolver::getDefaultArgumentValueResolvers()); - }; - } - - $app['argument_resolver'] = function ($app) { - if (Kernel::VERSION_ID >= 30100) { - return new ArgumentResolver($app['argument_metadata_factory'], $app['argument_value_resolvers']); - } - }; - - $app['kernel'] = function ($app) { - return new HttpKernel($app['dispatcher'], $app['resolver'], $app['request_stack'], $app['argument_resolver']); - }; - - $app['request_stack'] = function () { - return new RequestStack(); - }; - - $app['dispatcher'] = function () { - return new EventDispatcher(); - }; - - $app['callback_resolver'] = function ($app) { - return new CallbackResolver($app); - }; - } - - /** - * {@inheritdoc} - */ - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber(new ResponseListener($app['charset'])); - $dispatcher->addSubscriber(new MiddlewareListener($app)); - $dispatcher->addSubscriber(new ConverterListener($app['routes'], $app['callback_resolver'])); - $dispatcher->addSubscriber(new StringToResponseListener()); - - if (class_exists(HttpHeaderSerializer::class)) { - $dispatcher->addSubscriber(new AddLinkHeaderListener()); - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/LICENSE b/lib/silex/vendor/silex/silex/src/Silex/Provider/LICENSE deleted file mode 100644 index bc6ad0497..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Locale/LocaleListener.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Locale/LocaleListener.php deleted file mode 100644 index d5002640e..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Locale/LocaleListener.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Locale; - -use Pimple\Container; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Initializes the locale based on the current request. - * - * @author Fabien Potencier - * @author Jérôme Tamarelle - */ -class LocaleListener implements EventSubscriberInterface -{ - private $app; - private $defaultLocale; - private $requestStack; - private $requestContext; - - public function __construct(Container $app, $defaultLocale = 'en', RequestStack $requestStack, RequestContext $requestContext = null) - { - $this->app = $app; - $this->defaultLocale = $defaultLocale; - $this->requestStack = $requestStack; - $this->requestContext = $requestContext; - } - - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - $request->setDefaultLocale($this->defaultLocale); - - $this->setLocale($request); - $this->setRouterContext($request); - - $this->app['locale'] = $request->getLocale(); - } - - public function onKernelFinishRequest(FinishRequestEvent $event) - { - if (null !== $parentRequest = $this->requestStack->getParentRequest()) { - $this->setRouterContext($parentRequest); - } - } - - private function setLocale(Request $request) - { - if ($locale = $request->attributes->get('_locale')) { - $request->setLocale($locale); - } - } - - private function setRouterContext(Request $request) - { - if (null !== $this->requestContext) { - $this->requestContext->setParameter('_locale', $request->getLocale()); - } - } - - public static function getSubscribedEvents() - { - return array( - // must be registered after the Router to have access to the _locale - KernelEvents::REQUEST => array(array('onKernelRequest', 16)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/LocaleServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/LocaleServiceProvider.php deleted file mode 100644 index ddea81bfe..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/LocaleServiceProvider.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Api\EventListenerProviderInterface; -use Silex\Provider\Locale\LocaleListener; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * Locale Provider. - * - * @author Fabien Potencier - */ -class LocaleServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['locale.listener'] = function ($app) { - return new LocaleListener($app, $app['locale'], $app['request_stack'], isset($app['request_context']) ? $app['request_context'] : null); - }; - - $app['locale'] = 'en'; - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber($app['locale.listener']); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/MonologServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/MonologServiceProvider.php deleted file mode 100644 index f8cba4e2c..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/MonologServiceProvider.php +++ /dev/null @@ -1,146 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Monolog\Formatter\LineFormatter; -use Monolog\Logger; -use Monolog\Handler; -use Monolog\ErrorHandler; -use Silex\Application; -use Silex\Api\BootableProviderInterface; -use Symfony\Bridge\Monolog\Handler\DebugHandler; -use Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy; -use Symfony\Bridge\Monolog\Processor\DebugProcessor; -use Silex\EventListener\LogListener; - -/** - * Monolog Provider. - * - * @author Fabien Potencier - */ -class MonologServiceProvider implements ServiceProviderInterface, BootableProviderInterface -{ - public function register(Container $app) - { - $app['logger'] = function () use ($app) { - return $app['monolog']; - }; - - if ($bridge = class_exists('Symfony\Bridge\Monolog\Logger')) { - $app['monolog.handler.debug'] = function () use ($app) { - $level = MonologServiceProvider::translateLevel($app['monolog.level']); - - return new DebugHandler($level); - }; - - if (isset($app['request_stack'])) { - $app['monolog.not_found_activation_strategy'] = function () use ($app) { - return new NotFoundActivationStrategy($app['request_stack'], array('^/'), $app['monolog.level']); - }; - } - } - - $app['monolog.logger.class'] = $bridge ? 'Symfony\Bridge\Monolog\Logger' : 'Monolog\Logger'; - - $app['monolog'] = function ($app) use ($bridge) { - $log = new $app['monolog.logger.class']($app['monolog.name']); - - $handler = new Handler\GroupHandler($app['monolog.handlers']); - if (isset($app['monolog.not_found_activation_strategy'])) { - $handler = new Handler\FingersCrossedHandler($handler, $app['monolog.not_found_activation_strategy']); - } - - $log->pushHandler($handler); - - if ($app['debug'] && $bridge) { - if (class_exists(DebugProcessor::class)) { - $log->pushProcessor(new DebugProcessor()); - } else { - $log->pushHandler($app['monolog.handler.debug']); - } - } - - return $log; - }; - - $app['monolog.formatter'] = function () { - return new LineFormatter(); - }; - - $app['monolog.handler'] = $defaultHandler = function () use ($app) { - $level = MonologServiceProvider::translateLevel($app['monolog.level']); - - $handler = new Handler\StreamHandler($app['monolog.logfile'], $level, $app['monolog.bubble'], $app['monolog.permission']); - $handler->setFormatter($app['monolog.formatter']); - - return $handler; - }; - - $app['monolog.handlers'] = function () use ($app, $defaultHandler) { - $handlers = array(); - - // enables the default handler if a logfile was set or the monolog.handler service was redefined - if ($app['monolog.logfile'] || $defaultHandler !== $app->raw('monolog.handler')) { - $handlers[] = $app['monolog.handler']; - } - - return $handlers; - }; - - $app['monolog.level'] = function () { - return Logger::DEBUG; - }; - - $app['monolog.listener'] = function () use ($app) { - return new LogListener($app['logger'], $app['monolog.exception.logger_filter']); - }; - - $app['monolog.name'] = 'app'; - $app['monolog.bubble'] = true; - $app['monolog.permission'] = null; - $app['monolog.exception.logger_filter'] = null; - $app['monolog.logfile'] = null; - $app['monolog.use_error_handler'] = function ($app) { - return !$app['debug']; - }; - } - - public function boot(Application $app) - { - if ($app['monolog.use_error_handler']) { - ErrorHandler::register($app['monolog']); - } - - if (isset($app['monolog.listener'])) { - $app['dispatcher']->addSubscriber($app['monolog.listener']); - } - } - - public static function translateLevel($name) - { - // level is already translated to logger constant, return as-is - if (is_int($name)) { - return $name; - } - - $levels = Logger::getLevels(); - $upper = strtoupper($name); - - if (!isset($levels[$upper])) { - throw new \InvalidArgumentException("Provided logging level '$name' does not exist. Must be a valid monolog logging level."); - } - - return $levels[$upper]; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/RememberMeServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/RememberMeServiceProvider.php deleted file mode 100644 index 766631c5a..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/RememberMeServiceProvider.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Api\EventListenerProviderInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider; -use Symfony\Component\Security\Http\Firewall\RememberMeListener; -use Symfony\Component\Security\Http\RememberMe\TokenBasedRememberMeServices; -use Symfony\Component\Security\Http\RememberMe\ResponseListener; - -/** - * Remember-me authentication for the SecurityServiceProvider. - * - * @author Jérôme Tamarelle - */ -class RememberMeServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['security.remember_me.response_listener'] = function ($app) { - if (!isset($app['security.token_storage'])) { - throw new \LogicException('You must register the SecurityServiceProvider to use the RememberMeServiceProvider'); - } - - return new ResponseListener(); - }; - - $app['security.authentication_listener.factory.remember_me'] = $app->protect(function ($name, $options) use ($app) { - if (empty($options['key'])) { - $options['key'] = $name; - } - - if (!isset($app['security.remember_me.service.'.$name])) { - $app['security.remember_me.service.'.$name] = $app['security.remember_me.service._proto']($name, $options); - } - - if (!isset($app['security.authentication_listener.'.$name.'.remember_me'])) { - $app['security.authentication_listener.'.$name.'.remember_me'] = $app['security.authentication_listener.remember_me._proto']($name, $options); - } - - if (!isset($app['security.authentication_provider.'.$name.'.remember_me'])) { - $app['security.authentication_provider.'.$name.'.remember_me'] = $app['security.authentication_provider.remember_me._proto']($name, $options); - } - - return array( - 'security.authentication_provider.'.$name.'.remember_me', - 'security.authentication_listener.'.$name.'.remember_me', - null, // entry point - 'remember_me', - ); - }); - - $app['security.remember_me.service._proto'] = $app->protect(function ($providerKey, $options) use ($app) { - return function () use ($providerKey, $options, $app) { - $options = array_replace(array( - 'name' => 'REMEMBERME', - 'lifetime' => 31536000, - 'path' => '/', - 'domain' => null, - 'secure' => false, - 'httponly' => true, - 'always_remember_me' => false, - 'remember_me_parameter' => '_remember_me', - ), $options); - - return new TokenBasedRememberMeServices(array($app['security.user_provider.'.$providerKey]), $options['key'], $providerKey, $options, $app['logger']); - }; - }); - - $app['security.authentication_listener.remember_me._proto'] = $app->protect(function ($providerKey) use ($app) { - return function () use ($app, $providerKey) { - $listener = new RememberMeListener( - $app['security.token_storage'], - $app['security.remember_me.service.'.$providerKey], - $app['security.authentication_manager'], - $app['logger'], - $app['dispatcher'] - ); - - return $listener; - }; - }); - - $app['security.authentication_provider.remember_me._proto'] = $app->protect(function ($name, $options) use ($app) { - return function () use ($app, $name, $options) { - return new RememberMeAuthenticationProvider($app['security.user_checker'], $options['key'], $name); - }; - }); - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber($app['security.remember_me.response_listener']); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/LazyRequestMatcher.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/LazyRequestMatcher.php deleted file mode 100644 index 6837c79ab..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/LazyRequestMatcher.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Routing; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; - -/** - * Implements a lazy UrlMatcher. - * - * @author Igor Wiedler - * @author Jérôme Tamarelle - */ -class LazyRequestMatcher implements RequestMatcherInterface -{ - private $factory; - - public function __construct(\Closure $factory) - { - $this->factory = $factory; - } - - /** - * Returns the corresponding RequestMatcherInterface instance. - * - * @return UrlMatcherInterface - */ - public function getRequestMatcher() - { - $matcher = call_user_func($this->factory); - if (!$matcher instanceof RequestMatcherInterface) { - throw new \LogicException("Factory supplied to LazyRequestMatcher must return implementation of Symfony\Component\Routing\RequestMatcherInterface."); - } - - return $matcher; - } - - /** - * {@inheritdoc} - */ - public function matchRequest(Request $request) - { - return $this->getRequestMatcher()->matchRequest($request); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/RedirectableUrlMatcher.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/RedirectableUrlMatcher.php deleted file mode 100644 index 8b4a4dae9..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Routing/RedirectableUrlMatcher.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Routing; - -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\Routing\Matcher\RedirectableUrlMatcher as BaseRedirectableUrlMatcher; - -/** - * Implements the RedirectableUrlMatcherInterface for Silex. - * - * @author Fabien Potencier - */ -class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher -{ - /** - * {@inheritdoc} - */ - public function redirect($path, $route, $scheme = null) - { - $url = $this->context->getBaseUrl().$path; - $query = $this->context->getQueryString() ?: ''; - - if ($query !== '') { - $url .= '?'.$query; - } - - if ($this->context->getHost()) { - if ($scheme) { - $port = ''; - if ('http' === $scheme && 80 != $this->context->getHttpPort()) { - $port = ':'.$this->context->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) { - $port = ':'.$this->context->getHttpsPort(); - } - - $url = $scheme.'://'.$this->context->getHost().$port.$url; - } - } - - return array( - '_controller' => function ($url) { return new RedirectResponse($url, 301); }, - '_route' => $route, - 'url' => $url, - ); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/RoutingServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/RoutingServiceProvider.php deleted file mode 100644 index d040ba0d6..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/RoutingServiceProvider.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\ControllerCollection; -use Silex\Api\EventListenerProviderInterface; -use Silex\Provider\Routing\RedirectableUrlMatcher; -use Silex\Provider\Routing\LazyRequestMatcher; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Generator\UrlGenerator; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\HttpKernel\EventListener\RouterListener; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * Symfony Routing component Provider. - * - * @author Fabien Potencier - */ -class RoutingServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['route_class'] = 'Silex\\Route'; - - $app['route_factory'] = $app->factory(function ($app) { - return new $app['route_class'](); - }); - - $app['routes_factory'] = $app->factory(function () { - return new RouteCollection(); - }); - - $app['routes'] = function ($app) { - return $app['routes_factory']; - }; - $app['url_generator'] = function ($app) { - return new UrlGenerator($app['routes'], $app['request_context']); - }; - - $app['request_matcher'] = function ($app) { - return new RedirectableUrlMatcher($app['routes'], $app['request_context']); - }; - - $app['request_context'] = function ($app) { - $context = new RequestContext(); - - $context->setHttpPort(isset($app['request.http_port']) ? $app['request.http_port'] : 80); - $context->setHttpsPort(isset($app['request.https_port']) ? $app['request.https_port'] : 443); - - return $context; - }; - - $app['controllers'] = function ($app) { - return $app['controllers_factory']; - }; - - $controllers_factory = function () use ($app, &$controllers_factory) { - return new ControllerCollection($app['route_factory'], $app['routes_factory'], $controllers_factory); - }; - $app['controllers_factory'] = $app->factory($controllers_factory); - - $app['routing.listener'] = function ($app) { - $urlMatcher = new LazyRequestMatcher(function () use ($app) { - return $app['request_matcher']; - }); - - return new RouterListener($urlMatcher, $app['request_stack'], $app['request_context'], $app['logger']); - }; - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber($app['routing.listener']); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php deleted file mode 100644 index 06d2e40d1..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php +++ /dev/null @@ -1,696 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Application; -use Silex\Api\BootableProviderInterface; -use Silex\Api\ControllerProviderInterface; -use Silex\Api\EventListenerProviderInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\RequestMatcher; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Security\Core\Security; -use Symfony\Component\Security\Core\User\UserChecker; -use Symfony\Component\Security\Core\User\InMemoryUserProvider; -use Symfony\Component\Security\Core\Encoder\EncoderFactory; -use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; -use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder; -use Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder; -use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider; -use Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider; -use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager; -use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; -use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler; -use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; -use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; -use Symfony\Component\Security\Core\Authorization\Voter\RoleHierarchyVoter; -use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter; -use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; -use Symfony\Component\Security\Core\Role\RoleHierarchy; -use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator; -use Symfony\Component\Security\Http\Firewall; -use Symfony\Component\Security\Http\FirewallMap; -use Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener; -use Symfony\Component\Security\Http\Firewall\AccessListener; -use Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener; -use Symfony\Component\Security\Http\Firewall\LogoutListener; -use Symfony\Component\Security\Http\Firewall\SwitchUserListener; -use Symfony\Component\Security\Http\Firewall\AnonymousAuthenticationListener; -use Symfony\Component\Security\Http\Firewall\ContextListener; -use Symfony\Component\Security\Http\Firewall\ExceptionListener; -use Symfony\Component\Security\Http\Firewall\ChannelListener; -use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint; -use Symfony\Component\Security\Http\EntryPoint\BasicAuthenticationEntryPoint; -use Symfony\Component\Security\Http\EntryPoint\RetryAuthenticationEntryPoint; -use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy; -use Symfony\Component\Security\Http\Logout\SessionLogoutHandler; -use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler; -use Symfony\Component\Security\Http\AccessMap; -use Symfony\Component\Security\Http\HttpUtils; -use Symfony\Component\Security\Guard\GuardAuthenticatorHandler; -use Symfony\Component\Security\Guard\Firewall\GuardAuthenticationListener; -use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider; - -/** - * Symfony Security component Provider. - * - * @author Fabien Potencier - */ -class SecurityServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface, ControllerProviderInterface, BootableProviderInterface -{ - protected $fakeRoutes; - - public function register(Container $app) - { - // used to register routes for login_check and logout - $this->fakeRoutes = array(); - - $that = $this; - - $app['security.role_hierarchy'] = array(); - $app['security.access_rules'] = array(); - $app['security.hide_user_not_found'] = true; - $app['security.encoder.bcrypt.cost'] = 13; - - $app['security.authorization_checker'] = function ($app) { - return new AuthorizationChecker($app['security.token_storage'], $app['security.authentication_manager'], $app['security.access_manager']); - }; - - $app['security.token_storage'] = function ($app) { - return new TokenStorage(); - }; - - $app['user'] = $app->factory(function ($app) { - if (null === $token = $app['security.token_storage']->getToken()) { - return; - } - - if (!is_object($user = $token->getUser())) { - return; - } - - return $user; - }); - - $app['security.authentication_manager'] = function ($app) { - $manager = new AuthenticationProviderManager($app['security.authentication_providers']); - $manager->setEventDispatcher($app['dispatcher']); - - return $manager; - }; - - // by default, all users use the digest encoder - $app['security.encoder_factory'] = function ($app) { - return new EncoderFactory(array( - 'Symfony\Component\Security\Core\User\UserInterface' => $app['security.default_encoder'], - )); - }; - - // by default, all users use the BCrypt encoder - $app['security.default_encoder'] = function ($app) { - return $app['security.encoder.bcrypt']; - }; - - $app['security.encoder.digest'] = function ($app) { - return new MessageDigestPasswordEncoder(); - }; - - $app['security.encoder.bcrypt'] = function ($app) { - return new BCryptPasswordEncoder($app['security.encoder.bcrypt.cost']); - }; - - $app['security.encoder.pbkdf2'] = function ($app) { - return new Pbkdf2PasswordEncoder(); - }; - - $app['security.user_checker'] = function ($app) { - return new UserChecker(); - }; - - $app['security.access_manager'] = function ($app) { - return new AccessDecisionManager($app['security.voters']); - }; - - $app['security.voters'] = function ($app) { - return array( - new RoleHierarchyVoter(new RoleHierarchy($app['security.role_hierarchy'])), - new AuthenticatedVoter($app['security.trust_resolver']), - ); - }; - - $app['security.firewall'] = function ($app) { - return new Firewall($app['security.firewall_map'], $app['dispatcher']); - }; - - $app['security.channel_listener'] = function ($app) { - return new ChannelListener( - $app['security.access_map'], - new RetryAuthenticationEntryPoint( - isset($app['request.http_port']) ? $app['request.http_port'] : 80, - isset($app['request.https_port']) ? $app['request.https_port'] : 443 - ), - $app['logger'] - ); - }; - - // generate the build-in authentication factories - foreach (array('logout', 'pre_auth', 'guard', 'form', 'http', 'remember_me', 'anonymous') as $type) { - $entryPoint = null; - if ('http' === $type) { - $entryPoint = 'http'; - } elseif ('form' === $type) { - $entryPoint = 'form'; - } elseif ('guard' === $type) { - $entryPoint = 'guard'; - } - - $app['security.authentication_listener.factory.'.$type] = $app->protect(function ($name, $options) use ($type, $app, $entryPoint) { - if ($entryPoint && !isset($app['security.entry_point.'.$name.'.'.$entryPoint])) { - $app['security.entry_point.'.$name.'.'.$entryPoint] = $app['security.entry_point.'.$entryPoint.'._proto']($name, $options); - } - - if (!isset($app['security.authentication_listener.'.$name.'.'.$type])) { - $app['security.authentication_listener.'.$name.'.'.$type] = $app['security.authentication_listener.'.$type.'._proto']($name, $options); - } - - $provider = 'dao'; - if ('anonymous' === $type) { - $provider = 'anonymous'; - } elseif ('guard' === $type) { - $provider = 'guard'; - } - if (!isset($app['security.authentication_provider.'.$name.'.'.$provider])) { - $app['security.authentication_provider.'.$name.'.'.$provider] = $app['security.authentication_provider.'.$provider.'._proto']($name, $options); - } - - return array( - 'security.authentication_provider.'.$name.'.'.$provider, - 'security.authentication_listener.'.$name.'.'.$type, - $entryPoint ? 'security.entry_point.'.$name.'.'.$entryPoint : null, - $type, - ); - }); - } - - $app['security.firewall_map'] = function ($app) { - $positions = array('logout', 'pre_auth', 'guard', 'form', 'http', 'remember_me', 'anonymous'); - $providers = array(); - $configs = array(); - foreach ($app['security.firewalls'] as $name => $firewall) { - $entryPoint = null; - $pattern = isset($firewall['pattern']) ? $firewall['pattern'] : null; - $users = isset($firewall['users']) ? $firewall['users'] : array(); - $security = isset($firewall['security']) ? (bool) $firewall['security'] : true; - $stateless = isset($firewall['stateless']) ? (bool) $firewall['stateless'] : false; - $context = isset($firewall['context']) ? $firewall['context'] : $name; - $hosts = isset($firewall['hosts']) ? $firewall['hosts'] : null; - $methods = isset($firewall['methods']) ? $firewall['methods'] : null; - unset($firewall['pattern'], $firewall['users'], $firewall['security'], $firewall['stateless'], $firewall['context'], $firewall['methods'], $firewall['hosts']); - $protected = false === $security ? false : count($firewall); - $listeners = array('security.channel_listener'); - - if ($protected) { - if (!isset($app['security.context_listener.'.$name])) { - if (!isset($app['security.user_provider.'.$name])) { - $app['security.user_provider.'.$name] = is_array($users) ? $app['security.user_provider.inmemory._proto']($users) : $users; - } - - $app['security.context_listener.'.$name] = $app['security.context_listener._proto']($name, array($app['security.user_provider.'.$name])); - } - - if (false === $stateless) { - $listeners[] = 'security.context_listener.'.$context; - } - - $factories = array(); - foreach ($positions as $position) { - $factories[$position] = array(); - } - - foreach ($firewall as $type => $options) { - if ('switch_user' === $type) { - continue; - } - - // normalize options - if (!is_array($options)) { - if (!$options) { - continue; - } - - $options = array(); - } - - if (!isset($app['security.authentication_listener.factory.'.$type])) { - throw new \LogicException(sprintf('The "%s" authentication entry is not registered.', $type)); - } - - $options['stateless'] = $stateless; - - list($providerId, $listenerId, $entryPointId, $position) = $app['security.authentication_listener.factory.'.$type]($name, $options); - - if (null !== $entryPointId) { - $entryPoint = $entryPointId; - } - - $factories[$position][] = $listenerId; - $providers[] = $providerId; - } - - foreach ($positions as $position) { - foreach ($factories[$position] as $listener) { - $listeners[] = $listener; - } - } - - $listeners[] = 'security.access_listener'; - - if (isset($firewall['switch_user'])) { - $app['security.switch_user.'.$name] = $app['security.authentication_listener.switch_user._proto']($name, $firewall['switch_user']); - - $listeners[] = 'security.switch_user.'.$name; - } - - if (!isset($app['security.exception_listener.'.$name])) { - if (null === $entryPoint) { - $app[$entryPoint = 'security.entry_point.'.$name.'.form'] = $app['security.entry_point.form._proto']($name, array()); - } - $accessDeniedHandler = null; - if (isset($app['security.access_denied_handler.'.$name])) { - $accessDeniedHandler = $app['security.access_denied_handler.'.$name]; - } - $app['security.exception_listener.'.$name] = $app['security.exception_listener._proto']($entryPoint, $name, $accessDeniedHandler); - } - } - - $configs[$name] = array( - 'pattern' => $pattern, - 'listeners' => $listeners, - 'protected' => $protected, - 'methods' => $methods, - 'hosts' => $hosts, - ); - } - - $app['security.authentication_providers'] = array_map(function ($provider) use ($app) { - return $app[$provider]; - }, array_unique($providers)); - - $map = new FirewallMap(); - foreach ($configs as $name => $config) { - if (is_string($config['pattern'])) { - $requestMatcher = new RequestMatcher($config['pattern'], $config['hosts'], $config['methods']); - } else { - $requestMatcher = $config['pattern']; - } - - $map->add( - $requestMatcher, - array_map(function ($listenerId) use ($app, $name) { - $listener = $app[$listenerId]; - - if (isset($app['security.remember_me.service.'.$name])) { - if ($listener instanceof AbstractAuthenticationListener || $listener instanceof GuardAuthenticationListener) { - $listener->setRememberMeServices($app['security.remember_me.service.'.$name]); - } - if ($listener instanceof LogoutListener) { - $listener->addHandler($app['security.remember_me.service.'.$name]); - } - } - - return $listener; - }, $config['listeners']), - $config['protected'] ? $app['security.exception_listener.'.$name] : null - ); - } - - return $map; - }; - - $app['security.access_listener'] = function ($app) { - return new AccessListener( - $app['security.token_storage'], - $app['security.access_manager'], - $app['security.access_map'], - $app['security.authentication_manager'], - $app['logger'] - ); - }; - - $app['security.access_map'] = function ($app) { - $map = new AccessMap(); - - foreach ($app['security.access_rules'] as $rule) { - if (is_string($rule[0])) { - $rule[0] = new RequestMatcher($rule[0]); - } elseif (is_array($rule[0])) { - $rule[0] += array( - 'path' => null, - 'host' => null, - 'methods' => null, - 'ips' => null, - 'attributes' => array(), - 'schemes' => null, - ); - $rule[0] = new RequestMatcher($rule[0]['path'], $rule[0]['host'], $rule[0]['methods'], $rule[0]['ips'], $rule[0]['attributes'], $rule[0]['schemes']); - } - $map->add($rule[0], (array) $rule[1], isset($rule[2]) ? $rule[2] : null); - } - - return $map; - }; - - $app['security.trust_resolver'] = function ($app) { - return new AuthenticationTrustResolver('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', 'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken'); - }; - - $app['security.session_strategy'] = function ($app) { - return new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); - }; - - $app['security.http_utils'] = function ($app) { - return new HttpUtils($app['url_generator'], $app['request_matcher']); - }; - - $app['security.last_error'] = $app->protect(function (Request $request) { - if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { - return $request->attributes->get(Security::AUTHENTICATION_ERROR)->getMessage(); - } - - $session = $request->getSession(); - if ($session && $session->has(Security::AUTHENTICATION_ERROR)) { - $message = $session->get(Security::AUTHENTICATION_ERROR)->getMessage(); - $session->remove(Security::AUTHENTICATION_ERROR); - - return $message; - } - }); - - // prototypes (used by the Firewall Map) - - $app['security.context_listener._proto'] = $app->protect(function ($providerKey, $userProviders) use ($app) { - return function () use ($app, $userProviders, $providerKey) { - return new ContextListener( - $app['security.token_storage'], - $userProviders, - $providerKey, - $app['logger'], - $app['dispatcher'] - ); - }; - }); - - $app['security.user_provider.inmemory._proto'] = $app->protect(function ($params) use ($app) { - return function () use ($app, $params) { - $users = array(); - foreach ($params as $name => $user) { - $users[$name] = array('roles' => (array) $user[0], 'password' => $user[1]); - } - - return new InMemoryUserProvider($users); - }; - }); - - $app['security.exception_listener._proto'] = $app->protect(function ($entryPoint, $name, $accessDeniedHandler = null) use ($app) { - return function () use ($app, $entryPoint, $name, $accessDeniedHandler) { - return new ExceptionListener( - $app['security.token_storage'], - $app['security.trust_resolver'], - $app['security.http_utils'], - $name, - $app[$entryPoint], - null, // errorPage - $accessDeniedHandler, - $app['logger'] - ); - }; - }); - - $app['security.authentication.success_handler._proto'] = $app->protect(function ($name, $options) use ($app) { - return function () use ($name, $options, $app) { - $handler = new DefaultAuthenticationSuccessHandler( - $app['security.http_utils'], - $options - ); - $handler->setProviderKey($name); - - return $handler; - }; - }); - - $app['security.authentication.failure_handler._proto'] = $app->protect(function ($name, $options) use ($app) { - return function () use ($name, $options, $app) { - return new DefaultAuthenticationFailureHandler( - $app, - $app['security.http_utils'], - $options, - $app['logger'] - ); - }; - }); - - $app['security.authentication_listener.guard._proto'] = $app->protect(function ($providerKey, $options) use ($app, $that) { - return function () use ($app, $providerKey, $options, $that) { - if (!isset($app['security.authentication.guard_handler'])) { - $app['security.authentication.guard_handler'] = new GuardAuthenticatorHandler($app['security.token_storage'], $app['dispatcher']); - } - - $authenticators = array(); - foreach ($options['authenticators'] as $authenticatorId) { - $authenticators[] = $app[$authenticatorId]; - } - - return new GuardAuthenticationListener( - $app['security.authentication.guard_handler'], - $app['security.authentication_manager'], - $providerKey, - $authenticators, - $app['logger'] - ); - }; - }); - - $app['security.authentication_listener.form._proto'] = $app->protect(function ($name, $options) use ($app, $that) { - return function () use ($app, $name, $options, $that) { - $that->addFakeRoute( - 'match', - $tmp = isset($options['check_path']) ? $options['check_path'] : '/login_check', - str_replace('/', '_', ltrim($tmp, '/')) - ); - - $class = isset($options['listener_class']) ? $options['listener_class'] : 'Symfony\\Component\\Security\\Http\\Firewall\\UsernamePasswordFormAuthenticationListener'; - - if (!isset($app['security.authentication.success_handler.'.$name])) { - $app['security.authentication.success_handler.'.$name] = $app['security.authentication.success_handler._proto']($name, $options); - } - - if (!isset($app['security.authentication.failure_handler.'.$name])) { - $app['security.authentication.failure_handler.'.$name] = $app['security.authentication.failure_handler._proto']($name, $options); - } - - return new $class( - $app['security.token_storage'], - $app['security.authentication_manager'], - isset($app['security.session_strategy.'.$name]) ? $app['security.session_strategy.'.$name] : $app['security.session_strategy'], - $app['security.http_utils'], - $name, - $app['security.authentication.success_handler.'.$name], - $app['security.authentication.failure_handler.'.$name], - $options, - $app['logger'], - $app['dispatcher'], - isset($options['with_csrf']) && $options['with_csrf'] && isset($app['csrf.token_manager']) ? $app['csrf.token_manager'] : null - ); - }; - }); - - $app['security.authentication_listener.http._proto'] = $app->protect(function ($providerKey, $options) use ($app) { - return function () use ($app, $providerKey, $options) { - return new BasicAuthenticationListener( - $app['security.token_storage'], - $app['security.authentication_manager'], - $providerKey, - $app['security.entry_point.'.$providerKey.'.http'], - $app['logger'] - ); - }; - }); - - $app['security.authentication_listener.anonymous._proto'] = $app->protect(function ($providerKey, $options) use ($app) { - return function () use ($app, $providerKey, $options) { - return new AnonymousAuthenticationListener( - $app['security.token_storage'], - $providerKey, - $app['logger'] - ); - }; - }); - - $app['security.authentication.logout_handler._proto'] = $app->protect(function ($name, $options) use ($app) { - return function () use ($name, $options, $app) { - return new DefaultLogoutSuccessHandler( - $app['security.http_utils'], - isset($options['target_url']) ? $options['target_url'] : '/' - ); - }; - }); - - $app['security.authentication_listener.logout._proto'] = $app->protect(function ($name, $options) use ($app, $that) { - return function () use ($app, $name, $options, $that) { - $that->addFakeRoute( - 'get', - $tmp = isset($options['logout_path']) ? $options['logout_path'] : '/logout', - str_replace('/', '_', ltrim($tmp, '/')) - ); - - if (!isset($app['security.authentication.logout_handler.'.$name])) { - $app['security.authentication.logout_handler.'.$name] = $app['security.authentication.logout_handler._proto']($name, $options); - } - - $listener = new LogoutListener( - $app['security.token_storage'], - $app['security.http_utils'], - $app['security.authentication.logout_handler.'.$name], - $options, - isset($options['with_csrf']) && $options['with_csrf'] && isset($app['csrf.token_manager']) ? $app['csrf.token_manager'] : null - ); - - $invalidateSession = isset($options['invalidate_session']) ? $options['invalidate_session'] : true; - if (true === $invalidateSession && false === $options['stateless']) { - $listener->addHandler(new SessionLogoutHandler()); - } - - return $listener; - }; - }); - - $app['security.authentication_listener.switch_user._proto'] = $app->protect(function ($name, $options) use ($app, $that) { - return function () use ($app, $name, $options, $that) { - return new SwitchUserListener( - $app['security.token_storage'], - $app['security.user_provider.'.$name], - $app['security.user_checker'], - $name, - $app['security.access_manager'], - $app['logger'], - isset($options['parameter']) ? $options['parameter'] : '_switch_user', - isset($options['role']) ? $options['role'] : 'ROLE_ALLOWED_TO_SWITCH', - $app['dispatcher'] - ); - }; - }); - - $app['security.entry_point.form._proto'] = $app->protect(function ($name, array $options) use ($app) { - return function () use ($app, $options) { - $loginPath = isset($options['login_path']) ? $options['login_path'] : '/login'; - $useForward = isset($options['use_forward']) ? $options['use_forward'] : false; - - return new FormAuthenticationEntryPoint($app, $app['security.http_utils'], $loginPath, $useForward); - }; - }); - - $app['security.entry_point.http._proto'] = $app->protect(function ($name, array $options) use ($app) { - return function () use ($app, $name, $options) { - return new BasicAuthenticationEntryPoint(isset($options['real_name']) ? $options['real_name'] : 'Secured'); - }; - }); - - $app['security.entry_point.guard._proto'] = $app->protect(function ($name, array $options) use ($app) { - if (isset($options['entry_point'])) { - // if it's configured explicitly, use it! - return $app[$options['entry_point']]; - } - $authenticatorIds = $options['authenticators']; - if (count($authenticatorIds) == 1) { - // if there is only one authenticator, use that as the entry point - return $app[reset($authenticatorIds)]; - } - // we have multiple entry points - we must ask them to configure one - throw new \LogicException(sprintf( - 'Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of your configurators (%s)', - implode(', ', $authenticatorIds) - )); - }); - - $app['security.authentication_provider.dao._proto'] = $app->protect(function ($name, $options) use ($app) { - return function () use ($app, $name) { - return new DaoAuthenticationProvider( - $app['security.user_provider.'.$name], - $app['security.user_checker'], - $name, - $app['security.encoder_factory'], - $app['security.hide_user_not_found'] - ); - }; - }); - - $app['security.authentication_provider.guard._proto'] = $app->protect(function ($name, $options) use ($app) { - return function () use ($app, $name, $options) { - $authenticators = array(); - foreach ($options['authenticators'] as $authenticatorId) { - $authenticators[] = $app[$authenticatorId]; - } - - return new GuardAuthenticationProvider( - $authenticators, - $app['security.user_provider.'.$name], - $name, - $app['security.user_checker'] - ); - }; - }); - - $app['security.authentication_provider.anonymous._proto'] = $app->protect(function ($name, $options) use ($app) { - return function () use ($app, $name) { - return new AnonymousAuthenticationProvider($name); - }; - }); - - if (isset($app['validator'])) { - $app['security.validator.user_password_validator'] = function ($app) { - return new UserPasswordValidator($app['security.token_storage'], $app['security.encoder_factory']); - }; - - $app['validator.validator_service_ids'] = array_merge($app['validator.validator_service_ids'], array('security.validator.user_password' => 'security.validator.user_password_validator')); - } - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber($app['security.firewall']); - } - - public function connect(Application $app) - { - $controllers = $app['controllers_factory']; - foreach ($this->fakeRoutes as $route) { - list($method, $pattern, $name) = $route; - - $controllers->$method($pattern)->run(null)->bind($name); - } - - return $controllers; - } - - public function boot(Application $app) - { - $app->mount('/', $this->connect($app)); - } - - public function addFakeRoute($method, $pattern, $name) - { - $this->fakeRoutes[] = array($method, $pattern, $name); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/SerializerServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/SerializerServiceProvider.php deleted file mode 100644 index 8986abeff..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/SerializerServiceProvider.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Symfony\Component\Serializer\Serializer; -use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Symfony\Component\Serializer\Encoder\XmlEncoder; -use Symfony\Component\Serializer\Normalizer\CustomNormalizer; -use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; - -/** - * Symfony Serializer component Provider. - * - * @author Fabien Potencier - * @author Marijn Huizendveld - */ -class SerializerServiceProvider implements ServiceProviderInterface -{ - /** - * {@inheritdoc} - * - * This method registers a serializer service. {@link http://api.symfony.com/master/Symfony/Component/Serializer/Serializer.html - * The service is provided by the Symfony Serializer component}. - */ - public function register(Container $app) - { - $app['serializer'] = function ($app) { - return new Serializer($app['serializer.normalizers'], $app['serializer.encoders']); - }; - - $app['serializer.encoders'] = function () { - return array(new JsonEncoder(), new XmlEncoder()); - }; - - $app['serializer.normalizers'] = function () { - return array(new CustomNormalizer(), new GetSetMethodNormalizer()); - }; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/ServiceControllerServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/ServiceControllerServiceProvider.php deleted file mode 100644 index 1c38adc9c..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/ServiceControllerServiceProvider.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\ServiceControllerResolver; - -class ServiceControllerServiceProvider implements ServiceProviderInterface -{ - public function register(Container $app) - { - $app->extend('resolver', function ($resolver, $app) { - return new ServiceControllerResolver($resolver, $app['callback_resolver']); - }); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Session/SessionListener.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Session/SessionListener.php deleted file mode 100644 index aba4c4e86..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Session/SessionListener.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Session; - -use Pimple\Container; -use Symfony\Component\HttpKernel\EventListener\SessionListener as BaseSessionListener; - -/** - * Sets the session in the request. - * - * @author Fabien Potencier - */ -class SessionListener extends BaseSessionListener -{ - private $app; - - public function __construct(Container $app) - { - $this->app = $app; - } - - protected function getSession() - { - if (!isset($this->app['session'])) { - return; - } - - return $this->app['session']; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Session/TestSessionListener.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Session/TestSessionListener.php deleted file mode 100644 index ab98eb12b..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Session/TestSessionListener.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Session; - -use Pimple\Container; -use Symfony\Component\HttpKernel\EventListener\TestSessionListener as BaseTestSessionListener; - -/** - * Simulates sessions for testing purpose. - * - * @author Fabien Potencier - */ -class TestSessionListener extends BaseTestSessionListener -{ - private $app; - - public function __construct(Container $app) - { - $this->app = $app; - } - - protected function getSession() - { - if (!isset($this->app['session'])) { - return; - } - - return $this->app['session']; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/SessionServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/SessionServiceProvider.php deleted file mode 100644 index a51e230e3..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/SessionServiceProvider.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Api\EventListenerProviderInterface; -use Silex\Provider\Session\SessionListener; -use Silex\Provider\Session\TestSessionListener; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage; -use Symfony\Component\HttpFoundation\Session\Session; - -/** - * Symfony HttpFoundation component Provider for sessions. - * - * @author Fabien Potencier - */ -class SessionServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['session.test'] = false; - - $app['session'] = function ($app) { - return new Session($app['session.storage'], $app['session.attribute_bag'], $app['session.flash_bag']); - }; - - $app['session.storage'] = function ($app) { - if ($app['session.test']) { - return $app['session.storage.test']; - } - - return $app['session.storage.native']; - }; - - $app['session.storage.handler'] = function ($app) { - return new NativeFileSessionHandler($app['session.storage.save_path']); - }; - - $app['session.storage.native'] = function ($app) { - return new NativeSessionStorage( - $app['session.storage.options'], - $app['session.storage.handler'] - ); - }; - - $app['session.listener'] = function ($app) { - return new SessionListener($app); - }; - - $app['session.storage.test'] = function () { - return new MockFileSessionStorage(); - }; - - $app['session.listener.test'] = function ($app) { - return new TestSessionListener($app); - }; - - $app['session.storage.options'] = array(); - $app['session.default_locale'] = 'en'; - $app['session.storage.save_path'] = null; - $app['session.attribute_bag'] = null; - $app['session.flash_bag'] = null; - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - $dispatcher->addSubscriber($app['session.listener']); - - if ($app['session.test']) { - $app['dispatcher']->addSubscriber($app['session.listener.test']); - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/SwiftmailerServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/SwiftmailerServiceProvider.php deleted file mode 100644 index 541993f6b..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/SwiftmailerServiceProvider.php +++ /dev/null @@ -1,140 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Api\EventListenerProviderInterface; -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; - -/** - * Swiftmailer Provider. - * - * @author Fabien Potencier - */ -class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['swiftmailer.options'] = array(); - $app['swiftmailer.use_spool'] = true; - - $app['mailer.initialized'] = false; - - $app['mailer'] = function ($app) { - $app['mailer.initialized'] = true; - $transport = $app['swiftmailer.use_spool'] ? $app['swiftmailer.spooltransport'] : $app['swiftmailer.transport']; - - return new \Swift_Mailer($transport); - }; - - $app['swiftmailer.spooltransport'] = function ($app) { - return new \Swift_Transport_SpoolTransport($app['swiftmailer.transport.eventdispatcher'], $app['swiftmailer.spool']); - }; - - $app['swiftmailer.spool'] = function ($app) { - return new \Swift_MemorySpool(); - }; - - $app['swiftmailer.transport'] = function ($app) { - $transport = new \Swift_Transport_EsmtpTransport( - $app['swiftmailer.transport.buffer'], - array($app['swiftmailer.transport.authhandler']), - $app['swiftmailer.transport.eventdispatcher'] - ); - - $options = $app['swiftmailer.options'] = array_replace(array( - 'host' => 'localhost', - 'port' => 25, - 'username' => '', - 'password' => '', - 'encryption' => null, - 'auth_mode' => null, - 'stream_context_options' => [], - ), $app['swiftmailer.options']); - - $transport->setHost($options['host']); - $transport->setPort($options['port']); - $transport->setEncryption($options['encryption']); - $transport->setUsername($options['username']); - $transport->setPassword($options['password']); - $transport->setAuthMode($options['auth_mode']); - $transport->setStreamOptions($options['stream_context_options']); - - return $transport; - }; - - $app['swiftmailer.transport.buffer'] = function () { - return new \Swift_Transport_StreamBuffer(new \Swift_StreamFilters_StringReplacementFilterFactory()); - }; - - $app['swiftmailer.transport.authhandler'] = function () { - return new \Swift_Transport_Esmtp_AuthHandler(array( - new \Swift_Transport_Esmtp_Auth_CramMd5Authenticator(), - new \Swift_Transport_Esmtp_Auth_LoginAuthenticator(), - new \Swift_Transport_Esmtp_Auth_PlainAuthenticator(), - )); - }; - - $app['swiftmailer.transport.eventdispatcher'] = function ($app) { - $dispatcher = new \Swift_Events_SimpleEventDispatcher(); - - $plugins = $app['swiftmailer.plugins']; - - if (null !== $app['swiftmailer.sender_address']) { - $plugins[] = new \Swift_Plugins_ImpersonatePlugin($app['swiftmailer.sender_address']); - } - - if (!empty($app['swiftmailer.delivery_addresses'])) { - $plugins[] = new \Swift_Plugins_RedirectingPlugin( - $app['swiftmailer.delivery_addresses'], - $app['swiftmailer.delivery_whitelist'] - ); - } - - foreach ($plugins as $plugin) { - $dispatcher->bindEventListener($plugin); - } - - return $dispatcher; - }; - - $app['swiftmailer.plugins'] = function ($app) { - return array(); - }; - - $app['swiftmailer.sender_address'] = null; - $app['swiftmailer.delivery_addresses'] = array(); - $app['swiftmailer.delivery_whitelist'] = array(); - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - // Event has no typehint as it can be either a PostResponseEvent or a ConsoleTerminateEvent - $onTerminate = function ($event) use ($app) { - // To speed things up (by avoiding Swift Mailer initialization), flush - // messages only if our mailer has been created (potentially used) - if ($app['mailer.initialized'] && $app['swiftmailer.use_spool'] && $app['swiftmailer.spooltransport'] instanceof \Swift_Transport_SpoolTransport) { - $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']); - } - }; - - $dispatcher->addListener(KernelEvents::TERMINATE, $onTerminate); - - if (class_exists('Symfony\Component\Console\ConsoleEvents')) { - $dispatcher->addListener(ConsoleEvents::TERMINATE, $onTerminate); - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/TranslationServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/TranslationServiceProvider.php deleted file mode 100644 index a9ee55c99..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/TranslationServiceProvider.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Symfony\Component\Translation\Translator; -use Symfony\Component\Translation\MessageSelector; -use Symfony\Component\Translation\Loader\ArrayLoader; -use Symfony\Component\Translation\Loader\XliffFileLoader; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\EventListener\TranslatorListener; -use Silex\Api\EventListenerProviderInterface; - -/** - * Symfony Translation component Provider. - * - * @author Fabien Potencier - */ -class TranslationServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface -{ - public function register(Container $app) - { - $app['translator'] = function ($app) { - if (!isset($app['locale'])) { - throw new \LogicException('You must define \'locale\' parameter or register the LocaleServiceProvider to use the TranslationServiceProvider'); - } - - $translator = new Translator($app['locale'], $app['translator.message_selector'], $app['translator.cache_dir'], $app['debug']); - $translator->setFallbackLocales($app['locale_fallbacks']); - $translator->addLoader('array', new ArrayLoader()); - $translator->addLoader('xliff', new XliffFileLoader()); - - if (isset($app['validator'])) { - $r = new \ReflectionClass('Symfony\Component\Validator\Validation'); - $file = dirname($r->getFilename()).'/Resources/translations/validators.'.$app['locale'].'.xlf'; - if (file_exists($file)) { - $translator->addResource('xliff', $file, $app['locale'], 'validators'); - } - } - - if (isset($app['form.factory'])) { - $r = new \ReflectionClass('Symfony\Component\Form\Form'); - $file = dirname($r->getFilename()).'/Resources/translations/validators.'.$app['locale'].'.xlf'; - if (file_exists($file)) { - $translator->addResource('xliff', $file, $app['locale'], 'validators'); - } - } - - // Register default resources - foreach ($app['translator.resources'] as $resource) { - $translator->addResource($resource[0], $resource[1], $resource[2], $resource[3]); - } - - foreach ($app['translator.domains'] as $domain => $data) { - foreach ($data as $locale => $messages) { - $translator->addResource('array', $messages, $locale, $domain); - } - } - - return $translator; - }; - - if (isset($app['request_stack'])) { - $app['translator.listener'] = function ($app) { - return new TranslatorListener($app['translator'], $app['request_stack']); - }; - } - - $app['translator.message_selector'] = function () { - return new MessageSelector(); - }; - - $app['translator.resources'] = function ($app) { - return array(); - }; - - $app['translator.domains'] = array(); - $app['locale_fallbacks'] = array('en'); - $app['translator.cache_dir'] = null; - } - - public function subscribe(Container $app, EventDispatcherInterface $dispatcher) - { - if (isset($app['translator.listener'])) { - $dispatcher->addSubscriber($app['translator.listener']); - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Twig/RuntimeLoader.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Twig/RuntimeLoader.php deleted file mode 100644 index 9a7aa915e..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Twig/RuntimeLoader.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Twig; - -use Pimple\Container; - -/** - * Loads Twig extension runtimes via Pimple. - * - * @author Fabien Potencier - */ -class RuntimeLoader implements \Twig_RuntimeLoaderInterface -{ - private $container; - private $mapping; - - public function __construct(Container $container, array $mapping) - { - $this->container = $container; - $this->mapping = $mapping; - } - - /** - * {@inheritdoc} - */ - public function load($class) - { - if (isset($this->mapping[$class])) { - return $this->container[$this->mapping[$class]]; - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/TwigCoreExtension.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/TwigCoreExtension.php deleted file mode 100644 index 06e41a0cc..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/TwigCoreExtension.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * Twig extension. - * - * @author Fabien Potencier - * - * @deprecated deprecated since 1.2, will be removed in 1.3. Use HttpFragmentServiceProvider instead - */ -class TwigCoreExtension extends \Twig_Extension -{ - public function getFunctions() - { - return array( - 'render' => new \Twig_Function_Method($this, 'render', array('needs_environment' => true, 'is_safe' => array('html'))), - ); - } - - public function render(\Twig_Environment $twig, $uri) - { - $globals = $twig->getGlobals(); - $request = $globals['app']['request']; - - $subRequest = Request::create($uri, 'get', array(), $request->cookies->all(), array(), $request->server->all()); - if ($request->getSession()) { - $subRequest->setSession($request->getSession()); - } - - $response = $globals['app']->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false); - - if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $request->getUri(), $response->getStatusCode())); - } - - return $response->getContent(); - } - - public function getName() - { - return 'silex'; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/TwigServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/TwigServiceProvider.php deleted file mode 100644 index a5c43ccbc..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/TwigServiceProvider.php +++ /dev/null @@ -1,199 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Provider\Twig\RuntimeLoader; -use Symfony\Bridge\Twig\AppVariable; -use Symfony\Bridge\Twig\Extension\AssetExtension; -use Symfony\Bridge\Twig\Extension\DumpExtension; -use Symfony\Bridge\Twig\Extension\RoutingExtension; -use Symfony\Bridge\Twig\Extension\TranslationExtension; -use Symfony\Bridge\Twig\Extension\FormExtension; -use Symfony\Bridge\Twig\Extension\SecurityExtension; -use Symfony\Bridge\Twig\Extension\HttpFoundationExtension; -use Symfony\Bridge\Twig\Extension\HttpKernelExtension; -use Symfony\Bridge\Twig\Extension\WebLinkExtension; -use Symfony\Bridge\Twig\Form\TwigRendererEngine; -use Symfony\Bridge\Twig\Form\TwigRenderer; -use Symfony\Bridge\Twig\Extension\HttpKernelRuntime; -use Symfony\Component\WebLink\HttpHeaderSerializer; - -/** - * Twig integration for Silex. - * - * @author Fabien Potencier - */ -class TwigServiceProvider implements ServiceProviderInterface -{ - public function register(Container $app) - { - $app['twig.options'] = array(); - $app['twig.form.templates'] = array('form_div_layout.html.twig'); - $app['twig.path'] = array(); - $app['twig.templates'] = array(); - - $app['twig.date.format'] = 'F j, Y H:i'; - $app['twig.date.interval_format'] = '%d days'; - $app['twig.date.timezone'] = null; - - $app['twig.number_format.decimals'] = 0; - $app['twig.number_format.decimal_point'] = '.'; - $app['twig.number_format.thousands_separator'] = ','; - - $app['twig'] = function ($app) { - $app['twig.options'] = array_replace( - array( - 'charset' => $app['charset'], - 'debug' => $app['debug'], - 'strict_variables' => $app['debug'], - ), $app['twig.options'] - ); - - $twig = $app['twig.environment_factory']($app); - // registered for BC, but should not be used anymore - // deprecated and should probably be removed in Silex 3.0 - $twig->addGlobal('app', $app); - - $coreExtension = $twig->getExtension('Twig_Extension_Core'); - - $coreExtension->setDateFormat($app['twig.date.format'], $app['twig.date.interval_format']); - - if (null !== $app['twig.date.timezone']) { - $coreExtension->setTimezone($app['twig.date.timezone']); - } - - $coreExtension->setNumberFormat($app['twig.number_format.decimals'], $app['twig.number_format.decimal_point'], $app['twig.number_format.thousands_separator']); - - if ($app['debug']) { - $twig->addExtension(new \Twig_Extension_Debug()); - } - - if (class_exists('Symfony\Bridge\Twig\Extension\RoutingExtension')) { - $app['twig.app_variable'] = function ($app) { - $var = new AppVariable(); - if (isset($app['security.token_storage'])) { - $var->setTokenStorage($app['security.token_storage']); - } - if (isset($app['request_stack'])) { - $var->setRequestStack($app['request_stack']); - } - $var->setDebug($app['debug']); - - return $var; - }; - - $twig->addGlobal('global', $app['twig.app_variable']); - - if (isset($app['request_stack'])) { - $twig->addExtension(new HttpFoundationExtension($app['request_stack'])); - $twig->addExtension(new RoutingExtension($app['url_generator'])); - } - - if (isset($app['translator'])) { - $twig->addExtension(new TranslationExtension($app['translator'])); - } - - if (isset($app['security.authorization_checker'])) { - $twig->addExtension(new SecurityExtension($app['security.authorization_checker'])); - } - - if (isset($app['fragment.handler'])) { - $app['fragment.renderer.hinclude']->setTemplating($twig); - - $twig->addExtension(new HttpKernelExtension($app['fragment.handler'])); - } - - if (isset($app['assets.packages'])) { - $twig->addExtension(new AssetExtension($app['assets.packages'])); - } - - if (isset($app['form.factory'])) { - $app['twig.form.engine'] = function ($app) use ($twig) { - return new TwigRendererEngine($app['twig.form.templates'], $twig); - }; - - $app['twig.form.renderer'] = function ($app) { - $csrfTokenManager = isset($app['csrf.token_manager']) ? $app['csrf.token_manager'] : null; - - return new TwigRenderer($app['twig.form.engine'], $csrfTokenManager); - }; - - $twig->addExtension(new FormExtension(class_exists(HttpKernelRuntime::class) ? null : $app['twig.form.renderer'])); - - // add loader for Symfony built-in form templates - $reflected = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'); - $path = dirname($reflected->getFileName()).'/../Resources/views/Form'; - $app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($path)); - } - - if (isset($app['var_dumper.cloner'])) { - $twig->addExtension(new DumpExtension($app['var_dumper.cloner'])); - } - - if (class_exists(HttpKernelRuntime::class)) { - $twig->addRuntimeLoader($app['twig.runtime_loader']); - } - - if (class_exists(HttpHeaderSerializer::class) && class_exists(WebLinkExtension::class)) { - $twig->addExtension(new WebLinkExtension($app['request_stack'])); - } - } - - return $twig; - }; - - $app['twig.loader.filesystem'] = function ($app) { - $loader = new \Twig_Loader_Filesystem(); - foreach (is_array($app['twig.path']) ? $app['twig.path'] : array($app['twig.path']) as $key => $val) { - if (is_string($key)) { - $loader->addPath($key, $val); - } else { - $loader->addPath($val); - } - } - - return $loader; - }; - - $app['twig.loader.array'] = function ($app) { - return new \Twig_Loader_Array($app['twig.templates']); - }; - - $app['twig.loader'] = function ($app) { - return new \Twig_Loader_Chain(array( - $app['twig.loader.array'], - $app['twig.loader.filesystem'], - )); - }; - - $app['twig.environment_factory'] = $app->protect(function ($app) { - return new \Twig_Environment($app['twig.loader'], $app['twig.options']); - }); - - $app['twig.runtime.httpkernel'] = function ($app) { - return new HttpKernelRuntime($app['fragment.handler']); - }; - - $app['twig.runtimes'] = function ($app) { - return array( - HttpKernelRuntime::class => 'twig.runtime.httpkernel', - TwigRenderer::class => 'twig.form.renderer', - ); - }; - - $app['twig.runtime_loader'] = function ($app) { - return new RuntimeLoader($app, $app['twig.runtimes']); - }; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/UrlGeneratorServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/UrlGeneratorServiceProvider.php deleted file mode 100644 index ccbd2e7bc..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/UrlGeneratorServiceProvider.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Silex\Application; -use Silex\ServiceProviderInterface; -use Symfony\Component\Routing\Generator\UrlGenerator; - -/** - * Symfony Routing component Provider for URL generation. - * - * @author Fabien Potencier - */ -class UrlGeneratorServiceProvider implements ServiceProviderInterface -{ - public function register(Application $app) - { - $app['url_generator'] = $app->share(function ($app) { - $app->flush(); - - return new UrlGenerator($app['routes'], $app['request_context']); - }); - } - - public function boot(Application $app) - { - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/Validator/ConstraintValidatorFactory.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/Validator/ConstraintValidatorFactory.php deleted file mode 100644 index 9f5e499d9..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/Validator/ConstraintValidatorFactory.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider\Validator; - -use Pimple\Container; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidatorFactory as BaseConstraintValidatorFactory; - -/** - * Uses a service container to create constraint validators with dependencies. - * - * @author Kris Wallsmith - * @author Alex Kalyvitis - */ -class ConstraintValidatorFactory extends BaseConstraintValidatorFactory -{ - /** - * @var Container - */ - protected $container; - - /** - * @var array - */ - protected $serviceNames; - - /** - * Constructor. - * - * @param Container $container DI container - * @param array $serviceNames Validator service names - */ - public function __construct(Container $container, array $serviceNames = array(), $propertyAccessor = null) - { - parent::__construct($propertyAccessor); - - $this->container = $container; - $this->serviceNames = $serviceNames; - } - - /** - * {@inheritdoc} - */ - public function getInstance(Constraint $constraint) - { - $name = $constraint->validatedBy(); - - if (isset($this->serviceNames[$name])) { - return $this->container[$this->serviceNames[$name]]; - } - - return parent::getInstance($constraint); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/ValidatorServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/ValidatorServiceProvider.php deleted file mode 100644 index d89a3cb52..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/ValidatorServiceProvider.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Provider\Validator\ConstraintValidatorFactory; -use Symfony\Component\Validator\Validator; -use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; -use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; -use Symfony\Component\Validator\Validation; - -/** - * Symfony Validator component Provider. - * - * @author Fabien Potencier - */ -class ValidatorServiceProvider implements ServiceProviderInterface -{ - public function register(Container $app) - { - $app['validator'] = function ($app) { - return $app['validator.builder']->getValidator(); - }; - - $app['validator.builder'] = function ($app) { - $builder = Validation::createValidatorBuilder(); - $builder->setConstraintValidatorFactory($app['validator.validator_factory']); - $builder->setTranslationDomain('validators'); - $builder->addObjectInitializers($app['validator.object_initializers']); - $builder->setMetadataFactory($app['validator.mapping.class_metadata_factory']); - if (isset($app['translator'])) { - $builder->setTranslator($app['translator']); - } - - return $builder; - }; - - $app['validator.mapping.class_metadata_factory'] = function ($app) { - return new LazyLoadingMetadataFactory(new StaticMethodLoader()); - }; - - $app['validator.validator_factory'] = function () use ($app) { - return new ConstraintValidatorFactory($app, $app['validator.validator_service_ids']); - }; - - $app['validator.object_initializers'] = function ($app) { - return array(); - }; - - $app['validator.validator_service_ids'] = array(); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/VarDumperServiceProvider.php b/lib/silex/vendor/silex/silex/src/Silex/Provider/VarDumperServiceProvider.php deleted file mode 100644 index 7c40b5ee3..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/VarDumperServiceProvider.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Provider; - -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Silex\Application; -use Silex\Api\BootableProviderInterface; -use Symfony\Component\VarDumper\VarDumper; -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; - -/** - * Symfony Var Dumper component Provider. - * - * @author Fabien Potencier - */ -class VarDumperServiceProvider implements ServiceProviderInterface, BootableProviderInterface -{ - public function register(Container $app) - { - $app['var_dumper.cli_dumper'] = function ($app) { - return new CliDumper($app['var_dumper.dump_destination'], $app['charset']); - }; - - $app['var_dumper.cloner'] = function ($app) { - return new VarCloner(); - }; - - $app['var_dumper.dump_destination'] = null; - } - - public function boot(Application $app) - { - if (!$app['debug']) { - return; - } - - // This code is here to lazy load the dump stack. This default - // configuration for CLI mode is overridden in HTTP mode on - // 'kernel.request' event - VarDumper::setHandler(function ($var) use ($app) { - VarDumper::setHandler($handler = function ($var) use ($app) { - $app['var_dumper.cli_dumper']->dump($app['var_dumper.cloner']->cloneVar($var)); - }); - $handler($var); - }); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Provider/composer.json b/lib/silex/vendor/silex/silex/src/Silex/Provider/composer.json deleted file mode 100644 index a1e9fbfe0..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Provider/composer.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "minimum-stability": "dev", - "name": "silex/providers", - "description": "The Silex providers", - "keywords": ["microframework"], - "homepage": "http://silex.sensiolabs.org", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "require": { - "php": ">=5.5.9", - "pimple/pimple": "~3.0", - "silex/api": "~2.2" - }, - "autoload": { - "psr-4": { "Silex\\Provider\\": "" } - }, - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/RedirectableUrlMatcher.php b/lib/silex/vendor/silex/silex/src/Silex/RedirectableUrlMatcher.php deleted file mode 100644 index aa0cdf13e..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/RedirectableUrlMatcher.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\Routing\Matcher\RedirectableUrlMatcher as BaseRedirectableUrlMatcher; - -/** - * Implements the RedirectableUrlMatcherInterface for Silex. - * - * @author Fabien Potencier - */ -class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher -{ - /** - * {@inheritdoc} - */ - public function redirect($path, $route, $scheme = null) - { - $url = $this->context->getBaseUrl().$path; - $query = $this->context->getQueryString() ?: ''; - - if ($query !== '') { - $url .= '?'.$query; - } - - if ($this->context->getHost()) { - if ($scheme) { - $port = ''; - if ('http' === $scheme && 80 != $this->context->getHttpPort()) { - $port = ':'.$this->context->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) { - $port = ':'.$this->context->getHttpsPort(); - } - - $url = $scheme.'://'.$this->context->getHost().$port.$url; - } - } - - return array( - '_controller' => function ($url) { return new RedirectResponse($url, 301); }, - '_route' => null, - 'url' => $url, - ); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Route.php b/lib/silex/vendor/silex/silex/src/Silex/Route.php deleted file mode 100644 index 99e82d87b..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Route.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\Routing\Route as BaseRoute; - -/** - * A wrapper for a controller, mapped to a route. - * - * @author Fabien Potencier - */ -class Route extends BaseRoute -{ - /** - * Constructor. - * - * Available options: - * - * * compiler_class: A class name able to compile this route instance (RouteCompiler by default) - * - * @param string $path 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 $host The host pattern to match - * @param string|array $schemes A required URI scheme or an array of restricted schemes - * @param string|array $methods A required HTTP method or an array of restricted methods - */ - public function __construct($path = '/', array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array()) - { - // overridden constructor to make $path optional - parent::__construct($path, $defaults, $requirements, $options, $host, $schemes, $methods); - } - - /** - * Sets the route code that should be executed when matched. - * - * @param callable $to PHP callback that returns the response when matched - * - * @return Route $this The current Route instance - */ - public function run($to) - { - $this->setDefault('_controller', $to); - - return $this; - } - - /** - * Sets the requirement for a route variable. - * - * @param string $variable The variable name - * @param string $regexp The regexp to apply - * - * @return Route $this The current route instance - */ - public function assert($variable, $regexp) - { - $this->setRequirement($variable, $regexp); - - return $this; - } - - /** - * Sets the default value for a route variable. - * - * @param string $variable The variable name - * @param mixed $default The default value - * - * @return Route $this The current Route instance - */ - public function value($variable, $default) - { - $this->setDefault($variable, $default); - - return $this; - } - - /** - * Sets a converter for a route variable. - * - * @param string $variable The variable name - * @param mixed $callback A PHP callback that converts the original value - * - * @return Route $this The current Route instance - */ - public function convert($variable, $callback) - { - $converters = $this->getOption('_converters'); - $converters[$variable] = $callback; - $this->setOption('_converters', $converters); - - return $this; - } - - /** - * Sets the requirement for the HTTP method. - * - * @param string $method The HTTP method name. Multiple methods can be supplied, delimited by a pipe character '|', eg. 'GET|POST' - * - * @return Route $this The current Route instance - */ - public function method($method) - { - $this->setMethods(explode('|', $method)); - - return $this; - } - - /** - * Sets the requirement of host on this Route. - * - * @param string $host The host for which this route should be enabled - * - * @return Route $this The current Route instance - */ - public function host($host) - { - $this->setHost($host); - - return $this; - } - - /** - * Sets the requirement of HTTP (no HTTPS) on this Route. - * - * @return Route $this The current Route instance - */ - public function requireHttp() - { - $this->setSchemes('http'); - - return $this; - } - - /** - * Sets the requirement of HTTPS on this Route. - * - * @return Route $this The current Route instance - */ - public function requireHttps() - { - $this->setSchemes('https'); - - return $this; - } - - /** - * Sets a callback to handle before triggering the route callback. - * - * @param mixed $callback A PHP callback to be triggered when the Route is matched, just before the route callback - * - * @return Route $this The current Route instance - */ - public function before($callback) - { - $callbacks = $this->getOption('_before_middlewares'); - $callbacks[] = $callback; - $this->setOption('_before_middlewares', $callbacks); - - return $this; - } - - /** - * Sets a callback to handle after the route callback. - * - * @param mixed $callback A PHP callback to be triggered after the route callback - * - * @return Route $this The current Route instance - */ - public function after($callback) - { - $callbacks = $this->getOption('_after_middlewares'); - $callbacks[] = $callback; - $this->setOption('_after_middlewares', $callbacks); - - return $this; - } - - /** - * Sets a condition for the route to match. - * - * @param string $condition The condition - * - * @return Route $this The current Route instance - */ - public function when($condition) - { - $this->setCondition($condition); - - return $this; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Route/SecurityTrait.php b/lib/silex/vendor/silex/silex/src/Silex/Route/SecurityTrait.php deleted file mode 100644 index d42ba2fbb..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Route/SecurityTrait.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Route; - -use Symfony\Component\Security\Core\Exception\AccessDeniedException; - -/** - * Security trait. - * - * @author Fabien Potencier - */ -trait SecurityTrait -{ - public function secure($roles) - { - $this->before(function ($request, $app) use ($roles) { - if (!$app['security.authorization_checker']->isGranted($roles)) { - throw new AccessDeniedException(); - } - }); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ServiceControllerResolver.php b/lib/silex/vendor/silex/silex/src/Silex/ServiceControllerResolver.php deleted file mode 100644 index 87f91b04f..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ServiceControllerResolver.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; - -/** - * Enables name_of_service:method_name syntax for declaring controllers. - * - * @link http://silex.sensiolabs.org/doc/providers/service_controller.html - */ -class ServiceControllerResolver implements ControllerResolverInterface -{ - protected $controllerResolver; - protected $callbackResolver; - - /** - * Constructor. - * - * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance to delegate to - * @param CallbackResolver $callbackResolver A service resolver instance - */ - public function __construct(ControllerResolverInterface $controllerResolver, CallbackResolver $callbackResolver) - { - $this->controllerResolver = $controllerResolver; - $this->callbackResolver = $callbackResolver; - } - - /** - * {@inheritdoc} - */ - public function getController(Request $request) - { - $controller = $request->attributes->get('_controller', null); - - if (!$this->callbackResolver->isValid($controller)) { - return $this->controllerResolver->getController($request); - } - - return $this->callbackResolver->convertCallback($controller); - } - - /** - * {@inheritdoc} - */ - public function getArguments(Request $request, $controller) - { - return $this->controllerResolver->getArguments($request, $controller); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ServiceProviderInterface.php b/lib/silex/vendor/silex/silex/src/Silex/ServiceProviderInterface.php deleted file mode 100644 index cd0407950..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ServiceProviderInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -/** - * Interface that all Silex service providers must implement. - * - * @author Fabien Potencier - */ -interface ServiceProviderInterface -{ - /** - * Registers services on the given app. - * - * This method should only be used to configure services and parameters. - * It should not get services. - */ - public function register(Application $app); - - /** - * Bootstraps the application. - * - * This method is called after all services are registered - * and should be used for "dynamic" configuration (whenever - * a service must be requested). - */ - public function boot(Application $app); -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Translator.php b/lib/silex/vendor/silex/silex/src/Silex/Translator.php deleted file mode 100644 index f91666fa5..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Translator.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\Translation\Translator as BaseTranslator; -use Symfony\Component\Translation\MessageSelector; - -/** - * Translator that gets the current locale from the Silex application. - * - * @author Fabien Potencier - */ -class Translator extends BaseTranslator -{ - protected $app; - - public function __construct(Application $app, MessageSelector $selector) - { - $this->app = $app; - - parent::__construct(null, $selector); - } - - public function getLocale() - { - return $this->app['locale']; - } - - public function setLocale($locale) - { - if (null === $locale) { - return; - } - - $this->app['locale'] = $locale; - - parent::setLocale($locale); - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/Util/Compiler.php b/lib/silex/vendor/silex/silex/src/Silex/Util/Compiler.php deleted file mode 100644 index 2d2930d4c..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/Util/Compiler.php +++ /dev/null @@ -1,188 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Util; - -use Symfony\Component\Finder\Finder; -use Symfony\Component\Process\Process; - -/** - * The Compiler class compiles the Silex framework. - * - * This is deprecated. Use composer instead. - * - * @author Fabien Potencier - */ -class Compiler -{ - protected $version; - - /** - * Compiles the Silex source code into one single Phar file. - * - * @param string $pharFile Name of the output Phar file - */ - public function compile($pharFile = 'silex.phar') - { - if (file_exists($pharFile)) { - unlink($pharFile); - } - - $process = new Process('git log --pretty="%h %ci" -n1 HEAD'); - if ($process->run() > 0) { - throw new \RuntimeException('The git binary cannot be found.'); - } - $this->version = trim($process->getOutput()); - - $phar = new \Phar($pharFile, 0, 'silex.phar'); - $phar->setSignatureAlgorithm(\Phar::SHA1); - - $phar->startBuffering(); - - $root = __DIR__.'/../../..'; - - $finder = new Finder(); - $finder->files() - ->ignoreVCS(true) - ->name('*.php') - ->notName('Compiler.php') - ->exclude('Tests') - ->in($root.'/src') - ->in($root.'/vendor/pimple/pimple/lib') - ->in($root.'/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher') - ->in($root.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation') - ->in($root.'/vendor/symfony/http-kernel/Symfony/Component/HttpKernel') - ->in($root.'/vendor/symfony/routing/Symfony/Component/Routing') - ->in($root.'/vendor/symfony/browser-kit/Symfony/Component/BrowserKit') - ->in($root.'/vendor/symfony/css-selector/Symfony/Component/CssSelector') - ->in($root.'/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler') - ; - - foreach ($finder as $file) { - $this->addFile($phar, $file); - } - - $this->addFile($phar, new \SplFileInfo($root.'/LICENSE'), false); - $this->addFile($phar, new \SplFileInfo($root.'/vendor/autoload.php')); - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/ClassLoader.php')); - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/autoload_namespaces.php')); - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/autoload_classmap.php')); - - // Stubs - $phar->setStub($this->getStub()); - - $phar->stopBuffering(); - - unset($phar); - } - - protected function addFile(\Phar $phar, \SplFileInfo $file, $strip = true) - { - $path = str_replace(dirname(dirname(dirname(__DIR__))).DIRECTORY_SEPARATOR, '', $file->getRealPath()); - - $content = file_get_contents($file); - if ($strip) { - $content = self::stripWhitespace($content); - } - - $content = preg_replace("/const VERSION = '.*?';/", "const VERSION = '".$this->version."';", $content); - - $phar->addFromString($path, $content); - } - - protected function getStub() - { - return <<<'EOF' - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -Phar::mapPhar('silex.phar'); - -require_once 'phar://silex.phar/vendor/autoload.php'; - -if ('cli' === php_sapi_name() && basename(__FILE__) === basename($_SERVER['argv'][0]) && isset($_SERVER['argv'][1])) { - switch ($_SERVER['argv'][1]) { - case 'update': - $remoteFilename = 'http://silex.sensiolabs.org/get/silex.phar'; - $localFilename = __DIR__.'/silex.phar'; - - file_put_contents($localFilename, file_get_contents($remoteFilename)); - break; - - case 'check': - $latest = trim(file_get_contents('http://silex.sensiolabs.org/get/version')); - - if ($latest != Silex\Application::VERSION) { - printf("A newer Silex version is available (%s).\n", $latest); - } else { - print("You are using the latest Silex version.\n"); - } - break; - - case 'version': - printf("Silex version %s\n", Silex\Application::VERSION); - break; - - default: - printf("Unknown command '%s' (available commands: version, check, and update).\n", $_SERVER['argv'][1]); - } - - exit(0); -} - -__HALT_COMPILER(); -EOF; - } - - /** - * Removes whitespace from a PHP source string while preserving line numbers. - * - * Based on Kernel::stripComments(), but keeps line numbers intact. - * - * @param string $source A PHP string - * - * @return string The PHP string with the whitespace removed - */ - public static function stripWhitespace($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 .= str_repeat("\n", substr_count($token[1], "\n")); - } elseif (T_WHITESPACE === $token[0]) { - // reduce wide spaces - $whitespace = preg_replace('{[ \t]+}', ' ', $token[1]); - // normalize newlines to \n - $whitespace = preg_replace('{(?:\r\n|\r|\n)}', "\n", $whitespace); - // trim leading spaces - $whitespace = preg_replace('{\n +}', "\n", $whitespace); - $output .= $whitespace; - } else { - $output .= $token[1]; - } - } - - return $output; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/ViewListenerWrapper.php b/lib/silex/vendor/silex/silex/src/Silex/ViewListenerWrapper.php deleted file mode 100644 index a67ec938e..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/ViewListenerWrapper.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; - -/** - * Wraps view listeners. - * - * @author Dave Marshall - */ -class ViewListenerWrapper -{ - private $app; - private $callback; - - /** - * Constructor. - * - * @param Application $app An Application instance - * @param mixed $callback - */ - public function __construct(Application $app, $callback) - { - $this->app = $app; - $this->callback = $callback; - } - - public function __invoke(GetResponseForControllerResultEvent $event) - { - $controllerResult = $event->getControllerResult(); - $callback = $this->app['callback_resolver']->resolveCallback($this->callback); - - if (!$this->shouldRun($callback, $controllerResult)) { - return; - } - - $response = call_user_func($callback, $controllerResult, $event->getRequest()); - - if ($response instanceof Response) { - $event->setResponse($response); - } elseif (null !== $response) { - $event->setControllerResult($response); - } - } - - private function shouldRun($callback, $controllerResult) - { - if (is_array($callback)) { - $callbackReflection = new \ReflectionMethod($callback[0], $callback[1]); - } elseif (is_object($callback) && !$callback instanceof \Closure) { - $callbackReflection = new \ReflectionObject($callback); - $callbackReflection = $callbackReflection->getMethod('__invoke'); - } else { - $callbackReflection = new \ReflectionFunction($callback); - } - - if ($callbackReflection->getNumberOfParameters() > 0) { - $parameters = $callbackReflection->getParameters(); - $expectedControllerResult = $parameters[0]; - - if ($expectedControllerResult->getClass() && (!is_object($controllerResult) || !$expectedControllerResult->getClass()->isInstance($controllerResult))) { - return false; - } - - if ($expectedControllerResult->isArray() && !is_array($controllerResult)) { - return false; - } - - if (method_exists($expectedControllerResult, 'isCallable') && $expectedControllerResult->isCallable() && !is_callable($controllerResult)) { - return false; - } - } - - return true; - } -} diff --git a/lib/silex/vendor/silex/silex/src/Silex/WebTestCase.php b/lib/silex/vendor/silex/silex/src/Silex/WebTestCase.php deleted file mode 100644 index e72403a1c..000000000 --- a/lib/silex/vendor/silex/silex/src/Silex/WebTestCase.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Client; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * WebTestCase is the base class for functional tests. - * - * @author Igor Wiedler - */ -abstract class WebTestCase extends TestCase -{ - /** - * HttpKernelInterface instance. - * - * @var HttpKernelInterface - */ - protected $app; - - /** - * PHPUnit setUp for setting up the application. - * - * Note: Child classes that define a setUp method must call - * parent::setUp(). - */ - protected function setUp() - { - $this->app = $this->createApplication(); - } - - /** - * Creates the application. - * - * @return HttpKernelInterface - */ - abstract public function createApplication(); - - /** - * Creates a Client. - * - * @param array $server Server parameters - * - * @return Client A Client instance - */ - public function createClient(array $server = array()) - { - if (!class_exists('Symfony\Component\BrowserKit\Client')) { - throw new \LogicException('Component "symfony/browser-kit" is required by WebTestCase.'.PHP_EOL.'Run composer require symfony/browser-kit'); - } - - return new Client($this->app, $server); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormApplication.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormApplication.php deleted file mode 100644 index 5851a4c9c..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormApplication.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use Silex\Application; - -class FormApplication extends Application -{ - use Application\FormTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormTraitTest.php deleted file mode 100644 index 1d36a0cb3..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/FormTraitTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use PHPUnit\Framework\TestCase; -use Silex\Provider\FormServiceProvider; -use Symfony\Component\Form\FormBuilder; - -/** - * FormTrait test cases. - * - * @author Fabien Potencier - */ -class FormTraitTest extends TestCase -{ - public function testForm() - { - $this->assertInstanceOf(FormBuilder::class, $this->createApplication()->form()); - } - - public function testNamedForm() - { - $builder = $this->createApplication()->namedForm('foo'); - - $this->assertInstanceOf(FormBuilder::class, $builder); - $this->assertSame('foo', $builder->getName()); - } - - public function createApplication() - { - $app = new FormApplication(); - $app->register(new FormServiceProvider()); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologApplication.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologApplication.php deleted file mode 100644 index 9fec12fb8..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologApplication.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use Silex\Application; - -class MonologApplication extends Application -{ - use Application\MonologTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologTraitTest.php deleted file mode 100644 index 73dcda65b..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/MonologTraitTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use PHPUnit\Framework\TestCase; -use Silex\Provider\MonologServiceProvider; -use Monolog\Handler\TestHandler; -use Monolog\Logger; - -/** - * MonologTrait test cases. - * - * @author Fabien Potencier - */ -class MonologTraitTest extends TestCase -{ - public function testLog() - { - $app = $this->createApplication(); - - $app->log('Foo'); - $app->log('Bar', array(), Logger::DEBUG); - $this->assertTrue($app['monolog.handler']->hasInfo('Foo')); - $this->assertTrue($app['monolog.handler']->hasDebug('Bar')); - } - - public function createApplication() - { - $app = new MonologApplication(); - $app->register(new MonologServiceProvider(), array( - 'monolog.handler' => function () use ($app) { - return new TestHandler($app['monolog.level']); - }, - 'monolog.logfile' => 'php://memory', - )); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityApplication.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityApplication.php deleted file mode 100644 index dc85999e4..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityApplication.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use Silex\Application; - -class SecurityApplication extends Application -{ - use Application\SecurityTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityTraitTest.php deleted file mode 100644 index 71cb3af62..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SecurityTraitTest.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use PHPUnit\Framework\TestCase; -use Silex\Provider\SecurityServiceProvider; -use Symfony\Component\Security\Core\User\User; -use Symfony\Component\HttpFoundation\Request; - -/** - * SecurityTrait test cases. - * - * @author Fabien Potencier - */ -class SecurityTraitTest extends TestCase -{ - public function testEncodePassword() - { - $app = $this->createApplication(array( - 'fabien' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - )); - - $user = new User('foo', 'bar'); - $password = 'foo'; - $encoded = $app->encodePassword($user, $password); - - $this->assertTrue( - $app['security.encoder_factory']->getEncoder($user)->isPasswordValid($encoded, $password, $user->getSalt()) - ); - } - - /** - * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException - */ - public function testIsGrantedWithoutTokenThrowsException() - { - $app = $this->createApplication(); - $app->get('/', function () { return 'foo'; }); - $app->handle(Request::create('/')); - $app->isGranted('ROLE_ADMIN'); - } - - public function testIsGranted() - { - $request = Request::create('/'); - - $app = $this->createApplication(array( - 'fabien' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - 'monique' => array('ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - )); - $app->get('/', function () { return 'foo'; }); - - // User is Monique (ROLE_USER) - $request->headers->set('PHP_AUTH_USER', 'monique'); - $request->headers->set('PHP_AUTH_PW', 'foo'); - $app->handle($request); - $this->assertTrue($app->isGranted('ROLE_USER')); - $this->assertFalse($app->isGranted('ROLE_ADMIN')); - - // User is Fabien (ROLE_ADMIN) - $request->headers->set('PHP_AUTH_USER', 'fabien'); - $request->headers->set('PHP_AUTH_PW', 'foo'); - $app->handle($request); - $this->assertFalse($app->isGranted('ROLE_USER')); - $this->assertTrue($app->isGranted('ROLE_ADMIN')); - } - - public function createApplication($users = array()) - { - $app = new SecurityApplication(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'http' => true, - 'users' => $users, - ), - ), - )); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerApplication.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerApplication.php deleted file mode 100644 index 6a28d5392..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerApplication.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use Silex\Application; - -class SwiftmailerApplication extends Application -{ - use Application\SwiftmailerTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerTraitTest.php deleted file mode 100644 index 34620b719..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/SwiftmailerTraitTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use PHPUnit\Framework\TestCase; -use Silex\Provider\SwiftmailerServiceProvider; - -/** - * SwiftmailerTrait test cases. - * - * @author Fabien Potencier - */ -class SwiftmailerTraitTest extends TestCase -{ - public function testMail() - { - $app = $this->createApplication(); - - $message = $this->getMockBuilder('Swift_Message')->disableOriginalConstructor()->getMock(); - $app['mailer'] = $mailer = $this->getMockBuilder('Swift_Mailer')->disableOriginalConstructor()->getMock(); - $mailer->expects($this->once()) - ->method('send') - ->with($message) - ; - - $app->mail($message); - } - - public function createApplication() - { - $app = new SwiftmailerApplication(); - $app->register(new SwiftmailerServiceProvider()); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationApplication.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationApplication.php deleted file mode 100644 index 3e51b9c21..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationApplication.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use Silex\Application; - -class TranslationApplication extends Application -{ - use Application\TranslationTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationTraitTest.php deleted file mode 100644 index 5c0546002..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TranslationTraitTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use PHPUnit\Framework\TestCase; -use Silex\Provider\TranslationServiceProvider; - -/** - * TranslationTrait test cases. - * - * @author Fabien Potencier - */ -class TranslationTraitTest extends TestCase -{ - public function testTrans() - { - $app = $this->createApplication(); - $app['translator'] = $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')->disableOriginalConstructor()->getMock(); - $translator->expects($this->once())->method('trans'); - $app->trans('foo'); - } - - public function testTransChoice() - { - $app = $this->createApplication(); - $app['translator'] = $translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')->disableOriginalConstructor()->getMock(); - $translator->expects($this->once())->method('transChoice'); - $app->transChoice('foo', 2); - } - - public function createApplication() - { - $app = new TranslationApplication(); - $app->register(new TranslationServiceProvider()); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigApplication.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigApplication.php deleted file mode 100644 index f1bb47380..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigApplication.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use Silex\Application; - -class TwigApplication extends Application -{ - use Application\TwigTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigTraitTest.php deleted file mode 100644 index 250ebcfae..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/TwigTraitTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use PHPUnit\Framework\TestCase; -use Silex\Provider\TwigServiceProvider; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; - -/** - * TwigTrait test cases. - * - * @author Fabien Potencier - */ -class TwigTraitTest extends TestCase -{ - public function testRender() - { - $app = $this->createApplication(); - - $app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); - $mailer->expects($this->once())->method('render')->will($this->returnValue('foo')); - - $response = $app->render('view'); - $this->assertEquals('Symfony\Component\HttpFoundation\Response', get_class($response)); - $this->assertEquals('foo', $response->getContent()); - } - - public function testRenderKeepResponse() - { - $app = $this->createApplication(); - - $app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); - $mailer->expects($this->once())->method('render')->will($this->returnValue('foo')); - - $response = $app->render('view', array(), new Response('', 404)); - $this->assertEquals(404, $response->getStatusCode()); - } - - public function testRenderForStream() - { - $app = $this->createApplication(); - - $app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); - $mailer->expects($this->once())->method('display')->will($this->returnCallback(function () { echo 'foo'; })); - - $response = $app->render('view', array(), new StreamedResponse()); - $this->assertEquals('Symfony\Component\HttpFoundation\StreamedResponse', get_class($response)); - - ob_start(); - $response->send(); - $this->assertEquals('foo', ob_get_clean()); - } - - public function testRenderView() - { - $app = $this->createApplication(); - - $app['twig'] = $mailer = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); - $mailer->expects($this->once())->method('render'); - - $app->renderView('view'); - } - - public function createApplication() - { - $app = new TwigApplication(); - $app->register(new TwigServiceProvider()); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorApplication.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorApplication.php deleted file mode 100644 index 4239af465..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorApplication.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use Silex\Application; - -class UrlGeneratorApplication extends Application -{ - use Application\UrlGeneratorTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorTraitTest.php deleted file mode 100644 index df29d6e79..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Application/UrlGeneratorTraitTest.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Application; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * UrlGeneratorTrait test cases. - * - * @author Fabien Potencier - */ -class UrlGeneratorTraitTest extends TestCase -{ - public function testUrl() - { - $app = new UrlGeneratorApplication(); - $app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock(); - $app['url_generator']->expects($this->once())->method('generate')->with('foo', array(), UrlGeneratorInterface::ABSOLUTE_URL); - $app->url('foo'); - } - - public function testPath() - { - $app = new UrlGeneratorApplication(); - $app['url_generator'] = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->disableOriginalConstructor()->getMock(); - $app['url_generator']->expects($this->once())->method('generate')->with('foo', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - $app->path('foo'); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ApplicationTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/ApplicationTest.php deleted file mode 100644 index bcf202955..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ApplicationTest.php +++ /dev/null @@ -1,725 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use Fig\Link\GenericLinkProvider; -use Fig\Link\Link; -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\ControllerCollection; -use Silex\Api\ControllerProviderInterface; -use Silex\Route; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\HttpException; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\WebLink\HttpHeaderSerializer; - -/** - * Application test cases. - * - * @author Igor Wiedler - */ -class ApplicationTest extends TestCase -{ - public function testMatchReturnValue() - { - $app = new Application(); - - $returnValue = $app->match('/foo', function () {}); - $this->assertInstanceOf('Silex\Controller', $returnValue); - - $returnValue = $app->get('/foo', function () {}); - $this->assertInstanceOf('Silex\Controller', $returnValue); - - $returnValue = $app->post('/foo', function () {}); - $this->assertInstanceOf('Silex\Controller', $returnValue); - - $returnValue = $app->put('/foo', function () {}); - $this->assertInstanceOf('Silex\Controller', $returnValue); - - $returnValue = $app->patch('/foo', function () {}); - $this->assertInstanceOf('Silex\Controller', $returnValue); - - $returnValue = $app->delete('/foo', function () {}); - $this->assertInstanceOf('Silex\Controller', $returnValue); - } - - public function testConstructorInjection() - { - // inject a custom parameter - $params = array('param' => 'value'); - $app = new Application($params); - $this->assertSame($params['param'], $app['param']); - - // inject an existing parameter - $params = array('locale' => 'value'); - $app = new Application($params); - $this->assertSame($params['locale'], $app['locale']); - } - - public function testGetRequest() - { - $request = Request::create('/'); - - $app = new Application(); - $app->get('/', function (Request $req) use ($request) { - return $request === $req ? 'ok' : 'ko'; - }); - - $this->assertEquals('ok', $app->handle($request)->getContent()); - } - - public function testGetRoutesWithNoRoutes() - { - $app = new Application(); - - $routes = $app['routes']; - $this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $routes); - $this->assertCount(0, $routes->all()); - } - - public function testGetRoutesWithRoutes() - { - $app = new Application(); - - $app->get('/foo', function () { - return 'foo'; - }); - - $app->get('/bar')->run(function () { - return 'bar'; - }); - - $routes = $app['routes']; - $this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $routes); - $this->assertCount(0, $routes->all()); - $app->flush(); - $this->assertCount(2, $routes->all()); - } - - public function testOnCoreController() - { - $app = new Application(); - - $app->get('/foo/{foo}', function (\ArrayObject $foo) { - return $foo['foo']; - })->convert('foo', function ($foo) { return new \ArrayObject(array('foo' => $foo)); }); - - $response = $app->handle(Request::create('/foo/bar')); - $this->assertEquals('bar', $response->getContent()); - - $app->get('/foo/{foo}/{bar}', function (\ArrayObject $foo) { - return $foo['foo']; - })->convert('foo', function ($foo, Request $request) { return new \ArrayObject(array('foo' => $foo.$request->attributes->get('bar'))); }); - - $response = $app->handle(Request::create('/foo/foo/bar')); - $this->assertEquals('foobar', $response->getContent()); - } - - public function testOn() - { - $app = new Application(); - $app['pass'] = false; - - $app->on('test', function (Event $e) use ($app) { - $app['pass'] = true; - }); - - $app['dispatcher']->dispatch('test'); - - $this->assertTrue($app['pass']); - } - - public function testAbort() - { - $app = new Application(); - - try { - $app->abort(404); - $this->fail(); - } catch (HttpException $e) { - $this->assertEquals(404, $e->getStatusCode()); - } - } - - /** - * @dataProvider escapeProvider - */ - public function testEscape($expected, $text) - { - $app = new Application(); - - $this->assertEquals($expected, $app->escape($text)); - } - - public function escapeProvider() - { - return array( - array('<', '<'), - array('>', '>'), - array('"', '"'), - array("'", "'"), - array('abc', 'abc'), - ); - } - - public function testControllersAsMethods() - { - $app = new Application(); - unset($app['exception_handler']); - - $app->get('/{name}', 'Silex\Tests\FooController::barAction'); - - $this->assertEquals('Hello Fabien', $app->handle(Request::create('/Fabien'))->getContent()); - } - - public function testApplicationTypeHintWorks() - { - $app = new SpecialApplication(); - unset($app['exception_handler']); - - $app->get('/{name}', 'Silex\Tests\FooController::barSpecialAction'); - - $this->assertEquals('Hello Fabien in Silex\Tests\SpecialApplication', $app->handle(Request::create('/Fabien'))->getContent()); - } - - /** - * @requires PHP 7.0 - */ - public function testPhp7TypeHintWorks() - { - $app = new SpecialApplication(); - unset($app['exception_handler']); - - $app->get('/{name}', 'Silex\Tests\Fixtures\Php7Controller::typehintedAction'); - - $this->assertEquals('Hello Fabien in Silex\Tests\SpecialApplication', $app->handle(Request::create('/Fabien'))->getContent()); - } - - public function testHttpSpec() - { - $app = new Application(); - $app['charset'] = 'ISO-8859-1'; - - $app->get('/', function () { - return 'hello'; - }); - - // content is empty for HEAD requests - $response = $app->handle(Request::create('/', 'HEAD')); - $this->assertEquals('', $response->getContent()); - - // charset is appended to Content-Type - $response = $app->handle(Request::create('/')); - - $this->assertEquals('text/html; charset=ISO-8859-1', $response->headers->get('Content-Type')); - } - - public function testRoutesMiddlewares() - { - $app = new Application(); - - $test = $this; - - $middlewareTarget = array(); - $beforeMiddleware1 = function (Request $request) use (&$middlewareTarget, $test) { - $test->assertEquals('/reached', $request->getRequestUri()); - $middlewareTarget[] = 'before_middleware1_triggered'; - }; - $beforeMiddleware2 = function (Request $request) use (&$middlewareTarget, $test) { - $test->assertEquals('/reached', $request->getRequestUri()); - $middlewareTarget[] = 'before_middleware2_triggered'; - }; - $beforeMiddleware3 = function (Request $request) use (&$middlewareTarget, $test) { - throw new \Exception('This middleware shouldn\'t run!'); - }; - - $afterMiddleware1 = function (Request $request, Response $response) use (&$middlewareTarget, $test) { - $test->assertEquals('/reached', $request->getRequestUri()); - $middlewareTarget[] = 'after_middleware1_triggered'; - }; - $afterMiddleware2 = function (Request $request, Response $response) use (&$middlewareTarget, $test) { - $test->assertEquals('/reached', $request->getRequestUri()); - $middlewareTarget[] = 'after_middleware2_triggered'; - }; - $afterMiddleware3 = function (Request $request, Response $response) use (&$middlewareTarget, $test) { - throw new \Exception('This middleware shouldn\'t run!'); - }; - - $app->get('/reached', function () use (&$middlewareTarget) { - $middlewareTarget[] = 'route_triggered'; - - return 'hello'; - }) - ->before($beforeMiddleware1) - ->before($beforeMiddleware2) - ->after($afterMiddleware1) - ->after($afterMiddleware2); - - $app->get('/never-reached', function () use (&$middlewareTarget) { - throw new \Exception('This route shouldn\'t run!'); - }) - ->before($beforeMiddleware3) - ->after($afterMiddleware3); - - $result = $app->handle(Request::create('/reached')); - - $this->assertSame(array('before_middleware1_triggered', 'before_middleware2_triggered', 'route_triggered', 'after_middleware1_triggered', 'after_middleware2_triggered'), $middlewareTarget); - $this->assertEquals('hello', $result->getContent()); - } - - public function testRoutesBeforeMiddlewaresWithResponseObject() - { - $app = new Application(); - - $app->get('/foo', function () { - throw new \Exception('This route shouldn\'t run!'); - }) - ->before(function () { - return new Response('foo'); - }); - - $request = Request::create('/foo'); - $result = $app->handle($request); - - $this->assertEquals('foo', $result->getContent()); - } - - public function testRoutesAfterMiddlewaresWithResponseObject() - { - $app = new Application(); - - $app->get('/foo', function () { - return new Response('foo'); - }) - ->after(function () { - return new Response('bar'); - }); - - $request = Request::create('/foo'); - $result = $app->handle($request); - - $this->assertEquals('bar', $result->getContent()); - } - - public function testRoutesBeforeMiddlewaresWithRedirectResponseObject() - { - $app = new Application(); - - $app->get('/foo', function () { - throw new \Exception('This route shouldn\'t run!'); - }) - ->before(function () use ($app) { - return $app->redirect('/bar'); - }); - - $request = Request::create('/foo'); - $result = $app->handle($request); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $result); - $this->assertEquals('/bar', $result->getTargetUrl()); - } - - public function testRoutesBeforeMiddlewaresTriggeredAfterSilexBeforeFilters() - { - $app = new Application(); - - $middlewareTarget = array(); - $middleware = function (Request $request) use (&$middlewareTarget) { - $middlewareTarget[] = 'middleware_triggered'; - }; - - $app->get('/foo', function () use (&$middlewareTarget) { - $middlewareTarget[] = 'route_triggered'; - }) - ->before($middleware); - - $app->before(function () use (&$middlewareTarget) { - $middlewareTarget[] = 'before_triggered'; - }); - - $app->handle(Request::create('/foo')); - - $this->assertSame(array('before_triggered', 'middleware_triggered', 'route_triggered'), $middlewareTarget); - } - - public function testRoutesAfterMiddlewaresTriggeredBeforeSilexAfterFilters() - { - $app = new Application(); - - $middlewareTarget = array(); - $middleware = function (Request $request) use (&$middlewareTarget) { - $middlewareTarget[] = 'middleware_triggered'; - }; - - $app->get('/foo', function () use (&$middlewareTarget) { - $middlewareTarget[] = 'route_triggered'; - }) - ->after($middleware); - - $app->after(function () use (&$middlewareTarget) { - $middlewareTarget[] = 'after_triggered'; - }); - - $app->handle(Request::create('/foo')); - - $this->assertSame(array('route_triggered', 'middleware_triggered', 'after_triggered'), $middlewareTarget); - } - - public function testFinishFilter() - { - $containerTarget = array(); - - $app = new Application(); - - $app->finish(function () use (&$containerTarget) { - $containerTarget[] = '4_filterFinish'; - }); - - $app->get('/foo', function () use (&$containerTarget) { - $containerTarget[] = '1_routeTriggered'; - - return new StreamedResponse(function () use (&$containerTarget) { - $containerTarget[] = '3_responseSent'; - }); - }); - - $app->after(function () use (&$containerTarget) { - $containerTarget[] = '2_filterAfter'; - }); - - $app->run(Request::create('/foo')); - - $this->assertSame(array('1_routeTriggered', '2_filterAfter', '3_responseSent', '4_filterFinish'), $containerTarget); - } - - /** - * @expectedException \RuntimeException - */ - public function testNonResponseAndNonNullReturnFromRouteBeforeMiddlewareShouldThrowRuntimeException() - { - $app = new Application(); - - $middleware = function (Request $request) { - return 'string return'; - }; - - $app->get('/', function () { - return 'hello'; - }) - ->before($middleware); - - $app->handle(Request::create('/'), HttpKernelInterface::MASTER_REQUEST, false); - } - - /** - * @expectedException \RuntimeException - */ - public function testNonResponseAndNonNullReturnFromRouteAfterMiddlewareShouldThrowRuntimeException() - { - $app = new Application(); - - $middleware = function (Request $request) { - return 'string return'; - }; - - $app->get('/', function () { - return 'hello'; - }) - ->after($middleware); - - $app->handle(Request::create('/'), HttpKernelInterface::MASTER_REQUEST, false); - } - - public function testSubRequest() - { - $app = new Application(); - $app->get('/sub', function (Request $request) { - return new Response('foo'); - }); - $app->get('/', function (Request $request) use ($app) { - return $app->handle(Request::create('/sub'), HttpKernelInterface::SUB_REQUEST); - }); - - $this->assertEquals('foo', $app->handle(Request::create('/'))->getContent()); - } - - public function testRegisterShouldReturnSelf() - { - $app = new Application(); - $provider = $this->getMockBuilder('Pimple\ServiceProviderInterface')->getMock(); - - $this->assertSame($app, $app->register($provider)); - } - - public function testMountShouldReturnSelf() - { - $app = new Application(); - $mounted = new ControllerCollection(new Route()); - $mounted->get('/{name}', function ($name) { return new Response($name); }); - - $this->assertSame($app, $app->mount('/hello', $mounted)); - } - - public function testMountPreservesOrder() - { - $app = new Application(); - $mounted = new ControllerCollection(new Route()); - $mounted->get('/mounted')->bind('second'); - - $app->get('/before')->bind('first'); - $app->mount('/', $mounted); - $app->get('/after')->bind('third'); - $app->flush(); - - $this->assertEquals(array('first', 'second', 'third'), array_keys(iterator_to_array($app['routes']))); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage The "mount" method takes either a "ControllerCollection" instance, "ControllerProviderInterface" instance, or a callable. - */ - public function testMountNullException() - { - $app = new Application(); - $app->mount('/exception', null); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage The method "Silex\Tests\IncorrectControllerCollection::connect" must return a "ControllerCollection" instance. Got: "NULL" - */ - public function testMountWrongConnectReturnValueException() - { - $app = new Application(); - $app->mount('/exception', new IncorrectControllerCollection()); - } - - public function testMountCallable() - { - $app = new Application(); - $app->mount('/prefix', function (ControllerCollection $coll) { - $coll->get('/path'); - }); - - $app->flush(); - - $this->assertEquals(1, $app['routes']->count()); - } - - public function testSendFile() - { - $app = new Application(); - - $response = $app->sendFile(__FILE__, 200, array('Content-Type: application/php')); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\BinaryFileResponse', $response); - $this->assertEquals(__FILE__, (string) $response->getFile()); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage The "homepage" route must have code to run when it matches. - */ - public function testGetRouteCollectionWithRouteWithoutController() - { - $app = new Application(); - unset($app['exception_handler']); - $app->match('/')->bind('homepage'); - $app->handle(Request::create('/')); - } - - public function testBeforeFilterOnMountedControllerGroupIsolatedToGroup() - { - $app = new Application(); - $app->match('/', function () { return new Response('ok'); }); - $mounted = $app['controllers_factory']; - $mounted->before(function () { return new Response('not ok'); }); - $app->mount('/group', $mounted); - - $response = $app->handle(Request::create('/')); - $this->assertEquals('ok', $response->getContent()); - } - - public function testViewListenerWithPrimitive() - { - $app = new Application(); - $app->get('/foo', function () { return 123; }); - $app->view(function ($view, Request $request) { - return new Response($view); - }); - - $response = $app->handle(Request::create('/foo')); - - $this->assertEquals('123', $response->getContent()); - } - - public function testViewListenerWithArrayTypeHint() - { - $app = new Application(); - $app->get('/foo', function () { return array('ok'); }); - $app->view(function (array $view) { - return new Response($view[0]); - }); - - $response = $app->handle(Request::create('/foo')); - - $this->assertEquals('ok', $response->getContent()); - } - - public function testViewListenerWithObjectTypeHint() - { - $app = new Application(); - $app->get('/foo', function () { return (object) array('name' => 'world'); }); - $app->view(function (\stdClass $view) { - return new Response('Hello '.$view->name); - }); - - $response = $app->handle(Request::create('/foo')); - - $this->assertEquals('Hello world', $response->getContent()); - } - - public function testViewListenerWithCallableTypeHint() - { - $app = new Application(); - $app->get('/foo', function () { return function () { return 'world'; }; }); - $app->view(function (callable $view) { - return new Response('Hello '.$view()); - }); - - $response = $app->handle(Request::create('/foo')); - - $this->assertEquals('Hello world', $response->getContent()); - } - - public function testViewListenersCanBeChained() - { - $app = new Application(); - $app->get('/foo', function () { return (object) array('name' => 'world'); }); - - $app->view(function (\stdClass $view) { - return array('msg' => 'Hello '.$view->name); - }); - - $app->view(function (array $view) { - return $view['msg']; - }); - - $response = $app->handle(Request::create('/foo')); - - $this->assertEquals('Hello world', $response->getContent()); - } - - public function testViewListenersAreIgnoredIfNotSuitable() - { - $app = new Application(); - $app->get('/foo', function () { return 'Hello world'; }); - - $app->view(function (\stdClass $view) { - throw new \Exception('View listener was called'); - }); - - $app->view(function (array $view) { - throw new \Exception('View listener was called'); - }); - - $response = $app->handle(Request::create('/foo')); - - $this->assertEquals('Hello world', $response->getContent()); - } - - public function testViewListenersResponsesAreNotUsedIfNull() - { - $app = new Application(); - $app->get('/foo', function () { return 'Hello world'; }); - - $app->view(function ($view) { - return 'Hello view listener'; - }); - - $app->view(function ($view) { - return; - }); - - $response = $app->handle(Request::create('/foo')); - - $this->assertEquals('Hello view listener', $response->getContent()); - } - - public function testWebLinkListener() - { - if (!class_exists(HttpHeaderSerializer::class)) { - self::markTestSkipped('Symfony WebLink component is required.'); - } - - $app = new Application(); - - $app->get('/', function () { - return 'hello'; - }); - - $request = Request::create('/'); - $request->attributes->set('_links', (new GenericLinkProvider())->withLink(new Link('preload', '/foo.css'))); - - $response = $app->handle($request); - - $this->assertEquals('; rel="preload"', $response->headers->get('Link')); - } - - public function testDefaultRoutesFactory() - { - $app = new Application(); - $this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $app['routes']); - } - - public function testOverriddenRoutesFactory() - { - $app = new Application(); - $app['routes_factory'] = $app->factory(function () { - return new RouteCollectionSubClass(); - }); - $this->assertInstanceOf('Silex\Tests\RouteCollectionSubClass', $app['routes']); - } -} - -class FooController -{ - public function barAction(Application $app, $name) - { - return 'Hello '.$app->escape($name); - } - - public function barSpecialAction(SpecialApplication $app, $name) - { - return 'Hello '.$app->escape($name).' in '.get_class($app); - } -} - -class IncorrectControllerCollection implements ControllerProviderInterface -{ - public function connect(Application $app) - { - return; - } -} - -class RouteCollectionSubClass extends RouteCollection -{ -} - -class SpecialApplication extends Application -{ -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackResolverTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackResolverTest.php deleted file mode 100644 index b637a944e..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackResolverTest.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Pimple\Container; -use Silex\CallbackResolver; - -class CallbackResolverTest extends Testcase -{ - private $app; - private $resolver; - - public function setup() - { - $this->app = new Container(); - $this->resolver = new CallbackResolver($this->app); - } - - public function testShouldResolveCallback() - { - $callable = function () {}; - $this->app['some_service'] = function () { return new \ArrayObject(); }; - $this->app['callable_service'] = function () use ($callable) { - return $callable; - }; - - $this->assertTrue($this->resolver->isValid('some_service:methodName')); - $this->assertTrue($this->resolver->isValid('callable_service')); - $this->assertEquals( - array($this->app['some_service'], 'append'), - $this->resolver->convertCallback('some_service:append') - ); - $this->assertSame($callable, $this->resolver->convertCallback('callable_service')); - } - - /** - * @dataProvider nonStringsAreNotValidProvider - */ - public function testNonStringsAreNotValid($name) - { - $this->assertFalse($this->resolver->isValid($name)); - } - - public function nonStringsAreNotValidProvider() - { - return array( - array(null), - array('some_service::methodName'), - array('missing_service'), - ); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /Service "[a-z_]+" is not callable./ - * @dataProvider shouldThrowAnExceptionIfServiceIsNotCallableProvider - */ - public function testShouldThrowAnExceptionIfServiceIsNotCallable($name) - { - $this->app['non_callable_obj'] = function () { return new \stdClass(); }; - $this->app['non_callable'] = function () { return array(); }; - $this->resolver->convertCallback($name); - } - - public function shouldThrowAnExceptionIfServiceIsNotCallableProvider() - { - return array( - array('non_callable_obj:methodA'), - array('non_callable'), - ); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackServicesTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackServicesTest.php deleted file mode 100644 index 915c04965..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/CallbackServicesTest.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; -use Silex\Provider\ServiceControllerServiceProvider; - -/** - * Callback as services test cases. - * - * @author Fabien Potencier - */ -class CallbackServicesTest extends TestCase -{ - public $called = array(); - - public function testCallbacksAsServices() - { - $app = new Application(); - $app->register(new ServiceControllerServiceProvider()); - - $app['service'] = function () { - return new CallbackServicesTest(); - }; - - $app->before('service:beforeApp'); - $app->after('service:afterApp'); - $app->finish('service:finishApp'); - $app->error('service:error'); - $app->on('kernel.request', 'service:onRequest'); - - $app - ->match('/', 'service:controller') - ->convert('foo', 'service:convert') - ->before('service:before') - ->after('service:after') - ; - - $request = Request::create('/'); - $response = $app->handle($request); - $app->terminate($request, $response); - - $this->assertEquals(array( - 'BEFORE APP', - 'ON REQUEST', - 'BEFORE', - 'CONVERT', - 'ERROR', - 'AFTER', - 'AFTER APP', - 'FINISH APP', - ), $app['service']->called); - } - - public function controller(Application $app) - { - $app->abort(404); - } - - public function before() - { - $this->called[] = 'BEFORE'; - } - - public function after() - { - $this->called[] = 'AFTER'; - } - - public function beforeApp() - { - $this->called[] = 'BEFORE APP'; - } - - public function afterApp() - { - $this->called[] = 'AFTER APP'; - } - - public function finishApp() - { - $this->called[] = 'FINISH APP'; - } - - public function error() - { - $this->called[] = 'ERROR'; - } - - public function convert() - { - $this->called[] = 'CONVERT'; - } - - public function onRequest() - { - $this->called[] = 'ON REQUEST'; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerCollectionTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerCollectionTest.php deleted file mode 100644 index 9b96e00c7..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerCollectionTest.php +++ /dev/null @@ -1,345 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Controller; -use Silex\ControllerCollection; -use Silex\Exception\ControllerFrozenException; -use Silex\Route; -use Symfony\Component\Routing\RouteCollection; - -/** - * ControllerCollection test cases. - * - * @author Igor Wiedler - */ -class ControllerCollectionTest extends TestCase -{ - public function testGetRouteCollectionWithNoRoutes() - { - $controllers = new ControllerCollection(new Route()); - $routes = $controllers->flush(); - $this->assertCount(0, $routes->all()); - } - - public function testGetRouteCollectionWithRoutes() - { - $controllers = new ControllerCollection(new Route()); - $controllers->match('/foo', function () {}); - $controllers->match('/bar', function () {}); - - $routes = $controllers->flush(); - $this->assertCount(2, $routes->all()); - } - - public function testControllerFreezing() - { - $controllers = new ControllerCollection(new Route()); - - $fooController = $controllers->match('/foo', function () {})->bind('foo'); - $barController = $controllers->match('/bar', function () {})->bind('bar'); - - $controllers->flush(); - - try { - $fooController->bind('foo2'); - $this->fail(); - } catch (ControllerFrozenException $e) { - } - - try { - $barController->bind('bar2'); - $this->fail(); - } catch (ControllerFrozenException $e) { - } - } - - public function testConflictingRouteNames() - { - $controllers = new ControllerCollection(new Route()); - - $mountedRootController = $controllers->match('/', function () {}); - - $mainRootController = new Controller(new Route('/')); - $mainRootController->bind($mainRootController->generateRouteName('main_1')); - - $controllers->flush(); - - $this->assertNotEquals($mainRootController->getRouteName(), $mountedRootController->getRouteName()); - } - - public function testUniqueGeneratedRouteNames() - { - $controllers = new ControllerCollection(new Route()); - - $controllers->match('/a-a', function () {}); - $controllers->match('/a_a', function () {}); - $controllers->match('/a/a', function () {}); - - $routes = $controllers->flush(); - - $this->assertCount(3, $routes->all()); - $this->assertEquals(array('_a_a', '_a_a_1', '_a_a_2'), array_keys($routes->all())); - } - - public function testUniqueGeneratedRouteNamesAmongMounts() - { - $controllers = new ControllerCollection(new Route()); - - $controllers->mount('/root-a', $rootA = new ControllerCollection(new Route())); - $controllers->mount('/root_a', $rootB = new ControllerCollection(new Route())); - - $rootA->match('/leaf', function () {}); - $rootB->match('/leaf', function () {}); - - $routes = $controllers->flush(); - - $this->assertCount(2, $routes->all()); - $this->assertEquals(array('_root_a_leaf', '_root_a_leaf_1'), array_keys($routes->all())); - } - - public function testUniqueGeneratedRouteNamesAmongNestedMounts() - { - $controllers = new ControllerCollection(new Route()); - - $controllers->mount('/root-a', $rootA = new ControllerCollection(new Route())); - $controllers->mount('/root_a', $rootB = new ControllerCollection(new Route())); - - $rootA->mount('/tree', $treeA = new ControllerCollection(new Route())); - $rootB->mount('/tree', $treeB = new ControllerCollection(new Route())); - - $treeA->match('/leaf', function () {}); - $treeB->match('/leaf', function () {}); - - $routes = $controllers->flush(); - - $this->assertCount(2, $routes->all()); - $this->assertEquals(array('_root_a_tree_leaf', '_root_a_tree_leaf_1'), array_keys($routes->all())); - } - - public function testMountCallable() - { - $controllers = new ControllerCollection(new Route()); - $controllers->mount('/prefix', function (ControllerCollection $coll) { - $coll->mount('/path', function ($coll) { - $coll->get('/part'); - }); - }); - - $routes = $controllers->flush(); - $this->assertEquals('/prefix/path/part', current($routes->all())->getPath()); - } - - public function testMountCallableProperClone() - { - $controllers = new ControllerCollection(new Route(), new RouteCollection()); - $controllers->get('/'); - - $subControllers = null; - $controllers->mount('/prefix', function (ControllerCollection $coll) use (&$subControllers) { - $subControllers = $coll; - $coll->get('/'); - }); - - $routes = $controllers->flush(); - $subRoutes = $subControllers->flush(); - $this->assertTrue($routes->count() == 2 && $subRoutes->count() == 0); - } - - public function testMountControllersFactory() - { - $testControllers = new ControllerCollection(new Route()); - $controllers = new ControllerCollection(new Route(), null, function () use ($testControllers) { - return $testControllers; - }); - - $controllers->mount('/prefix', function ($mounted) use ($testControllers) { - $this->assertSame($mounted, $testControllers); - }); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage The "mount" method takes either a "ControllerCollection" instance or callable. - */ - public function testMountCallableException() - { - $controllers = new ControllerCollection(new Route()); - $controllers->mount('/prefix', ''); - } - - public function testAssert() - { - $controllers = new ControllerCollection(new Route()); - $controllers->assert('id', '\d+'); - $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->assert('name', '\w+')->assert('extra', '.*'); - $controllers->assert('extra', '\w+'); - - $this->assertEquals('\d+', $controller->getRoute()->getRequirement('id')); - $this->assertEquals('\w+', $controller->getRoute()->getRequirement('name')); - $this->assertEquals('\w+', $controller->getRoute()->getRequirement('extra')); - } - - public function testAssertWithMountCallable() - { - $controllers = new ControllerCollection(new Route()); - $controller = null; - $controllers->mount('/{name}', function ($mounted) use (&$controller) { - $mounted->assert('name', '\w+'); - $mounted->mount('/{id}', function ($mounted2) use (&$controller) { - $mounted2->assert('id', '\d+'); - $controller = $mounted2->match('/{extra}', function () {})->assert('extra', '\w+'); - }); - }); - - $this->assertEquals('\d+', $controller->getRoute()->getRequirement('id')); - $this->assertEquals('\w+', $controller->getRoute()->getRequirement('name')); - $this->assertEquals('\w+', $controller->getRoute()->getRequirement('extra')); - } - - public function testValue() - { - $controllers = new ControllerCollection(new Route()); - $controllers->value('id', '1'); - $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->value('name', 'Fabien')->value('extra', 'Symfony'); - $controllers->value('extra', 'Twig'); - - $this->assertEquals('1', $controller->getRoute()->getDefault('id')); - $this->assertEquals('Fabien', $controller->getRoute()->getDefault('name')); - $this->assertEquals('Twig', $controller->getRoute()->getDefault('extra')); - } - - public function testConvert() - { - $controllers = new ControllerCollection(new Route()); - $controllers->convert('id', '1'); - $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->convert('name', 'Fabien')->convert('extra', 'Symfony'); - $controllers->convert('extra', 'Twig'); - - $this->assertEquals(array('id' => '1', 'name' => 'Fabien', 'extra' => 'Twig'), $controller->getRoute()->getOption('_converters')); - } - - public function testRequireHttp() - { - $controllers = new ControllerCollection(new Route()); - $controllers->requireHttp(); - $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->requireHttps(); - - $this->assertEquals(array('https'), $controller->getRoute()->getSchemes()); - - $controllers->requireHttp(); - - $this->assertEquals(array('http'), $controller->getRoute()->getSchemes()); - } - - public function testBefore() - { - $controllers = new ControllerCollection(new Route()); - $controllers->before('mid1'); - $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->before('mid2'); - $controllers->before('mid3'); - - $this->assertEquals(array('mid1', 'mid2', 'mid3'), $controller->getRoute()->getOption('_before_middlewares')); - } - - public function testAfter() - { - $controllers = new ControllerCollection(new Route()); - $controllers->after('mid1'); - $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->after('mid2'); - $controllers->after('mid3'); - - $this->assertEquals(array('mid1', 'mid2', 'mid3'), $controller->getRoute()->getOption('_after_middlewares')); - } - - public function testWhen() - { - $controllers = new ControllerCollection(new Route()); - $controller = $controllers->match('/{id}/{name}/{extra}', function () {})->when('request.isSecure() == true'); - - $this->assertEquals('request.isSecure() == true', $controller->getRoute()->getCondition()); - } - - public function testRouteExtension() - { - $route = new MyRoute1(); - - $controller = new ControllerCollection($route); - $controller->foo('foo'); - - $this->assertEquals('foo', $route->foo); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRouteMethodDoesNotExist() - { - $route = new MyRoute1(); - - $controller = new ControllerCollection($route); - $controller->bar(); - } - - public function testNestedCollectionRouteCallbacks() - { - $cl1 = new ControllerCollection(new MyRoute1()); - $cl2 = new ControllerCollection(new MyRoute1()); - - $c1 = $cl2->match('/c1', function () {}); - $cl1->mount('/foo', $cl2); - $c2 = $cl2->match('/c2', function () {}); - $cl1->before('before'); - $c3 = $cl2->match('/c3', function () {}); - - $cl1->flush(); - - $this->assertEquals(array('before'), $c1->getRoute()->getOption('_before_middlewares')); - $this->assertEquals(array('before'), $c2->getRoute()->getOption('_before_middlewares')); - $this->assertEquals(array('before'), $c3->getRoute()->getOption('_before_middlewares')); - } - - public function testRoutesFactoryOmitted() - { - $controllers = new ControllerCollection(new Route()); - $routes = $controllers->flush(); - $this->assertInstanceOf('Symfony\Component\Routing\RouteCollection', $routes); - } - - public function testRoutesFactoryInConstructor() - { - $app = new Application(); - $app['routes_factory'] = $app->factory(function () { - return new RouteCollectionSubClass2(); - }); - - $controllers = new ControllerCollection(new Route(), $app['routes_factory']); - $routes = $controllers->flush(); - $this->assertInstanceOf('Silex\Tests\RouteCollectionSubClass2', $routes); - } -} - -class MyRoute1 extends Route -{ - public $foo; - - public function foo($value) - { - $this->foo = $value; - } -} - -class RouteCollectionSubClass2 extends RouteCollection -{ -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerResolverTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerResolverTest.php deleted file mode 100644 index 14ccbbdf7..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerResolverTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\ControllerResolver; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Kernel; - -/** - * ControllerResolver test cases. - * - * @author Fabien Potencier - */ -class ControllerResolverTest extends TestCase -{ - /** - * @group legacy - */ - public function testGetArguments() - { - if (Kernel::VERSION_ID >= 30100) { - self::markTestSkipped('HttpKernel < 3.1.0 is required'); - } - - $app = new Application(); - $resolver = new ControllerResolver($app); - - $controller = function (Application $app) {}; - - $args = $resolver->getArguments(Request::create('/'), $controller); - $this->assertSame($app, $args[0]); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerTest.php deleted file mode 100644 index 88c6f0a11..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ControllerTest.php +++ /dev/null @@ -1,133 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Controller; -use Silex\Route; - -/** - * Controller test cases. - * - * @author Igor Wiedler - */ -class ControllerTest extends TestCase -{ - public function testBind() - { - $controller = new Controller(new Route('/foo')); - $ret = $controller->bind('foo'); - - $this->assertSame($ret, $controller); - $this->assertEquals('foo', $controller->getRouteName()); - } - - /** - * @expectedException \Silex\Exception\ControllerFrozenException - */ - public function testBindOnFrozenControllerShouldThrowException() - { - $controller = new Controller(new Route('/foo')); - $controller->bind('foo'); - $controller->freeze(); - $controller->bind('bar'); - } - - public function testAssert() - { - $controller = new Controller(new Route('/foo/{bar}')); - $ret = $controller->assert('bar', '\d+'); - - $this->assertSame($ret, $controller); - $this->assertEquals(array('bar' => '\d+'), $controller->getRoute()->getRequirements()); - } - - public function testValue() - { - $controller = new Controller(new Route('/foo/{bar}')); - $ret = $controller->value('bar', 'foo'); - - $this->assertSame($ret, $controller); - $this->assertEquals(array('bar' => 'foo'), $controller->getRoute()->getDefaults()); - } - - public function testConvert() - { - $controller = new Controller(new Route('/foo/{bar}')); - $ret = $controller->convert('bar', $func = function ($bar) { return $bar; }); - - $this->assertSame($ret, $controller); - $this->assertEquals(array('bar' => $func), $controller->getRoute()->getOption('_converters')); - } - - public function testRun() - { - $controller = new Controller(new Route('/foo/{bar}')); - $ret = $controller->run($cb = function () { return 'foo'; }); - - $this->assertSame($ret, $controller); - $this->assertEquals($cb, $controller->getRoute()->getDefault('_controller')); - } - - /** - * @dataProvider provideRouteAndExpectedRouteName - */ - public function testDefaultRouteNameGeneration(Route $route, $prefix, $expectedRouteName) - { - $controller = new Controller($route); - $controller->bind($controller->generateRouteName($prefix)); - - $this->assertEquals($expectedRouteName, $controller->getRouteName()); - } - - public function provideRouteAndExpectedRouteName() - { - return array( - array(new Route('/Invalid%Symbols#Stripped', array(), array(), array(), '', array(), array('POST')), '', 'POST_InvalidSymbolsStripped'), - array(new Route('/post/{id}', array(), array(), array(), '', array(), array('GET')), '', 'GET_post_id'), - array(new Route('/colon:pipe|dashes-escaped'), '', '_colon_pipe_dashes_escaped'), - array(new Route('/underscores_and.periods'), '', '_underscores_and.periods'), - array(new Route('/post/{id}', array(), array(), array(), '', array(), array('GET')), 'prefix', 'GET_prefix_post_id'), - ); - } - - public function testRouteExtension() - { - $route = new MyRoute(); - - $controller = new Controller($route); - $controller->foo('foo'); - - $this->assertEquals('foo', $route->foo); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRouteMethodDoesNotExist() - { - $route = new MyRoute(); - - $controller = new Controller($route); - $controller->bar(); - } -} - -class MyRoute extends Route -{ - public $foo; - - public function foo($value) - { - $this->foo = $value; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/EventListener/LogListenerTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/EventListener/LogListenerTest.php deleted file mode 100644 index b56082e09..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/EventListener/LogListenerTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Psr\Log\LogLevel; -use Silex\EventListener\LogListener; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Exception\HttpException; - -/** - * LogListener. - * - * @author Jérôme Tamarelle - */ -class LogListenerTest extends TestCase -{ - public function testRequestListener() - { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); - $logger - ->expects($this->once()) - ->method('log') - ->with(LogLevel::DEBUG, '> GET /foo') - ; - - $dispatcher = new EventDispatcher(); - $dispatcher->addSubscriber(new LogListener($logger)); - - $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->getMock(); - - $dispatcher->dispatch(KernelEvents::REQUEST, new GetResponseEvent($kernel, Request::create('/subrequest'), HttpKernelInterface::SUB_REQUEST), 'Skip sub requests'); - - $dispatcher->dispatch(KernelEvents::REQUEST, new GetResponseEvent($kernel, Request::create('/foo'), HttpKernelInterface::MASTER_REQUEST), 'Log master requests'); - } - - public function testResponseListener() - { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); - $logger - ->expects($this->once()) - ->method('log') - ->with(LogLevel::DEBUG, '< 301') - ; - - $dispatcher = new EventDispatcher(); - $dispatcher->addSubscriber(new LogListener($logger)); - - $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->getMock(); - - $dispatcher->dispatch(KernelEvents::RESPONSE, new FilterResponseEvent($kernel, Request::create('/foo'), HttpKernelInterface::SUB_REQUEST, Response::create('subrequest', 200)), 'Skip sub requests'); - - $dispatcher->dispatch(KernelEvents::RESPONSE, new FilterResponseEvent($kernel, Request::create('/foo'), HttpKernelInterface::MASTER_REQUEST, Response::create('bar', 301)), 'Log master requests'); - } - - public function testExceptionListener() - { - $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock(); - $logger - ->expects($this->at(0)) - ->method('log') - ->with(LogLevel::CRITICAL, 'RuntimeException: Fatal error (uncaught exception) at '.__FILE__.' line '.(__LINE__ + 13)) - ; - $logger - ->expects($this->at(1)) - ->method('log') - ->with(LogLevel::ERROR, 'Symfony\Component\HttpKernel\Exception\HttpException: Http error (uncaught exception) at '.__FILE__.' line '.(__LINE__ + 9)) - ; - - $dispatcher = new EventDispatcher(); - $dispatcher->addSubscriber(new LogListener($logger)); - - $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->getMock(); - - $dispatcher->dispatch(KernelEvents::EXCEPTION, new GetResponseForExceptionEvent($kernel, Request::create('/foo'), HttpKernelInterface::SUB_REQUEST, new \RuntimeException('Fatal error'))); - $dispatcher->dispatch(KernelEvents::EXCEPTION, new GetResponseForExceptionEvent($kernel, Request::create('/foo'), HttpKernelInterface::SUB_REQUEST, new HttpException(400, 'Http error'))); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ExceptionHandlerTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/ExceptionHandlerTest.php deleted file mode 100644 index aea31b08f..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ExceptionHandlerTest.php +++ /dev/null @@ -1,404 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -/** - * Error handler test cases. - * - * @author Igor Wiedler - */ -class ExceptionHandlerTest extends TestCase -{ - public function testExceptionHandlerExceptionNoDebug() - { - $app = new Application(); - $app['debug'] = false; - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('Whoops, looks like something went wrong.', $response->getContent()); - $this->assertEquals(500, $response->getStatusCode()); - } - - public function testExceptionHandlerExceptionDebug() - { - $app = new Application(); - $app['debug'] = true; - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - $request = Request::create('/foo'); - $response = $app->handle($request); - - $this->assertContains('foo exception', $response->getContent()); - $this->assertEquals(500, $response->getStatusCode()); - } - - public function testExceptionHandlerNotFoundNoDebug() - { - $app = new Application(); - $app['debug'] = false; - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent()); - $this->assertEquals(404, $response->getStatusCode()); - } - - public function testExceptionHandlerNotFoundDebug() - { - $app = new Application(); - $app['debug'] = true; - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('No route found for "GET /foo"', html_entity_decode($response->getContent())); - $this->assertEquals(404, $response->getStatusCode()); - } - - public function testExceptionHandlerMethodNotAllowedNoDebug() - { - $app = new Application(); - $app['debug'] = false; - - $app->get('/foo', function () { return 'foo'; }); - - $request = Request::create('/foo', 'POST'); - $response = $app->handle($request); - $this->assertContains('Whoops, looks like something went wrong.', $response->getContent()); - $this->assertEquals(405, $response->getStatusCode()); - $this->assertEquals('GET', $response->headers->get('Allow')); - } - - public function testExceptionHandlerMethodNotAllowedDebug() - { - $app = new Application(); - $app['debug'] = true; - - $app->get('/foo', function () { return 'foo'; }); - - $request = Request::create('/foo', 'POST'); - $response = $app->handle($request); - $this->assertContains('No route found for "POST /foo": Method Not Allowed (Allow: GET)', html_entity_decode($response->getContent())); - $this->assertEquals(405, $response->getStatusCode()); - $this->assertEquals('GET', $response->headers->get('Allow')); - } - - public function testNoExceptionHandler() - { - $app = new Application(); - unset($app['exception_handler']); - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - try { - $request = Request::create('/foo'); - $app->handle($request); - $this->fail('->handle() should not catch exceptions where no error handler was supplied'); - } catch (\RuntimeException $e) { - $this->assertEquals('foo exception', $e->getMessage()); - } - } - - public function testOneExceptionHandler() - { - $app = new Application(); - - $app->match('/500', function () { - throw new \RuntimeException('foo exception'); - }); - - $app->match('/404', function () { - throw new NotFoundHttpException('foo exception'); - }); - - $app->get('/405', function () { return 'foo'; }); - - $app->error(function ($e, $code) { - return new Response('foo exception handler'); - }); - - $response = $this->checkRouteResponse($app, '/500', 'foo exception handler'); - $this->assertEquals(500, $response->getStatusCode()); - - $response = $app->handle(Request::create('/404')); - $this->assertEquals(404, $response->getStatusCode()); - - $response = $app->handle(Request::create('/405', 'POST')); - $this->assertEquals(405, $response->getStatusCode()); - $this->assertEquals('GET', $response->headers->get('Allow')); - } - - public function testMultipleExceptionHandlers() - { - $app = new Application(); - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - $errors = 0; - - $app->error(function ($e) use (&$errors) { - ++$errors; - }); - - $app->error(function ($e) use (&$errors) { - ++$errors; - }); - - $app->error(function ($e) use (&$errors) { - ++$errors; - - return new Response('foo exception handler'); - }); - - $app->error(function ($e) use (&$errors) { - // should not execute - ++$errors; - }); - - $request = Request::create('/foo'); - $this->checkRouteResponse($app, '/foo', 'foo exception handler', 'should return the first response returned by an exception handler'); - - $this->assertEquals(3, $errors, 'should execute error handlers until a response is returned'); - } - - public function testNoResponseExceptionHandler() - { - $app = new Application(); - unset($app['exception_handler']); - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - $errors = 0; - - $app->error(function ($e) use (&$errors) { - ++$errors; - }); - - try { - $request = Request::create('/foo'); - $app->handle($request); - $this->fail('->handle() should not catch exceptions where an empty error handler was supplied'); - } catch (\RuntimeException $e) { - $this->assertEquals('foo exception', $e->getMessage()); - } catch (\LogicException $e) { - $this->assertEquals('foo exception', $e->getPrevious()->getMessage()); - } - - $this->assertEquals(1, $errors, 'should execute the error handler'); - } - - public function testStringResponseExceptionHandler() - { - $app = new Application(); - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - $app->error(function ($e) { - return 'foo exception handler'; - }); - - $request = Request::create('/foo'); - $this->checkRouteResponse($app, '/foo', 'foo exception handler', 'should accept a string response from the error handler'); - } - - public function testExceptionHandlerException() - { - $app = new Application(); - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - $app->error(function ($e) { - throw new \RuntimeException('foo exception handler exception'); - }); - - try { - $request = Request::create('/foo'); - $app->handle($request); - $this->fail('->handle() should not catch exceptions thrown from an error handler'); - } catch (\RuntimeException $e) { - $this->assertEquals('foo exception handler exception', $e->getMessage()); - } - } - - public function testRemoveExceptionHandlerAfterDispatcherAccess() - { - $app = new Application(); - - $app->match('/foo', function () { - throw new \RuntimeException('foo exception'); - }); - - $app->before(function () { - // just making sure the dispatcher gets created - }); - - unset($app['exception_handler']); - - try { - $request = Request::create('/foo'); - $app->handle($request); - $this->fail('default exception handler should have been removed'); - } catch (\RuntimeException $e) { - $this->assertEquals('foo exception', $e->getMessage()); - } - } - - public function testExceptionHandlerWithDefaultException() - { - $app = new Application(); - $app['debug'] = false; - - $app->match('/foo', function () { - throw new \Exception(); - }); - - $app->error(function (\Exception $e) { - return new Response('Exception thrown', 500); - }); - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('Exception thrown', $response->getContent()); - $this->assertEquals(500, $response->getStatusCode()); - } - - public function testExceptionHandlerWithStandardException() - { - $app = new Application(); - $app['debug'] = false; - - $app->match('/foo', function () { - // Throw a normal exception - throw new \Exception(); - }); - - // Register 2 error handlers, each with a specified Exception class - // Since we throw a standard Exception above only - // the second error handler should fire - $app->error(function (\LogicException $e) { // Extends \Exception - return 'Caught LogicException'; - }); - $app->error(function (\Exception $e) { - return 'Caught Exception'; - }); - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('Caught Exception', $response->getContent()); - } - - public function testExceptionHandlerWithSpecifiedException() - { - $app = new Application(); - $app['debug'] = false; - - $app->match('/foo', function () { - // Throw a specified exception - throw new \LogicException(); - }); - - // Register 2 error handlers, each with a specified Exception class - // Since we throw a LogicException above - // the first error handler should fire - $app->error(function (\LogicException $e) { // Extends \Exception - return 'Caught LogicException'; - }); - $app->error(function (\Exception $e) { - return 'Caught Exception'; - }); - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('Caught LogicException', $response->getContent()); - } - - public function testExceptionHandlerWithSpecifiedExceptionInReverseOrder() - { - $app = new Application(); - $app['debug'] = false; - - $app->match('/foo', function () { - // Throw a specified exception - throw new \LogicException(); - }); - - // Register the \Exception error handler first, since the - // error handler works with an instanceof mechanism the - // second more specific error handler should not fire since - // the \Exception error handler is registered first and also - // captures all exceptions that extend it - $app->error(function (\Exception $e) { - return 'Caught Exception'; - }); - $app->error(function (\LogicException $e) { // Extends \Exception - return 'Caught LogicException'; - }); - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('Caught Exception', $response->getContent()); - } - - public function testExceptionHandlerWithArrayStyleCallback() - { - $app = new Application(); - $app['debug'] = false; - - $app->match('/foo', function () { - throw new \Exception(); - }); - - // Array style callback for error handler - $app->error(array($this, 'exceptionHandler')); - - $request = Request::create('/foo'); - $response = $app->handle($request); - $this->assertContains('Caught Exception', $response->getContent()); - } - - protected function checkRouteResponse($app, $path, $expectedContent, $method = 'get', $message = null) - { - $request = Request::create($path, $method); - $response = $app->handle($request); - $this->assertEquals($expectedContent, $response->getContent(), $message); - - return $response; - } - - public function exceptionHandler() - { - return 'Caught Exception'; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/Php7Controller.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/Php7Controller.php deleted file mode 100644 index c16f14edb..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/Php7Controller.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Fixtures; - -use Silex\Application; - -class Php7Controller -{ - public function typehintedAction(Application $application, string $name) - { - return 'Hello '.$application->escape($name).' in '.get_class($application); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/manifest.json b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/manifest.json deleted file mode 100644 index 78c3bd61a..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Fixtures/manifest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "app.js": "some-random-hash.js" -} \ No newline at end of file diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/FunctionalTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/FunctionalTest.php deleted file mode 100644 index c6ee3359b..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/FunctionalTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Route; -use Silex\ControllerCollection; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Functional test cases. - * - * @author Igor Wiedler - */ -class FunctionalTest extends TestCase -{ - public function testBind() - { - $app = new Application(); - - $app->get('/', function () { - return 'hello'; - }) - ->bind('homepage'); - - $app->get('/foo', function () { - return 'foo'; - }) - ->bind('foo_abc'); - - $app->flush(); - $routes = $app['routes']; - $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('homepage')); - $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('foo_abc')); - } - - public function testMount() - { - $mounted = new ControllerCollection(new Route()); - $mounted->get('/{name}', function ($name) { return new Response($name); }); - - $app = new Application(); - $app->mount('/hello', $mounted); - - $response = $app->handle(Request::create('/hello/Silex')); - $this->assertEquals('Silex', $response->getContent()); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/JsonTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/JsonTest.php deleted file mode 100644 index 950437c37..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/JsonTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; - -/** - * JSON test cases. - * - * @author Igor Wiedler - */ -class JsonTest extends TestCase -{ - public function testJsonReturnsJsonResponse() - { - $app = new Application(); - - $response = $app->json(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); - $response = json_decode($response->getContent(), true); - $this->assertSame(array(), $response); - } - - public function testJsonUsesData() - { - $app = new Application(); - - $response = $app->json(array('foo' => 'bar')); - $this->assertSame('{"foo":"bar"}', $response->getContent()); - } - - public function testJsonUsesStatus() - { - $app = new Application(); - - $response = $app->json(array(), 202); - $this->assertSame(202, $response->getStatusCode()); - } - - public function testJsonUsesHeaders() - { - $app = new Application(); - - $response = $app->json(array(), 200, array('ETag' => 'foo')); - $this->assertSame('foo', $response->headers->get('ETag')); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyDispatcherTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyDispatcherTest.php deleted file mode 100644 index fcbbc62a9..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyDispatcherTest.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; - -class LazyDispatcherTest extends TestCase -{ - /** @test */ - public function beforeMiddlewareShouldNotCreateDispatcherEarly() - { - $dispatcherCreated = false; - - $app = new Application(); - $app->extend('dispatcher', function ($dispatcher, $app) use (&$dispatcherCreated) { - $dispatcherCreated = true; - - return $dispatcher; - }); - - $app->before(function () {}); - - $this->assertFalse($dispatcherCreated); - - $request = Request::create('/'); - $app->handle($request); - - $this->assertTrue($dispatcherCreated); - } - - /** @test */ - public function eventHelpersShouldDirectlyAddListenersAfterBoot() - { - $app = new Application(); - - $fired = false; - $app->get('/', function () use ($app, &$fired) { - $app->finish(function () use (&$fired) { - $fired = true; - }); - }); - - $request = Request::create('/'); - $response = $app->handle($request); - $app->terminate($request, $response); - - $this->assertTrue($fired, 'Event was not fired'); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyRequestMatcherTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyRequestMatcherTest.php deleted file mode 100644 index 879d46fac..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyRequestMatcherTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Silex\Provider\Routing\LazyRequestMatcher; - -/** - * LazyRequestMatcher test case. - * - * @author Leszek Prabucki - */ -class LazyRequestMatcherTest extends TestCase -{ - /** - * @covers \Silex\LazyRequestMatcher::getRequestMatcher - */ - public function testUserMatcherIsCreatedLazily() - { - $callCounter = 0; - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - - $matcher = new LazyRequestMatcher(function () use ($requestMatcher, &$callCounter) { - ++$callCounter; - - return $requestMatcher; - }); - - $this->assertEquals(0, $callCounter); - $request = Request::create('path'); - $matcher->matchRequest($request); - $this->assertEquals(1, $callCounter); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Factory supplied to LazyRequestMatcher must return implementation of Symfony\Component\Routing\RequestMatcherInterface. - */ - public function testThatCanInjectRequestMatcherOnly() - { - $matcher = new LazyRequestMatcher(function () { - return 'someMatcher'; - }); - - $request = Request::create('path'); - $matcher->matchRequest($request); - } - - /** - * @covers \Silex\LazyRequestMatcher::matchRequest - */ - public function testMatchIsProxy() - { - $request = Request::create('path'); - $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - $matcher->expects($this->once()) - ->method('matchRequest') - ->with($request) - ->will($this->returnValue('matcherReturnValue')); - - $matcher = new LazyRequestMatcher(function () use ($matcher) { - return $matcher; - }); - $result = $matcher->matchRequest($request); - - $this->assertEquals('matcherReturnValue', $result); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyUrlMatcherTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyUrlMatcherTest.php deleted file mode 100644 index a5ff4528c..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LazyUrlMatcherTest.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use Silex\LazyUrlMatcher; - -/** - * LazyUrlMatcher test case. - * - * @author Leszek Prabucki - */ -class LazyUrlMatcherTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Silex\LazyUrlMatcher::getUrlMatcher - */ - public function testUserMatcherIsCreatedLazily() - { - $callCounter = 0; - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); - - $matcher = new LazyUrlMatcher(function () use ($urlMatcher, &$callCounter) { - $callCounter++; - - return $urlMatcher; - }); - - $this->assertEquals(0, $callCounter); - $matcher->match('path'); - $this->assertEquals(1, $callCounter); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Factory supplied to LazyUrlMatcher must return implementation of UrlMatcherInterface. - */ - public function testThatCanInjectUrlMatcherOnly() - { - $matcher = new LazyUrlMatcher(function () { - return 'someMatcher'; - }); - - $matcher->match('path'); - } - - /** - * @covers Silex\LazyUrlMatcher::match - */ - public function testMatchIsProxy() - { - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); - $urlMatcher->expects($this->once()) - ->method('match') - ->with('path') - ->will($this->returnValue('matcherReturnValue')); - - $matcher = new LazyUrlMatcher(function () use ($urlMatcher) { - return $urlMatcher; - }); - $result = $matcher->match('path'); - - $this->assertEquals('matcherReturnValue', $result); - } - - /** - * @covers Silex\LazyUrlMatcher::setContext - */ - public function testSetContextIsProxy() - { - $context = $this->getMock('Symfony\Component\Routing\RequestContext'); - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); - $urlMatcher->expects($this->once()) - ->method('setContext') - ->with($context); - - $matcher = new LazyUrlMatcher(function () use ($urlMatcher) { - return $urlMatcher; - }); - $matcher->setContext($context); - } - - /** - * @covers Silex\LazyUrlMatcher::getContext - */ - public function testGetContextIsProxy() - { - $context = $this->getMock('Symfony\Component\Routing\RequestContext'); - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); - $urlMatcher->expects($this->once()) - ->method('getContext') - ->will($this->returnValue($context)); - - $matcher = new LazyUrlMatcher(function () use ($urlMatcher) { - return $urlMatcher; - }); - $resultContext = $matcher->getContext(); - - $this->assertSame($resultContext, $context); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LocaleTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/LocaleTest.php deleted file mode 100644 index 81bf04227..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/LocaleTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\LocaleServiceProvider; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * Locale test cases. - * - * @author Fabien Potencier - */ -class LocaleTest extends TestCase -{ - public function testLocale() - { - $app = new Application(); - $app->register(new LocaleServiceProvider()); - $app->get('/', function (Request $request) { return $request->getLocale(); }); - $response = $app->handle(Request::create('/')); - $this->assertEquals('en', $response->getContent()); - - $app = new Application(); - $app->register(new LocaleServiceProvider()); - $app['locale'] = 'fr'; - $app->get('/', function (Request $request) { return $request->getLocale(); }); - $response = $app->handle(Request::create('/')); - $this->assertEquals('fr', $response->getContent()); - - $app = new Application(); - $app->register(new LocaleServiceProvider()); - $app->get('/{_locale}', function (Request $request) { return $request->getLocale(); }); - $response = $app->handle(Request::create('/es')); - $this->assertEquals('es', $response->getContent()); - } - - public function testLocaleInSubRequests() - { - $app = new Application(); - $app->register(new LocaleServiceProvider()); - $app->get('/embed/{_locale}', function (Request $request) { return $request->getLocale(); }); - $app->get('/{_locale}', function (Request $request) use ($app) { - return $request->getLocale().$app->handle(Request::create('/embed/es'), HttpKernelInterface::SUB_REQUEST)->getContent().$request->getLocale(); - }); - $response = $app->handle(Request::create('/fr')); - $this->assertEquals('fresfr', $response->getContent()); - - $app = new Application(); - $app->register(new LocaleServiceProvider()); - $app->get('/embed', function (Request $request) { return $request->getLocale(); }); - $app->get('/{_locale}', function (Request $request) use ($app) { - return $request->getLocale().$app->handle(Request::create('/embed'), HttpKernelInterface::SUB_REQUEST)->getContent().$request->getLocale(); - }); - $response = $app->handle(Request::create('/fr')); - // locale in sub-request must be "en" as this is the value if the sub-request is converted to an ESI - $this->assertEquals('frenfr', $response->getContent()); - } - - public function testLocaleWithBefore() - { - $app = new Application(); - $app->register(new LocaleServiceProvider()); - $app->before(function (Request $request) use ($app) { $request->setLocale('fr'); }); - $app->get('/embed', function (Request $request) { return $request->getLocale(); }); - $app->get('/', function (Request $request) use ($app) { - return $request->getLocale().$app->handle(Request::create('/embed'), HttpKernelInterface::SUB_REQUEST)->getContent().$request->getLocale(); - }); - $response = $app->handle(Request::create('/')); - // locale in sub-request is "en" as the before filter is only executed for the main request - $this->assertEquals('frenfr', $response->getContent()); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/MiddlewareTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/MiddlewareTest.php deleted file mode 100644 index 6335dad3c..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/MiddlewareTest.php +++ /dev/null @@ -1,308 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Middleware test cases. - * - * @author Igor Wiedler - */ -class MiddlewareTest extends TestCase -{ - public function testBeforeAndAfterFilter() - { - $i = 0; - $test = $this; - - $app = new Application(); - - $app->before(function () use (&$i, $test) { - $test->assertEquals(0, $i); - ++$i; - }); - - $app->match('/foo', function () use (&$i, $test) { - $test->assertEquals(1, $i); - ++$i; - }); - - $app->after(function () use (&$i, $test) { - $test->assertEquals(2, $i); - ++$i; - }); - - $request = Request::create('/foo'); - $app->handle($request); - - $this->assertEquals(3, $i); - } - - public function testAfterFilterWithResponseObject() - { - $i = 0; - - $app = new Application(); - - $app->match('/foo', function () use (&$i) { - ++$i; - - return new Response('foo'); - }); - - $app->after(function () use (&$i) { - ++$i; - }); - - $request = Request::create('/foo'); - $app->handle($request); - - $this->assertEquals(2, $i); - } - - public function testMultipleFilters() - { - $i = 0; - $test = $this; - - $app = new Application(); - - $app->before(function () use (&$i, $test) { - $test->assertEquals(0, $i); - ++$i; - }); - - $app->before(function () use (&$i, $test) { - $test->assertEquals(1, $i); - ++$i; - }); - - $app->match('/foo', function () use (&$i, $test) { - $test->assertEquals(2, $i); - ++$i; - }); - - $app->after(function () use (&$i, $test) { - $test->assertEquals(3, $i); - ++$i; - }); - - $app->after(function () use (&$i, $test) { - $test->assertEquals(4, $i); - ++$i; - }); - - $request = Request::create('/foo'); - $app->handle($request); - - $this->assertEquals(5, $i); - } - - public function testFiltersShouldFireOnException() - { - $i = 0; - - $app = new Application(); - - $app->before(function () use (&$i) { - ++$i; - }); - - $app->match('/foo', function () { - throw new \RuntimeException(); - }); - - $app->after(function () use (&$i) { - ++$i; - }); - - $app->error(function () { - return 'error handled'; - }); - - $request = Request::create('/foo'); - $app->handle($request); - - $this->assertEquals(2, $i); - } - - public function testFiltersShouldFireOnHttpException() - { - $i = 0; - - $app = new Application(); - - $app->before(function () use (&$i) { - ++$i; - }, Application::EARLY_EVENT); - - $app->after(function () use (&$i) { - ++$i; - }); - - $app->error(function () { - return 'error handled'; - }); - - $request = Request::create('/nowhere'); - $app->handle($request); - - $this->assertEquals(2, $i); - } - - public function testBeforeFilterPreventsBeforeMiddlewaresToBeExecuted() - { - $app = new Application(); - - $app->before(function () { return new Response('app before'); }); - - $app->get('/', function () { - return new Response('test'); - })->before(function () { - return new Response('middleware before'); - }); - - $this->assertEquals('app before', $app->handle(Request::create('/'))->getContent()); - } - - public function testBeforeFilterExceptionsWhenHandlingAnException() - { - $app = new Application(); - - $app->before(function () { throw new \RuntimeException(''); }); - - // even if the before filter throws an exception, we must have the 404 - $this->assertEquals(404, $app->handle(Request::create('/'))->getStatusCode()); - } - - public function testRequestShouldBePopulatedOnBefore() - { - $app = new Application(); - - $app->before(function (Request $request) use ($app) { - $app['project'] = $request->get('project'); - }); - - $app->match('/foo/{project}', function () use ($app) { - return $app['project']; - }); - - $request = Request::create('/foo/bar'); - $this->assertEquals('bar', $app->handle($request)->getContent()); - - $request = Request::create('/foo/baz'); - $this->assertEquals('baz', $app->handle($request)->getContent()); - } - - public function testBeforeFilterAccessesRequestAndCanReturnResponse() - { - $app = new Application(); - - $app->before(function (Request $request) { - return new Response($request->get('name')); - }); - - $app->match('/', function () use ($app) { throw new \Exception('Should never be executed'); }); - - $request = Request::create('/?name=Fabien'); - $this->assertEquals('Fabien', $app->handle($request)->getContent()); - } - - public function testAfterFilterAccessRequestResponse() - { - $app = new Application(); - - $app->after(function (Request $request, Response $response) { - $response->setContent($response->getContent().'---'); - }); - - $app->match('/', function () { return new Response('foo'); }); - - $request = Request::create('/'); - $this->assertEquals('foo---', $app->handle($request)->getContent()); - } - - public function testAfterFilterCanReturnResponse() - { - $app = new Application(); - - $app->after(function (Request $request, Response $response) { - return new Response('bar'); - }); - - $app->match('/', function () { return new Response('foo'); }); - - $request = Request::create('/'); - $this->assertEquals('bar', $app->handle($request)->getContent()); - } - - public function testRouteAndApplicationMiddlewareParameterInjection() - { - $app = new Application(); - - $test = $this; - - $middlewareTarget = array(); - $applicationBeforeMiddleware = function ($request, $app) use (&$middlewareTarget, $test) { - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Request', $request); - $test->assertInstanceOf('\Silex\Application', $app); - $middlewareTarget[] = 'application_before_middleware_triggered'; - }; - - $applicationAfterMiddleware = function ($request, $response, $app) use (&$middlewareTarget, $test) { - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Request', $request); - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response); - $test->assertInstanceOf('\Silex\Application', $app); - $middlewareTarget[] = 'application_after_middleware_triggered'; - }; - - $applicationFinishMiddleware = function ($request, $response, $app) use (&$middlewareTarget, $test) { - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Request', $request); - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response); - $test->assertInstanceOf('\Silex\Application', $app); - $middlewareTarget[] = 'application_finish_middleware_triggered'; - }; - - $routeBeforeMiddleware = function ($request, $app) use (&$middlewareTarget, $test) { - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Request', $request); - $test->assertInstanceOf('\Silex\Application', $app); - $middlewareTarget[] = 'route_before_middleware_triggered'; - }; - - $routeAfterMiddleware = function ($request, $response, $app) use (&$middlewareTarget, $test) { - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Request', $request); - $test->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response); - $test->assertInstanceOf('\Silex\Application', $app); - $middlewareTarget[] = 'route_after_middleware_triggered'; - }; - - $app->before($applicationBeforeMiddleware); - $app->after($applicationAfterMiddleware); - $app->finish($applicationFinishMiddleware); - - $app->match('/', function () { - return new Response('foo'); - }) - ->before($routeBeforeMiddleware) - ->after($routeAfterMiddleware); - - $request = Request::create('/'); - $response = $app->handle($request); - $app->terminate($request, $response); - - $this->assertSame(array('application_before_middleware_triggered', 'route_before_middleware_triggered', 'route_after_middleware_triggered', 'application_after_middleware_triggered', 'application_finish_middleware_triggered'), $middlewareTarget); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/AssetServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/AssetServiceProviderTest.php deleted file mode 100644 index 940fdca3d..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/AssetServiceProviderTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\AssetServiceProvider; - -class AssetServiceProviderTest extends TestCase -{ - public function testGenerateAssetUrl() - { - $app = new Application(); - $app->register(new AssetServiceProvider(), array( - 'assets.version' => 'v1', - 'assets.version_format' => '%s?version=%s', - 'assets.named_packages' => array( - 'css' => array('version' => 'css2', 'base_path' => '/whatever-makes-sense'), - 'images' => array('base_urls' => array('https://img.example.com')), - ), - )); - - $this->assertEquals('/foo.png?version=v1', $app['assets.packages']->getUrl('/foo.png')); - $this->assertEquals('/whatever-makes-sense/foo.css?css2', $app['assets.packages']->getUrl('foo.css', 'css')); - $this->assertEquals('https://img.example.com/foo.png', $app['assets.packages']->getUrl('/foo.png', 'images')); - } - - public function testJsonManifestVersionStrategy() - { - if (!class_exists('Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy')) { - $this->markTestSkipped('JsonManifestVersionStrategy class is not available.'); - - return; - } - - $app = new Application(); - $app->register(new AssetServiceProvider(), array( - 'assets.json_manifest_path' => __DIR__.'/../Fixtures/manifest.json', - )); - - $this->assertEquals('/some-random-hash.js', $app['assets.packages']->getUrl('app.js')); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/DoctrineServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/DoctrineServiceProviderTest.php deleted file mode 100644 index 504e0ef3c..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/DoctrineServiceProviderTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Pimple\Container; -use Silex\Application; -use Silex\Provider\DoctrineServiceProvider; - -/** - * DoctrineProvider test cases. - * - * Fabien Potencier - */ -class DoctrineServiceProviderTest extends TestCase -{ - public function testOptionsInitializer() - { - $app = new Application(); - $app->register(new DoctrineServiceProvider()); - - $this->assertEquals($app['db.default_options'], $app['db']->getParams()); - } - - public function testSingleConnection() - { - if (!in_array('sqlite', \PDO::getAvailableDrivers())) { - $this->markTestSkipped('pdo_sqlite is not available'); - } - - $app = new Application(); - $app->register(new DoctrineServiceProvider(), array( - 'db.options' => array('driver' => 'pdo_sqlite', 'memory' => true), - )); - - $db = $app['db']; - $params = $db->getParams(); - $this->assertArrayHasKey('memory', $params); - $this->assertTrue($params['memory']); - $this->assertInstanceof('Doctrine\DBAL\Driver\PDOSqlite\Driver', $db->getDriver()); - $this->assertEquals(22, $app['db']->fetchColumn('SELECT 22')); - - $this->assertSame($app['dbs']['default'], $db); - } - - public function testMultipleConnections() - { - if (!in_array('sqlite', \PDO::getAvailableDrivers())) { - $this->markTestSkipped('pdo_sqlite is not available'); - } - - $app = new Application(); - $app->register(new DoctrineServiceProvider(), array( - 'dbs.options' => array( - 'sqlite1' => array('driver' => 'pdo_sqlite', 'memory' => true), - 'sqlite2' => array('driver' => 'pdo_sqlite', 'path' => sys_get_temp_dir().'/silex'), - ), - )); - - $db = $app['db']; - $params = $db->getParams(); - $this->assertArrayHasKey('memory', $params); - $this->assertTrue($params['memory']); - $this->assertInstanceof('Doctrine\DBAL\Driver\PDOSqlite\Driver', $db->getDriver()); - $this->assertEquals(22, $app['db']->fetchColumn('SELECT 22')); - - $this->assertSame($app['dbs']['sqlite1'], $db); - - $db2 = $app['dbs']['sqlite2']; - $params = $db2->getParams(); - $this->assertArrayHasKey('path', $params); - $this->assertEquals(sys_get_temp_dir().'/silex', $params['path']); - } - - public function testLoggerLoading() - { - if (!in_array('sqlite', \PDO::getAvailableDrivers())) { - $this->markTestSkipped('pdo_sqlite is not available'); - } - - $app = new Application(); - $this->assertArrayHasKey('logger', $app); - $this->assertNull($app['logger']); - $app->register(new DoctrineServiceProvider(), array( - 'dbs.options' => array( - 'sqlite1' => array('driver' => 'pdo_sqlite', 'memory' => true), - ), - )); - $this->assertEquals(22, $app['db']->fetchColumn('SELECT 22')); - $this->assertNull($app['db']->getConfiguration()->getSQLLogger()); - } - - public function testLoggerNotLoaded() - { - if (!in_array('sqlite', \PDO::getAvailableDrivers())) { - $this->markTestSkipped('pdo_sqlite is not available'); - } - - $app = new Container(); - $app->register(new DoctrineServiceProvider(), array( - 'dbs.options' => array( - 'sqlite1' => array('driver' => 'pdo_sqlite', 'memory' => true), - ), - )); - $this->assertEquals(22, $app['db']->fetchColumn('SELECT 22')); - $this->assertNull($app['db']->getConfiguration()->getSQLLogger()); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest.php deleted file mode 100644 index 981826e6f..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest.php +++ /dev/null @@ -1,363 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\FormServiceProvider; -use Silex\Provider\CsrfServiceProvider; -use Silex\Provider\SessionServiceProvider; -use Silex\Provider\TranslationServiceProvider; -use Silex\Provider\ValidatorServiceProvider; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\FormTypeGuesserChain; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Symfony\Component\Translation\Exception\NotFoundResourceException; - -class FormServiceProviderTest extends TestCase -{ - public function testFormFactoryServiceIsFormFactory() - { - $app = new Application(); - $app->register(new FormServiceProvider()); - $this->assertInstanceOf('Symfony\Component\Form\FormFactory', $app['form.factory']); - } - - public function testFormRegistryServiceIsFormRegistry() - { - $app = new Application(); - $app->register(new FormServiceProvider()); - $this->assertInstanceOf('Symfony\Component\Form\FormRegistry', $app['form.registry']); - } - - public function testFormServiceProviderWillLoadTypes() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app->extend('form.types', function ($extensions) { - $extensions[] = new DummyFormType(); - - return $extensions; - }); - - $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) - ->add('dummy', 'Silex\Tests\Provider\DummyFormType') - ->getForm(); - - $this->assertInstanceOf('Symfony\Component\Form\Form', $form); - } - - public function testFormServiceProviderWillLoadTypesServices() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app['dummy'] = function () { - return new DummyFormType(); - }; - $app->extend('form.types', function ($extensions) { - $extensions[] = 'dummy'; - - return $extensions; - }); - - $form = $app['form.factory'] - ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) - ->add('dummy', 'dummy') - ->getForm(); - - $this->assertInstanceOf('Symfony\Component\Form\Form', $form); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid form type. The silex service "dummy" does not exist. - */ - public function testNonExistentTypeService() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app->extend('form.types', function ($extensions) { - $extensions[] = 'dummy'; - - return $extensions; - }); - - $app['form.factory'] - ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) - ->add('dummy', 'dummy') - ->getForm(); - } - - public function testFormServiceProviderWillLoadTypeExtensions() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app->extend('form.type.extensions', function ($extensions) { - $extensions[] = new DummyFormTypeExtension(); - - return $extensions; - }); - - $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) - ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', array('image_path' => 'webPath')) - ->getForm(); - - $this->assertInstanceOf('Symfony\Component\Form\Form', $form); - } - - public function testFormServiceProviderWillLoadTypeExtensionsServices() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app['dummy.form.type.extension'] = function () { - return new DummyFormTypeExtension(); - }; - $app->extend('form.type.extensions', function ($extensions) { - $extensions[] = 'dummy.form.type.extension'; - - return $extensions; - }); - - $form = $app['form.factory'] - ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) - ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', array('image_path' => 'webPath')) - ->getForm(); - - $this->assertInstanceOf('Symfony\Component\Form\Form', $form); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid form type extension. The silex service "dummy.form.type.extension" does not exist. - */ - public function testNonExistentTypeExtensionService() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app->extend('form.type.extensions', function ($extensions) { - $extensions[] = 'dummy.form.type.extension'; - - return $extensions; - }); - - $app['form.factory'] - ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) - ->add('dummy', 'dummy.form.type') - ->getForm(); - } - - public function testFormServiceProviderWillLoadTypeGuessers() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app->extend('form.type.guessers', function ($guessers) { - $guessers[] = new FormTypeGuesserChain(array()); - - return $guessers; - }); - - $this->assertInstanceOf('Symfony\Component\Form\FormFactory', $app['form.factory']); - } - - public function testFormServiceProviderWillLoadTypeGuessersServices() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app['dummy.form.type.guesser'] = function () { - return new FormTypeGuesserChain(array()); - }; - $app->extend('form.type.guessers', function ($guessers) { - $guessers[] = 'dummy.form.type.guesser'; - - return $guessers; - }); - - $this->assertInstanceOf('Symfony\Component\Form\FormFactory', $app['form.factory']); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid form type guesser. The silex service "dummy.form.type.guesser" does not exist. - */ - public function testNonExistentTypeGuesserService() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - - $app->extend('form.type.guessers', function ($extensions) { - $extensions[] = 'dummy.form.type.guesser'; - - return $extensions; - }); - - $factory = $app['form.factory']; - } - - public function testFormServiceProviderWillUseTranslatorIfAvailable() - { - $app = new Application(); - - $app->register(new FormServiceProvider()); - $app->register(new TranslationServiceProvider()); - $app['translator.domains'] = array( - 'messages' => array( - 'de' => array( - 'The CSRF token is invalid. Please try to resubmit the form.' => 'German translation', - ), - ), - ); - $app['locale'] = 'de'; - - $app['csrf.token_manager'] = function () { - return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); - }; - - $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array()) - ->getForm(); - - $form->handleRequest($req = Request::create('/', 'POST', array('form' => array( - '_token' => 'the wrong token', - )))); - - $this->assertFalse($form->isValid()); - $r = new \ReflectionMethod($form, 'getErrors'); - if (!$r->getNumberOfParameters()) { - $this->assertContains('ERROR: German translation', $form->getErrorsAsString()); - } else { - // as of 2.5 - $this->assertContains('ERROR: German translation', (string) $form->getErrors(true, false)); - } - } - - public function testFormServiceProviderWillNotAddNonexistentTranslationFiles() - { - $app = new Application(array( - 'locale' => 'nonexistent', - )); - - $app->register(new FormServiceProvider()); - $app->register(new ValidatorServiceProvider()); - $app->register(new TranslationServiceProvider(), array( - 'locale_fallbacks' => array(), - )); - - $app['form.factory']; - $translator = $app['translator']; - - try { - $translator->trans('test'); - } catch (NotFoundResourceException $e) { - $this->fail('Form factory should not add a translation resource that does not exist'); - } - } - - public function testFormCsrf() - { - $app = new Application(); - $app->register(new FormServiceProvider()); - $app->register(new SessionServiceProvider()); - $app->register(new CsrfServiceProvider()); - $app['session.test'] = true; - - $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())->getForm(); - - $this->assertTrue(isset($form->createView()['_token'])); - } - - public function testUserExtensionCanConfigureDefaultExtensions() - { - $app = new Application(); - $app->register(new FormServiceProvider()); - $app->register(new SessionServiceProvider()); - $app->register(new CsrfServiceProvider()); - $app['session.test'] = true; - - $app->extend('form.type.extensions', function ($extensions) { - $extensions[] = new FormServiceProviderTest\DisableCsrfExtension(); - - return $extensions; - }); - $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())->getForm(); - - $this->assertFalse($form->getConfig()->getOption('csrf_protection')); - } -} - -if (!class_exists('Symfony\Component\Form\Deprecated\FormEvents')) { - class DummyFormType extends AbstractType - { - } -} else { - // FormTypeInterface::getName() is needed by the form component 2.8.x - class DummyFormType extends AbstractType - { - /** - * @return string The name of this type - */ - public function getName() - { - return 'dummy'; - } - } -} - -if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) { - class DummyFormTypeExtension extends AbstractTypeExtension - { - public function getExtendedType() - { - return 'Symfony\Component\Form\Extension\Core\Type\FileType'; - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefined(array('image_path')); - } - } -} else { - class DummyFormTypeExtension extends AbstractTypeExtension - { - public function getExtendedType() - { - return 'Symfony\Component\Form\Extension\Core\Type\FileType'; - } - - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - if (!method_exists($resolver, 'setDefined')) { - $resolver->setOptional(array('image_path')); - } else { - $resolver->setDefined(array('image_path')); - } - } - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest/DisableCsrfExtension.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest/DisableCsrfExtension.php deleted file mode 100644 index 8c82237db..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/FormServiceProviderTest/DisableCsrfExtension.php +++ /dev/null @@ -1,22 +0,0 @@ -setDefaults(array( - 'csrf_protection' => false, - )); - } - - public function getExtendedType() - { - return FormType::class; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpCacheServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpCacheServiceProviderTest.php deleted file mode 100644 index dca3f6a84..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpCacheServiceProviderTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\HttpCacheServiceProvider; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * HttpCacheProvider test cases. - * - * @author Igor Wiedler - */ -class HttpCacheServiceProviderTest extends TestCase -{ - public function testRegister() - { - $app = new Application(); - - $app->register(new HttpCacheServiceProvider(), array( - 'http_cache.cache_dir' => sys_get_temp_dir().'/silex_http_cache_'.uniqid(), - )); - - $this->assertInstanceOf('Silex\Provider\HttpCache\HttpCache', $app['http_cache']); - - return $app; - } - - /** - * @depends testRegister - */ - public function testRunCallsShutdown($app) - { - $finished = false; - - $app->finish(function () use (&$finished) { - $finished = true; - }); - - $app->get('/', function () use ($app) { - return new UnsendableResponse('will do something after finish'); - }); - - $request = Request::create('/'); - $app['http_cache']->run($request); - - $this->assertTrue($finished); - } - - public function testDebugDefaultsToThatOfApp() - { - $app = new Application(); - - $app->register(new HttpCacheServiceProvider(), array( - 'http_cache.cache_dir' => sys_get_temp_dir().'/silex_http_cache_'.uniqid(), - )); - - $app['debug'] = true; - $app['http_cache']; - $this->assertTrue($app['http_cache.options']['debug']); - } -} - -class UnsendableResponse extends Response -{ - public function send() - { - // do nothing - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpFragmentServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpFragmentServiceProviderTest.php deleted file mode 100644 index 6e12fcc5d..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/HttpFragmentServiceProviderTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\HttpCacheServiceProvider; -use Silex\Provider\HttpFragmentServiceProvider; -use Silex\Provider\TwigServiceProvider; -use Symfony\Component\HttpFoundation\Request; - -class HttpFragmentServiceProviderTest extends TestCase -{ - public function testRenderFunction() - { - $app = new Application(); - unset($app['exception_handler']); - - $app->register(new HttpFragmentServiceProvider()); - $app->register(new HttpCacheServiceProvider(), array('http_cache.cache_dir' => sys_get_temp_dir())); - $app->register(new TwigServiceProvider(), array( - 'twig.templates' => array( - 'hello' => '{{ render("/foo") }}{{ render_esi("/foo") }}{{ render_hinclude("/foo") }}', - 'foo' => 'foo', - ), - )); - - $app->get('/hello', function () use ($app) { - return $app['twig']->render('hello'); - }); - - $app->get('/foo', function () use ($app) { - return $app['twig']->render('foo'); - }); - - $response = $app['http_cache']->handle(Request::create('/hello')); - - $this->assertEquals('foofoo', $response->getContent()); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/MonologServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/MonologServiceProviderTest.php deleted file mode 100644 index 4585378f0..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/MonologServiceProviderTest.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use Monolog\Formatter\JsonFormatter; -use Monolog\Handler\TestHandler; -use Monolog\Logger; -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\MonologServiceProvider; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Kernel; - -/** - * MonologProvider test cases. - * - * @author Igor Wiedler - */ -class MonologServiceProviderTest extends TestCase -{ - private $currErrorHandler; - - protected function setUp() - { - $this->currErrorHandler = set_error_handler('var_dump'); - restore_error_handler(); - } - - protected function tearDown() - { - set_error_handler($this->currErrorHandler); - } - - public function testRequestLogging() - { - $app = $this->getApplication(); - - $app->get('/foo', function () use ($app) { - return 'foo'; - }); - - $this->assertFalse($app['monolog.handler']->hasInfoRecords()); - - $request = Request::create('/foo'); - $app->handle($request); - - $this->assertTrue($app['monolog.handler']->hasDebug('> GET /foo')); - $this->assertTrue($app['monolog.handler']->hasDebug('< 200')); - - $records = $app['monolog.handler']->getRecords(); - if (Kernel::VERSION_ID < 30100) { - $this->assertContains('Matched route "GET_foo"', $records[0]['message']); - } else { - $this->assertContains('Matched route "{route}".', $records[0]['message']); - $this->assertSame('GET_foo', $records[0]['context']['route']); - } - } - - public function testManualLogging() - { - $app = $this->getApplication(); - - $app->get('/log', function () use ($app) { - $app['monolog']->addDebug('logging a message'); - }); - - $this->assertFalse($app['monolog.handler']->hasDebugRecords()); - - $request = Request::create('/log'); - $app->handle($request); - - $this->assertTrue($app['monolog.handler']->hasDebug('logging a message')); - } - - public function testOverrideFormatter() - { - $app = new Application(); - - $app->register(new MonologServiceProvider(), array( - 'monolog.formatter' => new JsonFormatter(), - 'monolog.logfile' => 'php://memory', - )); - - $this->assertInstanceOf('Monolog\Formatter\JsonFormatter', $app['monolog.handler']->getFormatter()); - } - - public function testErrorLogging() - { - $app = $this->getApplication(); - - $app->error(function (\Exception $e) { - return 'error handled'; - }); - - /* - * Simulate 404, logged to error level - */ - $this->assertFalse($app['monolog.handler']->hasErrorRecords()); - - $request = Request::create('/error'); - $app->handle($request); - - $pattern = "#Symfony\\\\Component\\\\HttpKernel\\\\Exception\\\\NotFoundHttpException: No route found for \"GET /error\" \(uncaught exception\) at .* line \d+#"; - $this->assertMatchingRecord($pattern, Logger::ERROR, $app['monolog.handler']); - - /* - * Simulate unhandled exception, logged to critical - */ - $app->get('/error', function () { - throw new \RuntimeException('very bad error'); - }); - - $this->assertFalse($app['monolog.handler']->hasCriticalRecords()); - - $request = Request::create('/error'); - $app->handle($request); - - $pattern = "#RuntimeException: very bad error \(uncaught exception\) at .* line \d+#"; - $this->assertMatchingRecord($pattern, Logger::CRITICAL, $app['monolog.handler']); - } - - public function testRedirectLogging() - { - $app = $this->getApplication(); - - $app->get('/foo', function () use ($app) { - return new RedirectResponse('/bar', 302); - }); - - $this->assertFalse($app['monolog.handler']->hasInfoRecords()); - - $request = Request::create('/foo'); - $app->handle($request); - - $this->assertTrue($app['monolog.handler']->hasDebug('< 302 /bar')); - } - - public function testErrorLoggingGivesWayToSecurityExceptionHandling() - { - $app = $this->getApplication(); - $app['monolog.level'] = Logger::ERROR; - - $app->register(new \Silex\Provider\SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'admin' => array( - 'pattern' => '^/admin', - 'http' => true, - 'users' => array(), - ), - ), - )); - - $app->get('/admin', function () { - return 'SECURE!'; - }); - - $request = Request::create('/admin'); - $app->run($request); - - $this->assertEmpty($app['monolog.handler']->getRecords(), 'Expected no logging to occur'); - } - - public function testStringErrorLevel() - { - $app = $this->getApplication(); - $app['monolog.level'] = 'info'; - - $this->assertSame(Logger::INFO, $app['monolog.handler']->getLevel()); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Provided logging level 'foo' does not exist. Must be a valid monolog logging level. - */ - public function testNonExistentStringErrorLevel() - { - $app = $this->getApplication(); - $app['monolog.level'] = 'foo'; - - $app['monolog.handler']->getLevel(); - } - - public function testDisableListener() - { - $app = $this->getApplication(); - unset($app['monolog.listener']); - - $app->handle(Request::create('/404')); - - $this->assertEmpty($app['monolog.handler']->getRecords(), 'Expected no logging to occur'); - } - - public function testExceptionFiltering() - { - $app = new Application(); - $app->get('/foo', function () use ($app) { - throw new NotFoundHttpException(); - }); - - $level = Logger::ERROR; - $app->register(new MonologServiceProvider(), array( - 'monolog.exception.logger_filter' => $app->protect(function () { - return Logger::DEBUG; - }), - 'monolog.handler' => function () use ($app) { - return new TestHandler($app['monolog.level']); - }, - 'monolog.level' => $level, - 'monolog.logfile' => 'php://memory', - )); - - $request = Request::create('/foo'); - $app->handle($request); - - $this->assertCount(0, $app['monolog.handler']->getRecords(), 'Expected no logging to occur'); - } - - protected function assertMatchingRecord($pattern, $level, TestHandler $handler) - { - $found = false; - $records = $handler->getRecords(); - foreach ($records as $record) { - if (preg_match($pattern, $record['message']) && $record['level'] == $level) { - $found = true; - continue; - } - } - $this->assertTrue($found, "Trying to find record matching $pattern with level $level"); - } - - protected function getApplication() - { - $app = new Application(); - - $app->register(new MonologServiceProvider(), array( - 'monolog.handler' => function () use ($app) { - $level = MonologServiceProvider::translateLevel($app['monolog.level']); - - return new TestHandler($level); - }, - 'monolog.logfile' => 'php://memory', - )); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RememberMeServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RememberMeServiceProviderTest.php deleted file mode 100644 index b027497cd..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RememberMeServiceProviderTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use Silex\Application; -use Silex\WebTestCase; -use Silex\Provider\RememberMeServiceProvider; -use Silex\Provider\SecurityServiceProvider; -use Silex\Provider\SessionServiceProvider; -use Symfony\Component\HttpKernel\Client; -use Symfony\Component\Security\Http\SecurityEvents; - -/** - * SecurityServiceProvider. - * - * @author Fabien Potencier - */ -class RememberMeServiceProviderTest extends WebTestCase -{ - public function testRememberMeAuthentication() - { - $app = $this->createApplication(); - - $interactiveLogin = new InteractiveLoginTriggered(); - $app->on(SecurityEvents::INTERACTIVE_LOGIN, array($interactiveLogin, 'onInteractiveLogin')); - - $client = new Client($app); - - $client->request('get', '/'); - $this->assertFalse($interactiveLogin->triggered, 'The interactive login has not been triggered yet'); - $client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'foo', '_remember_me' => 'true')); - $client->followRedirect(); - $this->assertEquals('AUTHENTICATED_FULLY', $client->getResponse()->getContent()); - $this->assertTrue($interactiveLogin->triggered, 'The interactive login has been triggered'); - - $this->assertNotNull($client->getCookiejar()->get('REMEMBERME'), 'The REMEMBERME cookie is set'); - $event = false; - - $client->getCookiejar()->expire('MOCKSESSID'); - - $client->request('get', '/'); - $this->assertEquals('AUTHENTICATED_REMEMBERED', $client->getResponse()->getContent()); - $this->assertTrue($interactiveLogin->triggered, 'The interactive login has been triggered'); - - $client->request('get', '/logout'); - $client->followRedirect(); - - $this->assertNull($client->getCookiejar()->get('REMEMBERME'), 'The REMEMBERME cookie has been removed'); - } - - public function createApplication($authenticationMethod = 'form') - { - $app = new Application(); - - $app['debug'] = true; - unset($app['exception_handler']); - - $app->register(new SessionServiceProvider(), array( - 'session.test' => true, - )); - $app->register(new SecurityServiceProvider()); - $app->register(new RememberMeServiceProvider()); - - $app['security.firewalls'] = array( - 'http-auth' => array( - 'pattern' => '^.*$', - 'form' => true, - 'remember_me' => array(), - 'logout' => true, - 'users' => array( - 'fabien' => array('ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - ), - ), - ); - - $app->get('/', function () use ($app) { - if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) { - return 'AUTHENTICATED_FULLY'; - } elseif ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_REMEMBERED')) { - return 'AUTHENTICATED_REMEMBERED'; - } else { - return 'AUTHENTICATED_ANONYMOUSLY'; - } - }); - - return $app; - } -} - -class InteractiveLoginTriggered -{ - public $triggered = false; - - public function onInteractiveLogin() - { - $this->triggered = true; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RoutingServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RoutingServiceProviderTest.php deleted file mode 100644 index 2faaa683c..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/RoutingServiceProviderTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Pimple\Container; -use Silex\Application; -use Silex\Provider\RoutingServiceProvider; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * RoutingProvider test cases. - * - * @author Igor Wiedler - */ -class RoutingServiceProviderTest extends TestCase -{ - public function testRegister() - { - $app = new Application(); - - $app->get('/hello/{name}', function ($name) {}) - ->bind('hello'); - - $app->get('/', function () {}); - - $request = Request::create('/'); - $app->handle($request); - - $this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGenerator', $app['url_generator']); - } - - public function testUrlGeneration() - { - $app = new Application(); - - $app->get('/hello/{name}', function ($name) {}) - ->bind('hello'); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('hello', array('name' => 'john')); - }); - - $request = Request::create('/'); - $response = $app->handle($request); - - $this->assertEquals('/hello/john', $response->getContent()); - } - - public function testAbsoluteUrlGeneration() - { - $app = new Application(); - - $app->get('/hello/{name}', function ($name) {}) - ->bind('hello'); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('hello', array('name' => 'john'), UrlGeneratorInterface::ABSOLUTE_URL); - }); - - $request = Request::create('https://localhost:81/'); - $response = $app->handle($request); - - $this->assertEquals('https://localhost:81/hello/john', $response->getContent()); - } - - public function testUrlGenerationWithHttp() - { - $app = new Application(); - - $app->get('/insecure', function () {}) - ->bind('insecure_page') - ->requireHttp(); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('insecure_page'); - }); - - $request = Request::create('https://localhost/'); - $response = $app->handle($request); - - $this->assertEquals('http://localhost/insecure', $response->getContent()); - } - - public function testUrlGenerationWithHttps() - { - $app = new Application(); - - $app->get('/secure', function () {}) - ->bind('secure_page') - ->requireHttps(); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('secure_page'); - }); - - $request = Request::create('http://localhost/'); - $response = $app->handle($request); - - $this->assertEquals('https://localhost/secure', $response->getContent()); - } - - public function testControllersFactory() - { - $app = new Container(); - $app->register(new RoutingServiceProvider()); - $coll = $app['controllers_factory']; - $coll->mount('/blog', function ($blog) { - $this->assertInstanceOf('Silex\ControllerCollection', $blog); - }); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest.php deleted file mode 100644 index 3436c53b1..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest.php +++ /dev/null @@ -1,491 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use Silex\Application; -use Silex\WebTestCase; -use Silex\Provider\SecurityServiceProvider; -use Silex\Provider\SessionServiceProvider; -use Silex\Provider\ValidatorServiceProvider; -use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; -use Symfony\Component\HttpKernel\Client; -use Symfony\Component\HttpFoundation\Request; - -/** - * SecurityServiceProvider. - * - * @author Fabien Potencier - */ -class SecurityServiceProviderTest extends WebTestCase -{ - /** - * @expectedException \LogicException - */ - public function testWrongAuthenticationType() - { - $app = new Application(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'wrong' => array( - 'foobar' => true, - 'users' => array(), - ), - ), - )); - $app->get('/', function () {}); - $app->handle(Request::create('/')); - } - - public function testFormAuthentication() - { - $app = $this->createApplication('form'); - - $client = new Client($app); - - $client->request('get', '/'); - $this->assertEquals('ANONYMOUS', $client->getResponse()->getContent()); - - $client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'bar')); - $this->assertContains('Bad credentials', $app['security.last_error']($client->getRequest())); - // hack to re-close the session as the previous assertions re-opens it - $client->getRequest()->getSession()->save(); - - $client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'foo')); - $this->assertEquals('', $app['security.last_error']($client->getRequest())); - $client->getRequest()->getSession()->save(); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $this->assertEquals('http://localhost/', $client->getResponse()->getTargetUrl()); - - $client->request('get', '/'); - $this->assertEquals('fabienAUTHENTICATED', $client->getResponse()->getContent()); - $client->request('get', '/admin'); - $this->assertEquals(403, $client->getResponse()->getStatusCode()); - - $client->request('get', '/logout'); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $this->assertEquals('http://localhost/', $client->getResponse()->getTargetUrl()); - - $client->request('get', '/'); - $this->assertEquals('ANONYMOUS', $client->getResponse()->getContent()); - - $client->request('get', '/admin'); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $this->assertEquals('http://localhost/login', $client->getResponse()->getTargetUrl()); - - $client->request('post', '/login_check', array('_username' => 'admin', '_password' => 'foo')); - $this->assertEquals('', $app['security.last_error']($client->getRequest())); - $client->getRequest()->getSession()->save(); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $this->assertEquals('http://localhost/admin', $client->getResponse()->getTargetUrl()); - - $client->request('get', '/'); - $this->assertEquals('adminAUTHENTICATEDADMIN', $client->getResponse()->getContent()); - $client->request('get', '/admin'); - $this->assertEquals('admin', $client->getResponse()->getContent()); - } - - public function testHttpAuthentication() - { - $app = $this->createApplication('http'); - - $client = new Client($app); - - $client->request('get', '/'); - $this->assertEquals(401, $client->getResponse()->getStatusCode()); - $this->assertEquals('Basic realm="Secured"', $client->getResponse()->headers->get('www-authenticate')); - - $client->request('get', '/', array(), array(), array('PHP_AUTH_USER' => 'dennis', 'PHP_AUTH_PW' => 'foo')); - $this->assertEquals('dennisAUTHENTICATED', $client->getResponse()->getContent()); - $client->request('get', '/admin'); - $this->assertEquals(403, $client->getResponse()->getStatusCode()); - - $client->restart(); - - $client->request('get', '/'); - $this->assertEquals(401, $client->getResponse()->getStatusCode()); - $this->assertEquals('Basic realm="Secured"', $client->getResponse()->headers->get('www-authenticate')); - - $client->request('get', '/', array(), array(), array('PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => 'foo')); - $this->assertEquals('adminAUTHENTICATEDADMIN', $client->getResponse()->getContent()); - $client->request('get', '/admin'); - $this->assertEquals('admin', $client->getResponse()->getContent()); - } - - public function testGuardAuthentication() - { - $app = $this->createApplication('guard'); - - $client = new Client($app); - - $client->request('get', '/'); - $this->assertEquals(401, $client->getResponse()->getStatusCode(), 'The entry point is configured'); - $this->assertEquals('{"message":"Authentication Required"}', $client->getResponse()->getContent()); - - $client->request('get', '/', array(), array(), array('HTTP_X_AUTH_TOKEN' => 'lili:not the secret')); - $this->assertEquals(403, $client->getResponse()->getStatusCode(), 'User not found'); - $this->assertEquals('{"message":"Username could not be found."}', $client->getResponse()->getContent()); - - $client->request('get', '/', array(), array(), array('HTTP_X_AUTH_TOKEN' => 'victoria:not the secret')); - $this->assertEquals(403, $client->getResponse()->getStatusCode(), 'Invalid credentials'); - $this->assertEquals('{"message":"Invalid credentials."}', $client->getResponse()->getContent()); - - $client->request('get', '/', array(), array(), array('HTTP_X_AUTH_TOKEN' => 'victoria:victoriasecret')); - $this->assertEquals('victoria', $client->getResponse()->getContent()); - } - - public function testUserPasswordValidatorIsRegistered() - { - $app = new Application(); - - $app->register(new ValidatorServiceProvider()); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'admin' => array( - 'pattern' => '^/admin', - 'http' => true, - 'users' => array( - 'admin' => array('ROLE_ADMIN', '513aeb0121909'), - ), - ), - ), - )); - - $app->boot(); - - $this->assertInstanceOf('Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator', $app['security.validator.user_password_validator']); - } - - public function testExposedExceptions() - { - $app = $this->createApplication('form'); - $app['security.hide_user_not_found'] = false; - - $client = new Client($app); - - $client->request('get', '/'); - $this->assertEquals('ANONYMOUS', $client->getResponse()->getContent()); - - $client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'bar')); - $this->assertEquals('The presented password is invalid.', $app['security.last_error']($client->getRequest())); - $client->getRequest()->getSession()->save(); - - $client->request('post', '/login_check', array('_username' => 'unknown', '_password' => 'bar')); - $this->assertEquals('Username "unknown" does not exist.', $app['security.last_error']($client->getRequest())); - $client->getRequest()->getSession()->save(); - } - - public function testFakeRoutesAreSerializable() - { - $app = new Application(); - - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'admin' => array( - 'logout' => true, - ), - ), - )); - - $app->boot(); - $app->flush(); - - $this->assertCount(1, unserialize(serialize($app['routes']))); - } - - public function testFirewallWithMethod() - { - $app = new Application(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'pattern' => '/', - 'http' => true, - 'methods' => array('POST'), - ), - ), - )); - $app->match('/', function () { return 'foo'; }) - ->method('POST|GET'); - - $request = Request::create('/', 'GET'); - $response = $app->handle($request); - $this->assertEquals(200, $response->getStatusCode()); - - $request = Request::create('/', 'POST'); - $response = $app->handle($request); - $this->assertEquals(401, $response->getStatusCode()); - } - - public function testFirewallWithHost() - { - $app = new Application(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'pattern' => '/', - 'http' => true, - 'hosts' => 'localhost2', - ), - ), - )); - $app->get('/', function () { return 'foo'; }) - ->host('localhost2'); - - $app->get('/', function () { return 'foo'; }) - ->host('localhost1'); - - $request = Request::create('http://localhost2/'); - $response = $app->handle($request); - $this->assertEquals(401, $response->getStatusCode()); - - $request = Request::create('http://localhost1/'); - $response = $app->handle($request); - $this->assertEquals(200, $response->getStatusCode()); - } - - public function testUser() - { - $app = new Application(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'http' => true, - 'users' => array( - 'fabien' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - ), - ), - ), - )); - $app->get('/', function () { return 'foo'; }); - - $request = Request::create('/'); - $app->handle($request); - $this->assertNull($app['user']); - - $request->headers->set('PHP_AUTH_USER', 'fabien'); - $request->headers->set('PHP_AUTH_PW', 'foo'); - $app->handle($request); - $this->assertInstanceOf('Symfony\Component\Security\Core\User\UserInterface', $app['user']); - $this->assertEquals('fabien', $app['user']->getUsername()); - } - - public function testUserWithNoToken() - { - $app = new Application(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'http' => true, - ), - ), - )); - - $request = Request::create('/'); - - $app->get('/', function () { return 'foo'; }); - $app->handle($request); - $this->assertNull($app['user']); - } - - public function testUserWithInvalidUser() - { - $app = new Application(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'http' => true, - ), - ), - )); - - $request = Request::create('/'); - $app->boot(); - $app['security.token_storage']->setToken(new UsernamePasswordToken('foo', 'foo', 'foo')); - - $app->get('/', function () { return 'foo'; }); - $app->handle($request); - $this->assertNull($app['user']); - } - - public function testAccessRulePathArray() - { - $app = new Application(); - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'http' => true, - ), - ), - 'security.access_rules' => array( - array(array( - 'path' => '^/admin', - ), 'ROLE_ADMIN'), - ), - )); - - $request = Request::create('/admin'); - $app->boot(); - $accessMap = $app['security.access_map']; - $this->assertEquals($accessMap->getPatterns($request), array( - array('ROLE_ADMIN'), - '', - )); - } - - public function createApplication($authenticationMethod = 'form') - { - $app = new Application(); - $app->register(new SessionServiceProvider()); - - $app = call_user_func(array($this, 'add'.ucfirst($authenticationMethod).'Authentication'), $app); - - $app['session.test'] = true; - - return $app; - } - - private function addFormAuthentication($app) - { - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'login' => array( - 'pattern' => '^/login$', - ), - 'default' => array( - 'pattern' => '^.*$', - 'anonymous' => true, - 'form' => array( - 'require_previous_session' => false, - ), - 'logout' => true, - 'users' => array( - // password is foo - 'fabien' => array('ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - 'admin' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - ), - ), - ), - 'security.access_rules' => array( - array('^/admin', 'ROLE_ADMIN'), - ), - 'security.role_hierarchy' => array( - 'ROLE_ADMIN' => array('ROLE_USER'), - ), - )); - - $app->get('/login', function (Request $request) use ($app) { - $app['session']->start(); - - return $app['security.last_error']($request); - }); - - $app->get('/', function () use ($app) { - $user = $app['security.token_storage']->getToken()->getUser(); - - $content = is_object($user) ? $user->getUsername() : 'ANONYMOUS'; - - if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) { - $content .= 'AUTHENTICATED'; - } - - if ($app['security.authorization_checker']->isGranted('ROLE_ADMIN')) { - $content .= 'ADMIN'; - } - - return $content; - }); - - $app->get('/admin', function () use ($app) { - return 'admin'; - }); - - return $app; - } - - private function addHttpAuthentication($app) - { - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'http-auth' => array( - 'pattern' => '^.*$', - 'http' => true, - 'users' => array( - // password is foo - 'dennis' => array('ROLE_USER', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - 'admin' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - ), - ), - ), - 'security.access_rules' => array( - array('^/admin', 'ROLE_ADMIN'), - ), - 'security.role_hierarchy' => array( - 'ROLE_ADMIN' => array('ROLE_USER'), - ), - )); - - $app->get('/', function () use ($app) { - $user = $app['security.token_storage']->getToken()->getUser(); - $content = is_object($user) ? $user->getUsername() : 'ANONYMOUS'; - - if ($app['security.authorization_checker']->isGranted('IS_AUTHENTICATED_FULLY')) { - $content .= 'AUTHENTICATED'; - } - - if ($app['security.authorization_checker']->isGranted('ROLE_ADMIN')) { - $content .= 'ADMIN'; - } - - return $content; - }); - - $app->get('/admin', function () use ($app) { - return 'admin'; - }); - - return $app; - } - - private function addGuardAuthentication($app) - { - $app['app.authenticator.token'] = function ($app) { - return new SecurityServiceProviderTest\TokenAuthenticator($app); - }; - - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'guard' => array( - 'pattern' => '^.*$', - 'form' => true, - 'guard' => array( - 'authenticators' => array( - 'app.authenticator.token', - ), - ), - 'users' => array( - 'victoria' => array('ROLE_USER', 'victoriasecret'), - ), - ), - ), - )); - - $app->get('/', function () use ($app) { - $user = $app['security.token_storage']->getToken()->getUser(); - - $content = is_object($user) ? $user->getUsername() : 'ANONYMOUS'; - - return $content; - })->bind('homepage'); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest/TokenAuthenticator.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest/TokenAuthenticator.php deleted file mode 100644 index c569428bf..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SecurityServiceProviderTest/TokenAuthenticator.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider\SecurityServiceProviderTest; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Core\User\UserProviderInterface; -use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Exception\AuthenticationException; - -/** - * This class is used to test "guard" authentication with the SecurityServiceProvider. - */ -class TokenAuthenticator extends AbstractGuardAuthenticator -{ - public function getCredentials(Request $request) - { - if (!$token = $request->headers->get('X-AUTH-TOKEN')) { - return; - } - - list($username, $secret) = explode(':', $token); - - return array( - 'username' => $username, - 'secret' => $secret, - ); - } - - public function getUser($credentials, UserProviderInterface $userProvider) - { - return $userProvider->loadUserByUsername($credentials['username']); - } - - public function checkCredentials($credentials, UserInterface $user) - { - // This is not a safe way of validating a password. - return $user->getPassword() === $credentials['secret']; - } - - public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) - { - return; - } - - public function onAuthenticationFailure(Request $request, AuthenticationException $exception) - { - $data = array( - 'message' => strtr($exception->getMessageKey(), $exception->getMessageData()), - ); - - return new JsonResponse($data, 403); - } - - public function start(Request $request, AuthenticationException $authException = null) - { - $data = array( - 'message' => 'Authentication Required', - ); - - return new JsonResponse($data, 401); - } - - public function supportsRememberMe() - { - return false; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SerializerServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SerializerServiceProviderTest.php deleted file mode 100644 index c33cea7b0..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SerializerServiceProviderTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\SerializerServiceProvider; - -/** - * SerializerServiceProvider test cases. - * - * @author Fabien Potencier - */ -class SerializerServiceProviderTest extends TestCase -{ - public function testRegister() - { - $app = new Application(); - - $app->register(new SerializerServiceProvider()); - - $this->assertInstanceOf("Symfony\Component\Serializer\Serializer", $app['serializer']); - $this->assertTrue($app['serializer']->supportsEncoding('xml')); - $this->assertTrue($app['serializer']->supportsEncoding('json')); - $this->assertTrue($app['serializer']->supportsDecoding('xml')); - $this->assertTrue($app['serializer']->supportsDecoding('json')); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SessionServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SessionServiceProviderTest.php deleted file mode 100644 index fb7ae0cfd..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SessionServiceProviderTest.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use Silex\Application; -use Silex\WebTestCase; -use Silex\Provider\SessionServiceProvider; -use Symfony\Component\HttpKernel\Client; -use Symfony\Component\HttpFoundation\Session; - -/** - * SessionProvider test cases. - * - * @author Igor Wiedler - * @author Fabien Potencier - */ -class SessionServiceProviderTest extends WebTestCase -{ - public function testRegister() - { - /* - * Smoke test - */ - $defaultStorage = $this->app['session.storage.native']; - - $client = $this->createClient(); - - $client->request('get', '/login'); - $this->assertEquals('Logged in successfully.', $client->getResponse()->getContent()); - - $client->request('get', '/account'); - $this->assertEquals('This is your account.', $client->getResponse()->getContent()); - - $client->request('get', '/logout'); - $this->assertEquals('Logged out successfully.', $client->getResponse()->getContent()); - - $client->request('get', '/account'); - $this->assertEquals('You are not logged in.', $client->getResponse()->getContent()); - } - - public function createApplication() - { - $app = new Application(); - - $app->register(new SessionServiceProvider(), array( - 'session.test' => true, - )); - - $app->get('/login', function () use ($app) { - $app['session']->set('logged_in', true); - - return 'Logged in successfully.'; - }); - - $app->get('/account', function () use ($app) { - if (!$app['session']->get('logged_in')) { - return 'You are not logged in.'; - } - - return 'This is your account.'; - }); - - $app->get('/logout', function () use ($app) { - $app['session']->invalidate(); - - return 'Logged out successfully.'; - }); - - return $app; - } - - public function testWithRoutesThatDoesNotUseSession() - { - $app = new Application(); - - $app->register(new SessionServiceProvider(), array( - 'session.test' => true, - )); - - $app->get('/', function () { - return 'A welcome page.'; - }); - - $app->get('/robots.txt', function () { - return 'Informations for robots.'; - }); - - $app['debug'] = true; - unset($app['exception_handler']); - - $client = new Client($app); - - $client->request('get', '/'); - $this->assertEquals('A welcome page.', $client->getResponse()->getContent()); - - $client->request('get', '/robots.txt'); - $this->assertEquals('Informations for robots.', $client->getResponse()->getContent()); - } - - public function testSessionRegister() - { - $app = new Application(); - - $attrs = new Session\Attribute\AttributeBag(); - $flash = new Session\Flash\FlashBag(); - $app->register(new SessionServiceProvider(), array( - 'session.attribute_bag' => $attrs, - 'session.flash_bag' => $flash, - 'session.test' => true, - )); - - $session = $app['session']; - - $this->assertSame($flash, $session->getBag('flashes')); - $this->assertSame($attrs, $session->getBag('attributes')); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SpoolStub.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SpoolStub.php deleted file mode 100644 index c1eb2b0f4..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SpoolStub.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -class SpoolStub implements \Swift_Spool -{ - private $messages = array(); - public $hasFlushed = false; - - public function getMessages() - { - return $this->messages; - } - - public function start() - { - } - - public function stop() - { - } - - public function isStarted() - { - return count($this->messages) > 0; - } - - public function queueMessage(\Swift_Mime_Message $message) - { - $this->messages[] = clone $message; - } - - public function flushQueue(\Swift_Transport $transport, &$failedRecipients = null) - { - $this->hasFlushed = true; - $this->messages = array(); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SwiftmailerServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SwiftmailerServiceProviderTest.php deleted file mode 100644 index f80c2256b..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/SwiftmailerServiceProviderTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\SwiftmailerServiceProvider; -use Symfony\Component\HttpFoundation\Request; - -class SwiftmailerServiceProviderTest extends TestCase -{ - public function testSwiftMailerServiceIsSwiftMailer() - { - $app = new Application(); - - $app->register(new SwiftmailerServiceProvider()); - $app->boot(); - - $this->assertInstanceOf('Swift_Mailer', $app['mailer']); - } - - public function testSwiftMailerIgnoresSpoolIfDisabled() - { - $app = new Application(); - - $app->register(new SwiftmailerServiceProvider()); - $app->boot(); - - $app['swiftmailer.use_spool'] = false; - - $app['swiftmailer.spooltransport'] = function () { - throw new \Exception('Should not be instantiated'); - }; - - $this->assertInstanceOf('Swift_Mailer', $app['mailer']); - } - - public function testSwiftMailerSendsMailsOnFinish() - { - $app = new Application(); - - $app->register(new SwiftmailerServiceProvider()); - $app->boot(); - - $app['swiftmailer.spool'] = function () { - return new SpoolStub(); - }; - - $app->get('/', function () use ($app) { - $app['mailer']->send(\Swift_Message::newInstance()); - }); - - $this->assertCount(0, $app['swiftmailer.spool']->getMessages()); - - $request = Request::create('/'); - $response = $app->handle($request); - $this->assertCount(1, $app['swiftmailer.spool']->getMessages()); - - $app->terminate($request, $response); - $this->assertTrue($app['swiftmailer.spool']->hasFlushed); - $this->assertCount(0, $app['swiftmailer.spool']->getMessages()); - } - - public function testSwiftMailerAvoidsFlushesIfMailerIsUnused() - { - $app = new Application(); - - $app->register(new SwiftmailerServiceProvider()); - $app->boot(); - - $app['swiftmailer.spool'] = function () { - return new SpoolStub(); - }; - - $app->get('/', function () use ($app) { }); - - $request = Request::create('/'); - $response = $app->handle($request); - $this->assertCount(0, $app['swiftmailer.spool']->getMessages()); - - $app->terminate($request, $response); - $this->assertFalse($app['swiftmailer.spool']->hasFlushed); - } - - public function testSwiftMailerSenderAddress() - { - $app = new Application(); - - $app->register(new SwiftmailerServiceProvider()); - $app->boot(); - - $app['swiftmailer.spool'] = function () { - return new SpoolStub(); - }; - - $app['swiftmailer.sender_address'] = 'foo@example.com'; - - $app['mailer']->send(\Swift_Message::newInstance()); - - $messages = $app['swiftmailer.spool']->getMessages(); - $this->assertCount(1, $messages); - - list($message) = $messages; - $this->assertEquals('foo@example.com', $message->getReturnPath()); - } - - public function testSwiftMailerPlugins() - { - $plugin = $this->getMockBuilder('Swift_Events_TransportChangeListener')->getMock(); - $plugin->expects($this->once())->method('beforeTransportStarted'); - - $app = new Application(); - $app->boot(); - - $app->register(new SwiftmailerServiceProvider()); - - $app['swiftmailer.plugins'] = function ($app) use ($plugin) { - return array($plugin); - }; - - $dispatcher = $app['swiftmailer.transport.eventdispatcher']; - $event = $dispatcher->createTransportChangeEvent(new \Swift_Transport_NullTransport($dispatcher)); - $dispatcher->dispatchEvent($event, 'beforeTransportStarted'); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TranslationServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TranslationServiceProviderTest.php deleted file mode 100644 index b4132f9e7..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TranslationServiceProviderTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\TranslationServiceProvider; -use Silex\Provider\LocaleServiceProvider; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * TranslationProvider test cases. - * - * @author Daniel Tschinder - */ -class TranslationServiceProviderTest extends TestCase -{ - /** - * @return Application - */ - protected function getPreparedApp() - { - $app = new Application(); - - $app->register(new LocaleServiceProvider()); - $app->register(new TranslationServiceProvider()); - $app['translator.domains'] = array( - 'messages' => array( - 'en' => array( - 'key1' => 'The translation', - 'key_only_english' => 'Foo', - 'key2' => 'One apple|%count% apples', - 'test' => array( - 'key' => 'It works', - ), - ), - 'de' => array( - 'key1' => 'The german translation', - 'key2' => 'One german apple|%count% german apples', - 'test' => array( - 'key' => 'It works in german', - ), - ), - ), - ); - - return $app; - } - - public function transChoiceProvider() - { - return array( - array('key2', 0, null, '0 apples'), - array('key2', 1, null, 'One apple'), - array('key2', 2, null, '2 apples'), - array('key2', 0, 'de', '0 german apples'), - array('key2', 1, 'de', 'One german apple'), - array('key2', 2, 'de', '2 german apples'), - array('key2', 0, 'ru', '0 apples'), // fallback - array('key2', 1, 'ru', 'One apple'), // fallback - array('key2', 2, 'ru', '2 apples'), // fallback - ); - } - - public function transProvider() - { - return array( - array('key1', null, 'The translation'), - array('key1', 'de', 'The german translation'), - array('key1', 'ru', 'The translation'), // fallback - array('test.key', null, 'It works'), - array('test.key', 'de', 'It works in german'), - array('test.key', 'ru', 'It works'), // fallback - ); - } - - /** - * @dataProvider transProvider - */ - public function testTransForDefaultLanguage($key, $locale, $expected) - { - $app = $this->getPreparedApp(); - - $result = $app['translator']->trans($key, array(), null, $locale); - - $this->assertEquals($expected, $result); - } - - /** - * @dataProvider transChoiceProvider - */ - public function testTransChoiceForDefaultLanguage($key, $number, $locale, $expected) - { - $app = $this->getPreparedApp(); - - $result = $app['translator']->transChoice($key, $number, array('%count%' => $number), null, $locale); - $this->assertEquals($expected, $result); - } - - public function testFallbacks() - { - $app = $this->getPreparedApp(); - $app['locale_fallbacks'] = array('de', 'en'); - - // fallback to english - $result = $app['translator']->trans('key_only_english', array(), null, 'ru'); - $this->assertEquals('Foo', $result); - - // fallback to german - $result = $app['translator']->trans('key1', array(), null, 'ru'); - $this->assertEquals('The german translation', $result); - } - - public function testLocale() - { - $app = $this->getPreparedApp(); - $app->get('/', function () use ($app) { return $app['translator']->getLocale(); }); - $response = $app->handle(Request::create('/')); - $this->assertEquals('en', $response->getContent()); - - $app = $this->getPreparedApp(); - $app->get('/', function () use ($app) { return $app['translator']->getLocale(); }); - $request = Request::create('/'); - $request->setLocale('fr'); - $response = $app->handle($request); - $this->assertEquals('fr', $response->getContent()); - - $app = $this->getPreparedApp(); - $app->get('/{_locale}', function () use ($app) { return $app['translator']->getLocale(); }); - $response = $app->handle(Request::create('/es')); - $this->assertEquals('es', $response->getContent()); - } - - public function testLocaleInSubRequests() - { - $app = $this->getPreparedApp(); - $app->get('/embed/{_locale}', function () use ($app) { return $app['translator']->getLocale(); }); - $app->get('/{_locale}', function () use ($app) { - return $app['translator']->getLocale(). - $app->handle(Request::create('/embed/es'), HttpKernelInterface::SUB_REQUEST)->getContent(). - $app['translator']->getLocale(); - }); - $response = $app->handle(Request::create('/fr')); - $this->assertEquals('fresfr', $response->getContent()); - - $app = $this->getPreparedApp(); - $app->get('/embed', function () use ($app) { return $app['translator']->getLocale(); }); - $app->get('/{_locale}', function () use ($app) { - return $app['translator']->getLocale(). - $app->handle(Request::create('/embed'), HttpKernelInterface::SUB_REQUEST)->getContent(). - $app['translator']->getLocale(); - }); - $response = $app->handle(Request::create('/fr')); - // locale in sub-request must be "en" as this is the value if the sub-request is converted to an ESI - $this->assertEquals('frenfr', $response->getContent()); - } - - public function testLocaleWithBefore() - { - $app = $this->getPreparedApp(); - $app->before(function (Request $request) { $request->setLocale('fr'); }, Application::EARLY_EVENT); - $app->get('/embed', function () use ($app) { return $app['translator']->getLocale(); }); - $app->get('/', function () use ($app) { - return $app['translator']->getLocale(). - $app->handle(Request::create('/embed'), HttpKernelInterface::SUB_REQUEST)->getContent(). - $app['translator']->getLocale(); - }); - $response = $app->handle(Request::create('/')); - // locale in sub-request is "en" as the before filter is only executed for the main request - $this->assertEquals('frenfr', $response->getContent()); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TwigServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TwigServiceProviderTest.php deleted file mode 100644 index 1b5aef2c1..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/TwigServiceProviderTest.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use Fig\Link\Link; -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\CsrfServiceProvider; -use Silex\Provider\FormServiceProvider; -use Silex\Provider\TwigServiceProvider; -use Silex\Provider\AssetServiceProvider; -use Symfony\Bridge\Twig\Extension\WebLinkExtension; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\WebLink\HttpHeaderSerializer; - -/** - * TwigProvider test cases. - * - * @author Igor Wiedler - */ -class TwigServiceProviderTest extends TestCase -{ - public function testRegisterAndRender() - { - $app = new Application(); - - $app->register(new TwigServiceProvider(), array( - 'twig.templates' => array('hello' => 'Hello {{ name }}!'), - )); - - $app->get('/hello/{name}', function ($name) use ($app) { - return $app['twig']->render('hello', array('name' => $name)); - }); - - $request = Request::create('/hello/john'); - $response = $app->handle($request); - $this->assertEquals('Hello john!', $response->getContent()); - } - - public function testLoaderPriority() - { - $app = new Application(); - $app->register(new TwigServiceProvider(), array( - 'twig.templates' => array('foo' => 'foo'), - )); - $loader = $this->getMockBuilder('\Twig_LoaderInterface')->getMock(); - $loader->expects($this->never())->method('getSourceContext'); - $app['twig.loader.filesystem'] = function ($app) use ($loader) { - return $loader; - }; - $this->assertEquals('foo', $app['twig.loader']->getSourceContext('foo')->getCode()); - } - - public function testHttpFoundationIntegration() - { - $app = new Application(); - $app['request_stack']->push(Request::create('/dir1/dir2/file')); - $app->register(new TwigServiceProvider(), array( - 'twig.templates' => array( - 'absolute' => '{{ absolute_url("foo.css") }}', - 'relative' => '{{ relative_path("/dir1/foo.css") }}', - ), - )); - - $this->assertEquals('http://localhost/dir1/dir2/foo.css', $app['twig']->render('absolute')); - $this->assertEquals('../foo.css', $app['twig']->render('relative')); - } - - public function testAssetIntegration() - { - $app = new Application(); - $app->register(new TwigServiceProvider(), array( - 'twig.templates' => array('hello' => '{{ asset("/foo.css") }}'), - )); - $app->register(new AssetServiceProvider(), array( - 'assets.version' => 1, - )); - - $this->assertEquals('/foo.css?1', $app['twig']->render('hello')); - } - - public function testGlobalVariable() - { - $app = new Application(); - $app['request_stack']->push(Request::create('/?name=Fabien')); - - $app->register(new TwigServiceProvider(), array( - 'twig.templates' => array('hello' => '{{ global.request.get("name") }}'), - )); - - $this->assertEquals('Fabien', $app['twig']->render('hello')); - } - - public function testFormFactory() - { - $app = new Application(); - $app->register(new FormServiceProvider()); - $app->register(new CsrfServiceProvider()); - $app->register(new TwigServiceProvider()); - - $this->assertInstanceOf('Twig_Environment', $app['twig'], 'Service twig is created successful.'); - $this->assertInstanceOf('Symfony\Bridge\Twig\Form\TwigRendererEngine', $app['twig.form.engine'], 'Service twig.form.engine is created successful.'); - $this->assertInstanceOf('Symfony\Bridge\Twig\Form\TwigRenderer', $app['twig.form.renderer'], 'Service twig.form.renderer is created successful.'); - } - - public function testFormWithoutCsrf() - { - $app = new Application(); - $app->register(new FormServiceProvider()); - $app->register(new TwigServiceProvider()); - - $this->assertInstanceOf('Twig_Environment', $app['twig']); - } - - public function testFormatParameters() - { - $app = new Application(); - - $timezone = new \DateTimeZone('Europe/Paris'); - - $app->register(new TwigServiceProvider(), array( - 'twig.date.format' => 'Y-m-d', - 'twig.date.interval_format' => '%h hours', - 'twig.date.timezone' => $timezone, - 'twig.number_format.decimals' => 2, - 'twig.number_format.decimal_point' => ',', - 'twig.number_format.thousands_separator' => ' ', - )); - - $twig = $app['twig']; - - $this->assertSame(array('Y-m-d', '%h hours'), $twig->getExtension('Twig_Extension_Core')->getDateFormat()); - $this->assertSame($timezone, $twig->getExtension('Twig_Extension_Core')->getTimezone()); - $this->assertSame(array(2, ',', ' '), $twig->getExtension('Twig_Extension_Core')->getNumberFormat()); - } - - public function testWebLinkIntegration() - { - if (!class_exists(HttpHeaderSerializer::class) || !class_exists(WebLinkExtension::class)) { - $this->markTestSkipped('Twig WebLink extension not available.'); - } - - $app = new Application(); - $app['request_stack']->push($request = Request::create('/')); - $app->register(new TwigServiceProvider(), array( - 'twig.templates' => array( - 'preload' => '{{ preload("/foo.css") }}', - ), - )); - - $this->assertEquals('/foo.css', $app['twig']->render('preload')); - - $link = new Link('preload', '/foo.css'); - $this->assertEquals(array($link), array_values($request->attributes->get('_links')->getLinks())); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/UrlGeneratorServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/UrlGeneratorServiceProviderTest.php deleted file mode 100644 index 76d8e52f4..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/UrlGeneratorServiceProviderTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use Silex\Application; -use Silex\Provider\UrlGeneratorServiceProvider; -use Symfony\Component\HttpFoundation\Request; - -/** - * UrlGeneratorProvider test cases. - * - * @author Igor Wiedler - */ -class UrlGeneratorServiceProviderTest extends \PHPUnit_Framework_TestCase -{ - public function testRegister() - { - $app = new Application(); - - $app->register(new UrlGeneratorServiceProvider()); - - $app->get('/hello/{name}', function ($name) {}) - ->bind('hello'); - - $app->get('/', function () {}); - - $request = Request::create('/'); - $app->handle($request); - - $this->assertInstanceOf('Symfony\Component\Routing\Generator\UrlGenerator', $app['url_generator']); - } - - public function testUrlGeneration() - { - $app = new Application(); - - $app->register(new UrlGeneratorServiceProvider()); - - $app->get('/hello/{name}', function ($name) {}) - ->bind('hello'); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('hello', array('name' => 'john')); - }); - - $request = Request::create('/'); - $response = $app->handle($request); - - $this->assertEquals('/hello/john', $response->getContent()); - } - - public function testAbsoluteUrlGeneration() - { - $app = new Application(); - - $app->register(new UrlGeneratorServiceProvider()); - - $app->get('/hello/{name}', function ($name) {}) - ->bind('hello'); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('hello', array('name' => 'john'), true); - }); - - $request = Request::create('https://localhost:81/'); - $response = $app->handle($request); - - $this->assertEquals('https://localhost:81/hello/john', $response->getContent()); - } - - public function testUrlGenerationWithHttp() - { - $app = new Application(); - - $app->register(new UrlGeneratorServiceProvider()); - - $app->get('/insecure', function () {}) - ->bind('insecure_page') - ->requireHttp(); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('insecure_page'); - }); - - $request = Request::create('https://localhost/'); - $response = $app->handle($request); - - $this->assertEquals('http://localhost/insecure', $response->getContent()); - } - - public function testUrlGenerationWithHttps() - { - $app = new Application(); - - $app->register(new UrlGeneratorServiceProvider()); - - $app->get('/secure', function () {}) - ->bind('secure_page') - ->requireHttps(); - - $app->get('/', function () use ($app) { - return $app['url_generator']->generate('secure_page'); - }); - - $request = Request::create('http://localhost/'); - $response = $app->handle($request); - - $this->assertEquals('https://localhost/secure', $response->getContent()); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php deleted file mode 100644 index c53f349af..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php +++ /dev/null @@ -1,206 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\TranslationServiceProvider; -use Silex\Provider\ValidatorServiceProvider; -use Silex\Provider\FormServiceProvider; -use Symfony\Component\Translation\Exception\NotFoundResourceException; -use Symfony\Component\Validator\Constraints as Assert; -use Silex\Tests\Provider\ValidatorServiceProviderTest\Constraint\Custom; -use Silex\Tests\Provider\ValidatorServiceProviderTest\Constraint\CustomValidator; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * ValidatorServiceProvider. - * - * Javier Lopez - */ -class ValidatorServiceProviderTest extends TestCase -{ - public function testRegister() - { - $app = new Application(); - $app->register(new ValidatorServiceProvider()); - $app->register(new FormServiceProvider()); - - return $app; - } - - public function testRegisterWithCustomValidators() - { - $app = new Application(); - - $app['custom.validator'] = function () { - return new CustomValidator(); - }; - - $app->register(new ValidatorServiceProvider(), array( - 'validator.validator_service_ids' => array( - 'test.custom.validator' => 'custom.validator', - ), - )); - - return $app; - } - - /** - * @depends testRegisterWithCustomValidators - */ - public function testConstraintValidatorFactory($app) - { - $this->assertInstanceOf('Silex\Provider\Validator\ConstraintValidatorFactory', $app['validator.validator_factory']); - - $validator = $app['validator.validator_factory']->getInstance(new Custom()); - $this->assertInstanceOf('Silex\Tests\Provider\ValidatorServiceProviderTest\Constraint\CustomValidator', $validator); - } - - /** - * @depends testRegister - */ - public function testConstraintValidatorFactoryWithExpression($app) - { - $constraint = new Assert\Expression('true'); - $validator = $app['validator.validator_factory']->getInstance($constraint); - $this->assertInstanceOf('Symfony\Component\Validator\Constraints\ExpressionValidator', $validator); - } - - /** - * @depends testRegister - */ - public function testValidatorServiceIsAValidator($app) - { - $this->assertTrue($app['validator'] instanceof ValidatorInterface || $app['validator'] instanceof LegacyValidatorInterface); - } - - /** - * @depends testRegister - * @dataProvider getTestValidatorConstraintProvider - */ - public function testValidatorConstraint($email, $isValid, $nbGlobalError, $nbEmailError, $app) - { - $constraints = new Assert\Collection(array( - 'email' => array( - new Assert\NotBlank(), - new Assert\Email(), - ), - )); - - $builder = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array(), array( - 'constraints' => $constraints, - )); - - $form = $builder - ->add('email', 'Symfony\Component\Form\Extension\Core\Type\EmailType', array('label' => 'Email')) - ->getForm() - ; - - $form->submit(array('email' => $email)); - - $this->assertEquals($isValid, $form->isValid()); - $this->assertCount($nbGlobalError, $form->getErrors()); - $this->assertCount($nbEmailError, $form->offsetGet('email')->getErrors()); - } - - public function testValidatorWillNotAddNonexistentTranslationFiles() - { - $app = new Application(array( - 'locale' => 'nonexistent', - )); - - $app->register(new ValidatorServiceProvider()); - $app->register(new TranslationServiceProvider(), array( - 'locale_fallbacks' => array(), - )); - - $app['validator']; - $translator = $app['translator']; - - try { - $translator->trans('test'); - } catch (NotFoundResourceException $e) { - $this->fail('Validator should not add a translation resource that does not exist'); - } - } - - public function getTestValidatorConstraintProvider() - { - // Email, form is valid, nb global error, nb email error - return array( - array('', false, 0, 1), - array('not an email', false, 0, 1), - array('email@sample.com', true, 0, 0), - ); - } - - /** - * @dataProvider getAddResourceData - */ - public function testAddResource($registerValidatorFirst) - { - $app = new Application(); - $app['locale'] = 'fr'; - - $app->register(new ValidatorServiceProvider()); - $app->register(new TranslationServiceProvider()); - $app['translator'] = $app->extend('translator', function ($translator, $app) { - $translator->addResource('array', array('This value should not be blank.' => 'Pas vide'), 'fr', 'validators'); - - return $translator; - }); - - if ($registerValidatorFirst) { - $app['validator']; - } - - $this->assertEquals('Pas vide', $app['translator']->trans('This value should not be blank.', array(), 'validators', 'fr')); - } - - public function getAddResourceData() - { - return array(array(false), array(true)); - } - - public function testAddResourceAlternate() - { - $app = new Application(); - $app['locale'] = 'fr'; - - $app->register(new ValidatorServiceProvider()); - $app->register(new TranslationServiceProvider()); - $app->factory($app->extend('translator.resources', function ($resources, $app) { - $resources = array_merge($resources, array( - array('array', array('This value should not be blank.' => 'Pas vide'), 'fr', 'validators'), - )); - - return $resources; - })); - - $app['validator']; - - $this->assertEquals('Pas vide', $app['translator']->trans('This value should not be blank.', array(), 'validators', 'fr')); - } - - public function testTranslatorResourcesIsArray() - { - $app = new Application(); - $app['locale'] = 'fr'; - - $app->register(new ValidatorServiceProvider()); - $app->register(new TranslationServiceProvider()); - - $this->assertInternalType('array', $app['translator.resources']); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/Custom.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/Custom.php deleted file mode 100644 index bef911aa7..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/Custom.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider\ValidatorServiceProviderTest\Constraint; - -use Symfony\Component\Validator\Constraint; - -/** - * @author Alex Kalyvitis - */ -class Custom extends Constraint -{ - public $message = 'This field must be ...'; - public $table; - public $field; - - public function validatedBy() - { - return 'test.custom.validator'; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/CustomValidator.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/CustomValidator.php deleted file mode 100644 index 856927dba..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Provider/ValidatorServiceProviderTest/Constraint/CustomValidator.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Provider\ValidatorServiceProviderTest\Constraint; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; - -/** - * @author Alex Kalyvitis - */ -class CustomValidator extends ConstraintValidator -{ - public function isValid($value, Constraint $constraint) - { - // Validate... - return true; - } - - public function validate($value, Constraint $constraint) - { - return $this->isValid($value, $constraint); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityRoute.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityRoute.php deleted file mode 100644 index 48237194b..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityRoute.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Route; - -use Silex\Route; - -class SecurityRoute extends Route -{ - use Route\SecurityTrait; -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityTraitTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityTraitTest.php deleted file mode 100644 index e984fefb5..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/Route/SecurityTraitTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests\Route; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Silex\Provider\SecurityServiceProvider; -use Symfony\Component\HttpFoundation\Request; - -/** - * SecurityTrait test cases. - * - * @author Fabien Potencier - */ -class SecurityTraitTest extends TestCase -{ - public function testSecureWithNoAuthenticatedUser() - { - $app = $this->createApplication(); - - $app->get('/', function () { return 'foo'; }) - ->secure('ROLE_ADMIN') - ; - - $request = Request::create('/'); - $response = $app->handle($request); - $this->assertEquals(401, $response->getStatusCode()); - } - - public function testSecureWithAuthorizedRoles() - { - $app = $this->createApplication(); - - $app->get('/', function () { return 'foo'; }) - ->secure('ROLE_ADMIN') - ; - - $request = Request::create('/'); - $request->headers->set('PHP_AUTH_USER', 'fabien'); - $request->headers->set('PHP_AUTH_PW', 'foo'); - $response = $app->handle($request); - $this->assertEquals(200, $response->getStatusCode()); - } - - public function testSecureWithUnauthorizedRoles() - { - $app = $this->createApplication(); - - $app->get('/', function () { return 'foo'; }) - ->secure('ROLE_SUPER_ADMIN') - ; - - $request = Request::create('/'); - $request->headers->set('PHP_AUTH_USER', 'fabien'); - $request->headers->set('PHP_AUTH_PW', 'foo'); - $response = $app->handle($request); - $this->assertEquals(403, $response->getStatusCode()); - } - - private function createApplication() - { - $app = new Application(); - $app['route_class'] = 'Silex\Tests\Route\SecurityRoute'; - $app->register(new SecurityServiceProvider(), array( - 'security.firewalls' => array( - 'default' => array( - 'http' => true, - 'users' => array( - 'fabien' => array('ROLE_ADMIN', '$2y$15$lzUNsTegNXvZW3qtfucV0erYBcEqWVeyOmjolB7R1uodsAVJ95vvu'), - ), - ), - ), - )); - - return $app; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/RouterTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/RouterTest.php deleted file mode 100644 index 0d0bf518b..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/RouterTest.php +++ /dev/null @@ -1,286 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; - -/** - * Router test cases. - * - * @author Igor Wiedler - */ -class RouterTest extends TestCase -{ - public function testMapRouting() - { - $app = new Application(); - - $app->match('/foo', function () { - return 'foo'; - }); - - $app->match('/bar', function () { - return 'bar'; - }); - - $app->match('/', function () { - return 'root'; - }); - - $this->checkRouteResponse($app, '/foo', 'foo'); - $this->checkRouteResponse($app, '/bar', 'bar'); - $this->checkRouteResponse($app, '/', 'root'); - } - - public function testStatusCode() - { - $app = new Application(); - - $app->put('/created', function () { - return new Response('', 201); - }); - - $app->match('/forbidden', function () { - return new Response('', 403); - }); - - $app->match('/not_found', function () { - return new Response('', 404); - }); - - $request = Request::create('/created', 'put'); - $response = $app->handle($request); - $this->assertEquals(201, $response->getStatusCode()); - - $request = Request::create('/forbidden'); - $response = $app->handle($request); - $this->assertEquals(403, $response->getStatusCode()); - - $request = Request::create('/not_found'); - $response = $app->handle($request); - $this->assertEquals(404, $response->getStatusCode()); - } - - public function testRedirect() - { - $app = new Application(); - - $app->match('/redirect', function () { - return new RedirectResponse('/target'); - }); - - $app->match('/redirect2', function () use ($app) { - return $app->redirect('/target2'); - }); - - $request = Request::create('/redirect'); - $response = $app->handle($request); - $this->assertTrue($response->isRedirect('/target')); - - $request = Request::create('/redirect2'); - $response = $app->handle($request); - $this->assertTrue($response->isRedirect('/target2')); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ - public function testMissingRoute() - { - $app = new Application(); - unset($app['exception_handler']); - - $request = Request::create('/baz'); - $app->handle($request); - } - - public function testMethodRouting() - { - $app = new Application(); - - $app->match('/foo', function () { - return 'foo'; - }); - - $app->match('/bar', function () { - return 'bar'; - })->method('GET|POST'); - - $app->get('/resource', function () { - return 'get resource'; - }); - - $app->post('/resource', function () { - return 'post resource'; - }); - - $app->put('/resource', function () { - return 'put resource'; - }); - - $app->patch('/resource', function () { - return 'patch resource'; - }); - - $app->delete('/resource', function () { - return 'delete resource'; - }); - - $this->checkRouteResponse($app, '/foo', 'foo'); - $this->checkRouteResponse($app, '/bar', 'bar'); - $this->checkRouteResponse($app, '/bar', 'bar', 'post'); - $this->checkRouteResponse($app, '/resource', 'get resource'); - $this->checkRouteResponse($app, '/resource', 'post resource', 'post'); - $this->checkRouteResponse($app, '/resource', 'put resource', 'put'); - $this->checkRouteResponse($app, '/resource', 'patch resource', 'patch'); - $this->checkRouteResponse($app, '/resource', 'delete resource', 'delete'); - } - - public function testRequestShouldBeStoredRegardlessOfRouting() - { - $app = new Application(); - - $app->get('/foo', function (Request $request) use ($app) { - return new Response($request->getRequestUri()); - }); - - $app->error(function ($e, Request $request, $code) use ($app) { - return new Response($request->getRequestUri()); - }); - - foreach (array('/foo', '/bar') as $path) { - $request = Request::create($path); - $response = $app->handle($request); - $this->assertContains($path, $response->getContent()); - } - } - - public function testTrailingSlashBehavior() - { - $app = new Application(); - - $app->get('/foo/', function () use ($app) { - return new Response('ok'); - }); - - $request = Request::create('/foo'); - $response = $app->handle($request); - - $this->assertEquals(301, $response->getStatusCode()); - $this->assertEquals('/foo/', $response->getTargetUrl()); - } - - public function testHostSpecification() - { - $route = new \Silex\Route(); - - $this->assertSame($route, $route->host('{locale}.example.com')); - $this->assertEquals('{locale}.example.com', $route->getHost()); - } - - public function testRequireHttpRedirect() - { - $app = new Application(); - - $app->match('/secured', function () { - return 'secured content'; - }) - ->requireHttp(); - - $request = Request::create('https://example.com/secured'); - $response = $app->handle($request); - $this->assertTrue($response->isRedirect('http://example.com/secured')); - } - - public function testRequireHttpsRedirect() - { - $app = new Application(); - - $app->match('/secured', function () { - return 'secured content'; - }) - ->requireHttps(); - - $request = Request::create('http://example.com/secured'); - $response = $app->handle($request); - $this->assertTrue($response->isRedirect('https://example.com/secured')); - } - - public function testRequireHttpsRedirectIncludesQueryString() - { - $app = new Application(); - - $app->match('/secured', function () { - return 'secured content'; - }) - ->requireHttps(); - - $request = Request::create('http://example.com/secured?query=string'); - $response = $app->handle($request); - $this->assertTrue($response->isRedirect('https://example.com/secured?query=string')); - } - - public function testConditionOnRoute() - { - $app = new Application(); - $app->match('/secured', function () { - return 'secured content'; - }) - ->when('request.isSecure() == true'); - - $request = Request::create('http://example.com/secured'); - $response = $app->handle($request); - $this->assertEquals(404, $response->getStatusCode()); - } - - public function testClassNameControllerSyntax() - { - $app = new Application(); - - $app->get('/foo', 'Silex\Tests\MyController::getFoo'); - - $this->checkRouteResponse($app, '/foo', 'foo'); - } - - public function testClassNameControllerSyntaxWithStaticMethod() - { - $app = new Application(); - - $app->get('/bar', 'Silex\Tests\MyController::getBar'); - - $this->checkRouteResponse($app, '/bar', 'bar'); - } - - protected function checkRouteResponse(Application $app, $path, $expectedContent, $method = 'get', $message = null) - { - $request = Request::create($path, $method); - $response = $app->handle($request); - $this->assertEquals($expectedContent, $response->getContent(), $message); - } -} - -class MyController -{ - public function getFoo() - { - return 'foo'; - } - - public static function getBar() - { - return 'bar'; - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverRouterTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverRouterTest.php deleted file mode 100644 index 4bc88a451..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverRouterTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use Silex\Application; -use Silex\Provider\ServiceControllerServiceProvider; -use Symfony\Component\HttpFoundation\Request; - -/** - * Router test cases, using the ServiceControllerResolver. - */ -class ServiceControllerResolverRouterTest extends RouterTest -{ - public function testServiceNameControllerSyntax() - { - $app = new Application(); - $app->register(new ServiceControllerServiceProvider()); - - $app['service_name'] = function () { - return new MyController(); - }; - - $app->get('/bar', 'service_name:getBar'); - - $this->checkRouteResponse($app, '/bar', 'bar'); - } - - protected function checkRouteResponse(Application $app, $path, $expectedContent, $method = 'get', $message = null) - { - $request = Request::create($path, $method); - $response = $app->handle($request); - $this->assertEquals($expectedContent, $response->getContent(), $message); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverTest.php deleted file mode 100644 index a2bf35d30..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/ServiceControllerResolverTest.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\ServiceControllerResolver; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Kernel; - -/** - * Unit tests for ServiceControllerResolver, see ServiceControllerResolverRouterTest for some - * integration tests. - */ -class ServiceControllerResolverTest extends Testcase -{ - private $app; - private $mockCallbackResolver; - private $mockResolver; - private $resolver; - - public function setup() - { - $this->mockResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->mockCallbackResolver = $this->getMockBuilder('Silex\CallbackResolver') - ->disableOriginalConstructor() - ->getMock(); - - $this->app = new Application(); - $this->resolver = new ServiceControllerResolver($this->mockResolver, $this->mockCallbackResolver); - } - - public function testShouldResolveServiceController() - { - $this->mockCallbackResolver->expects($this->once()) - ->method('isValid') - ->will($this->returnValue(true)); - - $this->mockCallbackResolver->expects($this->once()) - ->method('convertCallback') - ->with('some_service:methodName') - ->will($this->returnValue(array('callback'))); - - $this->app['some_service'] = function () { return new \stdClass(); }; - - $req = Request::create('/'); - $req->attributes->set('_controller', 'some_service:methodName'); - - $this->assertEquals(array('callback'), $this->resolver->getController($req)); - } - - public function testShouldUnresolvedControllerNames() - { - $req = Request::create('/'); - $req->attributes->set('_controller', 'some_class::methodName'); - - $this->mockCallbackResolver->expects($this->once()) - ->method('isValid') - ->with('some_class::methodName') - ->will($this->returnValue(false)); - - $this->mockResolver->expects($this->once()) - ->method('getController') - ->with($req) - ->will($this->returnValue(123)); - - $this->assertEquals(123, $this->resolver->getController($req)); - } - - /** - * @group legacy - */ - public function testShouldDelegateGetArguments() - { - if (Kernel::VERSION_ID >= 40000) { - self::markTestSkipped('HttpKernel < 4.0 is required'); - } - - $req = Request::create('/'); - $this->mockResolver->expects($this->once()) - ->method('getArguments') - ->with($req) - ->will($this->returnValue(123)); - - $this->assertEquals(123, $this->resolver->getArguments($req, function () {})); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/StreamTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/StreamTest.php deleted file mode 100644 index 24c26b4cf..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/StreamTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use PHPUnit\Framework\TestCase; -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; - -/** - * Stream test cases. - * - * @author Igor Wiedler - */ -class StreamTest extends TestCase -{ - public function testStreamReturnsStreamingResponse() - { - $app = new Application(); - - $response = $app->stream(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response); - $this->assertFalse($response->getContent()); - } - - public function testStreamActuallyStreams() - { - $i = 0; - - $stream = function () use (&$i) { - ++$i; - }; - - $app = new Application(); - $response = $app->stream($stream); - - $this->assertEquals(0, $i); - - $request = Request::create('/stream'); - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(1, $i); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/Silex/Tests/WebTestCaseTest.php b/lib/silex/vendor/silex/silex/tests/Silex/Tests/WebTestCaseTest.php deleted file mode 100644 index 474ffc389..000000000 --- a/lib/silex/vendor/silex/silex/tests/Silex/Tests/WebTestCaseTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Silex\Tests; - -use Silex\Application; -use Silex\WebTestCase; -use Symfony\Component\HttpFoundation\Request; - -/** - * Functional test cases. - * - * @author Igor Wiedler - */ -class WebTestCaseTest extends WebTestCase -{ - public function createApplication() - { - $app = new Application(); - - $app->match('/hello', function () { - return 'world'; - }); - - $app->match('/html', function () { - return '

title

'; - }); - - $app->match('/server', function (Request $request) use ($app) { - $user = $request->server->get('PHP_AUTH_USER'); - $pass = $request->server->get('PHP_AUTH_PW'); - - return "

$user:$pass

"; - }); - - return $app; - } - - public function testGetHello() - { - $client = $this->createClient(); - - $client->request('GET', '/hello'); - $response = $client->getResponse(); - $this->assertTrue($response->isSuccessful()); - $this->assertEquals('world', $response->getContent()); - } - - public function testCrawlerFilter() - { - $client = $this->createClient(); - - $crawler = $client->request('GET', '/html'); - $this->assertEquals('title', $crawler->filter('h1')->text()); - } - - public function testServerVariables() - { - $user = 'klaus'; - $pass = '123456'; - - $client = $this->createClient(array( - 'PHP_AUTH_USER' => $user, - 'PHP_AUTH_PW' => $pass, - )); - - $crawler = $client->request('GET', '/server'); - $this->assertEquals("$user:$pass", $crawler->filter('h1')->text()); - } -} diff --git a/lib/silex/vendor/silex/silex/tests/bootstrap.php b/lib/silex/vendor/silex/silex/tests/bootstrap.php deleted file mode 100644 index a77cd2643..000000000 --- a/lib/silex/vendor/silex/silex/tests/bootstrap.php +++ /dev/null @@ -1,10 +0,0 @@ -add('Silex\Tests', __DIR__); - -if (!class_exists('Symfony\Component\Form\Form')) { - echo "You must install the dev dependencies using:\n"; - echo " composer install --dev\n"; - exit(1); -} diff --git a/lib/silex/vendor/symfony/debug/.gitignore b/lib/silex/vendor/symfony/debug/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/debug/BufferingLogger.php b/lib/silex/vendor/symfony/debug/BufferingLogger.php deleted file mode 100644 index a2ed75b9d..000000000 --- a/lib/silex/vendor/symfony/debug/BufferingLogger.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -use Psr\Log\AbstractLogger; - -/** - * A buffering logger that stacks logs for later. - * - * @author Nicolas Grekas - */ -class BufferingLogger extends AbstractLogger -{ - private $logs = array(); - - public function log($level, $message, array $context = array()) - { - $this->logs[] = array($level, $message, $context); - } - - public function cleanLogs() - { - $logs = $this->logs; - $this->logs = array(); - - return $logs; - } -} diff --git a/lib/silex/vendor/symfony/debug/CHANGELOG.md b/lib/silex/vendor/symfony/debug/CHANGELOG.md deleted file mode 100644 index 31c67eb60..000000000 --- a/lib/silex/vendor/symfony/debug/CHANGELOG.md +++ /dev/null @@ -1,64 +0,0 @@ -CHANGELOG -========= - -3.4.0 ------ - -* deprecated `ErrorHandler::stackErrors()` and `ErrorHandler::unstackErrors()` - -3.3.0 ------ - -* deprecated the `ContextErrorException` class: use \ErrorException directly now - -3.2.0 ------ - -* `FlattenException::getTrace()` now returns additional type descriptions - `integer` and `float`. - - -3.0.0 ------ - -* removed classes, methods and interfaces deprecated in 2.x - -2.8.0 ------ - -* added BufferingLogger for errors that happen before a proper logger is configured -* allow throwing from `__toString()` with `return trigger_error($e, E_USER_ERROR);` -* deprecate ExceptionHandler::createResponse - -2.7.0 ------ - -* added deprecations checking for parent interfaces/classes to DebugClassLoader -* added ZTS support to symfony_debug extension -* added symfony_debug_backtrace() to symfony_debug extension - to track the backtrace of fatal errors - -2.6.0 ------ - -* generalized ErrorHandler and ExceptionHandler, - with some new methods and others deprecated -* enhanced error messages for uncaught exceptions - -2.5.0 ------ - -* added ExceptionHandler::setHandler() -* added UndefinedMethodFatalErrorHandler -* deprecated DummyException - -2.4.0 ------ - - * added a DebugClassLoader able to wrap any autoloader providing a findFile method - * improved error messages for not found classes and functions - -2.3.0 ------ - - * added the component diff --git a/lib/silex/vendor/symfony/debug/Debug.php b/lib/silex/vendor/symfony/debug/Debug.php deleted file mode 100644 index e3665ae5f..000000000 --- a/lib/silex/vendor/symfony/debug/Debug.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -/** - * Registers all the debug tools. - * - * @author Fabien Potencier - */ -class Debug -{ - private static $enabled = false; - - /** - * Enables the debug tools. - * - * This method registers an error handler and an exception handler. - * - * If the Symfony ClassLoader component is available, a special - * class loader is also registered. - * - * @param int $errorReportingLevel The level of error reporting you want - * @param bool $displayErrors Whether to display errors (for development) or just log them (for production) - */ - public static function enable($errorReportingLevel = E_ALL, $displayErrors = true) - { - if (static::$enabled) { - return; - } - - static::$enabled = true; - - if (null !== $errorReportingLevel) { - error_reporting($errorReportingLevel); - } else { - error_reporting(E_ALL); - } - - if ('cli' !== PHP_SAPI) { - ini_set('display_errors', 0); - ExceptionHandler::register(); - } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { - // CLI - display errors only if they're not already logged to STDERR - ini_set('display_errors', 1); - } - if ($displayErrors) { - ErrorHandler::register(new ErrorHandler(new BufferingLogger())); - } else { - ErrorHandler::register()->throwAt(0, true); - } - - DebugClassLoader::enable(); - } -} diff --git a/lib/silex/vendor/symfony/debug/DebugClassLoader.php b/lib/silex/vendor/symfony/debug/DebugClassLoader.php deleted file mode 100644 index 78bfb8538..000000000 --- a/lib/silex/vendor/symfony/debug/DebugClassLoader.php +++ /dev/null @@ -1,409 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -/** - * Autoloader checking if the class is really defined in the file found. - * - * The ClassLoader will wrap all registered autoloaders - * and will throw an exception if a file is found but does - * not declare the class. - * - * @author Fabien Potencier - * @author Christophe Coevoet - * @author Nicolas Grekas - */ -class DebugClassLoader -{ - private $classLoader; - private $isFinder; - private $loaded = array(); - private static $caseCheck; - private static $checkedClasses = array(); - private static $final = array(); - private static $finalMethods = array(); - private static $deprecated = array(); - private static $internal = array(); - private static $internalMethods = array(); - private static $php7Reserved = array('int' => 1, 'float' => 1, 'bool' => 1, 'string' => 1, 'true' => 1, 'false' => 1, 'null' => 1); - private static $darwinCache = array('/' => array('/', array())); - - public function __construct(callable $classLoader) - { - $this->classLoader = $classLoader; - $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile'); - - if (!isset(self::$caseCheck)) { - $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR); - $i = strrpos($file, DIRECTORY_SEPARATOR); - $dir = substr($file, 0, 1 + $i); - $file = substr($file, 1 + $i); - $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file); - $test = realpath($dir.$test); - - if (false === $test || false === $i) { - // filesystem is case sensitive - self::$caseCheck = 0; - } elseif (substr($test, -strlen($file)) === $file) { - // filesystem is case insensitive and realpath() normalizes the case of characters - self::$caseCheck = 1; - } elseif (false !== stripos(PHP_OS, 'darwin')) { - // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters - self::$caseCheck = 2; - } else { - // filesystem case checks failed, fallback to disabling them - self::$caseCheck = 0; - } - } - } - - /** - * Gets the wrapped class loader. - * - * @return callable The wrapped class loader - */ - public function getClassLoader() - { - return $this->classLoader; - } - - /** - * Wraps all autoloaders. - */ - public static function enable() - { - // Ensures we don't hit https://bugs.php.net/42098 - class_exists('Symfony\Component\Debug\ErrorHandler'); - class_exists('Psr\Log\LogLevel'); - - if (!is_array($functions = spl_autoload_functions())) { - return; - } - - foreach ($functions as $function) { - spl_autoload_unregister($function); - } - - foreach ($functions as $function) { - if (!is_array($function) || !$function[0] instanceof self) { - $function = array(new static($function), 'loadClass'); - } - - spl_autoload_register($function); - } - } - - /** - * Disables the wrapping. - */ - public static function disable() - { - if (!is_array($functions = spl_autoload_functions())) { - return; - } - - foreach ($functions as $function) { - spl_autoload_unregister($function); - } - - foreach ($functions as $function) { - if (is_array($function) && $function[0] instanceof self) { - $function = $function[0]->getClassLoader(); - } - - spl_autoload_register($function); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * - * @return bool|null True, if loaded - * - * @throws \RuntimeException - */ - public function loadClass($class) - { - $e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); - - try { - if ($this->isFinder && !isset($this->loaded[$class])) { - $this->loaded[$class] = true; - if ($file = $this->classLoader[0]->findFile($class) ?: false) { - $wasCached = \function_exists('opcache_is_script_cached') && opcache_is_script_cached($file); - - require $file; - - if ($wasCached) { - return; - } - } - } else { - call_user_func($this->classLoader, $class); - $file = false; - } - } finally { - error_reporting($e); - } - - $this->checkClass($class, $file); - } - - private function checkClass($class, $file = null) - { - $exists = null === $file || \class_exists($class, false) || \interface_exists($class, false) || \trait_exists($class, false); - - if (null !== $file && $class && '\\' === $class[0]) { - $class = substr($class, 1); - } - - if ($exists) { - if (isset(self::$checkedClasses[$class])) { - return; - } - self::$checkedClasses[$class] = true; - - $refl = new \ReflectionClass($class); - if (null === $file && $refl->isInternal()) { - return; - } - $name = $refl->getName(); - - if ($name !== $class && 0 === \strcasecmp($name, $class)) { - throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: "%s" vs "%s".', $class, $name)); - } - - // Don't trigger deprecations for classes in the same vendor - if (2 > $len = 1 + (\strpos($name, '\\') ?: \strpos($name, '_'))) { - $len = 0; - $ns = ''; - } else { - $ns = \substr($name, 0, $len); - } - - // Detect annotations on the class - if (false !== $doc = $refl->getDocComment()) { - foreach (array('final', 'deprecated', 'internal') as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n \* @'.$annotation.'(?:( .+?)\.?)?\r?\n \*(?: @|/$)#s', $doc, $notice)) { - self::${$annotation}[$name] = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : ''; - } - } - } - - $parentAndTraits = \class_uses($name, false); - if ($parent = \get_parent_class($class)) { - $parentAndTraits[] = $parent; - - if (!isset(self::$checkedClasses[$parent])) { - $this->checkClass($parent); - } - - if (isset(self::$final[$parent])) { - @trigger_error(sprintf('The "%s" class is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $parent, self::$final[$parent], $name), E_USER_DEPRECATED); - } - } - - // Detect if the parent is annotated - foreach ($parentAndTraits + $this->getOwnInterfaces($name, $parent) as $use) { - if (!isset(self::$checkedClasses[$use])) { - $this->checkClass($use); - } - if (isset(self::$deprecated[$use]) && \strncmp($ns, $use, $len)) { - $type = class_exists($name, false) ? 'class' : (interface_exists($name, false) ? 'interface' : 'trait'); - $verb = class_exists($use, false) || interface_exists($name, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses'); - - @trigger_error(sprintf('The "%s" %s %s "%s" that is deprecated%s.', $name, $type, $verb, $use, self::$deprecated[$use]), E_USER_DEPRECATED); - } - if (isset(self::$internal[$use]) && \strncmp($ns, $use, $len)) { - @trigger_error(sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $name), E_USER_DEPRECATED); - } - } - - // Inherit @final and @internal annotations for methods - self::$finalMethods[$name] = array(); - self::$internalMethods[$name] = array(); - foreach ($parentAndTraits as $use) { - foreach (array('finalMethods', 'internalMethods') as $property) { - if (isset(self::${$property}[$use])) { - self::${$property}[$name] = self::${$property}[$name] ? self::${$property}[$use] + self::${$property}[$name] : self::${$property}[$use]; - } - } - } - - $isClass = \class_exists($name, false); - foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) { - if ($method->class !== $name) { - continue; - } - - // Method from a trait - if ($method->getFilename() !== $refl->getFileName()) { - continue; - } - - if ($isClass && $parent && isset(self::$finalMethods[$parent][$method->name])) { - list($declaringClass, $message) = self::$finalMethods[$parent][$method->name]; - @trigger_error(sprintf('The "%s::%s()" method is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $declaringClass, $method->name, $message, $name), E_USER_DEPRECATED); - } - - foreach ($parentAndTraits as $use) { - if (isset(self::$internalMethods[$use][$method->name])) { - list($declaringClass, $message) = self::$internalMethods[$use][$method->name]; - if (\strncmp($ns, $declaringClass, $len)) { - @trigger_error(sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $name), E_USER_DEPRECATED); - } - } - } - - // Detect method annotations - if (false === $doc = $method->getDocComment()) { - continue; - } - - foreach (array('final', 'internal') as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) { - $message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : ''; - self::${$annotation.'Methods'}[$name][$method->name] = array($name, $message); - } - } - } - - if (isset(self::$php7Reserved[\strtolower($refl->getShortName())])) { - @trigger_error(sprintf('The "%s" class uses the reserved name "%s", it will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED); - } - } - - if ($file) { - if (!$exists) { - if (false !== strpos($class, '/')) { - throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); - } - - throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); - } - if (self::$caseCheck) { - $real = explode('\\', $class.strrchr($file, '.')); - $tail = explode(DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, $file)); - - $i = count($tail) - 1; - $j = count($real) - 1; - - while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) { - --$i; - --$j; - } - - array_splice($tail, 0, $i + 1); - } - if (self::$caseCheck && $tail) { - $tail = DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $tail); - $tailLen = strlen($tail); - $real = $refl->getFileName(); - - if (2 === self::$caseCheck) { - // realpath() on MacOSX doesn't normalize the case of characters - - $i = 1 + strrpos($real, '/'); - $file = substr($real, $i); - $real = substr($real, 0, $i); - - if (isset(self::$darwinCache[$real])) { - $kDir = $real; - } else { - $kDir = strtolower($real); - - if (isset(self::$darwinCache[$kDir])) { - $real = self::$darwinCache[$kDir][0]; - } else { - $dir = getcwd(); - chdir($real); - $real = getcwd().'/'; - chdir($dir); - - $dir = $real; - $k = $kDir; - $i = strlen($dir) - 1; - while (!isset(self::$darwinCache[$k])) { - self::$darwinCache[$k] = array($dir, array()); - self::$darwinCache[$dir] = &self::$darwinCache[$k]; - - while ('/' !== $dir[--$i]) { - } - $k = substr($k, 0, ++$i); - $dir = substr($dir, 0, $i--); - } - } - } - - $dirFiles = self::$darwinCache[$kDir][1]; - - if (isset($dirFiles[$file])) { - $kFile = $file; - } else { - $kFile = strtolower($file); - - if (!isset($dirFiles[$kFile])) { - foreach (scandir($real, 2) as $f) { - if ('.' !== $f[0]) { - $dirFiles[$f] = $f; - if ($f === $file) { - $kFile = $k = $file; - } elseif ($f !== $k = strtolower($f)) { - $dirFiles[$k] = $f; - } - } - } - self::$darwinCache[$kDir][1] = $dirFiles; - } - } - - $real .= $dirFiles[$kFile]; - } - - if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true) - && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false) - ) { - throw new \RuntimeException(sprintf('Case mismatch between class and real file names: "%s" vs "%s" in "%s".', substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1))); - } - } - } - } - - /** - * `class_implements` includes interfaces from the parents so we have to manually exclude them. - * - * @param string $class - * @param string|false $parent - * - * @return string[] - */ - private function getOwnInterfaces($class, $parent) - { - $ownInterfaces = class_implements($class, false); - - if ($parent) { - foreach (class_implements($parent, false) as $interface) { - unset($ownInterfaces[$interface]); - } - } - - foreach ($ownInterfaces as $interface) { - foreach (class_implements($interface) as $interface) { - unset($ownInterfaces[$interface]); - } - } - - return $ownInterfaces; - } -} diff --git a/lib/silex/vendor/symfony/debug/ErrorHandler.php b/lib/silex/vendor/symfony/debug/ErrorHandler.php deleted file mode 100644 index 90e5535d9..000000000 --- a/lib/silex/vendor/symfony/debug/ErrorHandler.php +++ /dev/null @@ -1,758 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -use Psr\Log\LogLevel; -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\Exception\ContextErrorException; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\Exception\FatalThrowableError; -use Symfony\Component\Debug\Exception\OutOfMemoryException; -use Symfony\Component\Debug\Exception\SilencedErrorContext; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler; -use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; -use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface; - -/** - * A generic ErrorHandler for the PHP engine. - * - * Provides five bit fields that control how errors are handled: - * - thrownErrors: errors thrown as \ErrorException - * - loggedErrors: logged errors, when not @-silenced - * - scopedErrors: errors thrown or logged with their local context - * - tracedErrors: errors logged with their stack trace - * - screamedErrors: never @-silenced errors - * - * Each error level can be logged by a dedicated PSR-3 logger object. - * Screaming only applies to logging. - * Throwing takes precedence over logging. - * Uncaught exceptions are logged as E_ERROR. - * E_DEPRECATED and E_USER_DEPRECATED levels never throw. - * E_RECOVERABLE_ERROR and E_USER_ERROR levels always throw. - * Non catchable errors that can be detected at shutdown time are logged when the scream bit field allows so. - * As errors have a performance cost, repeated errors are all logged, so that the developer - * can see them and weight them as more important to fix than others of the same level. - * - * @author Nicolas Grekas - * @author Grégoire Pineau - */ -class ErrorHandler -{ - private $levels = array( - E_DEPRECATED => 'Deprecated', - E_USER_DEPRECATED => 'User Deprecated', - E_NOTICE => 'Notice', - E_USER_NOTICE => 'User Notice', - E_STRICT => 'Runtime Notice', - E_WARNING => 'Warning', - E_USER_WARNING => 'User Warning', - E_COMPILE_WARNING => 'Compile Warning', - E_CORE_WARNING => 'Core Warning', - E_USER_ERROR => 'User Error', - E_RECOVERABLE_ERROR => 'Catchable Fatal Error', - E_COMPILE_ERROR => 'Compile Error', - E_PARSE => 'Parse Error', - E_ERROR => 'Error', - E_CORE_ERROR => 'Core Error', - ); - - private $loggers = array( - E_DEPRECATED => array(null, LogLevel::INFO), - E_USER_DEPRECATED => array(null, LogLevel::INFO), - E_NOTICE => array(null, LogLevel::WARNING), - E_USER_NOTICE => array(null, LogLevel::WARNING), - E_STRICT => array(null, LogLevel::WARNING), - E_WARNING => array(null, LogLevel::WARNING), - E_USER_WARNING => array(null, LogLevel::WARNING), - E_COMPILE_WARNING => array(null, LogLevel::WARNING), - E_CORE_WARNING => array(null, LogLevel::WARNING), - E_USER_ERROR => array(null, LogLevel::CRITICAL), - E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL), - E_COMPILE_ERROR => array(null, LogLevel::CRITICAL), - E_PARSE => array(null, LogLevel::CRITICAL), - E_ERROR => array(null, LogLevel::CRITICAL), - E_CORE_ERROR => array(null, LogLevel::CRITICAL), - ); - - private $thrownErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED - private $scopedErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED - private $tracedErrors = 0x77FB; // E_ALL - E_STRICT - E_PARSE - private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE - private $loggedErrors = 0; - private $traceReflector; - - private $isRecursive = 0; - private $isRoot = false; - private $exceptionHandler; - private $bootstrappingLogger; - - private static $reservedMemory; - private static $stackedErrors = array(); - private static $stackedErrorLevels = array(); - private static $toStringException = null; - private static $silencedErrorCache = array(); - private static $silencedErrorCount = 0; - private static $exitCode = 0; - - /** - * Registers the error handler. - * - * @param self|null $handler The handler to register - * @param bool $replace Whether to replace or not any existing handler - * - * @return self The registered error handler - */ - public static function register(self $handler = null, $replace = true) - { - if (null === self::$reservedMemory) { - self::$reservedMemory = str_repeat('x', 10240); - register_shutdown_function(__CLASS__.'::handleFatalError'); - } - - if ($handlerIsNew = null === $handler) { - $handler = new static(); - } - - if (null === $prev = set_error_handler(array($handler, 'handleError'))) { - restore_error_handler(); - // Specifying the error types earlier would expose us to https://bugs.php.net/63206 - set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors); - $handler->isRoot = true; - } - - if ($handlerIsNew && is_array($prev) && $prev[0] instanceof self) { - $handler = $prev[0]; - $replace = false; - } - if (!$replace && $prev) { - restore_error_handler(); - } - if (is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] === $handler) { - restore_exception_handler(); - } else { - $handler->setExceptionHandler($prev); - } - - $handler->throwAt(E_ALL & $handler->thrownErrors, true); - - return $handler; - } - - public function __construct(BufferingLogger $bootstrappingLogger = null) - { - if ($bootstrappingLogger) { - $this->bootstrappingLogger = $bootstrappingLogger; - $this->setDefaultLogger($bootstrappingLogger); - } - $this->traceReflector = new \ReflectionProperty('Exception', 'trace'); - $this->traceReflector->setAccessible(true); - } - - /** - * Sets a logger to non assigned errors levels. - * - * @param LoggerInterface $logger A PSR-3 logger to put as default for the given levels - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants - * @param bool $replace Whether to replace or not any existing logger - */ - public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false) - { - $loggers = array(); - - if (is_array($levels)) { - foreach ($levels as $type => $logLevel) { - if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) { - $loggers[$type] = array($logger, $logLevel); - } - } - } else { - if (null === $levels) { - $levels = E_ALL; - } - foreach ($this->loggers as $type => $log) { - if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) { - $log[0] = $logger; - $loggers[$type] = $log; - } - } - } - - $this->setLoggers($loggers); - } - - /** - * Sets a logger for each error level. - * - * @param array $loggers Error levels to [LoggerInterface|null, LogLevel::*] map - * - * @return array The previous map - * - * @throws \InvalidArgumentException - */ - public function setLoggers(array $loggers) - { - $prevLogged = $this->loggedErrors; - $prev = $this->loggers; - $flush = array(); - - foreach ($loggers as $type => $log) { - if (!isset($prev[$type])) { - throw new \InvalidArgumentException('Unknown error type: '.$type); - } - if (!is_array($log)) { - $log = array($log); - } elseif (!array_key_exists(0, $log)) { - throw new \InvalidArgumentException('No logger provided'); - } - if (null === $log[0]) { - $this->loggedErrors &= ~$type; - } elseif ($log[0] instanceof LoggerInterface) { - $this->loggedErrors |= $type; - } else { - throw new \InvalidArgumentException('Invalid logger provided'); - } - $this->loggers[$type] = $log + $prev[$type]; - - if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) { - $flush[$type] = $type; - } - } - $this->reRegister($prevLogged | $this->thrownErrors); - - if ($flush) { - foreach ($this->bootstrappingLogger->cleanLogs() as $log) { - $type = $log[2]['exception'] instanceof \ErrorException ? $log[2]['exception']->getSeverity() : E_ERROR; - if (!isset($flush[$type])) { - $this->bootstrappingLogger->log($log[0], $log[1], $log[2]); - } elseif ($this->loggers[$type][0]) { - $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]); - } - } - } - - return $prev; - } - - /** - * Sets a user exception handler. - * - * @param callable $handler A handler that will be called on Exception - * - * @return callable|null The previous exception handler - */ - public function setExceptionHandler(callable $handler = null) - { - $prev = $this->exceptionHandler; - $this->exceptionHandler = $handler; - - return $prev; - } - - /** - * Sets the PHP error levels that throw an exception when a PHP error occurs. - * - * @param int $levels A bit field of E_* constants for thrown errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function throwAt($levels, $replace = false) - { - $prev = $this->thrownErrors; - $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; - if (!$replace) { - $this->thrownErrors |= $prev; - } - $this->reRegister($prev | $this->loggedErrors); - - return $prev; - } - - /** - * Sets the PHP error levels for which local variables are preserved. - * - * @param int $levels A bit field of E_* constants for scoped errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function scopeAt($levels, $replace = false) - { - $prev = $this->scopedErrors; - $this->scopedErrors = (int) $levels; - if (!$replace) { - $this->scopedErrors |= $prev; - } - - return $prev; - } - - /** - * Sets the PHP error levels for which the stack trace is preserved. - * - * @param int $levels A bit field of E_* constants for traced errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function traceAt($levels, $replace = false) - { - $prev = $this->tracedErrors; - $this->tracedErrors = (int) $levels; - if (!$replace) { - $this->tracedErrors |= $prev; - } - - return $prev; - } - - /** - * Sets the error levels where the @-operator is ignored. - * - * @param int $levels A bit field of E_* constants for screamed errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function screamAt($levels, $replace = false) - { - $prev = $this->screamedErrors; - $this->screamedErrors = (int) $levels; - if (!$replace) { - $this->screamedErrors |= $prev; - } - - return $prev; - } - - /** - * Re-registers as a PHP error handler if levels changed. - */ - private function reRegister($prev) - { - if ($prev !== $this->thrownErrors | $this->loggedErrors) { - $handler = set_error_handler('var_dump'); - $handler = is_array($handler) ? $handler[0] : null; - restore_error_handler(); - if ($handler === $this) { - restore_error_handler(); - if ($this->isRoot) { - set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors); - } else { - set_error_handler(array($this, 'handleError')); - } - } - } - } - - /** - * Handles errors by filtering then logging them according to the configured bit fields. - * - * @param int $type One of the E_* constants - * @param string $message - * @param string $file - * @param int $line - * - * @return bool Returns false when no handling happens so that the PHP engine can handle the error itself - * - * @throws \ErrorException When $this->thrownErrors requests so - * - * @internal - */ - public function handleError($type, $message, $file, $line) - { - // Level is the current error reporting level to manage silent error. - // Strong errors are not authorized to be silenced. - $level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED; - $log = $this->loggedErrors & $type; - $throw = $this->thrownErrors & $type & $level; - $type &= $level | $this->screamedErrors; - - if (!$type || (!$log && !$throw)) { - return $type && $log; - } - $scope = $this->scopedErrors & $type; - - if (4 < $numArgs = func_num_args()) { - $context = $scope ? (func_get_arg(4) ?: array()) : array(); - $backtrace = 5 < $numArgs ? func_get_arg(5) : null; // defined on HHVM - } else { - $context = array(); - $backtrace = null; - } - - if (isset($context['GLOBALS']) && $scope) { - $e = $context; // Whatever the signature of the method, - unset($e['GLOBALS'], $context); // $context is always a reference in 5.3 - $context = $e; - } - - if (null !== $backtrace && $type & E_ERROR) { - // E_ERROR fatal errors are triggered on HHVM when - // hhvm.error_handling.call_user_handler_on_fatals=1 - // which is the way to get their backtrace. - $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace')); - - return true; - } - - $logMessage = $this->levels[$type].': '.$message; - - if (null !== self::$toStringException) { - $errorAsException = self::$toStringException; - self::$toStringException = null; - } elseif (!$throw && !($type & $level)) { - if (!isset(self::$silencedErrorCache[$id = $file.':'.$line])) { - $lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3), $type, $file, $line, false) : array(); - $errorAsException = new SilencedErrorContext($type, $file, $line, $lightTrace); - } elseif (isset(self::$silencedErrorCache[$id][$message])) { - $lightTrace = null; - $errorAsException = self::$silencedErrorCache[$id][$message]; - ++$errorAsException->count; - } else { - $lightTrace = array(); - $errorAsException = null; - } - - if (100 < ++self::$silencedErrorCount) { - self::$silencedErrorCache = $lightTrace = array(); - self::$silencedErrorCount = 1; - } - if ($errorAsException) { - self::$silencedErrorCache[$id][$message] = $errorAsException; - } - if (null === $lightTrace) { - return; - } - } else { - if ($scope) { - $errorAsException = new ContextErrorException($logMessage, 0, $type, $file, $line, $context); - } else { - $errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line); - } - - // Clean the trace by removing function arguments and the first frames added by the error handler itself. - if ($throw || $this->tracedErrors & $type) { - $backtrace = $backtrace ?: $errorAsException->getTrace(); - $lightTrace = $this->cleanTrace($backtrace, $type, $file, $line, $throw); - $this->traceReflector->setValue($errorAsException, $lightTrace); - } else { - $this->traceReflector->setValue($errorAsException, array()); - } - } - - if ($throw) { - if (E_USER_ERROR & $type) { - for ($i = 1; isset($backtrace[$i]); ++$i) { - if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function']) - && '__toString' === $backtrace[$i]['function'] - && '->' === $backtrace[$i]['type'] - && !isset($backtrace[$i - 1]['class']) - && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function']) - ) { - // Here, we know trigger_error() has been called from __toString(). - // HHVM is fine with throwing from __toString() but PHP triggers a fatal error instead. - // A small convention allows working around the limitation: - // given a caught $e exception in __toString(), quitting the method with - // `return trigger_error($e, E_USER_ERROR);` allows this error handler - // to make $e get through the __toString() barrier. - - foreach ($context as $e) { - if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) { - if (1 === $i) { - // On HHVM - $errorAsException = $e; - break; - } - self::$toStringException = $e; - - return true; - } - } - - if (1 < $i) { - // On PHP (not on HHVM), display the original error message instead of the default one. - $this->handleException($errorAsException); - - // Stop the process by giving back the error to the native handler. - return false; - } - } - } - } - - throw $errorAsException; - } - - if ($this->isRecursive) { - $log = 0; - } elseif (self::$stackedErrorLevels) { - self::$stackedErrors[] = array( - $this->loggers[$type][0], - ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, - $logMessage, - $errorAsException ? array('exception' => $errorAsException) : array(), - ); - } else { - try { - $this->isRecursive = true; - $level = ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG; - $this->loggers[$type][0]->log($level, $logMessage, $errorAsException ? array('exception' => $errorAsException) : array()); - } finally { - $this->isRecursive = false; - } - } - - return $type && $log; - } - - /** - * Handles an exception by logging then forwarding it to another handler. - * - * @param \Exception|\Throwable $exception An exception to handle - * @param array $error An array as returned by error_get_last() - * - * @internal - */ - public function handleException($exception, array $error = null) - { - if (null === $error) { - self::$exitCode = 255; - } - if (!$exception instanceof \Exception) { - $exception = new FatalThrowableError($exception); - } - $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR; - $handlerException = null; - - if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) { - if ($exception instanceof FatalErrorException) { - if ($exception instanceof FatalThrowableError) { - $error = array( - 'type' => $type, - 'message' => $message = $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - ); - } else { - $message = 'Fatal '.$exception->getMessage(); - } - } elseif ($exception instanceof \ErrorException) { - $message = 'Uncaught '.$exception->getMessage(); - } else { - $message = 'Uncaught Exception: '.$exception->getMessage(); - } - } - if ($this->loggedErrors & $type) { - try { - $this->loggers[$type][0]->log($this->loggers[$type][1], $message, array('exception' => $exception)); - } catch (\Exception $handlerException) { - } catch (\Throwable $handlerException) { - } - } - if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) { - foreach ($this->getFatalErrorHandlers() as $handler) { - if ($e = $handler->handleError($error, $exception)) { - $exception = $e; - break; - } - } - } - try { - if (null !== $this->exceptionHandler) { - return \call_user_func($this->exceptionHandler, $exception); - } - $handlerException = $handlerException ?: $exception; - } catch (\Exception $handlerException) { - } catch (\Throwable $handlerException) { - } - $this->exceptionHandler = null; - if ($exception === $handlerException) { - self::$reservedMemory = null; // Disable the fatal error handler - throw $exception; // Give back $exception to the native handler - } - $this->handleException($handlerException); - } - - /** - * Shutdown registered function for handling PHP fatal errors. - * - * @param array $error An array as returned by error_get_last() - * - * @internal - */ - public static function handleFatalError(array $error = null) - { - if (null === self::$reservedMemory) { - return; - } - - $handler = self::$reservedMemory = null; - $handlers = array(); - $previousHandler = null; - $sameHandlerLimit = 10; - - while (!is_array($handler) || !$handler[0] instanceof self) { - $handler = set_exception_handler('var_dump'); - restore_exception_handler(); - - if (!$handler) { - break; - } - restore_exception_handler(); - - if ($handler !== $previousHandler) { - array_unshift($handlers, $handler); - $previousHandler = $handler; - } elseif (0 === --$sameHandlerLimit) { - $handler = null; - break; - } - } - foreach ($handlers as $h) { - set_exception_handler($h); - } - if (!$handler) { - return; - } - if ($handler !== $h) { - $handler[0]->setExceptionHandler($h); - } - $handler = $handler[0]; - $handlers = array(); - - if ($exit = null === $error) { - $error = error_get_last(); - } - - try { - while (self::$stackedErrorLevels) { - static::unstackErrors(); - } - } catch (\Exception $exception) { - // Handled below - } catch (\Throwable $exception) { - // Handled below - } - - if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) { - // Let's not throw anymore but keep logging - $handler->throwAt(0, true); - $trace = isset($error['backtrace']) ? $error['backtrace'] : null; - - if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) { - $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace); - } else { - $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace); - } - } - - try { - if (isset($exception)) { - self::$exitCode = 255; - $handler->handleException($exception, $error); - } - } catch (FatalErrorException $e) { - // Ignore this re-throw - } - - if ($exit && self::$exitCode) { - $exitCode = self::$exitCode; - register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); }); - } - } - - /** - * Configures the error handler for delayed handling. - * Ensures also that non-catchable fatal errors are never silenced. - * - * As shown by http://bugs.php.net/42098 and http://bugs.php.net/60724 - * PHP has a compile stage where it behaves unusually. To workaround it, - * we plug an error handler that only stacks errors for later. - * - * The most important feature of this is to prevent - * autoloading until unstackErrors() is called. - * - * @deprecated since version 3.4, to be removed in 4.0. - */ - public static function stackErrors() - { - @trigger_error('Support for stacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); - - self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); - } - - /** - * Unstacks stacked errors and forwards to the logger. - * - * @deprecated since version 3.4, to be removed in 4.0. - */ - public static function unstackErrors() - { - @trigger_error('Support for unstacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); - - $level = array_pop(self::$stackedErrorLevels); - - if (null !== $level) { - $errorReportingLevel = error_reporting($level); - if ($errorReportingLevel !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) { - // If the user changed the error level, do not overwrite it - error_reporting($errorReportingLevel); - } - } - - if (empty(self::$stackedErrorLevels)) { - $errors = self::$stackedErrors; - self::$stackedErrors = array(); - - foreach ($errors as $error) { - $error[0]->log($error[1], $error[2], $error[3]); - } - } - } - - /** - * Gets the fatal error handlers. - * - * Override this method if you want to define more fatal error handlers. - * - * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface - */ - protected function getFatalErrorHandlers() - { - return array( - new UndefinedFunctionFatalErrorHandler(), - new UndefinedMethodFatalErrorHandler(), - new ClassNotFoundFatalErrorHandler(), - ); - } - - private function cleanTrace($backtrace, $type, $file, $line, $throw) - { - $lightTrace = $backtrace; - - for ($i = 0; isset($backtrace[$i]); ++$i) { - if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { - $lightTrace = array_slice($lightTrace, 1 + $i); - break; - } - } - if (!($throw || $this->scopedErrors & $type)) { - for ($i = 0; isset($lightTrace[$i]); ++$i) { - unset($lightTrace[$i]['args'], $lightTrace[$i]['object']); - } - } - - return $lightTrace; - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/ClassNotFoundException.php b/lib/silex/vendor/symfony/debug/Exception/ClassNotFoundException.php deleted file mode 100644 index b91bf4663..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/ClassNotFoundException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Class (or Trait or Interface) Not Found Exception. - * - * @author Konstanton Myakshin - */ -class ClassNotFoundException extends FatalErrorException -{ - public function __construct($message, \ErrorException $previous) - { - parent::__construct( - $message, - $previous->getCode(), - $previous->getSeverity(), - $previous->getFile(), - $previous->getLine(), - $previous->getPrevious() - ); - $this->setTrace($previous->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/ContextErrorException.php b/lib/silex/vendor/symfony/debug/Exception/ContextErrorException.php deleted file mode 100644 index 554139da3..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/ContextErrorException.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Error Exception with Variable Context. - * - * @author Christian Sciberras - * - * @deprecated since version 3.3. Instead, \ErrorException will be used directly in 4.0. - */ -class ContextErrorException extends \ErrorException -{ - private $context = array(); - - public function __construct($message, $code, $severity, $filename, $lineno, $context = array()) - { - parent::__construct($message, $code, $severity, $filename, $lineno); - $this->context = $context; - } - - /** - * @return array Array of variables that existed when the exception occurred - */ - public function getContext() - { - @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED); - - return $this->context; - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/FatalErrorException.php b/lib/silex/vendor/symfony/debug/Exception/FatalErrorException.php deleted file mode 100644 index f24a54e77..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/FatalErrorException.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Fatal Error Exception. - * - * @author Konstanton Myakshin - */ -class FatalErrorException extends \ErrorException -{ - public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null) - { - parent::__construct($message, $code, $severity, $filename, $lineno); - - if (null !== $trace) { - if (!$traceArgs) { - foreach ($trace as &$frame) { - unset($frame['args'], $frame['this'], $frame); - } - } - - $this->setTrace($trace); - } elseif (null !== $traceOffset) { - if (function_exists('xdebug_get_function_stack')) { - $trace = xdebug_get_function_stack(); - if (0 < $traceOffset) { - array_splice($trace, -$traceOffset); - } - - foreach ($trace as &$frame) { - if (!isset($frame['type'])) { - // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 - if (isset($frame['class'])) { - $frame['type'] = '::'; - } - } elseif ('dynamic' === $frame['type']) { - $frame['type'] = '->'; - } elseif ('static' === $frame['type']) { - $frame['type'] = '::'; - } - - // XDebug also has a different name for the parameters array - if (!$traceArgs) { - unset($frame['params'], $frame['args']); - } elseif (isset($frame['params']) && !isset($frame['args'])) { - $frame['args'] = $frame['params']; - unset($frame['params']); - } - } - - unset($frame); - $trace = array_reverse($trace); - } elseif (function_exists('symfony_debug_backtrace')) { - $trace = symfony_debug_backtrace(); - if (0 < $traceOffset) { - array_splice($trace, 0, $traceOffset); - } - } else { - $trace = array(); - } - - $this->setTrace($trace); - } - } - - protected function setTrace($trace) - { - $traceReflector = new \ReflectionProperty('Exception', 'trace'); - $traceReflector->setAccessible(true); - $traceReflector->setValue($this, $trace); - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/FatalThrowableError.php b/lib/silex/vendor/symfony/debug/Exception/FatalThrowableError.php deleted file mode 100644 index 34f43b17b..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/FatalThrowableError.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Fatal Throwable Error. - * - * @author Nicolas Grekas - */ -class FatalThrowableError extends FatalErrorException -{ - public function __construct(\Throwable $e) - { - if ($e instanceof \ParseError) { - $message = 'Parse error: '.$e->getMessage(); - $severity = E_PARSE; - } elseif ($e instanceof \TypeError) { - $message = 'Type error: '.$e->getMessage(); - $severity = E_RECOVERABLE_ERROR; - } else { - $message = $e->getMessage(); - $severity = E_ERROR; - } - - \ErrorException::__construct( - $message, - $e->getCode(), - $severity, - $e->getFile(), - $e->getLine() - ); - - $this->setTrace($e->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/FlattenException.php b/lib/silex/vendor/symfony/debug/Exception/FlattenException.php deleted file mode 100644 index 24679dcaa..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/FlattenException.php +++ /dev/null @@ -1,263 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; - -/** - * FlattenException wraps a PHP Exception to be able to serialize it. - * - * Basically, this class removes all objects from the trace. - * - * @author Fabien Potencier - */ -class FlattenException -{ - private $message; - private $code; - private $previous; - private $trace; - private $class; - private $statusCode; - private $headers; - private $file; - private $line; - - public static function create(\Exception $exception, $statusCode = null, array $headers = array()) - { - $e = new static(); - $e->setMessage($exception->getMessage()); - $e->setCode($exception->getCode()); - - if ($exception instanceof HttpExceptionInterface) { - $statusCode = $exception->getStatusCode(); - $headers = array_merge($headers, $exception->getHeaders()); - } elseif ($exception instanceof RequestExceptionInterface) { - $statusCode = 400; - } - - if (null === $statusCode) { - $statusCode = 500; - } - - $e->setStatusCode($statusCode); - $e->setHeaders($headers); - $e->setTraceFromException($exception); - $e->setClass(get_class($exception)); - $e->setFile($exception->getFile()); - $e->setLine($exception->getLine()); - - $previous = $exception->getPrevious(); - - if ($previous instanceof \Exception) { - $e->setPrevious(static::create($previous)); - } elseif ($previous instanceof \Throwable) { - $e->setPrevious(static::create(new FatalThrowableError($previous))); - } - - return $e; - } - - public function toArray() - { - $exceptions = array(); - foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) { - $exceptions[] = array( - 'message' => $exception->getMessage(), - 'class' => $exception->getClass(), - 'trace' => $exception->getTrace(), - ); - } - - return $exceptions; - } - - public function getStatusCode() - { - return $this->statusCode; - } - - public function setStatusCode($code) - { - $this->statusCode = $code; - } - - public function getHeaders() - { - return $this->headers; - } - - public function setHeaders(array $headers) - { - $this->headers = $headers; - } - - public function getClass() - { - return $this->class; - } - - public function setClass($class) - { - $this->class = $class; - } - - public function getFile() - { - return $this->file; - } - - public function setFile($file) - { - $this->file = $file; - } - - public function getLine() - { - return $this->line; - } - - public function setLine($line) - { - $this->line = $line; - } - - public function getMessage() - { - return $this->message; - } - - public function setMessage($message) - { - $this->message = $message; - } - - public function getCode() - { - return $this->code; - } - - public function setCode($code) - { - $this->code = $code; - } - - public function getPrevious() - { - return $this->previous; - } - - public function setPrevious(FlattenException $previous) - { - $this->previous = $previous; - } - - public function getAllPrevious() - { - $exceptions = array(); - $e = $this; - while ($e = $e->getPrevious()) { - $exceptions[] = $e; - } - - return $exceptions; - } - - public function getTrace() - { - return $this->trace; - } - - public function setTraceFromException(\Exception $exception) - { - $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine()); - } - - public function setTrace($trace, $file, $line) - { - $this->trace = array(); - $this->trace[] = array( - 'namespace' => '', - 'short_class' => '', - 'class' => '', - 'type' => '', - 'function' => '', - 'file' => $file, - 'line' => $line, - 'args' => array(), - ); - foreach ($trace as $entry) { - $class = ''; - $namespace = ''; - if (isset($entry['class'])) { - $parts = explode('\\', $entry['class']); - $class = array_pop($parts); - $namespace = implode('\\', $parts); - } - - $this->trace[] = array( - 'namespace' => $namespace, - 'short_class' => $class, - 'class' => isset($entry['class']) ? $entry['class'] : '', - 'type' => isset($entry['type']) ? $entry['type'] : '', - 'function' => isset($entry['function']) ? $entry['function'] : null, - 'file' => isset($entry['file']) ? $entry['file'] : null, - 'line' => isset($entry['line']) ? $entry['line'] : null, - 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(), - ); - } - } - - private function flattenArgs($args, $level = 0, &$count = 0) - { - $result = array(); - foreach ($args as $key => $value) { - if (++$count > 1e4) { - return array('array', '*SKIPPED over 10000 entries*'); - } - if ($value instanceof \__PHP_Incomplete_Class) { - // is_object() returns false on PHP<=7.1 - $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value)); - } elseif (is_object($value)) { - $result[$key] = array('object', get_class($value)); - } elseif (is_array($value)) { - if ($level > 10) { - $result[$key] = array('array', '*DEEP NESTED ARRAY*'); - } else { - $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count)); - } - } elseif (null === $value) { - $result[$key] = array('null', null); - } elseif (is_bool($value)) { - $result[$key] = array('boolean', $value); - } elseif (is_int($value)) { - $result[$key] = array('integer', $value); - } elseif (is_float($value)) { - $result[$key] = array('float', $value); - } elseif (is_resource($value)) { - $result[$key] = array('resource', get_resource_type($value)); - } else { - $result[$key] = array('string', (string) $value); - } - } - - return $result; - } - - private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) - { - $array = new \ArrayObject($value); - - return $array['__PHP_Incomplete_Class_Name']; - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/OutOfMemoryException.php b/lib/silex/vendor/symfony/debug/Exception/OutOfMemoryException.php deleted file mode 100644 index fec197983..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/OutOfMemoryException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Out of memory exception. - * - * @author Nicolas Grekas - */ -class OutOfMemoryException extends FatalErrorException -{ -} diff --git a/lib/silex/vendor/symfony/debug/Exception/SilencedErrorContext.php b/lib/silex/vendor/symfony/debug/Exception/SilencedErrorContext.php deleted file mode 100644 index 4be83491b..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/SilencedErrorContext.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Data Object that represents a Silenced Error. - * - * @author Grégoire Pineau - */ -class SilencedErrorContext implements \JsonSerializable -{ - public $count = 1; - - private $severity; - private $file; - private $line; - private $trace; - - public function __construct($severity, $file, $line, array $trace = array(), $count = 1) - { - $this->severity = $severity; - $this->file = $file; - $this->line = $line; - $this->trace = $trace; - $this->count = $count; - } - - public function getSeverity() - { - return $this->severity; - } - - public function getFile() - { - return $this->file; - } - - public function getLine() - { - return $this->line; - } - - public function getTrace() - { - return $this->trace; - } - - public function JsonSerialize() - { - return array( - 'severity' => $this->severity, - 'file' => $this->file, - 'line' => $this->line, - 'trace' => $this->trace, - 'count' => $this->count, - ); - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/UndefinedFunctionException.php b/lib/silex/vendor/symfony/debug/Exception/UndefinedFunctionException.php deleted file mode 100644 index a66ae2a38..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/UndefinedFunctionException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Undefined Function Exception. - * - * @author Konstanton Myakshin - */ -class UndefinedFunctionException extends FatalErrorException -{ - public function __construct($message, \ErrorException $previous) - { - parent::__construct( - $message, - $previous->getCode(), - $previous->getSeverity(), - $previous->getFile(), - $previous->getLine(), - $previous->getPrevious() - ); - $this->setTrace($previous->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/Exception/UndefinedMethodException.php b/lib/silex/vendor/symfony/debug/Exception/UndefinedMethodException.php deleted file mode 100644 index 350dc3187..000000000 --- a/lib/silex/vendor/symfony/debug/Exception/UndefinedMethodException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Undefined Method Exception. - * - * @author Grégoire Pineau - */ -class UndefinedMethodException extends FatalErrorException -{ - public function __construct($message, \ErrorException $previous) - { - parent::__construct( - $message, - $previous->getCode(), - $previous->getSeverity(), - $previous->getFile(), - $previous->getLine(), - $previous->getPrevious() - ); - $this->setTrace($previous->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/ExceptionHandler.php b/lib/silex/vendor/symfony/debug/ExceptionHandler.php deleted file mode 100644 index 97470cb6b..000000000 --- a/lib/silex/vendor/symfony/debug/ExceptionHandler.php +++ /dev/null @@ -1,410 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\Debug\Exception\OutOfMemoryException; -use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; - -/** - * ExceptionHandler converts an exception to a Response object. - * - * It is mostly useful in debug mode to replace the default PHP/XDebug - * output with something prettier and more useful. - * - * As this class is mainly used during Kernel boot, where nothing is yet - * available, the Response content is always HTML. - * - * @author Fabien Potencier - * @author Nicolas Grekas - */ -class ExceptionHandler -{ - private $debug; - private $charset; - private $handler; - private $caughtBuffer; - private $caughtLength; - private $fileLinkFormat; - - public function __construct($debug = true, $charset = null, $fileLinkFormat = null) - { - $this->debug = $debug; - $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8'; - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - } - - /** - * Registers the exception handler. - * - * @param bool $debug Enable/disable debug mode, where the stack trace is displayed - * @param string|null $charset The charset used by exception messages - * @param string|null $fileLinkFormat The IDE link template - * - * @return static - */ - public static function register($debug = true, $charset = null, $fileLinkFormat = null) - { - $handler = new static($debug, $charset, $fileLinkFormat); - - $prev = set_exception_handler(array($handler, 'handle')); - if (is_array($prev) && $prev[0] instanceof ErrorHandler) { - restore_exception_handler(); - $prev[0]->setExceptionHandler(array($handler, 'handle')); - } - - return $handler; - } - - /** - * Sets a user exception handler. - * - * @param callable $handler An handler that will be called on Exception - * - * @return callable|null The previous exception handler if any - */ - public function setHandler(callable $handler = null) - { - $old = $this->handler; - $this->handler = $handler; - - return $old; - } - - /** - * Sets the format for links to source files. - * - * @param string|FileLinkFormatter $fileLinkFormat The format for links to source files - * - * @return string The previous file link format - */ - public function setFileLinkFormat($fileLinkFormat) - { - $old = $this->fileLinkFormat; - $this->fileLinkFormat = $fileLinkFormat; - - return $old; - } - - /** - * Sends a response for the given Exception. - * - * To be as fail-safe as possible, the exception is first handled - * by our simple exception handler, then by the user exception handler. - * The latter takes precedence and any output from the former is cancelled, - * if and only if nothing bad happens in this handling path. - */ - public function handle(\Exception $exception) - { - if (null === $this->handler || $exception instanceof OutOfMemoryException) { - $this->sendPhpResponse($exception); - - return; - } - - $caughtLength = $this->caughtLength = 0; - - ob_start(function ($buffer) { - $this->caughtBuffer = $buffer; - - return ''; - }); - - $this->sendPhpResponse($exception); - while (null === $this->caughtBuffer && ob_end_flush()) { - // Empty loop, everything is in the condition - } - if (isset($this->caughtBuffer[0])) { - ob_start(function ($buffer) { - if ($this->caughtLength) { - // use substr_replace() instead of substr() for mbstring overloading resistance - $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength); - if (isset($cleanBuffer[0])) { - $buffer = $cleanBuffer; - } - } - - return $buffer; - }); - - echo $this->caughtBuffer; - $caughtLength = ob_get_length(); - } - $this->caughtBuffer = null; - - try { - call_user_func($this->handler, $exception); - $this->caughtLength = $caughtLength; - } catch (\Exception $e) { - if (!$caughtLength) { - // All handlers failed. Let PHP handle that now. - throw $exception; - } - } - } - - /** - * Sends the error associated with the given Exception as a plain PHP response. - * - * This method uses plain PHP functions like header() and echo to output - * the response. - * - * @param \Exception|FlattenException $exception An \Exception or FlattenException instance - */ - public function sendPhpResponse($exception) - { - if (!$exception instanceof FlattenException) { - $exception = FlattenException::create($exception); - } - - if (!headers_sent()) { - header(sprintf('HTTP/1.0 %s', $exception->getStatusCode())); - foreach ($exception->getHeaders() as $name => $value) { - header($name.': '.$value, false); - } - header('Content-Type: text/html; charset='.$this->charset); - } - - echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception)); - } - - /** - * Gets the full HTML content associated with the given exception. - * - * @param \Exception|FlattenException $exception An \Exception or FlattenException instance - * - * @return string The HTML content as a string - */ - public function getHtml($exception) - { - if (!$exception instanceof FlattenException) { - $exception = FlattenException::create($exception); - } - - return $this->decorate($this->getContent($exception), $this->getStylesheet($exception)); - } - - /** - * Gets the HTML content associated with the given exception. - * - * @return string The content as a string - */ - public function getContent(FlattenException $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.'; - } - - $content = ''; - if ($this->debug) { - try { - $count = count($exception->getAllPrevious()); - $total = $count + 1; - foreach ($exception->toArray() as $position => $e) { - $ind = $count - $position + 1; - $class = $this->formatClass($e['class']); - $message = nl2br($this->escapeHtml($e['message'])); - $content .= sprintf(<<<'EOF' -
- - - -EOF - , $ind, $total, $class, $message); - foreach ($e['trace'] as $trace) { - $content .= '\n"; - } - - $content .= "\n
-

- (%d/%d) - %s -

-

%s

-
'; - if ($trace['function']) { - $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); - } - if (isset($trace['file']) && isset($trace['line'])) { - $content .= $this->formatPath($trace['file'], $trace['line']); - } - $content .= "
\n
\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($e), $this->escapeHtml($e->getMessage())); - } else { - $title = 'Whoops, looks like something went wrong.'; - } - } - } - - $symfonyGhostImageContents = $this->getSymfonyGhostAsSvg(); - - return << -
-
-

$title

-
$symfonyGhostImageContents
-
-
- - -
- $content -
-EOF; - } - - /** - * Gets the stylesheet associated with the given exception. - * - * @return string The stylesheet as a string - */ - public function getStylesheet(FlattenException $exception) - { - return <<<'EOF' - body { background-color: #F9F9F9; color: #222; font: 14px/1.4 Helvetica, Arial, sans-serif; margin: 0; padding-bottom: 45px; } - - a { cursor: pointer; text-decoration: none; } - a:hover { text-decoration: underline; } - abbr[title] { border-bottom: none; cursor: help; text-decoration: none; } - - code, pre { font: 13px/1.5 Consolas, Monaco, Menlo, "Ubuntu Mono", "Liberation Mono", monospace; } - - table, tr, th, td { background: #FFF; border-collapse: collapse; vertical-align: top; } - table { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; width: 100%; } - table th, table td { border: solid #E0E0E0; border-width: 1px 0; padding: 8px 10px; } - table th { background-color: #E0E0E0; font-weight: bold; text-align: left; } - - .hidden-xs-down { display: none; } - .block { display: block; } - .break-long-words { -ms-word-break: break-all; word-break: break-all; word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; } - .text-muted { color: #999; } - - .container { max-width: 1024px; margin: 0 auto; padding: 0 15px; } - .container::after { content: ""; display: table; clear: both; } - - .exception-summary { background: #B0413E; border-bottom: 2px solid rgba(0, 0, 0, 0.1); border-top: 1px solid rgba(0, 0, 0, .3); flex: 0 0 auto; margin-bottom: 30px; } - - .exception-message-wrapper { display: flex; align-items: center; min-height: 70px; } - .exception-message { flex-grow: 1; padding: 30px 0; } - .exception-message, .exception-message a { color: #FFF; font-size: 21px; font-weight: 400; margin: 0; } - .exception-message.long { font-size: 18px; } - .exception-message a { border-bottom: 1px solid rgba(255, 255, 255, 0.5); font-size: inherit; text-decoration: none; } - .exception-message a:hover { border-bottom-color: #ffffff; } - - .exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; } - - .trace + .trace { margin-top: 30px; } - .trace-head .trace-class { color: #222; font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; position: relative; } - - .trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; } - - .trace-file-path, .trace-file-path a { color: #222; margin-top: 3px; font-size: 13px; } - .trace-class { color: #B0413E; } - .trace-type { padding: 0 2px; } - .trace-method { color: #B0413E; font-weight: bold; } - .trace-arguments { color: #777; font-weight: normal; padding-left: 2px; } - - @media (min-width: 575px) { - .hidden-xs-down { display: initial; } - } -EOF; - } - - private function decorate($content, $css) - { - return << - - - - - - - - $content - - -EOF; - } - - private function formatClass($class) - { - $parts = explode('\\', $class); - - return sprintf('%s', $class, array_pop($parts)); - } - - private function formatPath($path, $line) - { - $file = $this->escapeHtml(preg_match('#[^/\\\\]*+$#', $path, $file) ? $file[0] : $path); - $fmt = $this->fileLinkFormat; - - if ($fmt && $link = is_string($fmt) ? strtr($fmt, array('%f' => $path, '%l' => $line)) : $fmt->format($path, $line)) { - return sprintf('in %s (line %d)', $this->escapeHtml($link), $file, $line); - } - - return sprintf('in %s (line %d)', $this->escapeHtml($path), $file, $line); - } - - /** - * Formats an array as a string. - * - * @param array $args The argument array - * - * @return string - */ - private function formatArgs(array $args) - { - $result = array(); - foreach ($args as $key => $item) { - if ('object' === $item[0]) { - $formattedValue = sprintf('object(%s)', $this->formatClass($item[1])); - } elseif ('array' === $item[0]) { - $formattedValue = sprintf('array(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); - } elseif ('null' === $item[0]) { - $formattedValue = 'null'; - } elseif ('boolean' === $item[0]) { - $formattedValue = ''.strtolower(var_export($item[1], true)).''; - } elseif ('resource' === $item[0]) { - $formattedValue = 'resource'; - } else { - $formattedValue = str_replace("\n", '', $this->escapeHtml(var_export($item[1], true))); - } - - $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue); - } - - return implode(', ', $result); - } - - /** - * HTML-encodes a string. - */ - private function escapeHtml($str) - { - return htmlspecialchars($str, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset); - } - - private function getSymfonyGhostAsSvg() - { - return ''; - } -} diff --git a/lib/silex/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/lib/silex/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php deleted file mode 100644 index 32ba9a09c..000000000 --- a/lib/silex/vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ /dev/null @@ -1,206 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\ClassNotFoundException; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\DebugClassLoader; -use Composer\Autoload\ClassLoader as ComposerClassLoader; -use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader; - -/** - * ErrorHandler for classes that do not exist. - * - * @author Fabien Potencier - */ -class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handleError(array $error, FatalErrorException $exception) - { - $messageLen = strlen($error['message']); - $notFoundSuffix = '\' not found'; - $notFoundSuffixLen = strlen($notFoundSuffix); - if ($notFoundSuffixLen > $messageLen) { - return; - } - - if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; - } - - foreach (array('class', 'interface', 'trait') as $typeName) { - $prefix = ucfirst($typeName).' \''; - $prefixLen = strlen($prefix); - if (0 !== strpos($error['message'], $prefix)) { - continue; - } - - $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); - if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) { - $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1); - $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex); - $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix); - $tail = ' for another namespace?'; - } else { - $className = $fullyQualifiedClassName; - $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className); - $tail = '?'; - } - - if ($candidates = $this->getClassCandidates($className)) { - $tail = array_pop($candidates).'"?'; - if ($candidates) { - $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail; - } else { - $tail = ' for "'.$tail; - } - } - $message .= "\nDid you forget a \"use\" statement".$tail; - - return new ClassNotFoundException($message, $exception); - } - } - - /** - * Tries to guess the full namespace for a given class name. - * - * By default, it looks for PSR-0 and PSR-4 classes registered via a Symfony or a Composer - * autoloader (that should cover all common cases). - * - * @param string $class A class name (without its namespace) - * - * @return array An array of possible fully qualified class names - */ - private function getClassCandidates($class) - { - if (!is_array($functions = spl_autoload_functions())) { - return array(); - } - - // find Symfony and Composer autoloaders - $classes = array(); - - foreach ($functions as $function) { - if (!is_array($function)) { - continue; - } - // get class loaders wrapped by DebugClassLoader - if ($function[0] instanceof DebugClassLoader) { - $function = $function[0]->getClassLoader(); - - if (!is_array($function)) { - continue; - } - } - - if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader) { - foreach ($function[0]->getPrefixes() as $prefix => $paths) { - foreach ($paths as $path) { - $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix)); - } - } - } - if ($function[0] instanceof ComposerClassLoader) { - foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) { - foreach ($paths as $path) { - $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix)); - } - } - } - } - - return array_unique($classes); - } - - /** - * @param string $path - * @param string $class - * @param string $prefix - * - * @return array - */ - private function findClassInPath($path, $class, $prefix) - { - if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) { - return array(); - } - - $classes = array(); - $filename = $class.'.php'; - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) { - $classes[] = $class; - } - } - - return $classes; - } - - /** - * @param string $path - * @param string $file - * @param string $prefix - * - * @return string|null - */ - private function convertFileToClass($path, $file, $prefix) - { - $candidates = array( - // namespaced class - $namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file), - // namespaced class (with target dir) - $prefix.$namespacedClass, - // namespaced class (with target dir and separator) - $prefix.'\\'.$namespacedClass, - // PEAR class - str_replace('\\', '_', $namespacedClass), - // PEAR class (with target dir) - str_replace('\\', '_', $prefix.$namespacedClass), - // PEAR class (with target dir and separator) - str_replace('\\', '_', $prefix.'\\'.$namespacedClass), - ); - - if ($prefix) { - $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); }); - } - - // We cannot use the autoloader here as most of them use require; but if the class - // is not found, the new autoloader call will require the file again leading to a - // "cannot redeclare class" error. - foreach ($candidates as $candidate) { - if ($this->classExists($candidate)) { - return $candidate; - } - } - - require_once $file; - - foreach ($candidates as $candidate) { - if ($this->classExists($candidate)) { - return $candidate; - } - } - } - - /** - * @param string $class - * - * @return bool - */ - private function classExists($class) - { - return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); - } -} diff --git a/lib/silex/vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php b/lib/silex/vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php deleted file mode 100644 index 6b87eb30a..000000000 --- a/lib/silex/vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\FatalErrorException; - -/** - * Attempts to convert fatal errors to exceptions. - * - * @author Fabien Potencier - */ -interface FatalErrorHandlerInterface -{ - /** - * Attempts to convert an error into an exception. - * - * @param array $error An array as returned by error_get_last() - * @param FatalErrorException $exception A FatalErrorException instance - * - * @return FatalErrorException|null A FatalErrorException instance if the class is able to convert the error, null otherwise - */ - public function handleError(array $error, FatalErrorException $exception); -} diff --git a/lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php deleted file mode 100644 index c6f391a79..000000000 --- a/lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\UndefinedFunctionException; -use Symfony\Component\Debug\Exception\FatalErrorException; - -/** - * ErrorHandler for undefined functions. - * - * @author Fabien Potencier - */ -class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handleError(array $error, FatalErrorException $exception) - { - $messageLen = strlen($error['message']); - $notFoundSuffix = '()'; - $notFoundSuffixLen = strlen($notFoundSuffix); - if ($notFoundSuffixLen > $messageLen) { - return; - } - - if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; - } - - $prefix = 'Call to undefined function '; - $prefixLen = strlen($prefix); - if (0 !== strpos($error['message'], $prefix)) { - return; - } - - $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); - if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) { - $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1); - $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex); - $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix); - } else { - $functionName = $fullyQualifiedFunctionName; - $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName); - } - - $candidates = array(); - foreach (get_defined_functions() as $type => $definedFunctionNames) { - foreach ($definedFunctionNames as $definedFunctionName) { - if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) { - $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1); - } else { - $definedFunctionNameBasename = $definedFunctionName; - } - - if ($definedFunctionNameBasename === $functionName) { - $candidates[] = '\\'.$definedFunctionName; - } - } - } - - if ($candidates) { - sort($candidates); - $last = array_pop($candidates).'"?'; - if ($candidates) { - $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last; - } else { - $candidates = '"'.$last; - } - $message .= "\nDid you mean to call ".$candidates; - } - - return new UndefinedFunctionException($message, $exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php deleted file mode 100644 index 6fa62b6f2..000000000 --- a/lib/silex/vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\Exception\UndefinedMethodException; - -/** - * ErrorHandler for undefined methods. - * - * @author Grégoire Pineau - */ -class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handleError(array $error, FatalErrorException $exception) - { - preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches); - if (!$matches) { - return; - } - - $className = $matches[1]; - $methodName = $matches[2]; - - $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className); - - if (!class_exists($className) || null === $methods = get_class_methods($className)) { - // failed to get the class or its methods on which an unknown method was called (for example on an anonymous class) - return new UndefinedMethodException($message, $exception); - } - - $candidates = array(); - foreach ($methods as $definedMethodName) { - $lev = levenshtein($methodName, $definedMethodName); - if ($lev <= strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) { - $candidates[] = $definedMethodName; - } - } - - if ($candidates) { - sort($candidates); - $last = array_pop($candidates).'"?'; - if ($candidates) { - $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last; - } else { - $candidates = '"'.$last; - } - - $message .= "\nDid you mean to call ".$candidates; - } - - return new UndefinedMethodException($message, $exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/LICENSE b/lib/silex/vendor/symfony/debug/LICENSE deleted file mode 100644 index 21d7fb9e2..000000000 --- a/lib/silex/vendor/symfony/debug/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2018 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/debug/README.md b/lib/silex/vendor/symfony/debug/README.md deleted file mode 100644 index a1d16175c..000000000 --- a/lib/silex/vendor/symfony/debug/README.md +++ /dev/null @@ -1,13 +0,0 @@ -Debug Component -=============== - -The Debug component provides tools to ease debugging PHP code. - -Resources ---------- - - * [Documentation](https://symfony.com/doc/current/components/debug/index.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/README.md b/lib/silex/vendor/symfony/debug/Resources/ext/README.md deleted file mode 100644 index 25dccf076..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/README.md +++ /dev/null @@ -1,134 +0,0 @@ -Symfony Debug Extension for PHP 5 -================================= - -This extension publishes several functions to help building powerful debugging tools. -It is compatible with PHP 5.3, 5.4, 5.5 and 5.6; with ZTS and non-ZTS modes. -It is not required thus not provided for PHP 7. - -symfony_zval_info() -------------------- - -- exposes zval_hash/refcounts, allowing e.g. efficient exploration of arbitrary structures in PHP, -- does work with references, preventing memory copying. - -Its behavior is about the same as: - -```php - gettype($array[$key]), - 'zval_hash' => /* hashed memory address of $array[$key] */, - 'zval_refcount' => /* internal zval refcount of $array[$key] */, - 'zval_isref' => /* is_ref status of $array[$key] */, - ); - - switch ($info['type']) { - case 'object': - $info += array( - 'object_class' => get_class($array[$key]), - 'object_refcount' => /* internal object refcount of $array[$key] */, - 'object_hash' => spl_object_hash($array[$key]), - 'object_handle' => /* internal object handle $array[$key] */, - ); - break; - - case 'resource': - $info += array( - 'resource_handle' => (int) $array[$key], - 'resource_type' => get_resource_type($array[$key]), - 'resource_refcount' => /* internal resource refcount of $array[$key] */, - ); - break; - - case 'array': - $info += array( - 'array_count' => count($array[$key]), - ); - break; - - case 'string': - $info += array( - 'strlen' => strlen($array[$key]), - ); - break; - } - - return $info; -} -``` - -symfony_debug_backtrace() -------------------------- - -This function works like debug_backtrace(), except that it can fetch the full backtrace in case of fatal errors: - -```php -function foo() { fatal(); } -function bar() { foo(); } - -function sd() { var_dump(symfony_debug_backtrace()); } - -register_shutdown_function('sd'); - -bar(); - -/* Will output -Fatal error: Call to undefined function fatal() in foo.php on line 42 -array(3) { - [0]=> - array(2) { - ["function"]=> - string(2) "sd" - ["args"]=> - array(0) { - } - } - [1]=> - array(4) { - ["file"]=> - string(7) "foo.php" - ["line"]=> - int(1) - ["function"]=> - string(3) "foo" - ["args"]=> - array(0) { - } - } - [2]=> - array(4) { - ["file"]=> - string(102) "foo.php" - ["line"]=> - int(2) - ["function"]=> - string(3) "bar" - ["args"]=> - array(0) { - } - } -} -*/ -``` - -Usage ------ - -To enable the extension from source, run: - -``` - phpize - ./configure - make - sudo make install -``` diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/config.m4 b/lib/silex/vendor/symfony/debug/Resources/ext/config.m4 deleted file mode 100644 index 3c5604715..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/config.m4 +++ /dev/null @@ -1,63 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension symfony_debug - -dnl Comments in this file start with the string 'dnl'. -dnl Remove where necessary. This file will not work -dnl without editing. - -dnl If your extension references something external, use with: - -dnl PHP_ARG_WITH(symfony_debug, for symfony_debug support, -dnl Make sure that the comment is aligned: -dnl [ --with-symfony_debug Include symfony_debug support]) - -dnl Otherwise use enable: - -PHP_ARG_ENABLE(symfony_debug, whether to enable symfony_debug support, -dnl Make sure that the comment is aligned: -[ --enable-symfony_debug Enable symfony_debug support]) - -if test "$PHP_SYMFONY_DEBUG" != "no"; then - dnl Write more examples of tests here... - - dnl # --with-symfony_debug -> check with-path - dnl SEARCH_PATH="/usr/local /usr" # you might want to change this - dnl SEARCH_FOR="/include/symfony_debug.h" # you most likely want to change this - dnl if test -r $PHP_SYMFONY_DEBUG/$SEARCH_FOR; then # path given as parameter - dnl SYMFONY_DEBUG_DIR=$PHP_SYMFONY_DEBUG - dnl else # search default path list - dnl AC_MSG_CHECKING([for symfony_debug files in default path]) - dnl for i in $SEARCH_PATH ; do - dnl if test -r $i/$SEARCH_FOR; then - dnl SYMFONY_DEBUG_DIR=$i - dnl AC_MSG_RESULT(found in $i) - dnl fi - dnl done - dnl fi - dnl - dnl if test -z "$SYMFONY_DEBUG_DIR"; then - dnl AC_MSG_RESULT([not found]) - dnl AC_MSG_ERROR([Please reinstall the symfony_debug distribution]) - dnl fi - - dnl # --with-symfony_debug -> add include path - dnl PHP_ADD_INCLUDE($SYMFONY_DEBUG_DIR/include) - - dnl # --with-symfony_debug -> check for lib and symbol presence - dnl LIBNAME=symfony_debug # you may want to change this - dnl LIBSYMBOL=symfony_debug # you most likely want to change this - - dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, - dnl [ - dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $SYMFONY_DEBUG_DIR/lib, SYMFONY_DEBUG_SHARED_LIBADD) - dnl AC_DEFINE(HAVE_SYMFONY_DEBUGLIB,1,[ ]) - dnl ],[ - dnl AC_MSG_ERROR([wrong symfony_debug lib version or lib not found]) - dnl ],[ - dnl -L$SYMFONY_DEBUG_DIR/lib -lm - dnl ]) - dnl - dnl PHP_SUBST(SYMFONY_DEBUG_SHARED_LIBADD) - - PHP_NEW_EXTENSION(symfony_debug, symfony_debug.c, $ext_shared) -fi diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/config.w32 b/lib/silex/vendor/symfony/debug/Resources/ext/config.w32 deleted file mode 100644 index 487e69138..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/config.w32 +++ /dev/null @@ -1,13 +0,0 @@ -// $Id$ -// vim:ft=javascript - -// If your extension references something external, use ARG_WITH -// ARG_WITH("symfony_debug", "for symfony_debug support", "no"); - -// Otherwise, use ARG_ENABLE -// ARG_ENABLE("symfony_debug", "enable symfony_debug support", "no"); - -if (PHP_SYMFONY_DEBUG != "no") { - EXTENSION("symfony_debug", "symfony_debug.c"); -} - diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/php_symfony_debug.h b/lib/silex/vendor/symfony/debug/Resources/ext/php_symfony_debug.h deleted file mode 100644 index 26d0e8c01..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/php_symfony_debug.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#ifndef PHP_SYMFONY_DEBUG_H -#define PHP_SYMFONY_DEBUG_H - -extern zend_module_entry symfony_debug_module_entry; -#define phpext_symfony_debug_ptr &symfony_debug_module_entry - -#define PHP_SYMFONY_DEBUG_VERSION "2.7" - -#ifdef PHP_WIN32 -# define PHP_SYMFONY_DEBUG_API __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -# define PHP_SYMFONY_DEBUG_API __attribute__ ((visibility("default"))) -#else -# define PHP_SYMFONY_DEBUG_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -ZEND_BEGIN_MODULE_GLOBALS(symfony_debug) - intptr_t req_rand_init; - void (*old_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); - zval *debug_bt; -ZEND_END_MODULE_GLOBALS(symfony_debug) - -PHP_MINIT_FUNCTION(symfony_debug); -PHP_MSHUTDOWN_FUNCTION(symfony_debug); -PHP_RINIT_FUNCTION(symfony_debug); -PHP_RSHUTDOWN_FUNCTION(symfony_debug); -PHP_MINFO_FUNCTION(symfony_debug); -PHP_GINIT_FUNCTION(symfony_debug); -PHP_GSHUTDOWN_FUNCTION(symfony_debug); - -PHP_FUNCTION(symfony_zval_info); -PHP_FUNCTION(symfony_debug_backtrace); - -static char *_symfony_debug_memory_address_hash(void * TSRMLS_DC); -static const char *_symfony_debug_zval_type(zval *); -static const char* _symfony_debug_get_resource_type(long TSRMLS_DC); -static int _symfony_debug_get_resource_refcount(long TSRMLS_DC); - -void symfony_debug_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); - -#ifdef ZTS -#define SYMFONY_DEBUG_G(v) TSRMG(symfony_debug_globals_id, zend_symfony_debug_globals *, v) -#else -#define SYMFONY_DEBUG_G(v) (symfony_debug_globals.v) -#endif - -#endif /* PHP_SYMFONY_DEBUG_H */ diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/symfony_debug.c b/lib/silex/vendor/symfony/debug/Resources/ext/symfony_debug.c deleted file mode 100644 index 0d7cb6023..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/symfony_debug.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#ifdef ZTS -#include "TSRM.h" -#endif -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_symfony_debug.h" -#include "ext/standard/php_rand.h" -#include "ext/standard/php_lcg.h" -#include "ext/spl/php_spl.h" -#include "Zend/zend_gc.h" -#include "Zend/zend_builtin_functions.h" -#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */ -#include "ext/standard/php_array.h" -#include "Zend/zend_interfaces.h" -#include "SAPI.h" - -#define IS_PHP_53 ZEND_EXTENSION_API_NO == 220090626 - -ZEND_DECLARE_MODULE_GLOBALS(symfony_debug) - -ZEND_BEGIN_ARG_INFO_EX(symfony_zval_arginfo, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_ARRAY_INFO(0, array, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -const zend_function_entry symfony_debug_functions[] = { - PHP_FE(symfony_zval_info, symfony_zval_arginfo) - PHP_FE(symfony_debug_backtrace, NULL) - PHP_FE_END -}; - -PHP_FUNCTION(symfony_debug_backtrace) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } -#if IS_PHP_53 - zend_fetch_debug_backtrace(return_value, 1, 0 TSRMLS_CC); -#else - zend_fetch_debug_backtrace(return_value, 1, 0, 0 TSRMLS_CC); -#endif - - if (!SYMFONY_DEBUG_G(debug_bt)) { - return; - } - - php_array_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_P(SYMFONY_DEBUG_G(debug_bt)), 0 TSRMLS_CC); -} - -PHP_FUNCTION(symfony_zval_info) -{ - zval *key = NULL, *arg = NULL; - zval **data = NULL; - HashTable *array = NULL; - long options = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zh|l", &key, &array, &options) == FAILURE) { - return; - } - - switch (Z_TYPE_P(key)) { - case IS_STRING: - if (zend_symtable_find(array, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&data) == FAILURE) { - return; - } - break; - case IS_LONG: - if (zend_hash_index_find(array, Z_LVAL_P(key), (void **)&data)) { - return; - } - break; - } - - arg = *data; - - array_init(return_value); - - add_assoc_string(return_value, "type", (char *)_symfony_debug_zval_type(arg), 1); - add_assoc_stringl(return_value, "zval_hash", _symfony_debug_memory_address_hash((void *)arg TSRMLS_CC), 16, 0); - add_assoc_long(return_value, "zval_refcount", Z_REFCOUNT_P(arg)); - add_assoc_bool(return_value, "zval_isref", (zend_bool)Z_ISREF_P(arg)); - - if (Z_TYPE_P(arg) == IS_OBJECT) { - char hash[33] = {0}; - - php_spl_object_hash(arg, (char *)hash TSRMLS_CC); - add_assoc_stringl(return_value, "object_class", (char *)Z_OBJCE_P(arg)->name, Z_OBJCE_P(arg)->name_length, 1); - add_assoc_long(return_value, "object_refcount", EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(arg)].bucket.obj.refcount); - add_assoc_string(return_value, "object_hash", hash, 1); - add_assoc_long(return_value, "object_handle", Z_OBJ_HANDLE_P(arg)); - } else if (Z_TYPE_P(arg) == IS_ARRAY) { - add_assoc_long(return_value, "array_count", zend_hash_num_elements(Z_ARRVAL_P(arg))); - } else if(Z_TYPE_P(arg) == IS_RESOURCE) { - add_assoc_long(return_value, "resource_handle", Z_LVAL_P(arg)); - add_assoc_string(return_value, "resource_type", (char *)_symfony_debug_get_resource_type(Z_LVAL_P(arg) TSRMLS_CC), 1); - add_assoc_long(return_value, "resource_refcount", _symfony_debug_get_resource_refcount(Z_LVAL_P(arg) TSRMLS_CC)); - } else if (Z_TYPE_P(arg) == IS_STRING) { - add_assoc_long(return_value, "strlen", Z_STRLEN_P(arg)); - } -} - -void symfony_debug_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) -{ - TSRMLS_FETCH(); - zval *retval; - - switch (type) { - case E_ERROR: - case E_PARSE: - case E_CORE_ERROR: - case E_CORE_WARNING: - case E_COMPILE_ERROR: - case E_COMPILE_WARNING: - ALLOC_INIT_ZVAL(retval); -#if IS_PHP_53 - zend_fetch_debug_backtrace(retval, 1, 0 TSRMLS_CC); -#else - zend_fetch_debug_backtrace(retval, 1, 0, 0 TSRMLS_CC); -#endif - SYMFONY_DEBUG_G(debug_bt) = retval; - } - - SYMFONY_DEBUG_G(old_error_cb)(type, error_filename, error_lineno, format, args); -} - -static const char* _symfony_debug_get_resource_type(long rsid TSRMLS_DC) -{ - const char *res_type; - res_type = zend_rsrc_list_get_rsrc_type(rsid TSRMLS_CC); - - if (!res_type) { - return "Unknown"; - } - - return res_type; -} - -static int _symfony_debug_get_resource_refcount(long rsid TSRMLS_DC) -{ - zend_rsrc_list_entry *le; - - if (zend_hash_index_find(&EG(regular_list), rsid, (void **) &le)==SUCCESS) { - return le->refcount; - } - - return 0; -} - -static char *_symfony_debug_memory_address_hash(void *address TSRMLS_DC) -{ - char *result = NULL; - intptr_t address_rand; - - if (!SYMFONY_DEBUG_G(req_rand_init)) { - if (!BG(mt_rand_is_seeded)) { - php_mt_srand(GENERATE_SEED() TSRMLS_CC); - } - SYMFONY_DEBUG_G(req_rand_init) = (intptr_t)php_mt_rand(TSRMLS_C); - } - - address_rand = (intptr_t)address ^ SYMFONY_DEBUG_G(req_rand_init); - - spprintf(&result, 17, "%016zx", address_rand); - - return result; -} - -static const char *_symfony_debug_zval_type(zval *zv) -{ - switch (Z_TYPE_P(zv)) { - case IS_NULL: - return "NULL"; - break; - - case IS_BOOL: - return "boolean"; - break; - - case IS_LONG: - return "integer"; - break; - - case IS_DOUBLE: - return "double"; - break; - - case IS_STRING: - return "string"; - break; - - case IS_ARRAY: - return "array"; - break; - - case IS_OBJECT: - return "object"; - - case IS_RESOURCE: - return "resource"; - - default: - return "unknown type"; - } -} - -zend_module_entry symfony_debug_module_entry = { - STANDARD_MODULE_HEADER, - "symfony_debug", - symfony_debug_functions, - PHP_MINIT(symfony_debug), - PHP_MSHUTDOWN(symfony_debug), - PHP_RINIT(symfony_debug), - PHP_RSHUTDOWN(symfony_debug), - PHP_MINFO(symfony_debug), - PHP_SYMFONY_DEBUG_VERSION, - PHP_MODULE_GLOBALS(symfony_debug), - PHP_GINIT(symfony_debug), - PHP_GSHUTDOWN(symfony_debug), - NULL, - STANDARD_MODULE_PROPERTIES_EX -}; - -#ifdef COMPILE_DL_SYMFONY_DEBUG -ZEND_GET_MODULE(symfony_debug) -#endif - -PHP_GINIT_FUNCTION(symfony_debug) -{ - memset(symfony_debug_globals, 0 , sizeof(*symfony_debug_globals)); -} - -PHP_GSHUTDOWN_FUNCTION(symfony_debug) -{ - -} - -PHP_MINIT_FUNCTION(symfony_debug) -{ - SYMFONY_DEBUG_G(old_error_cb) = zend_error_cb; - zend_error_cb = symfony_debug_error_cb; - - return SUCCESS; -} - -PHP_MSHUTDOWN_FUNCTION(symfony_debug) -{ - zend_error_cb = SYMFONY_DEBUG_G(old_error_cb); - - return SUCCESS; -} - -PHP_RINIT_FUNCTION(symfony_debug) -{ - return SUCCESS; -} - -PHP_RSHUTDOWN_FUNCTION(symfony_debug) -{ - return SUCCESS; -} - -PHP_MINFO_FUNCTION(symfony_debug) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "Symfony Debug support", "enabled"); - php_info_print_table_header(2, "Symfony Debug version", PHP_SYMFONY_DEBUG_VERSION); - php_info_print_table_end(); -} diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/tests/001.phpt b/lib/silex/vendor/symfony/debug/Resources/ext/tests/001.phpt deleted file mode 100644 index 4a87cd318..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/tests/001.phpt +++ /dev/null @@ -1,155 +0,0 @@ ---TEST-- -Test symfony_zval_info API ---SKIPIF-- - ---FILE-- - $int, - 'float' => $float, - 'str' => $str, - 'object' => $object, - 'array' => $array, - 'resource' => $resource, - 'null' => $null, - 'bool' => $bool, - 'refcount' => &$refcount2, -); - -var_dump(symfony_zval_info('int', $var)); -var_dump(symfony_zval_info('float', $var)); -var_dump(symfony_zval_info('str', $var)); -var_dump(symfony_zval_info('object', $var)); -var_dump(symfony_zval_info('array', $var)); -var_dump(symfony_zval_info('resource', $var)); -var_dump(symfony_zval_info('null', $var)); -var_dump(symfony_zval_info('bool', $var)); - -var_dump(symfony_zval_info('refcount', $var)); -var_dump(symfony_zval_info('not-exist', $var)); -?> ---EXPECTF-- -array(4) { - ["type"]=> - string(7) "integer" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(4) { - ["type"]=> - string(6) "double" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(5) { - ["type"]=> - string(6) "string" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["strlen"]=> - int(6) -} -array(8) { - ["type"]=> - string(6) "object" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["object_class"]=> - string(8) "stdClass" - ["object_refcount"]=> - int(1) - ["object_hash"]=> - string(32) "%s" - ["object_handle"]=> - int(%d) -} -array(5) { - ["type"]=> - string(5) "array" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["array_count"]=> - int(2) -} -array(7) { - ["type"]=> - string(8) "resource" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["resource_handle"]=> - int(%d) - ["resource_type"]=> - string(6) "stream" - ["resource_refcount"]=> - int(1) -} -array(4) { - ["type"]=> - string(4) "NULL" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(4) { - ["type"]=> - string(7) "boolean" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(4) { - ["type"]=> - string(7) "integer" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(3) - ["zval_isref"]=> - bool(true) -} -NULL diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/tests/002.phpt b/lib/silex/vendor/symfony/debug/Resources/ext/tests/002.phpt deleted file mode 100644 index afc7bb490..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/tests/002.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -Test symfony_debug_backtrace in case of fatal error ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -Fatal error: Call to undefined function notexist() in %s on line %d -Array -( - [0] => Array - ( - [function] => bt - [args] => Array - ( - ) - - ) - - [1] => Array - ( - [file] => %s - [line] => %d - [function] => foo - [args] => Array - ( - ) - - ) - - [2] => Array - ( - [file] => %s - [line] => %d - [function] => bar - [args] => Array - ( - ) - - ) - -) diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/tests/002_1.phpt b/lib/silex/vendor/symfony/debug/Resources/ext/tests/002_1.phpt deleted file mode 100644 index 86de3e177..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/tests/002_1.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Test symfony_debug_backtrace in case of non fatal error ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -Array -( - [0] => Array - ( - [file] => %s - [line] => %d - [function] => bt - [args] => Array - ( - ) - - ) - - [1] => Array - ( - [file] => %s - [line] => %d - [function] => bar - [args] => Array - ( - ) - - ) - -) diff --git a/lib/silex/vendor/symfony/debug/Resources/ext/tests/003.phpt b/lib/silex/vendor/symfony/debug/Resources/ext/tests/003.phpt deleted file mode 100644 index ce3c4e0ab..000000000 --- a/lib/silex/vendor/symfony/debug/Resources/ext/tests/003.phpt +++ /dev/null @@ -1,87 +0,0 @@ ---TEST-- -Test ErrorHandler in case of fatal error ---SKIPIF-- - ---FILE-- -setExceptionHandler('print_r'); - -if (function_exists('xdebug_disable')) { - xdebug_disable(); -} - -bar(); -?> ---EXPECTF-- -Fatal error: Call to undefined function Symfony\Component\Debug\notexist() in %s on line %d -Symfony\Component\Debug\Exception\UndefinedFunctionException Object -( - [message:protected] => Attempted to call function "notexist" from namespace "Symfony\Component\Debug". - [string:Exception:private] => - [code:protected] => 0 - [file:protected] => %s - [line:protected] => %d - [trace:Exception:private] => Array - ( - [0] => Array - ( -%A [function] => Symfony\Component\Debug\foo -%A [args] => Array - ( - ) - - ) - - [1] => Array - ( -%A [function] => Symfony\Component\Debug\bar -%A [args] => Array - ( - ) - - ) -%A - ) - - [previous:Exception:private] => - [severity:protected] => 1 -) diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/.gitignore b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md deleted file mode 100644 index ff7c6af2b..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -CHANGELOG -========= - -2.6.0 ------ - -* generalized ErrorHandler and ExceptionHandler, - with some new methods and others deprecated -* enhanced error messages for uncaught exceptions - -2.5.0 ------ - -* added ExceptionHandler::setHandler() -* added UndefinedMethodFatalErrorHandler -* deprecated DummyException - -2.4.0 ------ - - * added a DebugClassLoader able to wrap any autoloader providing a findFile method - * improved error messages for not found classes and functions - -2.3.0 ------ - - * added the component diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Debug.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Debug.php deleted file mode 100644 index 08b35f48b..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Debug.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -/** - * Registers all the debug tools. - * - * @author Fabien Potencier - */ -class Debug -{ - private static $enabled = false; - - /** - * Enables the debug tools. - * - * This method registers an error handler and an exception handler. - * - * If the Symfony ClassLoader component is available, a special - * class loader is also registered. - * - * @param int $errorReportingLevel The level of error reporting you want - * @param bool $displayErrors Whether to display errors (for development) or just log them (for production) - */ - public static function enable($errorReportingLevel = null, $displayErrors = true) - { - if (static::$enabled) { - return; - } - - static::$enabled = true; - - if (null !== $errorReportingLevel) { - error_reporting($errorReportingLevel); - } else { - error_reporting(-1); - } - - if ('cli' !== php_sapi_name()) { - ini_set('display_errors', 0); - ExceptionHandler::register(); - } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { - // CLI - display errors only if they're not already logged to STDERR - ini_set('display_errors', 1); - } - $handler = ErrorHandler::register(); - if (!$displayErrors) { - $handler->throwAt(0, true); - } - - DebugClassLoader::enable(); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php deleted file mode 100644 index a82f101b2..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php +++ /dev/null @@ -1,224 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -/** - * Autoloader checking if the class is really defined in the file found. - * - * The ClassLoader will wrap all registered autoloaders - * and will throw an exception if a file is found but does - * not declare the class. - * - * @author Fabien Potencier - * @author Christophe Coevoet - * @author Nicolas Grekas - * - * @api - */ -class DebugClassLoader -{ - private $classLoader; - private $isFinder; - private $wasFinder; - private static $caseCheck; - - /** - * Constructor. - * - * @param callable|object $classLoader - * - * @api - * - * @deprecated since 2.5, passing an object is deprecated and support for it will be removed in 3.0 - */ - public function __construct($classLoader) - { - $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile'); - - if ($this->wasFinder) { - $this->classLoader = array($classLoader, 'loadClass'); - $this->isFinder = true; - } else { - $this->classLoader = $classLoader; - $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile'); - } - - if (!isset(self::$caseCheck)) { - self::$caseCheck = false !== stripos(PHP_OS, 'win') ? (false !== stripos(PHP_OS, 'darwin') ? 2 : 1) : 0; - } - } - - /** - * Gets the wrapped class loader. - * - * @return callable|object a class loader - * - * @deprecated since 2.5, returning an object is deprecated and support for it will be removed in 3.0 - */ - public function getClassLoader() - { - return $this->wasFinder ? $this->classLoader[0] : $this->classLoader; - } - - /** - * Wraps all autoloaders. - */ - public static function enable() - { - // Ensures we don't hit https://bugs.php.net/42098 - class_exists('Symfony\Component\Debug\ErrorHandler'); - class_exists('Psr\Log\LogLevel'); - - if (!is_array($functions = spl_autoload_functions())) { - return; - } - - foreach ($functions as $function) { - spl_autoload_unregister($function); - } - - foreach ($functions as $function) { - if (!is_array($function) || !$function[0] instanceof self) { - $function = array(new static($function), 'loadClass'); - } - - spl_autoload_register($function); - } - } - - /** - * Disables the wrapping. - */ - public static function disable() - { - if (!is_array($functions = spl_autoload_functions())) { - return; - } - - foreach ($functions as $function) { - spl_autoload_unregister($function); - } - - foreach ($functions as $function) { - if (is_array($function) && $function[0] instanceof self) { - $function = $function[0]->getClassLoader(); - } - - spl_autoload_register($function); - } - } - - /** - * Finds a file by class name. - * - * @param string $class A class name to resolve to file - * - * @return string|null - * - * @deprecated Deprecated since 2.5, to be removed in 3.0. - */ - public function findFile($class) - { - if ($this->wasFinder) { - return $this->classLoader[0]->findFile($class); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * - * @return bool|null True, if loaded - * - * @throws \RuntimeException - */ - public function loadClass($class) - { - ErrorHandler::stackErrors(); - - try { - if ($this->isFinder) { - if ($file = $this->classLoader[0]->findFile($class)) { - require $file; - } - } else { - call_user_func($this->classLoader, $class); - $file = false; - } - } catch (\Exception $e) { - ErrorHandler::unstackErrors(); - - throw $e; - } - - ErrorHandler::unstackErrors(); - - $exists = class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); - - if ('\\' === $class[0]) { - $class = substr($class, 1); - } - - if ($exists) { - $refl = new \ReflectionClass($class); - $name = $refl->getName(); - - if ($name !== $class && 0 === strcasecmp($name, $class)) { - throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name)); - } - } - - if ($file) { - if (!$exists) { - if (false !== strpos($class, '/')) { - throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); - } - - throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); - } - if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*)+\.(php|hh)$#D', $file, $tail)) { - $tail = $tail[0]; - $real = $refl->getFileName(); - - if (2 === self::$caseCheck) { - // realpath() on MacOSX doesn't normalize the case of characters - $cwd = getcwd(); - $basename = strrpos($real, '/'); - chdir(substr($real, 0, $basename)); - $basename = substr($real, $basename + 1); - // glob() patterns are case-sensitive even if the underlying fs is not - if (!in_array($basename, glob($basename.'*', GLOB_NOSORT), true)) { - $real = getcwd().'/'; - $h = opendir('.'); - while (false !== $f = readdir($h)) { - if (0 === strcasecmp($f, $basename)) { - $real .= $f; - break; - } - } - closedir($h); - } - chdir($cwd); - } - - if (0 === substr_compare($real, $tail, -strlen($tail), strlen($tail), true) - && 0 !== substr_compare($real, $tail, -strlen($tail), strlen($tail), false) - ) { - throw new \RuntimeException(sprintf('Case mismatch between class and source file names: %s vs %s', $class, $real)); - } - } - - return true; - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php deleted file mode 100644 index f315a536e..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php +++ /dev/null @@ -1,731 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -use Psr\Log\LogLevel; -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\Exception\ContextErrorException; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\Exception\FatalThrowableError; -use Symfony\Component\Debug\Exception\OutOfMemoryException; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler; -use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; -use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface; - -/** - * A generic ErrorHandler for the PHP engine. - * - * Provides five bit fields that control how errors are handled: - * - thrownErrors: errors thrown as \ErrorException - * - loggedErrors: logged errors, when not @-silenced - * - scopedErrors: errors thrown or logged with their local context - * - tracedErrors: errors logged with their stack trace, only once for repeated errors - * - screamedErrors: never @-silenced errors - * - * Each error level can be logged by a dedicated PSR-3 logger object. - * Screaming only applies to logging. - * Throwing takes precedence over logging. - * Uncaught exceptions are logged as E_ERROR. - * E_DEPRECATED and E_USER_DEPRECATED levels never throw. - * E_RECOVERABLE_ERROR and E_USER_ERROR levels always throw. - * Non catchable errors that can be detected at shutdown time are logged when the scream bit field allows so. - * As errors have a performance cost, repeated errors are all logged, so that the developer - * can see them and weight them as more important to fix than others of the same level. - * - * @author Nicolas Grekas - */ -class ErrorHandler -{ - /** - * @deprecated since 2.6, to be removed in 3.0. - */ - const TYPE_DEPRECATION = -100; - - private $levels = array( - E_DEPRECATED => 'Deprecated', - E_USER_DEPRECATED => 'User Deprecated', - E_NOTICE => 'Notice', - E_USER_NOTICE => 'User Notice', - E_STRICT => 'Runtime Notice', - E_WARNING => 'Warning', - E_USER_WARNING => 'User Warning', - E_COMPILE_WARNING => 'Compile Warning', - E_CORE_WARNING => 'Core Warning', - E_USER_ERROR => 'User Error', - E_RECOVERABLE_ERROR => 'Catchable Fatal Error', - E_COMPILE_ERROR => 'Compile Error', - E_PARSE => 'Parse Error', - E_ERROR => 'Error', - E_CORE_ERROR => 'Core Error', - ); - - private $loggers = array( - E_DEPRECATED => array(null, LogLevel::INFO), - E_USER_DEPRECATED => array(null, LogLevel::INFO), - E_NOTICE => array(null, LogLevel::NOTICE), - E_USER_NOTICE => array(null, LogLevel::NOTICE), - E_STRICT => array(null, LogLevel::NOTICE), - E_WARNING => array(null, LogLevel::WARNING), - E_USER_WARNING => array(null, LogLevel::WARNING), - E_COMPILE_WARNING => array(null, LogLevel::WARNING), - E_CORE_WARNING => array(null, LogLevel::WARNING), - E_USER_ERROR => array(null, LogLevel::ERROR), - E_RECOVERABLE_ERROR => array(null, LogLevel::ERROR), - E_COMPILE_ERROR => array(null, LogLevel::EMERGENCY), - E_PARSE => array(null, LogLevel::EMERGENCY), - E_ERROR => array(null, LogLevel::EMERGENCY), - E_CORE_ERROR => array(null, LogLevel::EMERGENCY), - ); - - private $thrownErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED - private $scopedErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED - private $tracedErrors = 0x77FB; // E_ALL - E_STRICT - E_PARSE - private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE - private $loggedErrors = 0; - - private $loggedTraces = array(); - private $isRecursive = 0; - private $exceptionHandler; - - private static $reservedMemory; - private static $stackedErrors = array(); - private static $stackedErrorLevels = array(); - - /** - * Same init value as thrownErrors. - * - * @deprecated since 2.6, to be removed in 3.0. - */ - private $displayErrors = 0x1FFF; - - /** - * Registers the error handler. - * - * @param self|null|int $handler The handler to register, or @deprecated (since 2.6, to be removed in 3.0) bit field of thrown levels - * @param bool $replace Whether to replace or not any existing handler - * - * @return self The registered error handler - */ - public static function register($handler = null, $replace = true) - { - if (null === self::$reservedMemory) { - self::$reservedMemory = str_repeat('x', 10240); - register_shutdown_function(__CLASS__.'::handleFatalError'); - } - - $levels = -1; - - if ($handlerIsNew = !$handler instanceof self) { - // @deprecated polymorphism, to be removed in 3.0 - if (null !== $handler) { - $levels = $replace ? $handler : 0; - $replace = true; - } - $handler = new static(); - } - - $prev = set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors); - - if ($handlerIsNew && is_array($prev) && $prev[0] instanceof self) { - $handler = $prev[0]; - $replace = false; - } - if ($replace || !$prev) { - $handler->setExceptionHandler(set_exception_handler(array($handler, 'handleException'))); - } else { - restore_error_handler(); - } - - $handler->throwAt($levels & $handler->thrownErrors, true); - - return $handler; - } - - /** - * Sets a logger to non assigned errors levels. - * - * @param LoggerInterface $logger A PSR-3 logger to put as default for the given levels - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants - * @param bool $replace Whether to replace or not any existing logger - */ - public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false) - { - $loggers = array(); - - if (is_array($levels)) { - foreach ($levels as $type => $logLevel) { - if (empty($this->loggers[$type][0]) || $replace) { - $loggers[$type] = array($logger, $logLevel); - } - } - } else { - if (null === $levels) { - $levels = E_ALL | E_STRICT; - } - foreach ($this->loggers as $type => $log) { - if (($type & $levels) && (empty($log[0]) || $replace)) { - $log[0] = $logger; - $loggers[$type] = $log; - } - } - } - - $this->setLoggers($loggers); - } - - /** - * Sets a logger for each error level. - * - * @param array $loggers Error levels to [LoggerInterface|null, LogLevel::*] map - * - * @return array The previous map - * - * @throws \InvalidArgumentException - */ - public function setLoggers(array $loggers) - { - $prevLogged = $this->loggedErrors; - $prev = $this->loggers; - - foreach ($loggers as $type => $log) { - if (!isset($prev[$type])) { - throw new \InvalidArgumentException('Unknown error type: '.$type); - } - if (!is_array($log)) { - $log = array($log); - } elseif (!array_key_exists(0, $log)) { - throw new \InvalidArgumentException('No logger provided'); - } - if (null === $log[0]) { - $this->loggedErrors &= ~$type; - } elseif ($log[0] instanceof LoggerInterface) { - $this->loggedErrors |= $type; - } else { - throw new \InvalidArgumentException('Invalid logger provided'); - } - $this->loggers[$type] = $log + $prev[$type]; - } - $this->reRegister($prevLogged | $this->thrownErrors); - - return $prev; - } - - /** - * Sets a user exception handler. - * - * @param callable $handler A handler that will be called on Exception - * - * @return callable|null The previous exception handler - * - * @throws \InvalidArgumentException - */ - public function setExceptionHandler($handler) - { - if (null !== $handler && !is_callable($handler)) { - throw new \LogicException('The exception handler must be a valid PHP callable.'); - } - $prev = $this->exceptionHandler; - $this->exceptionHandler = $handler; - - return $prev; - } - - /** - * Sets the PHP error levels that throw an exception when a PHP error occurs. - * - * @param int $levels A bit field of E_* constants for thrown errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function throwAt($levels, $replace = false) - { - $prev = $this->thrownErrors; - $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; - if (!$replace) { - $this->thrownErrors |= $prev; - } - $this->reRegister($prev | $this->loggedErrors); - - // $this->displayErrors is @deprecated since 2.6 - $this->displayErrors = $this->thrownErrors; - - return $prev; - } - - /** - * Sets the PHP error levels for which local variables are preserved. - * - * @param int $levels A bit field of E_* constants for scoped errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function scopeAt($levels, $replace = false) - { - $prev = $this->scopedErrors; - $this->scopedErrors = (int) $levels; - if (!$replace) { - $this->scopedErrors |= $prev; - } - - return $prev; - } - - /** - * Sets the PHP error levels for which the stack trace is preserved. - * - * @param int $levels A bit field of E_* constants for traced errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function traceAt($levels, $replace = false) - { - $prev = $this->tracedErrors; - $this->tracedErrors = (int) $levels; - if (!$replace) { - $this->tracedErrors |= $prev; - } - - return $prev; - } - - /** - * Sets the error levels where the @-operator is ignored. - * - * @param int $levels A bit field of E_* constants for screamed errors - * @param bool $replace Replace or amend the previous value - * - * @return int The previous value - */ - public function screamAt($levels, $replace = false) - { - $prev = $this->screamedErrors; - $this->screamedErrors = (int) $levels; - if (!$replace) { - $this->screamedErrors |= $prev; - } - - return $prev; - } - - /** - * Re-registers as a PHP error handler if levels changed. - */ - private function reRegister($prev) - { - if ($prev !== $this->thrownErrors | $this->loggedErrors) { - $handler = set_error_handler('var_dump', 0); - $handler = is_array($handler) ? $handler[0] : null; - restore_error_handler(); - if ($handler === $this) { - restore_error_handler(); - set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors); - } - } - } - - /** - * Handles errors by filtering then logging them according to the configured bit fields. - * - * @param int $type One of the E_* constants - * @param string $file - * @param int $line - * @param array $context - * - * @return bool Returns false when no handling happens so that the PHP engine can handle the error itself. - * - * @throws \ErrorException When $this->thrownErrors requests so - * - * @internal - */ - public function handleError($type, $message, $file, $line, array $context, array $backtrace = null) - { - $level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR; - $log = $this->loggedErrors & $type; - $throw = $this->thrownErrors & $type & $level; - $type &= $level | $this->screamedErrors; - - if (!$type || (!$log && !$throw)) { - return $type && $log; - } - - if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && ($this->scopedErrors & $type)) { - $e = $context; // Whatever the signature of the method, - unset($e['GLOBALS'], $context); // $context is always a reference in 5.3 - $context = $e; - } - - if (null !== $backtrace && $type & E_ERROR) { - // E_ERROR fatal errors are triggered on HHVM when - // hhvm.error_handling.call_user_handler_on_fatals=1 - // which is the way to get their backtrace. - $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace')); - - return true; - } - - if ($throw) { - if (($this->scopedErrors & $type) && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) { - // Checking for class existence is a work around for https://bugs.php.net/42098 - $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context); - } else { - $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line); - } - - if (PHP_VERSION_ID <= 50407 && (PHP_VERSION_ID >= 50400 || PHP_VERSION_ID <= 50317)) { - // Exceptions thrown from error handlers are sometimes not caught by the exception - // handler and shutdown handlers are bypassed before 5.4.8/5.3.18. - // We temporarily re-enable display_errors to prevent any blank page related to this bug. - - $throw->errorHandlerCanary = new ErrorHandlerCanary(); - } - - throw $throw; - } - - // For duplicated errors, log the trace only once - $e = md5("{$type}/{$line}/{$file}\x00{$message}", true); - $trace = true; - - if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) { - $trace = false; - } else { - $this->loggedTraces[$e] = 1; - } - - $e = compact('type', 'file', 'line', 'level'); - - if ($type & $level) { - if ($this->scopedErrors & $type) { - $e['scope_vars'] = $context; - if ($trace) { - $e['stack'] = $backtrace ?: debug_backtrace(true); // Provide object - } - } elseif ($trace) { - if (null === $backtrace) { - $e['stack'] = debug_backtrace(PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false); - } else { - foreach ($backtrace as &$frame) { - unset($frame['args'], $frame); - } - $e['stack'] = $backtrace; - } - } - } - - if ($this->isRecursive) { - $log = 0; - } elseif (self::$stackedErrorLevels) { - self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e); - } else { - try { - $this->isRecursive = true; - $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e); - $this->isRecursive = false; - } catch (\Exception $e) { - $this->isRecursive = false; - - throw $e; - } - } - - return $type && $log; - } - - /** - * Handles an exception by logging then forwarding it to an other handler. - * - * @param \Exception|\Throwable $exception An exception to handle - * @param array $error An array as returned by error_get_last() - * - * @internal - */ - public function handleException($exception, array $error = null) - { - if (!$exception instanceof \Exception) { - $exception = new FatalThrowableError($exception); - } - $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR; - - if ($this->loggedErrors & $type) { - $e = array( - 'type' => $type, - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - 'level' => error_reporting(), - 'stack' => $exception->getTrace(), - ); - if ($exception instanceof FatalErrorException) { - if ($exception instanceof FatalThrowableError) { - $error = array( - 'type' => $type, - 'message' => $message = $exception->getMessage(), - 'file' => $e['file'], - 'line' => $e['line'], - ); - } else { - $message = 'Fatal '.$exception->getMessage(); - } - } elseif ($exception instanceof \ErrorException) { - $message = 'Uncaught '.$exception->getMessage(); - if ($exception instanceof ContextErrorException) { - $e['context'] = $exception->getContext(); - } - } else { - $message = 'Uncaught Exception: '.$exception->getMessage(); - } - if ($this->loggedErrors & $e['type']) { - $this->loggers[$e['type']][0]->log($this->loggers[$e['type']][1], $message, $e); - } - } - if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) { - foreach ($this->getFatalErrorHandlers() as $handler) { - if ($e = $handler->handleError($error, $exception)) { - $exception = $e; - break; - } - } - } - if (empty($this->exceptionHandler)) { - throw $exception; // Give back $exception to the native handler - } - try { - call_user_func($this->exceptionHandler, $exception); - } catch (\Exception $handlerException) { - } catch (\Throwable $handlerException) { - } - if (isset($handlerException)) { - $this->exceptionHandler = null; - $this->handleException($handlerException); - } - } - - /** - * Shutdown registered function for handling PHP fatal errors. - * - * @param array $error An array as returned by error_get_last() - * - * @internal - */ - public static function handleFatalError(array $error = null) - { - if (null === self::$reservedMemory) { - return; - } - - self::$reservedMemory = null; - - $handler = set_error_handler('var_dump', 0); - $handler = is_array($handler) ? $handler[0] : null; - restore_error_handler(); - - if (!$handler instanceof self) { - return; - } - - if (null === $error) { - $error = error_get_last(); - } - - try { - while (self::$stackedErrorLevels) { - static::unstackErrors(); - } - } catch (\Exception $exception) { - // Handled below - } - - if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) { - // Let's not throw anymore but keep logging - $handler->throwAt(0, true); - $trace = isset($error['backtrace']) ? $error['backtrace'] : null; - - if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) { - $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace); - } else { - $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace); - } - } elseif (!isset($exception)) { - return; - } - - try { - $handler->handleException($exception, $error); - } catch (FatalErrorException $e) { - // Ignore this re-throw - } - } - - /** - * Configures the error handler for delayed handling. - * Ensures also that non-catchable fatal errors are never silenced. - * - * As shown by http://bugs.php.net/42098 and http://bugs.php.net/60724 - * PHP has a compile stage where it behaves unusually. To workaround it, - * we plug an error handler that only stacks errors for later. - * - * The most important feature of this is to prevent - * autoloading until unstackErrors() is called. - */ - public static function stackErrors() - { - self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); - } - - /** - * Unstacks stacked errors and forwards to the logger. - */ - public static function unstackErrors() - { - $level = array_pop(self::$stackedErrorLevels); - - if (null !== $level) { - $e = error_reporting($level); - if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) { - // If the user changed the error level, do not overwrite it - error_reporting($e); - } - } - - if (empty(self::$stackedErrorLevels)) { - $errors = self::$stackedErrors; - self::$stackedErrors = array(); - - foreach ($errors as $e) { - $e[0]->log($e[1], $e[2], $e[3]); - } - } - } - - /** - * Gets the fatal error handlers. - * - * Override this method if you want to define more fatal error handlers. - * - * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface - */ - protected function getFatalErrorHandlers() - { - return array( - new UndefinedFunctionFatalErrorHandler(), - new UndefinedMethodFatalErrorHandler(), - new ClassNotFoundFatalErrorHandler(), - ); - } - - /** - * Sets the level at which the conversion to Exception is done. - * - * @param int|null $level The level (null to use the error_reporting() value and 0 to disable) - * - * @deprecated since 2.6, to be removed in 3.0. Use throwAt() instead. - */ - public function setLevel($level) - { - $level = null === $level ? error_reporting() : $level; - $this->throwAt($level, true); - } - - /** - * Sets the display_errors flag value. - * - * @param int $displayErrors The display_errors flag value - * - * @deprecated since 2.6, to be removed in 3.0. Use throwAt() instead. - */ - public function setDisplayErrors($displayErrors) - { - if ($displayErrors) { - $this->throwAt($this->displayErrors, true); - } else { - $displayErrors = $this->displayErrors; - $this->throwAt(0, true); - $this->displayErrors = $displayErrors; - } - } - - /** - * Sets a logger for the given channel. - * - * @param LoggerInterface $logger A logger interface - * @param string $channel The channel associated with the logger (deprecation, emergency or scream) - * - * @deprecated since 2.6, to be removed in 3.0. Use setLoggers() or setDefaultLogger() instead. - */ - public static function setLogger(LoggerInterface $logger, $channel = 'deprecation') - { - $handler = set_error_handler('var_dump', 0); - $handler = is_array($handler) ? $handler[0] : null; - restore_error_handler(); - if (!$handler instanceof self) { - return; - } - if ('deprecation' === $channel) { - $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true); - $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED); - } elseif ('scream' === $channel) { - $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false); - $handler->screamAt(E_ALL | E_STRICT); - } elseif ('emergency' === $channel) { - $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true); - $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); - } - } - - /** - * @deprecated since 2.6, to be removed in 3.0. Use handleError() instead. - */ - public function handle($level, $message, $file = 'unknown', $line = 0, $context = array()) - { - return $this->handleError($level, $message, $file, $line, (array) $context); - } - - /** - * Handles PHP fatal errors. - * - * @deprecated since 2.6, to be removed in 3.0. Use handleFatalError() instead. - */ - public function handleFatal() - { - static::handleFatalError(); - } -} - -/** - * Private class used to work around https://bugs.php.net/54275. - * - * @author Nicolas Grekas - * - * @internal - */ -class ErrorHandlerCanary -{ - private static $displayErrors = null; - - public function __construct() - { - if (null === self::$displayErrors) { - self::$displayErrors = ini_set('display_errors', 1); - } - } - - public function __destruct() - { - if (null !== self::$displayErrors) { - ini_set('display_errors', self::$displayErrors); - self::$displayErrors = null; - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php deleted file mode 100644 index b91bf4663..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Class (or Trait or Interface) Not Found Exception. - * - * @author Konstanton Myakshin - */ -class ClassNotFoundException extends FatalErrorException -{ - public function __construct($message, \ErrorException $previous) - { - parent::__construct( - $message, - $previous->getCode(), - $previous->getSeverity(), - $previous->getFile(), - $previous->getLine(), - $previous->getPrevious() - ); - $this->setTrace($previous->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php deleted file mode 100644 index 54f0198f1..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Error Exception with Variable Context. - * - * @author Christian Sciberras - */ -class ContextErrorException extends \ErrorException -{ - private $context = array(); - - public function __construct($message, $code, $severity, $filename, $lineno, $context = array()) - { - parent::__construct($message, $code, $severity, $filename, $lineno); - $this->context = $context; - } - - /** - * @return array Array of variables that existed when the exception occurred - */ - public function getContext() - { - return $this->context; - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php deleted file mode 100644 index 967e03377..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * @author Fabien Potencier - * - * @deprecated since version 2.5, to be removed in 3.0. - */ -class DummyException extends \ErrorException -{ -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php deleted file mode 100644 index f46e20875..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * Fatal Error Exception. - * - * @author Fabien Potencier - * @author Konstanton Myakshin - * @author Nicolas Grekas - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class FatalErrorException extends \ErrorException -{ -} - -namespace Symfony\Component\Debug\Exception; - -use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException; - -/** - * Fatal Error Exception. - * - * @author Konstanton Myakshin - */ -class FatalErrorException extends LegacyFatalErrorException -{ - public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null) - { - parent::__construct($message, $code, $severity, $filename, $lineno); - - if (null !== $trace) { - if (!$traceArgs) { - foreach ($trace as &$frame) { - unset($frame['args'], $frame['this'], $frame); - } - } - - $this->setTrace($trace); - } elseif (null !== $traceOffset) { - if (function_exists('xdebug_get_function_stack')) { - $trace = xdebug_get_function_stack(); - if (0 < $traceOffset) { - array_splice($trace, -$traceOffset); - } - - foreach ($trace as &$frame) { - if (!isset($frame['type'])) { - // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 - if (isset($frame['class'])) { - $frame['type'] = '::'; - } - } elseif ('dynamic' === $frame['type']) { - $frame['type'] = '->'; - } elseif ('static' === $frame['type']) { - $frame['type'] = '::'; - } - - // XDebug also has a different name for the parameters array - if (!$traceArgs) { - unset($frame['params'], $frame['args']); - } elseif (isset($frame['params']) && !isset($frame['args'])) { - $frame['args'] = $frame['params']; - unset($frame['params']); - } - } - - unset($frame); - $trace = array_reverse($trace); - } else { - $trace = array(); - } - - $this->setTrace($trace); - } - } - - protected function setTrace($trace) - { - $traceReflector = new \ReflectionProperty('Exception', 'trace'); - $traceReflector->setAccessible(true); - $traceReflector->setValue($this, $trace); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalThrowableError.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalThrowableError.php deleted file mode 100644 index 6ff5ecdaf..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalThrowableError.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Fatal Throwable Error. - * - * @author Nicolas Grekas - */ -class FatalThrowableError extends FatalErrorException -{ - public function __construct(\Throwable $e) - { - if ($e instanceof \ParseError) { - $message = 'Parse error: '.$e->getMessage(); - $severity = E_PARSE; - } elseif ($e instanceof \TypeError) { - $message = 'Type error: '.$e->getMessage(); - $severity = E_RECOVERABLE_ERROR; - } else { - $message = 'Fatal error: '.$e->getMessage(); - $severity = E_ERROR; - } - - \ErrorException::__construct( - $message, - $e->getCode(), - $severity, - $e->getFile(), - $e->getLine() - ); - - $this->setTrace($e->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php deleted file mode 100644 index d8d5c5b92..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php +++ /dev/null @@ -1,292 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException; - -/** - * FlattenException wraps a PHP Exception to be able to serialize it. - * - * Basically, this class removes all objects from the trace. - * - * @author Fabien Potencier - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class FlattenException -{ - private $handler; - - public static function __callStatic($method, $args) - { - if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) { - throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_called_class(), $method)); - } - - return call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args); - } - - public function __call($method, $args) - { - if (!isset($this->handler)) { - $this->handler = new DebugFlattenException(); - } - - if (!method_exists($this->handler, $method)) { - throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method)); - } - - return call_user_func_array(array($this->handler, $method), $args); - } -} - -namespace Symfony\Component\Debug\Exception; - -use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; - -/** - * FlattenException wraps a PHP Exception to be able to serialize it. - * - * Basically, this class removes all objects from the trace. - * - * @author Fabien Potencier - */ -class FlattenException extends LegacyFlattenException -{ - private $message; - private $code; - private $previous; - private $trace; - private $class; - private $statusCode; - private $headers; - private $file; - private $line; - - public static function create(\Exception $exception, $statusCode = null, array $headers = array()) - { - $e = new static(); - $e->setMessage($exception->getMessage()); - $e->setCode($exception->getCode()); - - if ($exception instanceof HttpExceptionInterface) { - $statusCode = $exception->getStatusCode(); - $headers = array_merge($headers, $exception->getHeaders()); - } - - if (null === $statusCode) { - $statusCode = 500; - } - - $e->setStatusCode($statusCode); - $e->setHeaders($headers); - $e->setTraceFromException($exception); - $e->setClass(get_class($exception)); - $e->setFile($exception->getFile()); - $e->setLine($exception->getLine()); - if ($exception->getPrevious()) { - $e->setPrevious(static::create($exception->getPrevious())); - } - - return $e; - } - - public function toArray() - { - $exceptions = array(); - foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) { - $exceptions[] = array( - 'message' => $exception->getMessage(), - 'class' => $exception->getClass(), - 'trace' => $exception->getTrace(), - ); - } - - return $exceptions; - } - - public function getStatusCode() - { - return $this->statusCode; - } - - public function setStatusCode($code) - { - $this->statusCode = $code; - } - - public function getHeaders() - { - return $this->headers; - } - - public function setHeaders(array $headers) - { - $this->headers = $headers; - } - - public function getClass() - { - return $this->class; - } - - public function setClass($class) - { - $this->class = $class; - } - - public function getFile() - { - return $this->file; - } - - public function setFile($file) - { - $this->file = $file; - } - - public function getLine() - { - return $this->line; - } - - public function setLine($line) - { - $this->line = $line; - } - - public function getMessage() - { - return $this->message; - } - - public function setMessage($message) - { - $this->message = $message; - } - - public function getCode() - { - return $this->code; - } - - public function setCode($code) - { - $this->code = $code; - } - - public function getPrevious() - { - return $this->previous; - } - - public function setPrevious(FlattenException $previous) - { - $this->previous = $previous; - } - - public function getAllPrevious() - { - $exceptions = array(); - $e = $this; - while ($e = $e->getPrevious()) { - $exceptions[] = $e; - } - - return $exceptions; - } - - public function getTrace() - { - return $this->trace; - } - - public function setTraceFromException(\Exception $exception) - { - $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine()); - } - - public function setTrace($trace, $file, $line) - { - $this->trace = array(); - $this->trace[] = array( - 'namespace' => '', - 'short_class' => '', - 'class' => '', - 'type' => '', - 'function' => '', - 'file' => $file, - 'line' => $line, - 'args' => array(), - ); - foreach ($trace as $entry) { - $class = ''; - $namespace = ''; - if (isset($entry['class'])) { - $parts = explode('\\', $entry['class']); - $class = array_pop($parts); - $namespace = implode('\\', $parts); - } - - $this->trace[] = array( - 'namespace' => $namespace, - 'short_class' => $class, - 'class' => isset($entry['class']) ? $entry['class'] : '', - 'type' => isset($entry['type']) ? $entry['type'] : '', - 'function' => isset($entry['function']) ? $entry['function'] : null, - 'file' => isset($entry['file']) ? $entry['file'] : null, - 'line' => isset($entry['line']) ? $entry['line'] : null, - 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(), - ); - } - } - - private function flattenArgs($args, $level = 0, &$count = 0) - { - $result = array(); - foreach ($args as $key => $value) { - if (++$count > 1e4) { - return array('array', '*SKIPPED over 10000 entries*'); - } - if (is_object($value)) { - $result[$key] = array('object', get_class($value)); - } elseif (is_array($value)) { - if ($level > 10) { - $result[$key] = array('array', '*DEEP NESTED ARRAY*'); - } else { - $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count)); - } - } elseif (null === $value) { - $result[$key] = array('null', null); - } elseif (is_bool($value)) { - $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); - } - } - - return $result; - } - - private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) - { - $array = new \ArrayObject($value); - - return $array['__PHP_Incomplete_Class_Name']; - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php deleted file mode 100644 index fec197983..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Out of memory exception. - * - * @author Nicolas Grekas - */ -class OutOfMemoryException extends FatalErrorException -{ -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php deleted file mode 100644 index a66ae2a38..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Undefined Function Exception. - * - * @author Konstanton Myakshin - */ -class UndefinedFunctionException extends FatalErrorException -{ - public function __construct($message, \ErrorException $previous) - { - parent::__construct( - $message, - $previous->getCode(), - $previous->getSeverity(), - $previous->getFile(), - $previous->getLine(), - $previous->getPrevious() - ); - $this->setTrace($previous->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedMethodException.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedMethodException.php deleted file mode 100644 index 350dc3187..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedMethodException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Exception; - -/** - * Undefined Method Exception. - * - * @author Grégoire Pineau - */ -class UndefinedMethodException extends FatalErrorException -{ - public function __construct($message, \ErrorException $previous) - { - parent::__construct( - $message, - $previous->getCode(), - $previous->getSeverity(), - $previous->getFile(), - $previous->getLine(), - $previous->getPrevious() - ); - $this->setTrace($previous->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php deleted file mode 100644 index bc66741bc..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php +++ /dev/null @@ -1,476 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\Debug\Exception\OutOfMemoryException; - -/** - * ExceptionHandler converts an exception to a Response object. - * - * It is mostly useful in debug mode to replace the default PHP/XDebug - * output with something prettier and more useful. - * - * As this class is mainly used during Kernel boot, where nothing is yet - * available, the Response content is always HTML. - * - * @author Fabien Potencier - * @author Nicolas Grekas - */ -class ExceptionHandler -{ - private $debug; - private $charset; - private $handler; - private $caughtBuffer; - private $caughtLength; - private $fileLinkFormat; - - public function __construct($debug = true, $charset = null, $fileLinkFormat = null) - { - if (false !== strpos($charset, '%') xor false === strpos($fileLinkFormat, '%')) { - // Swap $charset and $fileLinkFormat for BC reasons - $pivot = $fileLinkFormat; - $fileLinkFormat = $charset; - $charset = $pivot; - } - $this->debug = $debug; - $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8'; - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - } - - /** - * Registers the exception handler. - * - * @param bool $debug Enable/disable debug mode, where the stack trace is displayed - * @param string|null $charset The charset used by exception messages - * @param string|null $fileLinkFormat The IDE link template - * - * @return ExceptionHandler The registered exception handler - */ - public static function register($debug = true, $charset = null, $fileLinkFormat = null) - { - $handler = new static($debug, $charset, $fileLinkFormat); - - $prev = set_exception_handler(array($handler, 'handle')); - if (is_array($prev) && $prev[0] instanceof ErrorHandler) { - restore_exception_handler(); - $prev[0]->setExceptionHandler(array($handler, 'handle')); - } - - return $handler; - } - - /** - * Sets a user exception handler. - * - * @param callable $handler An handler that will be called on Exception - * - * @return callable|null The previous exception handler if any - */ - public function setHandler($handler) - { - if (null !== $handler && !is_callable($handler)) { - throw new \LogicException('The exception handler must be a valid PHP callable.'); - } - $old = $this->handler; - $this->handler = $handler; - - return $old; - } - - /** - * Sets the format for links to source files. - * - * @param string $format The format for links to source files - * - * @return string The previous file link format. - */ - public function setFileLinkFormat($format) - { - $old = $this->fileLinkFormat; - $this->fileLinkFormat = $format; - - return $old; - } - - /** - * Sends a response for the given Exception. - * - * To be as fail-safe as possible, the exception is first handled - * by our simple exception handler, then by the user exception handler. - * The latter takes precedence and any output from the former is cancelled, - * if and only if nothing bad happens in this handling path. - */ - public function handle(\Exception $exception) - { - if (null === $this->handler || $exception instanceof OutOfMemoryException) { - $this->failSafeHandle($exception); - - return; - } - - $caughtLength = $this->caughtLength = 0; - - ob_start(array($this, 'catchOutput')); - $this->failSafeHandle($exception); - while (null === $this->caughtBuffer && ob_end_flush()) { - // Empty loop, everything is in the condition - } - if (isset($this->caughtBuffer[0])) { - ob_start(array($this, 'cleanOutput')); - echo $this->caughtBuffer; - $caughtLength = ob_get_length(); - } - $this->caughtBuffer = null; - - try { - call_user_func($this->handler, $exception); - $this->caughtLength = $caughtLength; - } catch (\Exception $e) { - if (!$caughtLength) { - // All handlers failed. Let PHP handle that now. - throw $exception; - } - } - } - - /** - * Sends a response for the given Exception. - * - * If you have the Symfony HttpFoundation component installed, - * this method will use it to create and send the response. If not, - * it will fallback to plain PHP functions. - * - * @param \Exception $exception An \Exception instance - * - * @see sendPhpResponse() - * @see createResponse() - */ - private function failSafeHandle(\Exception $exception) - { - if (class_exists('Symfony\Component\HttpFoundation\Response', false)) { - $response = $this->createResponse($exception); - $response->sendHeaders(); - $response->sendContent(); - } else { - $this->sendPhpResponse($exception); - } - } - - /** - * Sends the error associated with the given Exception as a plain PHP response. - * - * This method uses plain PHP functions like header() and echo to output - * the response. - * - * @param \Exception|FlattenException $exception An \Exception instance - */ - public function sendPhpResponse($exception) - { - if (!$exception instanceof FlattenException) { - $exception = FlattenException::create($exception); - } - - if (!headers_sent()) { - header(sprintf('HTTP/1.0 %s', $exception->getStatusCode())); - foreach ($exception->getHeaders() as $name => $value) { - header($name.': '.$value, false); - } - header('Content-Type: text/html; charset='.$this->charset); - } - - echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception)); - } - - /** - * Creates the error Response associated with the given Exception. - * - * @param \Exception|FlattenException $exception An \Exception instance - * - * @return Response A Response instance - */ - public function createResponse($exception) - { - if (!$exception instanceof FlattenException) { - $exception = FlattenException::create($exception); - } - - return Response::create($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset); - } - - /** - * 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) - { - 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 = ''; - if ($this->debug) { - try { - $count = count($exception->getAllPrevious()); - $total = $count + 1; - foreach ($exception->toArray() as $position => $e) { - $ind = $count - $position + 1; - $class = $this->formatClass($e['class']); - $message = nl2br($this->escapeHtml($e['message'])); - $content .= sprintf(<< - %d/%d - %s%s: - %s - -
-
    - -EOF - , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message); - foreach ($e['trace'] as $trace) { - $content .= '
  1. '; - if ($trace['function']) { - $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); - } - if (isset($trace['file']) && isset($trace['line'])) { - $content .= $this->formatPath($trace['file'], $trace['line']); - } - $content .= "
  2. \n"; - } - - $content .= "
\n
\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($e), $this->escapeHtml($e->getMessage())); - } else { - $title = 'Whoops, looks like something went wrong.'; - } - } - } - - return << -

$title

- $content - -EOF; - } - - /** - * 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 << - - - - - - - - $content - - -EOF; - } - - private function formatClass($class) - { - $parts = explode('\\', $class); - - return sprintf('%s', $class, array_pop($parts)); - } - - private function formatPath($path, $line) - { - $path = $this->escapeHtml($path); - $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path; - - if ($linkFormat = $this->fileLinkFormat) { - $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line)); - - return sprintf(' in %s line %d', $link, $file, $line); - } - - return sprintf(' in %s line %d', $path, $file, $line); - } - - /** - * Formats an array as a string. - * - * @param array $args The argument array - * - * @return string - */ - private function formatArgs(array $args) - { - $result = array(); - foreach ($args as $key => $item) { - if ('object' === $item[0]) { - $formattedValue = sprintf('object(%s)', $this->formatClass($item[1])); - } elseif ('array' === $item[0]) { - $formattedValue = sprintf('array(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); - } elseif ('string' === $item[0]) { - $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1])); - } elseif ('null' === $item[0]) { - $formattedValue = 'null'; - } elseif ('boolean' === $item[0]) { - $formattedValue = ''.strtolower(var_export($item[1], true)).''; - } elseif ('resource' === $item[0]) { - $formattedValue = 'resource'; - } else { - $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true)); - } - - $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); - } - - return implode(', ', $result); - } - - /** - * Returns an UTF-8 and HTML encoded string. - */ - protected static function utf8Htmlize($str) - { - if (!preg_match('//u', $str) && function_exists('iconv')) { - set_error_handler('var_dump', 0); - $charset = ini_get('default_charset'); - if ('UTF-8' === $charset || $str !== @iconv($charset, $charset, $str)) { - $charset = 'CP1252'; - } - restore_error_handler(); - - $str = iconv($charset, 'UTF-8', $str); - } - - return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8'); - } - - /** - * HTML-encodes a string. - */ - private function escapeHtml($str) - { - return htmlspecialchars($str, ENT_QUOTES | (PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset); - } - - /** - * @internal - */ - public function catchOutput($buffer) - { - $this->caughtBuffer = $buffer; - - return ''; - } - - /** - * @internal - */ - public function cleanOutput($buffer) - { - if ($this->caughtLength) { - // use substr_replace() instead of substr() for mbstring overloading resistance - $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength); - if (isset($cleanBuffer[0])) { - $buffer = $cleanBuffer; - } - } - - return $buffer; - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php deleted file mode 100644 index abfe90d79..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ /dev/null @@ -1,212 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\ClassNotFoundException; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\DebugClassLoader; -use Composer\Autoload\ClassLoader as ComposerClassLoader; -use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader; -use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader; - -/** - * ErrorHandler for classes that do not exist. - * - * @author Fabien Potencier - */ -class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handleError(array $error, FatalErrorException $exception) - { - $messageLen = strlen($error['message']); - $notFoundSuffix = '\' not found'; - $notFoundSuffixLen = strlen($notFoundSuffix); - if ($notFoundSuffixLen > $messageLen) { - return; - } - - if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; - } - - foreach (array('class', 'interface', 'trait') as $typeName) { - $prefix = ucfirst($typeName).' \''; - $prefixLen = strlen($prefix); - if (0 !== strpos($error['message'], $prefix)) { - continue; - } - - $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); - if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) { - $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1); - $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex); - $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix); - $tail = ' for another namespace?'; - } else { - $className = $fullyQualifiedClassName; - $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className); - $tail = '?'; - } - - if ($candidates = $this->getClassCandidates($className)) { - $tail = array_pop($candidates).'"?'; - if ($candidates) { - $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail; - } else { - $tail = ' for "'.$tail; - } - } - $message .= "\nDid you forget a \"use\" statement".$tail; - - return new ClassNotFoundException($message, $exception); - } - } - - /** - * Tries to guess the full namespace for a given class name. - * - * By default, it looks for PSR-0 and PSR-4 classes registered via a Symfony or a Composer - * autoloader (that should cover all common cases). - * - * @param string $class A class name (without its namespace) - * - * @return array An array of possible fully qualified class names - */ - private function getClassCandidates($class) - { - if (!is_array($functions = spl_autoload_functions())) { - return array(); - } - - // find Symfony and Composer autoloaders - $classes = array(); - - foreach ($functions as $function) { - if (!is_array($function)) { - continue; - } - // get class loaders wrapped by DebugClassLoader - if ($function[0] instanceof DebugClassLoader) { - $function = $function[0]->getClassLoader(); - - // @deprecated since version 2.5. Returning an object from DebugClassLoader::getClassLoader() is deprecated. - if (is_object($function)) { - $function = array($function); - } - - if (!is_array($function)) { - continue; - } - } - - if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) { - foreach ($function[0]->getPrefixes() as $prefix => $paths) { - foreach ($paths as $path) { - $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix)); - } - } - } - if ($function[0] instanceof ComposerClassLoader) { - foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) { - foreach ($paths as $path) { - $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix)); - } - } - } - } - - return array_unique($classes); - } - - /** - * @param string $path - * @param string $class - * @param string $prefix - * - * @return array - */ - private function findClassInPath($path, $class, $prefix) - { - if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) { - return array(); - } - - $classes = array(); - $filename = $class.'.php'; - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) { - $classes[] = $class; - } - } - - return $classes; - } - - /** - * @param string $path - * @param string $file - * @param string $prefix - * - * @return string|null - */ - private function convertFileToClass($path, $file, $prefix) - { - $candidates = array( - // namespaced class - $namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file), - // namespaced class (with target dir) - $prefix.$namespacedClass, - // namespaced class (with target dir and separator) - $prefix.'\\'.$namespacedClass, - // PEAR class - str_replace('\\', '_', $namespacedClass), - // PEAR class (with target dir) - str_replace('\\', '_', $prefix.$namespacedClass), - // PEAR class (with target dir and separator) - str_replace('\\', '_', $prefix.'\\'.$namespacedClass), - ); - - if ($prefix) { - $candidates = array_filter($candidates, function ($candidate) use ($prefix) {return 0 === strpos($candidate, $prefix);}); - } - - // We cannot use the autoloader here as most of them use require; but if the class - // is not found, the new autoloader call will require the file again leading to a - // "cannot redeclare class" error. - foreach ($candidates as $candidate) { - if ($this->classExists($candidate)) { - return $candidate; - } - } - - require_once $file; - - foreach ($candidates as $candidate) { - if ($this->classExists($candidate)) { - return $candidate; - } - } - } - - /** - * @param string $class - * - * @return bool - */ - private function classExists($class) - { - return class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php deleted file mode 100644 index 6b87eb30a..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\FatalErrorException; - -/** - * Attempts to convert fatal errors to exceptions. - * - * @author Fabien Potencier - */ -interface FatalErrorHandlerInterface -{ - /** - * Attempts to convert an error into an exception. - * - * @param array $error An array as returned by error_get_last() - * @param FatalErrorException $exception A FatalErrorException instance - * - * @return FatalErrorException|null A FatalErrorException instance if the class is able to convert the error, null otherwise - */ - public function handleError(array $error, FatalErrorException $exception); -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php deleted file mode 100644 index c6f391a79..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\UndefinedFunctionException; -use Symfony\Component\Debug\Exception\FatalErrorException; - -/** - * ErrorHandler for undefined functions. - * - * @author Fabien Potencier - */ -class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handleError(array $error, FatalErrorException $exception) - { - $messageLen = strlen($error['message']); - $notFoundSuffix = '()'; - $notFoundSuffixLen = strlen($notFoundSuffix); - if ($notFoundSuffixLen > $messageLen) { - return; - } - - if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; - } - - $prefix = 'Call to undefined function '; - $prefixLen = strlen($prefix); - if (0 !== strpos($error['message'], $prefix)) { - return; - } - - $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); - if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) { - $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1); - $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex); - $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix); - } else { - $functionName = $fullyQualifiedFunctionName; - $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName); - } - - $candidates = array(); - foreach (get_defined_functions() as $type => $definedFunctionNames) { - foreach ($definedFunctionNames as $definedFunctionName) { - if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) { - $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1); - } else { - $definedFunctionNameBasename = $definedFunctionName; - } - - if ($definedFunctionNameBasename === $functionName) { - $candidates[] = '\\'.$definedFunctionName; - } - } - } - - if ($candidates) { - sort($candidates); - $last = array_pop($candidates).'"?'; - if ($candidates) { - $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last; - } else { - $candidates = '"'.$last; - } - $message .= "\nDid you mean to call ".$candidates; - } - - return new UndefinedFunctionException($message, $exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php deleted file mode 100644 index 917794cfa..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\Exception\UndefinedMethodException; - -/** - * ErrorHandler for undefined methods. - * - * @author Grégoire Pineau - */ -class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handleError(array $error, FatalErrorException $exception) - { - preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches); - if (!$matches) { - return; - } - - $className = $matches[1]; - $methodName = $matches[2]; - - $message = sprintf('Attempted to call method "%s" on class "%s".', $methodName, $className); - - $candidates = array(); - foreach (get_class_methods($className) as $definedMethodName) { - $lev = levenshtein($methodName, $definedMethodName); - if ($lev <= strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) { - $candidates[] = $definedMethodName; - } - } - - if ($candidates) { - sort($candidates); - $last = array_pop($candidates).'"?'; - if ($candidates) { - $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last; - } else { - $candidates = '"'.$last; - } - $message .= "\nDid you mean to call ".$candidates; - } - - return new UndefinedMethodException($message, $exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/LICENSE b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/LICENSE deleted file mode 100644 index 43028bc60..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/README.md b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/README.md deleted file mode 100644 index 67e6d6c27..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/README.md +++ /dev/null @@ -1,43 +0,0 @@ -Debug Component -=============== - -Debug provides tools to make debugging easier. - -Enabling all debug tools is as easy as calling the `enable()` method on the -main `Debug` class: - -```php -use Symfony\Component\Debug\Debug; - -Debug::enable(); -``` - -You can also use the tools individually: - -```php -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; - -if ('cli' !== php_sapi_name()) { - ini_set('display_errors', 0); - ExceptionHandler::register(); -} elseif (!ini_get('log_errors') || ini_get('error_log')) { - ini_set('display_errors', 1); -} -ErrorHandler::register(); -``` - -Note that the `Debug::enable()` call also registers the debug class loader -from the Symfony ClassLoader component when available. - -This component can optionally take advantage of the features of the HttpKernel -and HttpFoundation components. - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Debug/ - $ composer install - $ phpunit diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/README.rst b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/README.rst deleted file mode 100644 index b0d1c5895..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/README.rst +++ /dev/null @@ -1,72 +0,0 @@ -Symfony Debug Extension -======================= - -This extension adds a ``symfony_zval_info($key, $array, $options = 0)`` function that: - -- exposes zval_hash/refcounts, allowing e.g. efficient exploration of arbitrary structures in PHP, -- does work with references, preventing memory copying. - -Its behavior is about the same as: - -.. code-block:: php - - gettype($array[$key]), - 'zval_hash' => /* hashed memory address of $array[$key] */, - 'zval_refcount' => /* internal zval refcount of $array[$key] */, - 'zval_isref' => /* is_ref status of $array[$key] */, - ); - - switch ($info['type']) { - case 'object': - $info += array( - 'object_class' => get_class($array[$key]), - 'object_refcount' => /* internal object refcount of $array[$key] */, - 'object_hash' => spl_object_hash($array[$key]), - 'object_handle' => /* internal object handle $array[$key] */, - ); - break; - - case 'resource': - $info += array( - 'resource_handle' => (int) $array[$key], - 'resource_type' => get_resource_type($array[$key]), - 'resource_refcount' => /* internal resource refcount of $array[$key] */, - ); - break; - - case 'array': - $info += array( - 'array_count' => count($array[$key]), - ); - break; - - case 'string': - $info += array( - 'strlen' => strlen($array[$key]), - ); - break; - } - - return $info; - } - -To enable the extension from source, run: - -.. code-block:: sh - - phpize - ./configure - make - sudo make install - diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.m4 b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.m4 deleted file mode 100644 index 3c5604715..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.m4 +++ /dev/null @@ -1,63 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension symfony_debug - -dnl Comments in this file start with the string 'dnl'. -dnl Remove where necessary. This file will not work -dnl without editing. - -dnl If your extension references something external, use with: - -dnl PHP_ARG_WITH(symfony_debug, for symfony_debug support, -dnl Make sure that the comment is aligned: -dnl [ --with-symfony_debug Include symfony_debug support]) - -dnl Otherwise use enable: - -PHP_ARG_ENABLE(symfony_debug, whether to enable symfony_debug support, -dnl Make sure that the comment is aligned: -[ --enable-symfony_debug Enable symfony_debug support]) - -if test "$PHP_SYMFONY_DEBUG" != "no"; then - dnl Write more examples of tests here... - - dnl # --with-symfony_debug -> check with-path - dnl SEARCH_PATH="/usr/local /usr" # you might want to change this - dnl SEARCH_FOR="/include/symfony_debug.h" # you most likely want to change this - dnl if test -r $PHP_SYMFONY_DEBUG/$SEARCH_FOR; then # path given as parameter - dnl SYMFONY_DEBUG_DIR=$PHP_SYMFONY_DEBUG - dnl else # search default path list - dnl AC_MSG_CHECKING([for symfony_debug files in default path]) - dnl for i in $SEARCH_PATH ; do - dnl if test -r $i/$SEARCH_FOR; then - dnl SYMFONY_DEBUG_DIR=$i - dnl AC_MSG_RESULT(found in $i) - dnl fi - dnl done - dnl fi - dnl - dnl if test -z "$SYMFONY_DEBUG_DIR"; then - dnl AC_MSG_RESULT([not found]) - dnl AC_MSG_ERROR([Please reinstall the symfony_debug distribution]) - dnl fi - - dnl # --with-symfony_debug -> add include path - dnl PHP_ADD_INCLUDE($SYMFONY_DEBUG_DIR/include) - - dnl # --with-symfony_debug -> check for lib and symbol presence - dnl LIBNAME=symfony_debug # you may want to change this - dnl LIBSYMBOL=symfony_debug # you most likely want to change this - - dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, - dnl [ - dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $SYMFONY_DEBUG_DIR/lib, SYMFONY_DEBUG_SHARED_LIBADD) - dnl AC_DEFINE(HAVE_SYMFONY_DEBUGLIB,1,[ ]) - dnl ],[ - dnl AC_MSG_ERROR([wrong symfony_debug lib version or lib not found]) - dnl ],[ - dnl -L$SYMFONY_DEBUG_DIR/lib -lm - dnl ]) - dnl - dnl PHP_SUBST(SYMFONY_DEBUG_SHARED_LIBADD) - - PHP_NEW_EXTENSION(symfony_debug, symfony_debug.c, $ext_shared) -fi diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.w32 b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.w32 deleted file mode 100644 index 487e69138..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/config.w32 +++ /dev/null @@ -1,13 +0,0 @@ -// $Id$ -// vim:ft=javascript - -// If your extension references something external, use ARG_WITH -// ARG_WITH("symfony_debug", "for symfony_debug support", "no"); - -// Otherwise, use ARG_ENABLE -// ARG_ENABLE("symfony_debug", "enable symfony_debug support", "no"); - -if (PHP_SYMFONY_DEBUG != "no") { - EXTENSION("symfony_debug", "symfony_debug.c"); -} - diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/php_symfony_debug.h b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/php_symfony_debug.h deleted file mode 100644 index c935f6701..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/php_symfony_debug.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#ifndef PHP_SYMFONY_DEBUG_H -#define PHP_SYMFONY_DEBUG_H - -extern zend_module_entry symfony_debug_module_entry; -#define phpext_symfony_debug_ptr &symfony_debug_module_entry - -#define PHP_SYMFONY_DEBUG_VERSION "1.0" - -#ifdef PHP_WIN32 -# define PHP_SYMFONY_DEBUG_API __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -# define PHP_SYMFONY_DEBUG_API __attribute__ ((visibility("default"))) -#else -# define PHP_SYMFONY_DEBUG_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -ZEND_BEGIN_MODULE_GLOBALS(symfony_debug) - intptr_t req_rand_init; -ZEND_END_MODULE_GLOBALS(symfony_debug) - -PHP_MINIT_FUNCTION(symfony_debug); -PHP_MSHUTDOWN_FUNCTION(symfony_debug); -PHP_RINIT_FUNCTION(symfony_debug); -PHP_RSHUTDOWN_FUNCTION(symfony_debug); -PHP_MINFO_FUNCTION(symfony_debug); -PHP_GINIT_FUNCTION(symfony_debug); -PHP_GSHUTDOWN_FUNCTION(symfony_debug); - -PHP_FUNCTION(symfony_zval_info); - -static char *_symfony_debug_memory_address_hash(void *); -static const char *_symfony_debug_zval_type(zval *); -static const char* _symfony_debug_get_resource_type(long); -static int _symfony_debug_get_resource_refcount(long); - -#ifdef ZTS -#define SYMFONY_DEBUG_G(v) TSRMG(symfony_debug_globals_id, zend_symfony_debug_globals *, v) -#else -#define SYMFONY_DEBUG_G(v) (symfony_debug_globals.v) -#endif - -#endif /* PHP_SYMFONY_DEBUG_H */ diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/symfony_debug.c b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/symfony_debug.c deleted file mode 100644 index 8dc5d4356..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/symfony_debug.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_symfony_debug.h" -#include "ext/standard/php_rand.h" -#include "ext/standard/php_lcg.h" -#include "ext/spl/php_spl.h" -#include "Zend/zend_gc.h" - -ZEND_DECLARE_MODULE_GLOBALS(symfony_debug) - -ZEND_BEGIN_ARG_INFO_EX(symfony_zval_arginfo, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_ARRAY_INFO(0, array, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -const zend_function_entry symfony_debug_functions[] = { - PHP_FE(symfony_zval_info, symfony_zval_arginfo) - PHP_FE_END -}; - -PHP_FUNCTION(symfony_zval_info) -{ - zval *key = NULL, *arg = NULL; - zval **data = NULL; - HashTable *array = NULL; - long options = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zh|l", &key, &array, &options) == FAILURE) { - return; - } - - switch (Z_TYPE_P(key)) { - case IS_STRING: - if (zend_symtable_find(array, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&data) == FAILURE) { - return; - } - break; - case IS_LONG: - if (zend_hash_index_find(array, Z_LVAL_P(key), (void **)&data)) { - return; - } - break; - } - - arg = *data; - - array_init(return_value); - - add_assoc_string(return_value, "type", (char *)_symfony_debug_zval_type(arg), 1); - add_assoc_stringl(return_value, "zval_hash", _symfony_debug_memory_address_hash((void *)arg), 16, 1); - add_assoc_long(return_value, "zval_refcount", Z_REFCOUNT_P(arg)); - add_assoc_bool(return_value, "zval_isref", (zend_bool)Z_ISREF_P(arg)); - - if (Z_TYPE_P(arg) == IS_OBJECT) { - static char hash[33] = {0}; - php_spl_object_hash(arg, (char *)hash); - add_assoc_stringl(return_value, "object_class", (char *)Z_OBJCE_P(arg)->name, Z_OBJCE_P(arg)->name_length, 1); - add_assoc_long(return_value, "object_refcount", EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(arg)].bucket.obj.refcount); - add_assoc_string(return_value, "object_hash", hash, 1); - add_assoc_long(return_value, "object_handle", Z_OBJ_HANDLE_P(arg)); - } else if (Z_TYPE_P(arg) == IS_ARRAY) { - add_assoc_long(return_value, "array_count", zend_hash_num_elements(Z_ARRVAL_P(arg))); - } else if(Z_TYPE_P(arg) == IS_RESOURCE) { - add_assoc_long(return_value, "resource_handle", Z_LVAL_P(arg)); - add_assoc_string(return_value, "resource_type", (char *)_symfony_debug_get_resource_type(Z_LVAL_P(arg)), 1); - add_assoc_long(return_value, "resource_refcount", _symfony_debug_get_resource_refcount(Z_LVAL_P(arg))); - } else if (Z_TYPE_P(arg) == IS_STRING) { - add_assoc_long(return_value, "strlen", Z_STRLEN_P(arg)); - } -} - -static const char* _symfony_debug_get_resource_type(long rsid) -{ - const char *res_type; - res_type = zend_rsrc_list_get_rsrc_type(rsid); - - if (!res_type) { - return "Unknown"; - } - - return res_type; -} - -static int _symfony_debug_get_resource_refcount(long rsid) -{ - zend_rsrc_list_entry *le; - - if (zend_hash_index_find(&EG(regular_list), rsid, (void **) &le)==SUCCESS) { - return le->refcount; - } - - return 0; -} - -static char *_symfony_debug_memory_address_hash(void *address) -{ - static char result[17] = {0}; - intptr_t address_rand; - - if (!SYMFONY_DEBUG_G(req_rand_init)) { - if (!BG(mt_rand_is_seeded)) { - php_mt_srand(GENERATE_SEED() TSRMLS_CC); - } - SYMFONY_DEBUG_G(req_rand_init) = (intptr_t)php_mt_rand(); - } - - address_rand = (intptr_t)address ^ SYMFONY_DEBUG_G(req_rand_init); - - snprintf(result, 17, "%016zx", address_rand); - - return result; -} - -static const char *_symfony_debug_zval_type(zval *zv) -{ - switch (Z_TYPE_P(zv)) { - case IS_NULL: - return "NULL"; - break; - - case IS_BOOL: - return "boolean"; - break; - - case IS_LONG: - return "integer"; - break; - - case IS_DOUBLE: - return "double"; - break; - - case IS_STRING: - return "string"; - break; - - case IS_ARRAY: - return "array"; - break; - - case IS_OBJECT: - return "object"; - - case IS_RESOURCE: - return "resource"; - - default: - return "unknown type"; - } -} - -zend_module_entry symfony_debug_module_entry = { - STANDARD_MODULE_HEADER, - "symfony_debug", - symfony_debug_functions, - PHP_MINIT(symfony_debug), - PHP_MSHUTDOWN(symfony_debug), - PHP_RINIT(symfony_debug), - PHP_RSHUTDOWN(symfony_debug), - PHP_MINFO(symfony_debug), - PHP_SYMFONY_DEBUG_VERSION, - PHP_MODULE_GLOBALS(symfony_debug), - PHP_GINIT(symfony_debug), - PHP_GSHUTDOWN(symfony_debug), - NULL, - STANDARD_MODULE_PROPERTIES_EX -}; - -#ifdef COMPILE_DL_SYMFONY_DEBUG -ZEND_GET_MODULE(symfony_debug) -#endif - -PHP_GINIT_FUNCTION(symfony_debug) -{ - symfony_debug_globals->req_rand_init = 0; -} - -PHP_GSHUTDOWN_FUNCTION(symfony_debug) -{ - -} - -PHP_MINIT_FUNCTION(symfony_debug) -{ - return SUCCESS; -} - -PHP_MSHUTDOWN_FUNCTION(symfony_debug) -{ - return SUCCESS; -} - -PHP_RINIT_FUNCTION(symfony_debug) -{ - return SUCCESS; -} - -PHP_RSHUTDOWN_FUNCTION(symfony_debug) -{ - return SUCCESS; -} - -PHP_MINFO_FUNCTION(symfony_debug) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "Symfony Debug support", "enabled"); - php_info_print_table_header(2, "Symfony Debug version", PHP_SYMFONY_DEBUG_VERSION); - php_info_print_table_end(); -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/tests/001.phpt b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/tests/001.phpt deleted file mode 100644 index 30b25a25e..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Resources/ext/tests/001.phpt +++ /dev/null @@ -1,151 +0,0 @@ ---TEST-- -Test symfony_zval_info API ---SKIPIF-- - ---FILE-- - $int, - 'float' => $float, - 'str' => $str, - 'object' => $object, - 'array' => $array, - 'resource' => $resource, - 'null' => $null, - 'bool' => $bool, - 'refcount' => &$refcount2); - -var_dump(symfony_zval_info('int', $var)); -var_dump(symfony_zval_info('float', $var)); -var_dump(symfony_zval_info('str', $var)); -var_dump(symfony_zval_info('object', $var)); -var_dump(symfony_zval_info('array', $var)); -var_dump(symfony_zval_info('resource', $var)); -var_dump(symfony_zval_info('null', $var)); -var_dump(symfony_zval_info('bool', $var)); - -var_dump(symfony_zval_info('refcount', $var)); -var_dump(symfony_zval_info('not-exist', $var)); -?> ---EXPECTF-- -array(4) { - ["type"]=> - string(7) "integer" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(4) { - ["type"]=> - string(6) "double" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(5) { - ["type"]=> - string(6) "string" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["strlen"]=> - int(6) -} -array(8) { - ["type"]=> - string(6) "object" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["object_class"]=> - string(8) "stdClass" - ["object_refcount"]=> - int(1) - ["object_hash"]=> - string(32) "%s" - ["object_handle"]=> - int(1) -} -array(5) { - ["type"]=> - string(5) "array" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["array_count"]=> - int(2) -} -array(7) { - ["type"]=> - string(8) "resource" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) - ["resource_handle"]=> - int(4) - ["resource_type"]=> - string(6) "stream" - ["resource_refcount"]=> - int(1) -} -array(4) { - ["type"]=> - string(4) "NULL" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(4) { - ["type"]=> - string(7) "boolean" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(2) - ["zval_isref"]=> - bool(false) -} -array(4) { - ["type"]=> - string(7) "integer" - ["zval_hash"]=> - string(16) "%s" - ["zval_refcount"]=> - int(3) - ["zval_isref"]=> - bool(true) -} -NULL diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php deleted file mode 100644 index 9c4e23a2c..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ /dev/null @@ -1,205 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use Symfony\Component\Debug\DebugClassLoader; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\Exception\ContextErrorException; - -class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var int Error reporting level before running tests. - */ - private $errorReporting; - - private $loader; - - protected function setUp() - { - $this->errorReporting = error_reporting(E_ALL | E_STRICT); - $this->loader = new ClassLoader(); - spl_autoload_register(array($this->loader, 'loadClass'), true, true); - DebugClassLoader::enable(); - } - - protected function tearDown() - { - DebugClassLoader::disable(); - spl_autoload_unregister(array($this->loader, 'loadClass')); - error_reporting($this->errorReporting); - } - - public function testIdempotence() - { - DebugClassLoader::enable(); - - $functions = spl_autoload_functions(); - foreach ($functions as $function) { - if (is_array($function) && $function[0] instanceof DebugClassLoader) { - $reflClass = new \ReflectionClass($function[0]); - $reflProp = $reflClass->getProperty('classLoader'); - $reflProp->setAccessible(true); - - $this->assertNotInstanceOf('Symfony\Component\Debug\DebugClassLoader', $reflProp->getValue($function[0])); - - return; - } - } - - $this->fail('DebugClassLoader did not register'); - } - - public function testUnsilencing() - { - if (PHP_VERSION_ID >= 70000) { - $this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.'); - } - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('HHVM is not handled in this test case.'); - } - - ob_start(); - - $this->iniSet('log_errors', 0); - $this->iniSet('display_errors', 1); - - // See below: this will fail with parse error - // but this should not be @-silenced. - @class_exists(__NAMESPACE__.'\TestingUnsilencing', true); - - $output = ob_get_clean(); - - $this->assertStringMatchesFormat('%aParse error%a', $output); - } - - public function testStacking() - { - // the ContextErrorException must not be loaded to test the workaround - // for https://bugs.php.net/65322. - if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) { - $this->markTestSkipped('The ContextErrorException class is already loaded.'); - } - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('HHVM is not handled in this test case.'); - } - - ErrorHandler::register(); - - try { - // Trigger autoloading + E_STRICT at compile time - // which in turn triggers $errorHandler->handle() - // that again triggers autoloading for ContextErrorException. - // Error stacking works around the bug above and everything is fine. - - eval(' - namespace '.__NAMESPACE__.'; - class ChildTestingStacking extends TestingStacking { function foo($bar) {} } - '); - $this->fail('ContextErrorException expected'); - } catch (\ErrorException $exception) { - // if an exception is thrown, the test passed - restore_error_handler(); - restore_exception_handler(); - $this->assertStringStartsWith(__FILE__, $exception->getFile()); - if (PHP_VERSION_ID < 70000) { - $this->assertRegExp('/^Runtime Notice: Declaration/', $exception->getMessage()); - $this->assertEquals(E_STRICT, $exception->getSeverity()); - } else { - $this->assertRegExp('/^Warning: Declaration/', $exception->getMessage()); - $this->assertEquals(E_WARNING, $exception->getSeverity()); - } - } catch (\Exception $exception) { - restore_error_handler(); - restore_exception_handler(); - - throw $exception; - } - } - - /** - * @expectedException \RuntimeException - */ - public function testNameCaseMismatch() - { - class_exists(__NAMESPACE__.'\TestingCaseMismatch', true); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Case mismatch between class and source file names - */ - public function testFileCaseMismatch() - { - if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) { - $this->markTestSkipped('Can only be run on case insensitive filesystems'); - } - - class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true); - } - - /** - * @expectedException \RuntimeException - */ - public function testPsr4CaseMismatch() - { - class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true); - } - - public function testNotPsr0() - { - $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\NotPSR0', true)); - } - - public function testNotPsr0Bis() - { - $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\NotPSR0bis', true)); - } - - public function testClassAlias() - { - $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\ClassAlias', true)); - } -} - -class ClassLoader -{ - public function loadClass($class) - { - } - - public function getClassMap() - { - return array(__NAMESPACE__.'\Fixtures\NotPSR0bis' => __DIR__.'/Fixtures/notPsr0Bis.php'); - } - - public function findFile($class) - { - $fixtureDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR; - - if (__NAMESPACE__.'\TestingUnsilencing' === $class) { - eval('-- parse error --'); - } elseif (__NAMESPACE__.'\TestingStacking' === $class) { - eval('namespace '.__NAMESPACE__.'; class TestingStacking { function foo() {} }'); - } elseif (__NAMESPACE__.'\TestingCaseMismatch' === $class) { - eval('namespace '.__NAMESPACE__.'; class TestingCaseMisMatch {}'); - } elseif (__NAMESPACE__.'\Fixtures\CaseMismatch' === $class) { - return $fixtureDir.'CaseMismatch.php'; - } elseif (__NAMESPACE__.'\Fixtures\Psr4CaseMismatch' === $class) { - return $fixtureDir.'psr4'.DIRECTORY_SEPARATOR.'Psr4CaseMismatch.php'; - } elseif (__NAMESPACE__.'\Fixtures\NotPSR0' === $class) { - return $fixtureDir.'reallyNotPsr0.php'; - } elseif (__NAMESPACE__.'\Fixtures\NotPSR0bis' === $class) { - return $fixtureDir.'notPsr0Bis.php'; - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php deleted file mode 100644 index 3b0cc7bdf..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ /dev/null @@ -1,485 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use Psr\Log\LogLevel; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\Exception\ContextErrorException; - -/** - * ErrorHandlerTest. - * - * @author Robert Schönthal - * @author Nicolas Grekas - */ -class ErrorHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testRegister() - { - $handler = ErrorHandler::register(); - - try { - $this->assertInstanceOf('Symfony\Component\Debug\ErrorHandler', $handler); - $this->assertSame($handler, ErrorHandler::register()); - - $newHandler = new ErrorHandler(); - - $this->assertSame($newHandler, ErrorHandler::register($newHandler, false)); - $h = set_error_handler('var_dump'); - restore_error_handler(); - $this->assertSame(array($handler, 'handleError'), $h); - - try { - $this->assertSame($newHandler, ErrorHandler::register($newHandler, true)); - $h = set_error_handler('var_dump'); - restore_error_handler(); - $this->assertSame(array($newHandler, 'handleError'), $h); - } catch (\Exception $e) { - } - - restore_error_handler(); - restore_exception_handler(); - - if (isset($e)) { - throw $e; - } - } catch (\Exception $e) { - } - - restore_error_handler(); - restore_exception_handler(); - - if (isset($e)) { - throw $e; - } - } - - public function testNotice() - { - ErrorHandler::register(); - - try { - self::triggerNotice($this); - $this->fail('ContextErrorException expected'); - } catch (ContextErrorException $exception) { - // if an exception is thrown, the test passed - restore_error_handler(); - restore_exception_handler(); - - $this->assertEquals(E_NOTICE, $exception->getSeverity()); - $this->assertEquals(__FILE__, $exception->getFile()); - $this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); - $this->assertArrayHasKey('foobar', $exception->getContext()); - - $trace = $exception->getTrace(); - $this->assertEquals(__FILE__, $trace[0]['file']); - $this->assertEquals('Symfony\Component\Debug\ErrorHandler', $trace[0]['class']); - $this->assertEquals('handleError', $trace[0]['function']); - $this->assertEquals('->', $trace[0]['type']); - - $this->assertEquals(__FILE__, $trace[1]['file']); - $this->assertEquals(__CLASS__, $trace[1]['class']); - $this->assertEquals('triggerNotice', $trace[1]['function']); - $this->assertEquals('::', $trace[1]['type']); - - $this->assertEquals(__FILE__, $trace[1]['file']); - $this->assertEquals(__CLASS__, $trace[2]['class']); - $this->assertEquals(__FUNCTION__, $trace[2]['function']); - $this->assertEquals('->', $trace[2]['type']); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - // dummy function to test trace in error handler. - private static function triggerNotice($that) - { - // dummy variable to check for in error handler. - $foobar = 123; - $that->assertSame('', $foo.$foo.$bar); - } - - public function testConstruct() - { - try { - $handler = ErrorHandler::register(); - $handler->throwAt(3, true); - $this->assertEquals(3 | E_RECOVERABLE_ERROR | E_USER_ERROR, $handler->throwAt(0)); - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - public function testDefaultLogger() - { - try { - $handler = ErrorHandler::register(); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $handler->setDefaultLogger($logger, E_NOTICE); - $handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL)); - - $loggers = array( - E_DEPRECATED => array(null, LogLevel::INFO), - E_USER_DEPRECATED => array(null, LogLevel::INFO), - E_NOTICE => array($logger, LogLevel::NOTICE), - E_USER_NOTICE => array($logger, LogLevel::CRITICAL), - E_STRICT => array(null, LogLevel::NOTICE), - E_WARNING => array(null, LogLevel::WARNING), - E_USER_WARNING => array(null, LogLevel::WARNING), - E_COMPILE_WARNING => array(null, LogLevel::WARNING), - E_CORE_WARNING => array(null, LogLevel::WARNING), - E_USER_ERROR => array(null, LogLevel::ERROR), - E_RECOVERABLE_ERROR => array(null, LogLevel::ERROR), - E_COMPILE_ERROR => array(null, LogLevel::EMERGENCY), - E_PARSE => array(null, LogLevel::EMERGENCY), - E_ERROR => array(null, LogLevel::EMERGENCY), - E_CORE_ERROR => array(null, LogLevel::EMERGENCY), - ); - $this->assertSame($loggers, $handler->setLoggers(array())); - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - public function testHandleError() - { - $this->iniSet('error_reporting', -1); - - try { - $handler = ErrorHandler::register(); - $handler->throwAt(0, true); - $this->assertFalse($handler->handleError(0, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(3, true); - $this->assertFalse($handler->handleError(4, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(3, true); - try { - $handler->handleError(4, 'foo', 'foo.php', 12, array()); - } catch (\ErrorException $e) { - $this->assertSame('Parse Error: foo', $e->getMessage()); - $this->assertSame(4, $e->getSeverity()); - $this->assertSame('foo.php', $e->getFile()); - $this->assertSame(12, $e->getLine()); - } - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(E_USER_DEPRECATED, true); - $this->assertFalse($handler->handleError(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(E_DEPRECATED, true); - $this->assertFalse($handler->handleError(E_DEPRECATED, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $that = $this; - $warnArgCheck = function ($logLevel, $message, $context) use ($that) { - $that->assertEquals('info', $logLevel); - $that->assertEquals('foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_USER_DEPRECATED); - $that->assertArrayHasKey('stack', $context); - $that->assertInternalType('array', $context['stack']); - }; - - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($warnArgCheck)) - ; - - $handler = ErrorHandler::register(); - $handler->setDefaultLogger($logger, E_USER_DEPRECATED); - $this->assertTrue($handler->handleError(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Undefined variable: undefVar', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_NOTICE); - }; - - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler = ErrorHandler::register(); - $handler->setDefaultLogger($logger, E_NOTICE); - $handler->screamAt(E_NOTICE); - unset($undefVar); - @$undefVar++; - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - public function testHandleException() - { - try { - $handler = ErrorHandler::register(); - - $exception = new \Exception('foo'); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Uncaught Exception: foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_ERROR); - }; - - $logger - ->expects($this->exactly(2)) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler->setDefaultLogger($logger, E_ERROR); - - try { - $handler->handleException($exception); - $this->fail('Exception expected'); - } catch (\Exception $e) { - $this->assertSame($exception, $e); - } - - $that = $this; - $handler->setExceptionHandler(function ($e) use ($exception, $that) { - $that->assertSame($exception, $e); - }); - - $handler->handleException($exception); - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - public function testErrorStacking() - { - try { - $handler = ErrorHandler::register(); - $handler->screamAt(E_USER_WARNING); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $logger - ->expects($this->exactly(2)) - ->method('log') - ->withConsecutive( - array($this->equalTo(LogLevel::WARNING), $this->equalTo('Dummy log')), - array($this->equalTo(LogLevel::DEBUG), $this->equalTo('Silenced warning')) - ) - ; - - $handler->setDefaultLogger($logger, array(E_USER_WARNING => LogLevel::WARNING)); - - ErrorHandler::stackErrors(); - @trigger_error('Silenced warning', E_USER_WARNING); - $logger->log(LogLevel::WARNING, 'Dummy log'); - ErrorHandler::unstackErrors(); - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - public function testHandleFatalError() - { - try { - $handler = ErrorHandler::register(); - - $error = array( - 'type' => E_PARSE, - 'message' => 'foo', - 'file' => 'bar', - 'line' => 123, - ); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Fatal Parse Error: foo', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_PARSE); - }; - - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler->setDefaultLogger($logger, E_PARSE); - - $handler->handleFatalError($error); - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - public function testHandleFatalErrorOnHHVM() - { - try { - $handler = ErrorHandler::register(); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $logger - ->expects($this->once()) - ->method('log') - ->with( - $this->equalTo(LogLevel::EMERGENCY), - $this->equalTo('Fatal Error: foo'), - $this->equalTo(array( - 'type' => 1, - 'file' => 'bar', - 'line' => 123, - 'level' => -1, - 'stack' => array(456), - )) - ) - ; - - $handler->setDefaultLogger($logger, E_ERROR); - - $error = array( - 'type' => E_ERROR + 0x1000000, // This error level is used by HHVM for fatal errors - 'message' => 'foo', - 'file' => 'bar', - 'line' => 123, - 'context' => array(123), - 'backtrace' => array(456), - ); - - call_user_func_array(array($handler, 'handleError'), $error); - $handler->handleFatalError($error); - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - /** - * @group legacy - */ - public function testLegacyInterface() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - try { - $handler = ErrorHandler::register(0); - $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $that = $this; - $logArgCheck = function ($level, $message, $context) use ($that) { - $that->assertEquals('Undefined variable: undefVar', $message); - $that->assertArrayHasKey('type', $context); - $that->assertEquals($context['type'], E_NOTICE); - }; - - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler = ErrorHandler::register(E_NOTICE); - $handler->setLogger($logger, 'scream'); - unset($undefVar); - @$undefVar++; - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php deleted file mode 100644 index 99eaf497d..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php +++ /dev/null @@ -1,256 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\Exception; - -use Symfony\Component\Debug\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 -{ - public function testStatusCode() - { - $flattened = FlattenException::create(new \RuntimeException(), 403); - $this->assertEquals('403', $flattened->getStatusCode()); - - $flattened = FlattenException::create(new \RuntimeException()); - $this->assertEquals('500', $flattened->getStatusCode()); - - $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()); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testFlattenHttpException(\Exception $exception, $statusCode) - { - $flattened = FlattenException::create($exception); - $flattened2 = FlattenException::create($exception); - - $flattened->setPrevious($flattened2); - - $this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.'); - $this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.'); - $this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception'); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testPrevious(\Exception $exception, $statusCode) - { - $flattened = FlattenException::create($exception); - $flattened2 = FlattenException::create($exception); - - $flattened->setPrevious($flattened2); - - $this->assertSame($flattened2, $flattened->getPrevious()); - - $this->assertSame(array($flattened2), $flattened->getAllPrevious()); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testLine(\Exception $exception) - { - $flattened = FlattenException::create($exception); - $this->assertSame($exception->getLine(), $flattened->getLine()); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testFile(\Exception $exception) - { - $flattened = FlattenException::create($exception); - $this->assertSame($exception->getFile(), $flattened->getFile()); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testToArray(\Exception $exception, $statusCode) - { - $flattened = FlattenException::create($exception); - $flattened->setTrace(array(), '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(), - )), - ), - ), $flattened->toArray()); - } - - public function flattenDataProvider() - { - return array( - array(new \Exception('test', 123), 500), - ); - } - - public function testRecursionInArguments() - { - $a = array('foo', array(2, &$a)); - $exception = $this->createException($a); - - $flattened = FlattenException::create($exception); - $trace = $flattened->getTrace(); - $this->assertContains('*DEEP NESTED ARRAY*', serialize($trace)); - } - - public function testTooBigArray() - { - $a = array(); - for ($i = 0; $i < 20; ++$i) { - for ($j = 0; $j < 50; ++$j) { - for ($k = 0; $k < 10; ++$k) { - $a[$i][$j][$k] = 'value'; - } - } - } - $a[20] = 'value'; - $a[21] = 'value1'; - $exception = $this->createException($a); - - $flattened = FlattenException::create($exception); - $trace = $flattened->getTrace(); - $serializeTrace = serialize($trace); - - $this->assertContains('*SKIPPED over 10000 entries*', $serializeTrace); - $this->assertNotContains('*value1*', $serializeTrace); - } - - 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/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php deleted file mode 100644 index 26f889288..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\Debug\Exception\OutOfMemoryException; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; - -class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testDebug() - { - $handler = new ExceptionHandler(false); - $response = $handler->createResponse(new \RuntimeException('Foo')); - - $this->assertContains('

Whoops, looks like something went wrong.

', $response->getContent()); - $this->assertNotContains('

', $response->getContent()); - - $handler = new ExceptionHandler(true); - $response = $handler->createResponse(new \RuntimeException('Foo')); - - $this->assertContains('

Whoops, looks like something went wrong.

', $response->getContent()); - $this->assertContains('

', $response->getContent()); - } - - public function testStatusCode() - { - $handler = new ExceptionHandler(false); - - $response = $handler->createResponse(new \RuntimeException('Foo')); - $this->assertEquals('500', $response->getStatusCode()); - $this->assertContains('Whoops, looks like something went wrong.', $response->getContent()); - - $response = $handler->createResponse(new NotFoundHttpException('Foo')); - $this->assertEquals('404', $response->getStatusCode()); - $this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent()); - } - - public function testHeaders() - { - $handler = new ExceptionHandler(false); - - $response = $handler->createResponse(new MethodNotAllowedHttpException(array('POST'))); - $this->assertEquals('405', $response->getStatusCode()); - $this->assertEquals('POST', $response->headers->get('Allow')); - } - - public function testNestedExceptions() - { - $handler = new ExceptionHandler(true); - $response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar'))); - } - - public function testHandle() - { - $exception = new \Exception('foo'); - - if (class_exists('Symfony\Component\HttpFoundation\Response')) { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse')); - $handler - ->expects($this->exactly(2)) - ->method('createResponse') - ->will($this->returnValue(new Response())); - } else { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); - $handler - ->expects($this->exactly(2)) - ->method('sendPhpResponse'); - } - - $handler->handle($exception); - - $that = $this; - $handler->setHandler(function ($e) use ($exception, $that) { - $that->assertSame($exception, $e); - }); - - $handler->handle($exception); - } - - public function testHandleOutOfMemoryException() - { - $exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__); - - if (class_exists('Symfony\Component\HttpFoundation\Response')) { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse')); - $handler - ->expects($this->once()) - ->method('createResponse') - ->will($this->returnValue(new Response())); - } else { - $handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse')); - $handler - ->expects($this->once()) - ->method('sendPhpResponse'); - } - - $that = $this; - $handler->setHandler(function ($e) use ($that) { - $that->fail('OutOfMemoryException should bypass the handler'); - }); - - $handler->handle($exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php deleted file mode 100644 index 26eeede02..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\FatalErrorHandler; - -use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader; -use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; -use Symfony\Component\Debug\DebugClassLoader; -use Composer\Autoload\ClassLoader as ComposerClassLoader; - -class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase -{ - public static function setUpBeforeClass() - { - foreach (spl_autoload_functions() as $function) { - if (!is_array($function)) { - continue; - } - - // get class loaders wrapped by DebugClassLoader - if ($function[0] instanceof DebugClassLoader) { - $function = $function[0]->getClassLoader(); - } - - if ($function[0] instanceof ComposerClassLoader) { - $function[0]->add('Symfony_Component_Debug_Tests_Fixtures', dirname(dirname(dirname(dirname(dirname(__DIR__)))))); - break; - } - } - } - - /** - * @dataProvider provideClassNotFoundData - */ - public function testHandleClassNotFound($error, $translatedMessage, $autoloader = null) - { - if ($autoloader) { - // Unregister all autoloaders to ensure the custom provided - // autoloader is the only one to be used during the test run. - $autoloaders = spl_autoload_functions(); - array_map('spl_autoload_unregister', $autoloaders); - spl_autoload_register($autoloader); - } - - $handler = new ClassNotFoundFatalErrorHandler(); - - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - if ($autoloader) { - spl_autoload_unregister($autoloader); - array_map('spl_autoload_register', $autoloaders); - } - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); - $this->assertSame($translatedMessage, $exception->getMessage()); - $this->assertSame($error['type'], $exception->getSeverity()); - $this->assertSame($error['file'], $exception->getFile()); - $this->assertSame($error['line'], $exception->getLine()); - } - - /** - * @group legacy - */ - public function testLegacyHandleClassNotFound() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception')); - $symfonyUniversalClassLoader = new SymfonyUniversalClassLoader(); - $symfonyUniversalClassLoader->registerPrefixes($prefixes); - - $this->testHandleClassNotFound( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - array($symfonyUniversalClassLoader, 'loadClass') - ); - } - - public function provideClassNotFoundData() - { - $prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception')); - - $symfonyAutoloader = new SymfonyClassLoader(); - $symfonyAutoloader->addPrefixes($prefixes); - - $debugClassLoader = new DebugClassLoader(array($symfonyAutoloader, 'loadClass')); - - return array( - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'WhizBangFactory\' not found', - ), - "Attempted to load class \"WhizBangFactory\" from the global namespace.\nDid you forget a \"use\" statement?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found', - ), - "Attempted to load class \"WhizBangFactory\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'PEARClass\' not found', - ), - "Attempted to load class \"PEARClass\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony_Component_Debug_Tests_Fixtures_PEARClass\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - array($symfonyAutoloader, 'loadClass'), - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - array($debugClassLoader, 'loadClass'), - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", - function ($className) { /* do nothing here */ }, - ), - ); - } - - public function testCannotRedeclareClass() - { - if (!file_exists(__DIR__.'/../FIXTURES2/REQUIREDTWICE.PHP')) { - $this->markTestSkipped('Can only be run on case insensitive filesystems'); - } - - require_once __DIR__.'/../FIXTURES2/REQUIREDTWICE.PHP'; - - $error = array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\RequiredTwice\' not found', - ); - - $handler = new ClassNotFoundFatalErrorHandler(); - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php deleted file mode 100644 index 795b74781..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; - -class UndefinedFunctionFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider provideUndefinedFunctionData - */ - public function testUndefinedFunction($error, $translatedMessage) - { - $handler = new UndefinedFunctionFatalErrorHandler(); - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception); - // class names are case insensitive and PHP/HHVM do not return the same - $this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage())); - $this->assertSame($error['type'], $exception->getSeverity()); - $this->assertSame($error['file'], $exception->getFile()); - $this->assertSame($error['line'], $exception->getLine()); - } - - public function provideUndefinedFunctionData() - { - return array( - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function test_namespaced_function()', - ), - "Attempted to call function \"test_namespaced_function\" from the global namespace.\nDid you mean to call \"\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function Foo\\Bar\\Baz\\test_namespaced_function()', - ), - "Attempted to call function \"test_namespaced_function\" from namespace \"Foo\\Bar\\Baz\".\nDid you mean to call \"\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function foo()', - ), - 'Attempted to call function "foo" from the global namespace.', - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function Foo\\Bar\\Baz\\foo()', - ), - 'Attempted to call function "foo" from namespace "Foo\Bar\Baz".', - ), - ); - } -} - -function test_namespaced_function() -{ -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php deleted file mode 100644 index 794bf4c3a..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\FatalErrorHandler; - -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler; - -class UndefinedMethodFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider provideUndefinedMethodData - */ - public function testUndefinedMethod($error, $translatedMessage) - { - $handler = new UndefinedMethodFatalErrorHandler(); - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception); - $this->assertSame($translatedMessage, $exception->getMessage()); - $this->assertSame($error['type'], $exception->getSeverity()); - $this->assertSame($error['file'], $exception->getFile()); - $this->assertSame($error['line'], $exception->getLine()); - } - - public function provideUndefinedMethodData() - { - return array( - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined method SplObjectStorage::what()', - ), - 'Attempted to call method "what" on class "SplObjectStorage".', - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined method SplObjectStorage::walid()', - ), - "Attempted to call method \"walid\" on class \"SplObjectStorage\".\nDid you mean to call \"valid\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined method SplObjectStorage::offsetFet()', - ), - "Attempted to call method \"offsetFet\" on class \"SplObjectStorage\".\nDid you mean to call e.g. \"offsetGet\", \"offsetSet\" or \"offsetUnset\"?", - ), - ); - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/ClassAlias.php b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/ClassAlias.php deleted file mode 100644 index 9d6dbaa71..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/ClassAlias.php +++ /dev/null @@ -1,3 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use Symfony\Component\Debug\ExceptionHandler; - -class MockExceptionHandler extends Exceptionhandler -{ - public $e; - - public function handle(\Exception $e) - { - $this->e = $e; - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/composer.json b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/composer.json deleted file mode 100644 index 2d101813a..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/composer.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "symfony/debug", - "type": "library", - "description": "Symfony Debug Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7", - "symfony/class-loader": "~2.2", - "symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2", - "symfony/http-foundation": "~2.1" - }, - "suggest": { - "symfony/http-foundation": "", - "symfony/http-kernel": "" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\Debug\\": "" } - }, - "target-dir": "Symfony/Component/Debug", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/exclude.txt b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/exclude.txt deleted file mode 100644 index 9010fbf2e..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/exclude.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -# The following source files are not re-distributed with the "build" of the application -# since they are used solely for constructing other files during the build process -# -Tests \ No newline at end of file diff --git a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist b/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist deleted file mode 100644 index e91766065..000000000 --- a/lib/silex/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/symfony/debug/Tests/DebugClassLoaderTest.php b/lib/silex/vendor/symfony/debug/Tests/DebugClassLoaderTest.php deleted file mode 100644 index 0219f5335..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/DebugClassLoaderTest.php +++ /dev/null @@ -1,425 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\DebugClassLoader; -use Symfony\Component\Debug\ErrorHandler; - -class DebugClassLoaderTest extends TestCase -{ - /** - * @var int Error reporting level before running tests - */ - private $errorReporting; - - private $loader; - - protected function setUp() - { - $this->errorReporting = error_reporting(E_ALL); - $this->loader = new ClassLoader(); - spl_autoload_register(array($this->loader, 'loadClass'), true, true); - DebugClassLoader::enable(); - } - - protected function tearDown() - { - DebugClassLoader::disable(); - spl_autoload_unregister(array($this->loader, 'loadClass')); - error_reporting($this->errorReporting); - } - - public function testIdempotence() - { - DebugClassLoader::enable(); - - $functions = spl_autoload_functions(); - foreach ($functions as $function) { - if (is_array($function) && $function[0] instanceof DebugClassLoader) { - $reflClass = new \ReflectionClass($function[0]); - $reflProp = $reflClass->getProperty('classLoader'); - $reflProp->setAccessible(true); - - $this->assertNotInstanceOf('Symfony\Component\Debug\DebugClassLoader', $reflProp->getValue($function[0])); - - return; - } - } - - $this->fail('DebugClassLoader did not register'); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage boo - */ - public function testThrowingClass() - { - try { - class_exists(__NAMESPACE__.'\Fixtures\Throwing'); - $this->fail('Exception expected'); - } catch (\Exception $e) { - $this->assertSame('boo', $e->getMessage()); - } - - // the second call also should throw - class_exists(__NAMESPACE__.'\Fixtures\Throwing'); - } - - public function testUnsilencing() - { - if (\PHP_VERSION_ID >= 70000) { - $this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.'); - } - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('HHVM is not handled in this test case.'); - } - - ob_start(); - - $this->iniSet('log_errors', 0); - $this->iniSet('display_errors', 1); - - // See below: this will fail with parse error - // but this should not be @-silenced. - @class_exists(__NAMESPACE__.'\TestingUnsilencing', true); - - $output = ob_get_clean(); - - $this->assertStringMatchesFormat('%aParse error%a', $output); - } - - public function testStacking() - { - // the ContextErrorException must not be loaded to test the workaround - // for https://bugs.php.net/65322. - if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) { - $this->markTestSkipped('The ContextErrorException class is already loaded.'); - } - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('HHVM is not handled in this test case.'); - } - - ErrorHandler::register(); - - try { - // Trigger autoloading + E_STRICT at compile time - // which in turn triggers $errorHandler->handle() - // that again triggers autoloading for ContextErrorException. - // Error stacking works around the bug above and everything is fine. - - eval(' - namespace '.__NAMESPACE__.'; - class ChildTestingStacking extends TestingStacking { function foo($bar) {} } - '); - $this->fail('ContextErrorException expected'); - } catch (\ErrorException $exception) { - // if an exception is thrown, the test passed - $this->assertStringStartsWith(__FILE__, $exception->getFile()); - if (\PHP_VERSION_ID < 70000) { - $this->assertRegExp('/^Runtime Notice: Declaration/', $exception->getMessage()); - $this->assertEquals(E_STRICT, $exception->getSeverity()); - } else { - $this->assertRegExp('/^Warning: Declaration/', $exception->getMessage()); - $this->assertEquals(E_WARNING, $exception->getSeverity()); - } - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Case mismatch between loaded and declared class names - */ - public function testNameCaseMismatch() - { - class_exists(__NAMESPACE__.'\TestingCaseMismatch', true); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Case mismatch between class and real file names - */ - public function testFileCaseMismatch() - { - if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) { - $this->markTestSkipped('Can only be run on case insensitive filesystems'); - } - - class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Case mismatch between loaded and declared class names - */ - public function testPsr4CaseMismatch() - { - class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true); - } - - public function testNotPsr0() - { - $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\NotPSR0', true)); - } - - public function testNotPsr0Bis() - { - $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\NotPSR0bis', true)); - } - - public function testClassAlias() - { - $this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\ClassAlias', true)); - } - - /** - * @dataProvider provideDeprecatedSuper - */ - public function testDeprecatedSuper($class, $super, $type) - { - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_DEPRECATED); - - class_exists('Test\\'.__NAMESPACE__.'\\'.$class, true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $xError = array( - 'type' => E_USER_DEPRECATED, - 'message' => 'The "Test\Symfony\Component\Debug\Tests\\'.$class.'" class '.$type.' "Symfony\Component\Debug\Tests\Fixtures\\'.$super.'" that is deprecated but this is a test deprecation notice.', - ); - - $this->assertSame($xError, $lastError); - } - - public function provideDeprecatedSuper() - { - return array( - array('DeprecatedInterfaceClass', 'DeprecatedInterface', 'implements'), - array('DeprecatedParentClass', 'DeprecatedClass', 'extends'), - ); - } - - public function testInterfaceExtendsDeprecatedInterface() - { - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); - - class_exists('Test\\'.__NAMESPACE__.'\\NonDeprecatedInterfaceClass', true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $xError = array( - 'type' => E_USER_NOTICE, - 'message' => '', - ); - - $this->assertSame($xError, $lastError); - } - - public function testDeprecatedSuperInSameNamespace() - { - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); - - class_exists('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent', true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $xError = array( - 'type' => E_USER_NOTICE, - 'message' => '', - ); - - $this->assertSame($xError, $lastError); - } - - public function testReservedForPhp7() - { - if (\PHP_VERSION_ID >= 70000) { - $this->markTestSkipped('PHP7 already prevents using reserved names.'); - } - - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); - - class_exists('Test\\'.__NAMESPACE__.'\\Float', true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $xError = array( - 'type' => E_USER_DEPRECATED, - 'message' => 'The "Test\Symfony\Component\Debug\Tests\Float" class uses the reserved name "Float", it will break on PHP 7 and higher', - ); - - $this->assertSame($xError, $lastError); - } - - public function testExtendedFinalClass() - { - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); - - class_exists('Test\\'.__NAMESPACE__.'\\ExtendsFinalClass', true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $xError = array( - 'type' => E_USER_DEPRECATED, - 'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass" class is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass".', - ); - - $this->assertSame($xError, $lastError); - } - - public function testExtendedFinalMethod() - { - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); - - class_exists(__NAMESPACE__.'\\Fixtures\\ExtendedFinalMethod', true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $xError = array( - 'type' => E_USER_DEPRECATED, - 'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".', - ); - - $this->assertSame($xError, $lastError); - } - - public function testExtendedDeprecatedMethodDoesntTriggerAnyNotice() - { - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); - - class_exists('Test\\'.__NAMESPACE__.'\\ExtendsAnnotatedClass', true); - - error_reporting($e); - restore_error_handler(); - - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - - $this->assertSame(array('type' => E_USER_NOTICE, 'message' => ''), $lastError); - } - - public function testInternalsUse() - { - $deprecations = array(); - set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; }); - $e = error_reporting(E_USER_DEPRECATED); - - class_exists('Test\\'.__NAMESPACE__.'\\ExtendsInternals', true); - - error_reporting($e); - restore_error_handler(); - - $this->assertSame($deprecations, array( - 'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass" class is considered internal since version 3.4. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".', - 'The "Symfony\Component\Debug\Tests\Fixtures\InternalInterface" interface is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".', - 'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait" trait is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".', - 'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait2::internalMethod()" method is considered internal since version 3.4. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".', - )); - } -} - -class ClassLoader -{ - public function loadClass($class) - { - } - - public function getClassMap() - { - return array(__NAMESPACE__.'\Fixtures\NotPSR0bis' => __DIR__.'/Fixtures/notPsr0Bis.php'); - } - - public function findFile($class) - { - $fixtureDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR; - - if (__NAMESPACE__.'\TestingUnsilencing' === $class) { - eval('-- parse error --'); - } elseif (__NAMESPACE__.'\TestingStacking' === $class) { - eval('namespace '.__NAMESPACE__.'; class TestingStacking { function foo() {} }'); - } elseif (__NAMESPACE__.'\TestingCaseMismatch' === $class) { - eval('namespace '.__NAMESPACE__.'; class TestingCaseMisMatch {}'); - } elseif (__NAMESPACE__.'\Fixtures\Psr4CaseMismatch' === $class) { - return $fixtureDir.'psr4'.DIRECTORY_SEPARATOR.'Psr4CaseMismatch.php'; - } elseif (__NAMESPACE__.'\Fixtures\NotPSR0' === $class) { - return $fixtureDir.'reallyNotPsr0.php'; - } elseif (__NAMESPACE__.'\Fixtures\NotPSR0bis' === $class) { - return $fixtureDir.'notPsr0Bis.php'; - } elseif ('Symfony\Bridge\Debug\Tests\Fixtures\ExtendsDeprecatedParent' === $class) { - eval('namespace Symfony\Bridge\Debug\Tests\Fixtures; class ExtendsDeprecatedParent extends \\'.__NAMESPACE__.'\Fixtures\DeprecatedClass {}'); - } elseif ('Test\\'.__NAMESPACE__.'\DeprecatedParentClass' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class DeprecatedParentClass extends \\'.__NAMESPACE__.'\Fixtures\DeprecatedClass {}'); - } elseif ('Test\\'.__NAMESPACE__.'\DeprecatedInterfaceClass' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class DeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\DeprecatedInterface {}'); - } elseif ('Test\\'.__NAMESPACE__.'\NonDeprecatedInterfaceClass' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class NonDeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\NonDeprecatedInterface {}'); - } elseif ('Test\\'.__NAMESPACE__.'\Float' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class Float {}'); - } elseif ('Test\\'.__NAMESPACE__.'\ExtendsFinalClass' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsFinalClass extends \\'.__NAMESPACE__.'\Fixtures\FinalClass {}'); - } elseif ('Test\\'.__NAMESPACE__.'\ExtendsAnnotatedClass' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsAnnotatedClass extends \\'.__NAMESPACE__.'\Fixtures\AnnotatedClass { - public function deprecatedMethod() { } - }'); - } elseif ('Test\\'.__NAMESPACE__.'\ExtendsInternals' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsInternals extends ExtendsInternalsParent { - use \\'.__NAMESPACE__.'\Fixtures\InternalTrait; - - public function internalMethod() { } - }'); - } elseif ('Test\\'.__NAMESPACE__.'\ExtendsInternalsParent' === $class) { - eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsInternalsParent extends \\'.__NAMESPACE__.'\Fixtures\InternalClass implements \\'.__NAMESPACE__.'\Fixtures\InternalInterface { }'); - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/ErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Tests/ErrorHandlerTest.php deleted file mode 100644 index a57e83ee4..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/ErrorHandlerTest.php +++ /dev/null @@ -1,548 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use PHPUnit\Framework\TestCase; -use Psr\Log\LogLevel; -use Symfony\Component\Debug\BufferingLogger; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\Exception\SilencedErrorContext; - -/** - * ErrorHandlerTest. - * - * @author Robert Schönthal - * @author Nicolas Grekas - */ -class ErrorHandlerTest extends TestCase -{ - public function testRegister() - { - $handler = ErrorHandler::register(); - - try { - $this->assertInstanceOf('Symfony\Component\Debug\ErrorHandler', $handler); - $this->assertSame($handler, ErrorHandler::register()); - - $newHandler = new ErrorHandler(); - - $this->assertSame($newHandler, ErrorHandler::register($newHandler, false)); - $h = set_error_handler('var_dump'); - restore_error_handler(); - $this->assertSame(array($handler, 'handleError'), $h); - - try { - $this->assertSame($newHandler, ErrorHandler::register($newHandler, true)); - $h = set_error_handler('var_dump'); - restore_error_handler(); - $this->assertSame(array($newHandler, 'handleError'), $h); - } catch (\Exception $e) { - } - - restore_error_handler(); - restore_exception_handler(); - - if (isset($e)) { - throw $e; - } - } catch (\Exception $e) { - } - - restore_error_handler(); - restore_exception_handler(); - - if (isset($e)) { - throw $e; - } - } - - public function testNotice() - { - ErrorHandler::register(); - - try { - self::triggerNotice($this); - $this->fail('ErrorException expected'); - } catch (\ErrorException $exception) { - // if an exception is thrown, the test passed - $this->assertEquals(E_NOTICE, $exception->getSeverity()); - $this->assertEquals(__FILE__, $exception->getFile()); - $this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); - - $trace = $exception->getTrace(); - - $this->assertEquals(__FILE__, $trace[0]['file']); - $this->assertEquals(__CLASS__, $trace[0]['class']); - $this->assertEquals('triggerNotice', $trace[0]['function']); - $this->assertEquals('::', $trace[0]['type']); - - $this->assertEquals(__FILE__, $trace[0]['file']); - $this->assertEquals(__CLASS__, $trace[1]['class']); - $this->assertEquals(__FUNCTION__, $trace[1]['function']); - $this->assertEquals('->', $trace[1]['type']); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } - - // dummy function to test trace in error handler. - private static function triggerNotice($that) - { - $that->assertSame('', $foo.$foo.$bar); - } - - public function testConstruct() - { - try { - $handler = ErrorHandler::register(); - $handler->throwAt(3, true); - $this->assertEquals(3 | E_RECOVERABLE_ERROR | E_USER_ERROR, $handler->throwAt(0)); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } - - public function testDefaultLogger() - { - try { - $handler = ErrorHandler::register(); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $handler->setDefaultLogger($logger, E_NOTICE); - $handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL)); - - $loggers = array( - E_DEPRECATED => array(null, LogLevel::INFO), - E_USER_DEPRECATED => array(null, LogLevel::INFO), - E_NOTICE => array($logger, LogLevel::WARNING), - E_USER_NOTICE => array($logger, LogLevel::CRITICAL), - E_STRICT => array(null, LogLevel::WARNING), - E_WARNING => array(null, LogLevel::WARNING), - E_USER_WARNING => array(null, LogLevel::WARNING), - E_COMPILE_WARNING => array(null, LogLevel::WARNING), - E_CORE_WARNING => array(null, LogLevel::WARNING), - E_USER_ERROR => array(null, LogLevel::CRITICAL), - E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL), - E_COMPILE_ERROR => array(null, LogLevel::CRITICAL), - E_PARSE => array(null, LogLevel::CRITICAL), - E_ERROR => array(null, LogLevel::CRITICAL), - E_CORE_ERROR => array(null, LogLevel::CRITICAL), - ); - $this->assertSame($loggers, $handler->setLoggers(array())); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } - - public function testHandleError() - { - try { - $handler = ErrorHandler::register(); - $handler->throwAt(0, true); - $this->assertFalse($handler->handleError(0, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(3, true); - $this->assertFalse($handler->handleError(4, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(3, true); - try { - $handler->handleError(4, 'foo', 'foo.php', 12, array()); - } catch (\ErrorException $e) { - $this->assertSame('Parse Error: foo', $e->getMessage()); - $this->assertSame(4, $e->getSeverity()); - $this->assertSame('foo.php', $e->getFile()); - $this->assertSame(12, $e->getLine()); - } - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(E_USER_DEPRECATED, true); - $this->assertFalse($handler->handleError(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $handler = ErrorHandler::register(); - $handler->throwAt(E_DEPRECATED, true); - $this->assertFalse($handler->handleError(E_DEPRECATED, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $warnArgCheck = function ($logLevel, $message, $context) { - $this->assertEquals('info', $logLevel); - $this->assertEquals('User Deprecated: foo', $message); - $this->assertArrayHasKey('exception', $context); - $exception = $context['exception']; - $this->assertInstanceOf(\ErrorException::class, $exception); - $this->assertSame('User Deprecated: foo', $exception->getMessage()); - $this->assertSame(E_USER_DEPRECATED, $exception->getSeverity()); - }; - - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($warnArgCheck)) - ; - - $handler = ErrorHandler::register(); - $handler->setDefaultLogger($logger, E_USER_DEPRECATED); - $this->assertTrue($handler->handleError(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); - - restore_error_handler(); - restore_exception_handler(); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $line = null; - $logArgCheck = function ($level, $message, $context) use (&$line) { - $this->assertEquals('Notice: Undefined variable: undefVar', $message); - $this->assertArrayHasKey('exception', $context); - $exception = $context['exception']; - $this->assertInstanceOf(SilencedErrorContext::class, $exception); - $this->assertSame(E_NOTICE, $exception->getSeverity()); - $this->assertSame(__FILE__, $exception->getFile()); - $this->assertSame($line, $exception->getLine()); - $this->assertNotEmpty($exception->getTrace()); - $this->assertSame(1, $exception->count); - }; - - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler = ErrorHandler::register(); - $handler->setDefaultLogger($logger, E_NOTICE); - $handler->screamAt(E_NOTICE); - unset($undefVar); - $line = __LINE__ + 1; - @$undefVar++; - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - public function testHandleUserError() - { - try { - $handler = ErrorHandler::register(); - $handler->throwAt(0, true); - - $e = null; - $x = new \Exception('Foo'); - - try { - $f = new Fixtures\ToStringThrower($x); - $f .= ''; // Trigger $f->__toString() - } catch (\Exception $e) { - } - - $this->assertSame($x, $e); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } - - public function testHandleDeprecation() - { - $logArgCheck = function ($level, $message, $context) { - $this->assertEquals(LogLevel::INFO, $level); - $this->assertArrayHasKey('exception', $context); - $exception = $context['exception']; - $this->assertInstanceOf(\ErrorException::class, $exception); - $this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage()); - }; - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler = new ErrorHandler(); - $handler->setDefaultLogger($logger); - @$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array()); - } - - /** - * @group no-hhvm - */ - public function testHandleException() - { - try { - $handler = ErrorHandler::register(); - - $exception = new \Exception('foo'); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $logArgCheck = function ($level, $message, $context) { - $this->assertSame('Uncaught Exception: foo', $message); - $this->assertArrayHasKey('exception', $context); - $this->assertInstanceOf(\Exception::class, $context['exception']); - }; - - $logger - ->expects($this->exactly(2)) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler->setDefaultLogger($logger, E_ERROR); - - try { - $handler->handleException($exception); - $this->fail('Exception expected'); - } catch (\Exception $e) { - $this->assertSame($exception, $e); - } - - $handler->setExceptionHandler(function ($e) use ($exception) { - $this->assertSame($exception, $e); - }); - - $handler->handleException($exception); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } - - /** - * @group legacy - */ - public function testErrorStacking() - { - try { - $handler = ErrorHandler::register(); - $handler->screamAt(E_USER_WARNING); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $logger - ->expects($this->exactly(2)) - ->method('log') - ->withConsecutive( - array($this->equalTo(LogLevel::WARNING), $this->equalTo('Dummy log')), - array($this->equalTo(LogLevel::DEBUG), $this->equalTo('User Warning: Silenced warning')) - ) - ; - - $handler->setDefaultLogger($logger, array(E_USER_WARNING => LogLevel::WARNING)); - - ErrorHandler::stackErrors(); - @trigger_error('Silenced warning', E_USER_WARNING); - $logger->log(LogLevel::WARNING, 'Dummy log'); - ErrorHandler::unstackErrors(); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } - - public function testBootstrappingLogger() - { - $bootLogger = new BufferingLogger(); - $handler = new ErrorHandler($bootLogger); - - $loggers = array( - E_DEPRECATED => array($bootLogger, LogLevel::INFO), - E_USER_DEPRECATED => array($bootLogger, LogLevel::INFO), - E_NOTICE => array($bootLogger, LogLevel::WARNING), - E_USER_NOTICE => array($bootLogger, LogLevel::WARNING), - E_STRICT => array($bootLogger, LogLevel::WARNING), - E_WARNING => array($bootLogger, LogLevel::WARNING), - E_USER_WARNING => array($bootLogger, LogLevel::WARNING), - E_COMPILE_WARNING => array($bootLogger, LogLevel::WARNING), - E_CORE_WARNING => array($bootLogger, LogLevel::WARNING), - E_USER_ERROR => array($bootLogger, LogLevel::CRITICAL), - E_RECOVERABLE_ERROR => array($bootLogger, LogLevel::CRITICAL), - E_COMPILE_ERROR => array($bootLogger, LogLevel::CRITICAL), - E_PARSE => array($bootLogger, LogLevel::CRITICAL), - E_ERROR => array($bootLogger, LogLevel::CRITICAL), - E_CORE_ERROR => array($bootLogger, LogLevel::CRITICAL), - ); - - $this->assertSame($loggers, $handler->setLoggers(array())); - - $handler->handleError(E_DEPRECATED, 'Foo message', __FILE__, 123, array()); - - $logs = $bootLogger->cleanLogs(); - - $this->assertCount(1, $logs); - $log = $logs[0]; - $this->assertSame('info', $log[0]); - $this->assertSame('Deprecated: Foo message', $log[1]); - $this->assertArrayHasKey('exception', $log[2]); - $exception = $log[2]['exception']; - $this->assertInstanceOf(\ErrorException::class, $exception); - $this->assertSame('Deprecated: Foo message', $exception->getMessage()); - $this->assertSame(__FILE__, $exception->getFile()); - $this->assertSame(123, $exception->getLine()); - $this->assertSame(E_DEPRECATED, $exception->getSeverity()); - - $bootLogger->log(LogLevel::WARNING, 'Foo message', array('exception' => $exception)); - - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $mockLogger->expects($this->once()) - ->method('log') - ->with(LogLevel::WARNING, 'Foo message', array('exception' => $exception)); - - $handler->setLoggers(array(E_DEPRECATED => array($mockLogger, LogLevel::WARNING))); - } - - /** - * @group no-hhvm - */ - public function testSettingLoggerWhenExceptionIsBuffered() - { - $bootLogger = new BufferingLogger(); - $handler = new ErrorHandler($bootLogger); - - $exception = new \Exception('Foo message'); - - $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $mockLogger->expects($this->once()) - ->method('log') - ->with(LogLevel::CRITICAL, 'Uncaught Exception: Foo message', array('exception' => $exception)); - - $handler->setExceptionHandler(function () use ($handler, $mockLogger) { - $handler->setDefaultLogger($mockLogger); - }); - - $handler->handleException($exception); - } - - /** - * @group no-hhvm - */ - public function testHandleFatalError() - { - try { - $handler = ErrorHandler::register(); - - $error = array( - 'type' => E_PARSE, - 'message' => 'foo', - 'file' => 'bar', - 'line' => 123, - ); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $logArgCheck = function ($level, $message, $context) { - $this->assertEquals('Fatal Parse Error: foo', $message); - $this->assertArrayHasKey('exception', $context); - $this->assertInstanceOf(\Exception::class, $context['exception']); - }; - - $logger - ->expects($this->once()) - ->method('log') - ->will($this->returnCallback($logArgCheck)) - ; - - $handler->setDefaultLogger($logger, E_PARSE); - - $handler->handleFatalError($error); - - restore_error_handler(); - restore_exception_handler(); - } catch (\Exception $e) { - restore_error_handler(); - restore_exception_handler(); - - throw $e; - } - } - - /** - * @requires PHP 7 - */ - public function testHandleErrorException() - { - $exception = new \Error("Class 'Foo' not found"); - - $handler = new ErrorHandler(); - $handler->setExceptionHandler(function () use (&$args) { - $args = func_get_args(); - }); - - $handler->handleException($exception); - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $args[0]); - $this->assertStringStartsWith("Attempted to load class \"Foo\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage()); - } - - /** - * @group no-hhvm - */ - public function testHandleFatalErrorOnHHVM() - { - try { - $handler = ErrorHandler::register(); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $logger - ->expects($this->once()) - ->method('log') - ->with( - $this->equalTo(LogLevel::CRITICAL), - $this->equalTo('Fatal Error: foo') - ) - ; - - $handler->setDefaultLogger($logger, E_ERROR); - - $error = array( - 'type' => E_ERROR + 0x1000000, // This error level is used by HHVM for fatal errors - 'message' => 'foo', - 'file' => 'bar', - 'line' => 123, - 'context' => array(123), - 'backtrace' => array(456), - ); - - call_user_func_array(array($handler, 'handleError'), $error); - $handler->handleFatalError($error); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php b/lib/silex/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php deleted file mode 100644 index 8fd1c7959..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/Exception/FlattenExceptionTest.php +++ /dev/null @@ -1,302 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\Exception; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException; -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 TestCase -{ - public function testStatusCode() - { - $flattened = FlattenException::create(new \RuntimeException(), 403); - $this->assertEquals('403', $flattened->getStatusCode()); - - $flattened = FlattenException::create(new \RuntimeException()); - $this->assertEquals('500', $flattened->getStatusCode()); - - $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()); - - if (class_exists(SuspiciousOperationException::class)) { - $flattened = FlattenException::create(new SuspiciousOperationException()); - $this->assertEquals('400', $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()); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testFlattenHttpException(\Exception $exception, $statusCode) - { - $flattened = FlattenException::create($exception); - $flattened2 = FlattenException::create($exception); - - $flattened->setPrevious($flattened2); - - $this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.'); - $this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.'); - $this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception'); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testPrevious(\Exception $exception, $statusCode) - { - $flattened = FlattenException::create($exception); - $flattened2 = FlattenException::create($exception); - - $flattened->setPrevious($flattened2); - - $this->assertSame($flattened2, $flattened->getPrevious()); - - $this->assertSame(array($flattened2), $flattened->getAllPrevious()); - } - - /** - * @requires PHP 7.0 - */ - public function testPreviousError() - { - $exception = new \Exception('test', 123, new \ParseError('Oh noes!', 42)); - - $flattened = FlattenException::create($exception)->getPrevious(); - - $this->assertEquals($flattened->getMessage(), 'Parse error: Oh noes!', 'The message is copied from the original exception.'); - $this->assertEquals($flattened->getCode(), 42, 'The code is copied from the original exception.'); - $this->assertEquals($flattened->getClass(), 'Symfony\Component\Debug\Exception\FatalThrowableError', 'The class is set to the class of the original exception'); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testLine(\Exception $exception) - { - $flattened = FlattenException::create($exception); - $this->assertSame($exception->getLine(), $flattened->getLine()); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testFile(\Exception $exception) - { - $flattened = FlattenException::create($exception); - $this->assertSame($exception->getFile(), $flattened->getFile()); - } - - /** - * @dataProvider flattenDataProvider - */ - public function testToArray(\Exception $exception, $statusCode) - { - $flattened = FlattenException::create($exception); - $flattened->setTrace(array(), '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(), - )), - ), - ), $flattened->toArray()); - } - - public function flattenDataProvider() - { - return array( - array(new \Exception('test', 123), 500), - ); - } - - public function testArguments() - { - $dh = opendir(__DIR__); - $fh = tmpfile(); - - $incomplete = unserialize('O:14:"BogusTestClass":0:{}'); - - $exception = $this->createException(array( - (object) array('foo' => 1), - new NotFoundHttpException(), - $incomplete, - $dh, - $fh, - function () {}, - array(1, 2), - array('foo' => 123), - null, - true, - false, - 0, - 0.0, - '0', - '', - INF, - NAN, - )); - - $flattened = FlattenException::create($exception); - $trace = $flattened->getTrace(); - $args = $trace[1]['args']; - $array = $args[0][1]; - - closedir($dh); - fclose($fh); - - $i = 0; - $this->assertSame(array('object', 'stdClass'), $array[$i++]); - $this->assertSame(array('object', 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'), $array[$i++]); - $this->assertSame(array('incomplete-object', 'BogusTestClass'), $array[$i++]); - $this->assertSame(array('resource', defined('HHVM_VERSION') ? 'Directory' : 'stream'), $array[$i++]); - $this->assertSame(array('resource', 'stream'), $array[$i++]); - - $args = $array[$i++]; - $this->assertSame($args[0], 'object'); - $this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], '\Closure'), 'Expect object class name to be Closure or a subclass of Closure.'); - - $this->assertSame(array('array', array(array('integer', 1), array('integer', 2))), $array[$i++]); - $this->assertSame(array('array', array('foo' => array('integer', 123))), $array[$i++]); - $this->assertSame(array('null', null), $array[$i++]); - $this->assertSame(array('boolean', true), $array[$i++]); - $this->assertSame(array('boolean', false), $array[$i++]); - $this->assertSame(array('integer', 0), $array[$i++]); - $this->assertSame(array('float', 0.0), $array[$i++]); - $this->assertSame(array('string', '0'), $array[$i++]); - $this->assertSame(array('string', ''), $array[$i++]); - $this->assertSame(array('float', INF), $array[$i++]); - - // assertEquals() does not like NAN values. - $this->assertEquals($array[$i][0], 'float'); - $this->assertTrue(is_nan($array[$i++][1])); - } - - public function testRecursionInArguments() - { - $a = null; - $a = array('foo', array(2, &$a)); - $exception = $this->createException($a); - - $flattened = FlattenException::create($exception); - $trace = $flattened->getTrace(); - $this->assertContains('*DEEP NESTED ARRAY*', serialize($trace)); - } - - public function testTooBigArray() - { - $a = array(); - for ($i = 0; $i < 20; ++$i) { - for ($j = 0; $j < 50; ++$j) { - for ($k = 0; $k < 10; ++$k) { - $a[$i][$j][$k] = 'value'; - } - } - } - $a[20] = 'value'; - $a[21] = 'value1'; - $exception = $this->createException($a); - - $flattened = FlattenException::create($exception); - $trace = $flattened->getTrace(); - - $this->assertSame($trace[1]['args'][0], array('array', array('array', '*SKIPPED over 10000 entries*'))); - - $serializeTrace = serialize($trace); - - $this->assertContains('*SKIPPED over 10000 entries*', $serializeTrace); - $this->assertNotContains('*value1*', $serializeTrace); - } - - private function createException($foo) - { - return new \Exception(); - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/ExceptionHandlerTest.php b/lib/silex/vendor/symfony/debug/Tests/ExceptionHandlerTest.php deleted file mode 100644 index 0285eff13..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/ExceptionHandlerTest.php +++ /dev/null @@ -1,133 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\Debug\Exception\OutOfMemoryException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; - -require_once __DIR__.'/HeaderMock.php'; - -class ExceptionHandlerTest extends TestCase -{ - protected function setUp() - { - testHeader(); - } - - protected function tearDown() - { - testHeader(); - } - - public function testDebug() - { - $handler = new ExceptionHandler(false); - - ob_start(); - $handler->sendPhpResponse(new \RuntimeException('Foo')); - $response = ob_get_clean(); - - $this->assertContains('Whoops, looks like something went wrong.', $response); - $this->assertNotContains('
', $response); - - $handler = new ExceptionHandler(true); - - ob_start(); - $handler->sendPhpResponse(new \RuntimeException('Foo')); - $response = ob_get_clean(); - - $this->assertContains('Whoops, looks like something went wrong.', $response); - $this->assertContains('
', $response); - } - - public function testStatusCode() - { - $handler = new ExceptionHandler(false, 'iso8859-1'); - - ob_start(); - $handler->sendPhpResponse(new NotFoundHttpException('Foo')); - $response = ob_get_clean(); - - $this->assertContains('Sorry, the page you are looking for could not be found.', $response); - - $expectedHeaders = array( - array('HTTP/1.0 404', true, null), - array('Content-Type: text/html; charset=iso8859-1', true, null), - ); - - $this->assertSame($expectedHeaders, testHeader()); - } - - public function testHeaders() - { - $handler = new ExceptionHandler(false, 'iso8859-1'); - - ob_start(); - $handler->sendPhpResponse(new MethodNotAllowedHttpException(array('POST'))); - $response = ob_get_clean(); - - $expectedHeaders = array( - array('HTTP/1.0 405', true, null), - array('Allow: POST', false, null), - array('Content-Type: text/html; charset=iso8859-1', true, null), - ); - - $this->assertSame($expectedHeaders, testHeader()); - } - - public function testNestedExceptions() - { - $handler = new ExceptionHandler(true); - ob_start(); - $handler->sendPhpResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar'))); - $response = ob_get_clean(); - - $this->assertStringMatchesFormat('%A

Foo

%A

Bar

%A', $response); - } - - public function testHandle() - { - $exception = new \Exception('foo'); - - $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock(); - $handler - ->expects($this->exactly(2)) - ->method('sendPhpResponse'); - - $handler->handle($exception); - - $handler->setHandler(function ($e) use ($exception) { - $this->assertSame($exception, $e); - }); - - $handler->handle($exception); - } - - public function testHandleOutOfMemoryException() - { - $exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__); - - $handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(array('sendPhpResponse'))->getMock(); - $handler - ->expects($this->once()) - ->method('sendPhpResponse'); - - $handler->setHandler(function ($e) { - $this->fail('OutOfMemoryException should bypass the handler'); - }); - - $handler->handle($exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php deleted file mode 100644 index 65c80fc1c..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php +++ /dev/null @@ -1,176 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\FatalErrorHandler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; -use Symfony\Component\Debug\DebugClassLoader; -use Composer\Autoload\ClassLoader as ComposerClassLoader; - -class ClassNotFoundFatalErrorHandlerTest extends TestCase -{ - public static function setUpBeforeClass() - { - foreach (spl_autoload_functions() as $function) { - if (!is_array($function)) { - continue; - } - - // get class loaders wrapped by DebugClassLoader - if ($function[0] instanceof DebugClassLoader) { - $function = $function[0]->getClassLoader(); - } - - if ($function[0] instanceof ComposerClassLoader) { - $function[0]->add('Symfony_Component_Debug_Tests_Fixtures', dirname(dirname(dirname(dirname(dirname(__DIR__)))))); - break; - } - } - } - - /** - * @dataProvider provideClassNotFoundData - */ - public function testHandleClassNotFound($error, $translatedMessage, $autoloader = null) - { - if ($autoloader) { - // Unregister all autoloaders to ensure the custom provided - // autoloader is the only one to be used during the test run. - $autoloaders = spl_autoload_functions(); - array_map('spl_autoload_unregister', $autoloaders); - spl_autoload_register($autoloader); - } - - $handler = new ClassNotFoundFatalErrorHandler(); - - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - if ($autoloader) { - spl_autoload_unregister($autoloader); - array_map('spl_autoload_register', $autoloaders); - } - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); - $this->assertSame($translatedMessage, $exception->getMessage()); - $this->assertSame($error['type'], $exception->getSeverity()); - $this->assertSame($error['file'], $exception->getFile()); - $this->assertSame($error['line'], $exception->getLine()); - } - - public function provideClassNotFoundData() - { - $autoloader = new ComposerClassLoader(); - $autoloader->add('Symfony\Component\Debug\Exception\\', realpath(__DIR__.'/../../Exception')); - - $debugClassLoader = new DebugClassLoader(array($autoloader, 'loadClass')); - - return array( - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'WhizBangFactory\' not found', - ), - "Attempted to load class \"WhizBangFactory\" from the global namespace.\nDid you forget a \"use\" statement?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found', - ), - "Attempted to load class \"WhizBangFactory\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'PEARClass\' not found', - ), - "Attempted to load class \"PEARClass\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony_Component_Debug_Tests_Fixtures_PEARClass\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - array($autoloader, 'loadClass'), - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?", - array($debugClassLoader, 'loadClass'), - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', - ), - "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", - function ($className) { /* do nothing here */ }, - ), - ); - } - - public function testCannotRedeclareClass() - { - if (!file_exists(__DIR__.'/../FIXTURES2/REQUIREDTWICE.PHP')) { - $this->markTestSkipped('Can only be run on case insensitive filesystems'); - } - - require_once __DIR__.'/../FIXTURES2/REQUIREDTWICE.PHP'; - - $error = array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Class \'Foo\\Bar\\RequiredTwice\' not found', - ); - - $handler = new ClassNotFoundFatalErrorHandler(); - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php deleted file mode 100644 index 1dc212004..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\FatalErrorHandler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; - -class UndefinedFunctionFatalErrorHandlerTest extends TestCase -{ - /** - * @dataProvider provideUndefinedFunctionData - */ - public function testUndefinedFunction($error, $translatedMessage) - { - $handler = new UndefinedFunctionFatalErrorHandler(); - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception); - // class names are case insensitive and PHP/HHVM do not return the same - $this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage())); - $this->assertSame($error['type'], $exception->getSeverity()); - $this->assertSame($error['file'], $exception->getFile()); - $this->assertSame($error['line'], $exception->getLine()); - } - - public function provideUndefinedFunctionData() - { - return array( - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function test_namespaced_function()', - ), - "Attempted to call function \"test_namespaced_function\" from the global namespace.\nDid you mean to call \"\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function Foo\\Bar\\Baz\\test_namespaced_function()', - ), - "Attempted to call function \"test_namespaced_function\" from namespace \"Foo\\Bar\\Baz\".\nDid you mean to call \"\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function foo()', - ), - 'Attempted to call function "foo" from the global namespace.', - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined function Foo\\Bar\\Baz\\foo()', - ), - 'Attempted to call function "foo" from namespace "Foo\Bar\Baz".', - ), - ); - } -} - -function test_namespaced_function() -{ -} diff --git a/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php deleted file mode 100644 index 739e5b2b1..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests\FatalErrorHandler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\Exception\FatalErrorException; -use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler; - -class UndefinedMethodFatalErrorHandlerTest extends TestCase -{ - /** - * @dataProvider provideUndefinedMethodData - */ - public function testUndefinedMethod($error, $translatedMessage) - { - $handler = new UndefinedMethodFatalErrorHandler(); - $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); - - $this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception); - $this->assertSame($translatedMessage, $exception->getMessage()); - $this->assertSame($error['type'], $exception->getSeverity()); - $this->assertSame($error['file'], $exception->getFile()); - $this->assertSame($error['line'], $exception->getLine()); - } - - public function provideUndefinedMethodData() - { - return array( - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined method SplObjectStorage::what()', - ), - 'Attempted to call an undefined method named "what" of class "SplObjectStorage".', - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined method SplObjectStorage::walid()', - ), - "Attempted to call an undefined method named \"walid\" of class \"SplObjectStorage\".\nDid you mean to call \"valid\"?", - ), - array( - array( - 'type' => 1, - 'line' => 12, - 'file' => 'foo.php', - 'message' => 'Call to undefined method SplObjectStorage::offsetFet()', - ), - "Attempted to call an undefined method named \"offsetFet\" of class \"SplObjectStorage\".\nDid you mean to call e.g. \"offsetGet\", \"offsetSet\" or \"offsetUnset\"?", - ), - array( - array( - 'type' => 1, - 'message' => 'Call to undefined method class@anonymous::test()', - 'file' => '/home/possum/work/symfony/test.php', - 'line' => 11, - ), - 'Attempted to call an undefined method named "test" of class "class@anonymous".', - ), - ); - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/Fixtures/AnnotatedClass.php b/lib/silex/vendor/symfony/debug/Tests/Fixtures/AnnotatedClass.php deleted file mode 100644 index dff9517d0..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/Fixtures/AnnotatedClass.php +++ /dev/null @@ -1,13 +0,0 @@ -exception = $e; - } - - public function __toString() - { - try { - throw $this->exception; - } catch (\Exception $e) { - // Using user_error() here is on purpose so we do not forget - // that this alias also should work alongside with trigger_error(). - return user_error($e, E_USER_ERROR); - } - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/Fixtures/casemismatch.php b/lib/silex/vendor/symfony/debug/Tests/Fixtures/casemismatch.php deleted file mode 100644 index 691d660fd..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/Fixtures/casemismatch.php +++ /dev/null @@ -1,7 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug; - -function headers_sent() -{ - return false; -} - -function header($str, $replace = true, $status = null) -{ - Tests\testHeader($str, $replace, $status); -} - -namespace Symfony\Component\Debug\Tests; - -function testHeader() -{ - static $headers = array(); - - if (!$h = func_get_args()) { - $h = $headers; - $headers = array(); - - return $h; - } - - $headers[] = func_get_args(); -} diff --git a/lib/silex/vendor/symfony/debug/Tests/MockExceptionHandler.php b/lib/silex/vendor/symfony/debug/Tests/MockExceptionHandler.php deleted file mode 100644 index 2d6ce564d..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/MockExceptionHandler.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Debug\Tests; - -use Symfony\Component\Debug\ExceptionHandler; - -class MockExceptionHandler extends ExceptionHandler -{ - public $e; - - public function handle(\Exception $e) - { - $this->e = $e; - } -} diff --git a/lib/silex/vendor/symfony/debug/Tests/phpt/debug_class_loader.phpt b/lib/silex/vendor/symfony/debug/Tests/phpt/debug_class_loader.phpt deleted file mode 100644 index b9d3d7288..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/phpt/debug_class_loader.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Test DebugClassLoader with previously loaded parents ---FILE-- - ---EXPECTF-- -The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod". diff --git a/lib/silex/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt b/lib/silex/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt deleted file mode 100644 index 7ce7b9dc6..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/phpt/decorate_exception_hander.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test catching fatal errors when handlers are nested ---FILE-- - ---EXPECTF-- -Fatal error: Class 'Symfony\Component\Debug\missing' not found in %s on line %d -object(Symfony\Component\Debug\Exception\ClassNotFoundException)#%d (8) { - ["message":protected]=> - string(131) "Attempted to load class "missing" from namespace "Symfony\Component\Debug". -Did you forget a "use" statement for another namespace?" - ["string":"Exception":private]=> - string(0) "" - ["code":protected]=> - int(0) - ["file":protected]=> - string(%d) "%s" - ["line":protected]=> - int(%d) - ["trace":"Exception":private]=> - array(0) { - } - ["previous":"Exception":private]=> - NULL - ["severity":protected]=> - int(1) -} diff --git a/lib/silex/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt b/lib/silex/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt deleted file mode 100644 index 9df0a65cf..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/phpt/exception_rethrown.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -Test rethrowing in custom exception handler ---FILE-- -setDefaultLogger(new TestLogger()); -ini_set('display_errors', 1); - -throw new \Exception('foo'); -?> ---EXPECTF-- -Uncaught Exception: foo -123 -Fatal error: Uncaught %s:25 -Stack trace: -%a diff --git a/lib/silex/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt b/lib/silex/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt deleted file mode 100644 index 5c5245c06..000000000 --- a/lib/silex/vendor/symfony/debug/Tests/phpt/fatal_with_nested_handlers.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -Test catching fatal errors when handlers are nested ---FILE-- -setExceptionHandler('print_r'); - -if (true) { - class Broken implements \Serializable - { - } -} - -?> ---EXPECTF-- -array(1) { - [0]=> - string(37) "Error and exception handlers do match" -} -object(Symfony\Component\Debug\Exception\FatalErrorException)#%d (%d) { - ["message":protected]=> - string(199) "Error: Class Symfony\Component\Debug\Broken contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize)" -%a -} diff --git a/lib/silex/vendor/symfony/debug/composer.json b/lib/silex/vendor/symfony/debug/composer.json deleted file mode 100644 index f98a5d07b..000000000 --- a/lib/silex/vendor/symfony/debug/composer.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "symfony/debug", - "type": "library", - "description": "Symfony Debug Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\Debug\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/debug/phpunit.xml.dist b/lib/silex/vendor/symfony/debug/phpunit.xml.dist deleted file mode 100644 index 12e58612b..000000000 --- a/lib/silex/vendor/symfony/debug/phpunit.xml.dist +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - ./Tests/ - - - ./Resources/ext/tests/ - - - - - - ./ - - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/symfony/event-dispatcher/.gitignore b/lib/silex/vendor/symfony/event-dispatcher/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/event-dispatcher/CHANGELOG.md b/lib/silex/vendor/symfony/event-dispatcher/CHANGELOG.md deleted file mode 100644 index c6aa5389a..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/CHANGELOG.md +++ /dev/null @@ -1,42 +0,0 @@ -CHANGELOG -========= - -3.4.0 ------ - - * Implementing `TraceableEventDispatcherInterface` without the `reset()` method has been deprecated. - -3.3.0 ------ - - * The ContainerAwareEventDispatcher class has been deprecated. Use EventDispatcher with closure factories instead. - -3.0.0 ------ - - * The method `getListenerPriority($eventName, $listener)` has been added to the - `EventDispatcherInterface`. - * The methods `Event::setDispatcher()`, `Event::getDispatcher()`, `Event::setName()` - and `Event::getName()` have been removed. - The event dispatcher and the event name are passed to the listener call. - -2.5.0 ------ - - * added Debug\TraceableEventDispatcher (originally in HttpKernel) - * changed Debug\TraceableEventDispatcherInterface to extend EventDispatcherInterface - * added RegisterListenersPass (originally in HttpKernel) - -2.1.0 ------ - - * added TraceableEventDispatcherInterface - * added ContainerAwareEventDispatcher - * added a reference to the EventDispatcher on the Event - * added a reference to the Event name on the event - * added fluid interface to the dispatch() method which now returns the Event - object - * added GenericEvent event class - * added the possibility for subscribers to subscribe several times for the - same event - * added ImmutableEventDispatcher diff --git a/lib/silex/vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php deleted file mode 100644 index 81a1ff7ca..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php +++ /dev/null @@ -1,197 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Lazily loads listeners and subscribers from the dependency injection - * container. - * - * @author Fabien Potencier - * @author Bernhard Schussek - * @author Jordan Alliot - * - * @deprecated since 3.3, to be removed in 4.0. Use EventDispatcher with closure factories instead. - */ -class ContainerAwareEventDispatcher extends EventDispatcher -{ - private $container; - - /** - * The service IDs of the event listeners and subscribers. - */ - private $listenerIds = array(); - - /** - * The services registered as listeners. - */ - private $listeners = array(); - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - - $class = get_class($this); - if ($this instanceof \PHPUnit_Framework_MockObject_MockObject || $this instanceof \Prophecy\Doubler\DoubleInterface) { - $class = get_parent_class($class); - } - if (__CLASS__ !== $class) { - @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead.', __CLASS__), E_USER_DEPRECATED); - } - } - - /** - * Adds a service as event listener. - * - * @param string $eventName Event for which the listener is added - * @param array $callback The service ID of the listener service & the method - * name that has to be called - * @param int $priority The higher this value, the earlier an event listener - * will be triggered in the chain. - * Defaults to 0. - * - * @throws \InvalidArgumentException - */ - public function addListenerService($eventName, $callback, $priority = 0) - { - @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead.', __CLASS__), E_USER_DEPRECATED); - - if (!is_array($callback) || 2 !== count($callback)) { - throw new \InvalidArgumentException('Expected an array("service", "method") argument'); - } - - $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority); - } - - public function removeListener($eventName, $listener) - { - $this->lazyLoad($eventName); - - if (isset($this->listenerIds[$eventName])) { - foreach ($this->listenerIds[$eventName] as $i => list($serviceId, $method)) { - $key = $serviceId.'.'.$method; - if (isset($this->listeners[$eventName][$key]) && $listener === array($this->listeners[$eventName][$key], $method)) { - unset($this->listeners[$eventName][$key]); - if (empty($this->listeners[$eventName])) { - unset($this->listeners[$eventName]); - } - unset($this->listenerIds[$eventName][$i]); - if (empty($this->listenerIds[$eventName])) { - unset($this->listenerIds[$eventName]); - } - } - } - } - - parent::removeListener($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - if (null === $eventName) { - return $this->listenerIds || $this->listeners || parent::hasListeners(); - } - - if (isset($this->listenerIds[$eventName])) { - return true; - } - - return parent::hasListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - if (null === $eventName) { - foreach ($this->listenerIds as $serviceEventName => $args) { - $this->lazyLoad($serviceEventName); - } - } else { - $this->lazyLoad($eventName); - } - - return parent::getListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function getListenerPriority($eventName, $listener) - { - $this->lazyLoad($eventName); - - return parent::getListenerPriority($eventName, $listener); - } - - /** - * Adds a service as event subscriber. - * - * @param string $serviceId The service ID of the subscriber service - * @param string $class The service's class name (which must implement EventSubscriberInterface) - */ - public function addSubscriberService($serviceId, $class) - { - @trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead.', __CLASS__), E_USER_DEPRECATED); - - foreach ($class::getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->listenerIds[$eventName][] = array($serviceId, $params, 0); - } elseif (is_string($params[0])) { - $this->listenerIds[$eventName][] = array($serviceId, $params[0], isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - public function getContainer() - { - @trigger_error('The '.__METHOD__.'() method is deprecated since Symfony 3.3 as its class will be removed in 4.0. Inject the container or the services you need in your listeners/subscribers instead.', E_USER_DEPRECATED); - - return $this->container; - } - - /** - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - */ - protected function lazyLoad($eventName) - { - if (isset($this->listenerIds[$eventName])) { - foreach ($this->listenerIds[$eventName] as list($serviceId, $method, $priority)) { - $listener = $this->container->get($serviceId); - - $key = $serviceId.'.'.$method; - if (!isset($this->listeners[$eventName][$key])) { - $this->addListener($eventName, array($listener, $method), $priority); - } elseif ($this->listeners[$eventName][$key] !== $listener) { - parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); - $this->addListener($eventName, array($listener, $method), $priority); - } - - $this->listeners[$eventName][$key] = $listener; - } - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php deleted file mode 100644 index 9b5c689ad..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php +++ /dev/null @@ -1,322 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\Stopwatch\Stopwatch; -use Psr\Log\LoggerInterface; - -/** - * Collects some data about event listeners. - * - * This event dispatcher delegates the dispatching to another one. - * - * @author Fabien Potencier - */ -class TraceableEventDispatcher implements TraceableEventDispatcherInterface -{ - protected $logger; - protected $stopwatch; - - private $called; - private $dispatcher; - private $wrappedListeners; - - 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(); - } - - /** - * {@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) - { - if (isset($this->wrappedListeners[$eventName])) { - foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) { - if ($wrappedListener->getWrappedListener() === $listener) { - $listener = $wrappedListener; - unset($this->wrappedListeners[$eventName][$index]); - break; - } - } - } - - 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 getListenerPriority($eventName, $listener) - { - // we might have wrapped listeners for the event (if called while dispatching) - // in that case get the priority by wrapper - if (isset($this->wrappedListeners[$eventName])) { - foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) { - if ($wrappedListener->getWrappedListener() === $listener) { - return $this->dispatcher->getListenerPriority($eventName, $wrappedListener); - } - } - } - - return $this->dispatcher->getListenerPriority($eventName, $listener); - } - - /** - * {@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(); - } - - if (null !== $this->logger && $event->isPropagationStopped()) { - $this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName)); - } - - $this->preProcess($eventName); - $this->preDispatch($eventName, $event); - - $e = $this->stopwatch->start($eventName, 'section'); - - $this->dispatcher->dispatch($eventName, $event); - - if ($e->isStarted()) { - $e->stop(); - } - - $this->postDispatch($eventName, $event); - $this->postProcess($eventName); - - return $event; - } - - /** - * {@inheritdoc} - */ - public function getCalledListeners() - { - $called = array(); - foreach ($this->called as $eventName => $listeners) { - foreach ($listeners as $listener) { - $called[$eventName.'.'.$listener->getPretty()] = $listener->getInfo($eventName); - } - } - - return $called; - } - - /** - * {@inheritdoc} - */ - public function getNotCalledListeners() - { - try { - $allListeners = $this->getListeners(); - } catch (\Exception $e) { - if (null !== $this->logger) { - $this->logger->info('An exception was thrown while getting the uncalled listeners.', array('exception' => $e)); - } - - // unable to retrieve the uncalled listeners - return array(); - } - - $notCalled = array(); - foreach ($allListeners as $eventName => $listeners) { - foreach ($listeners as $listener) { - $called = false; - if (isset($this->called[$eventName])) { - foreach ($this->called[$eventName] as $l) { - if ($l->getWrappedListener() === $listener) { - $called = true; - - break; - } - } - } - - if (!$called) { - if (!$listener instanceof WrappedListener) { - $listener = new WrappedListener($listener, null, $this->stopwatch, $this); - } - $notCalled[$eventName.'.'.$listener->getPretty()] = $listener->getInfo($eventName); - } - } - } - - uasort($notCalled, array($this, 'sortListenersByPriority')); - - return $notCalled; - } - - public function reset() - { - $this->called = array(); - } - - /** - * Proxies all method calls to the original event dispatcher. - * - * @param string $method The method name - * @param array $arguments The method arguments - * - * @return mixed - */ - public function __call($method, $arguments) - { - return call_user_func_array(array($this->dispatcher, $method), $arguments); - } - - /** - * Called before dispatching the event. - * - * @param string $eventName The event name - * @param Event $event The event - */ - protected function preDispatch($eventName, Event $event) - { - } - - /** - * Called after dispatching the event. - * - * @param string $eventName The event name - * @param Event $event The event - */ - protected function postDispatch($eventName, Event $event) - { - } - - private function preProcess($eventName) - { - foreach ($this->dispatcher->getListeners($eventName) as $listener) { - $priority = $this->getListenerPriority($eventName, $listener); - $wrappedListener = new WrappedListener($listener, null, $this->stopwatch, $this); - $this->wrappedListeners[$eventName][] = $wrappedListener; - $this->dispatcher->removeListener($eventName, $listener); - $this->dispatcher->addListener($eventName, $wrappedListener, $priority); - } - } - - private function postProcess($eventName) - { - unset($this->wrappedListeners[$eventName]); - $skipped = false; - foreach ($this->dispatcher->getListeners($eventName) as $listener) { - if (!$listener instanceof WrappedListener) { // #12845: a new listener was added during dispatch. - continue; - } - // Unwrap listener - $priority = $this->getListenerPriority($eventName, $listener); - $this->dispatcher->removeListener($eventName, $listener); - $this->dispatcher->addListener($eventName, $listener->getWrappedListener(), $priority); - - if (null !== $this->logger) { - $context = array('event' => $eventName, 'listener' => $listener->getPretty()); - } - - if ($listener->wasCalled()) { - if (null !== $this->logger) { - $this->logger->debug('Notified event "{event}" to listener "{listener}".', $context); - } - - if (!isset($this->called[$eventName])) { - $this->called[$eventName] = new \SplObjectStorage(); - } - - $this->called[$eventName]->attach($listener); - } - - if (null !== $this->logger && $skipped) { - $this->logger->debug('Listener "{listener}" was not called for event "{event}".', $context); - } - - if ($listener->stoppedPropagation()) { - if (null !== $this->logger) { - $this->logger->debug('Listener "{listener}" stopped propagation of the event "{event}".', $context); - } - - $skipped = true; - } - } - } - - private function sortListenersByPriority($a, $b) - { - if (is_int($a['priority']) && !is_int($b['priority'])) { - return 1; - } - - if (!is_int($a['priority']) && is_int($b['priority'])) { - return -1; - } - - if ($a['priority'] === $b['priority']) { - return 0; - } - - if ($a['priority'] > $b['priority']) { - return -1; - } - - return 1; - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcherInterface.php b/lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcherInterface.php deleted file mode 100644 index f0212753b..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcherInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * @author Fabien Potencier - * - * @method reset() Resets the trace. - */ -interface TraceableEventDispatcherInterface extends EventDispatcherInterface -{ - /** - * Gets the called listeners. - * - * @return array An array of called listeners - */ - public function getCalledListeners(); - - /** - * Gets the not called listeners. - * - * @return array An array of not called listeners - */ - public function getNotCalledListeners(); -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Debug/WrappedListener.php b/lib/silex/vendor/symfony/event-dispatcher/Debug/WrappedListener.php deleted file mode 100644 index f7b0273e1..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Debug/WrappedListener.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\VarDumper\Caster\ClassStub; - -/** - * @author Fabien Potencier - */ -class WrappedListener -{ - private $listener; - private $name; - private $called; - private $stoppedPropagation; - private $stopwatch; - private $dispatcher; - private $pretty; - private $stub; - private static $hasClassStub; - - public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null) - { - $this->listener = $listener; - $this->name = $name; - $this->stopwatch = $stopwatch; - $this->dispatcher = $dispatcher; - $this->called = false; - $this->stoppedPropagation = false; - - if (is_array($listener)) { - $this->name = is_object($listener[0]) ? get_class($listener[0]) : $listener[0]; - $this->pretty = $this->name.'::'.$listener[1]; - } elseif ($listener instanceof \Closure) { - $this->pretty = $this->name = 'closure'; - } elseif (is_string($listener)) { - $this->pretty = $this->name = $listener; - } else { - $this->name = get_class($listener); - $this->pretty = $this->name.'::__invoke'; - } - - if (null !== $name) { - $this->name = $name; - } - - if (null === self::$hasClassStub) { - self::$hasClassStub = class_exists(ClassStub::class); - } - } - - public function getWrappedListener() - { - return $this->listener; - } - - public function wasCalled() - { - return $this->called; - } - - public function stoppedPropagation() - { - return $this->stoppedPropagation; - } - - public function getPretty() - { - return $this->pretty; - } - - public function getInfo($eventName) - { - if (null === $this->stub) { - $this->stub = self::$hasClassStub ? new ClassStub($this->pretty.'()', $this->listener) : $this->pretty.'()'; - } - - return array( - 'event' => $eventName, - 'priority' => null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null, - 'pretty' => $this->pretty, - 'stub' => $this->stub, - ); - } - - public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher) - { - $this->called = true; - - $e = $this->stopwatch->start($this->name, 'event_listener'); - - call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher); - - if ($e->isStarted()) { - $e->stop(); - } - - if ($event->isPropagationStopped()) { - $this->stoppedPropagation = true; - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php b/lib/silex/vendor/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php deleted file mode 100644 index 9f9c09c52..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\DependencyInjection; - -use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Compiler pass to register tagged services for an event dispatcher. - */ -class RegisterListenersPass implements CompilerPassInterface -{ - protected $dispatcherService; - protected $listenerTag; - protected $subscriberTag; - - private $hotPathEvents = array(); - private $hotPathTagName; - - /** - * @param string $dispatcherService Service name of the event dispatcher in processed container - * @param string $listenerTag Tag name used for listener - * @param string $subscriberTag Tag name used for subscribers - */ - public function __construct($dispatcherService = 'event_dispatcher', $listenerTag = 'kernel.event_listener', $subscriberTag = 'kernel.event_subscriber') - { - $this->dispatcherService = $dispatcherService; - $this->listenerTag = $listenerTag; - $this->subscriberTag = $subscriberTag; - } - - public function setHotPathEvents(array $hotPathEvents, $tagName = 'container.hot_path') - { - $this->hotPathEvents = array_flip($hotPathEvents); - $this->hotPathTagName = $tagName; - - return $this; - } - - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { - return; - } - - $definition = $container->findDefinition($this->dispatcherService); - - foreach ($container->findTaggedServiceIds($this->listenerTag, true) as $id => $events) { - foreach ($events as $event) { - $priority = isset($event['priority']) ? $event['priority'] : 0; - - if (!isset($event['event'])) { - throw new InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag)); - } - - if (!isset($event['method'])) { - $event['method'] = 'on'.preg_replace_callback(array( - '/(?<=\b)[a-z]/i', - '/[^a-z0-9]/i', - ), function ($matches) { return strtoupper($matches[0]); }, $event['event']); - $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']); - } - - $definition->addMethodCall('addListener', array($event['event'], array(new ServiceClosureArgument(new Reference($id)), $event['method']), $priority)); - - if (isset($this->hotPathEvents[$event['event']])) { - $container->getDefinition($id)->addTag($this->hotPathTagName); - } - } - } - - $extractingDispatcher = new ExtractingEventDispatcher(); - - foreach ($container->findTaggedServiceIds($this->subscriberTag, true) as $id => $attributes) { - $def = $container->getDefinition($id); - - // We must assume that the class value has been correctly filled, even if the service is created by a factory - $class = $container->getParameterBag()->resolveValue($def->getClass()); - $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; - - if (!is_subclass_of($class, $interface)) { - if (!class_exists($class, false)) { - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); - } - - throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); - } - $container->addObjectResource($class); - - ExtractingEventDispatcher::$subscriber = $class; - $extractingDispatcher->addSubscriber($extractingDispatcher); - foreach ($extractingDispatcher->listeners as $args) { - $args[1] = array(new ServiceClosureArgument(new Reference($id)), $args[1]); - $definition->addMethodCall('addListener', $args); - - if (isset($this->hotPathEvents[$args[0]])) { - $container->getDefinition($id)->addTag('container.hot_path'); - } - } - $extractingDispatcher->listeners = array(); - } - } -} - -/** - * @internal - */ -class ExtractingEventDispatcher extends EventDispatcher implements EventSubscriberInterface -{ - public $listeners = array(); - - public static $subscriber; - - public function addListener($eventName, $listener, $priority = 0) - { - $this->listeners[] = array($eventName, $listener[1], $priority); - } - - public static function getSubscribedEvents() - { - $callback = array(self::$subscriber, 'getSubscribedEvents'); - - return $callback(); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Event.php b/lib/silex/vendor/symfony/event-dispatcher/Event.php deleted file mode 100644 index 9c56b2f55..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Event.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * Event is the base class for classes containing event data. - * - * This class contains no event data. It is used by events that do not pass - * state information to an event handler when an event is raised. - * - * You can call the method stopPropagation() to abort the execution of - * further listeners in your event listener. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - */ -class Event -{ - /** - * @var bool Whether no further event listeners should be triggered - */ - private $propagationStopped = false; - - /** - * Returns whether further event listeners should be triggered. - * - * @see Event::stopPropagation() - * - * @return bool Whether propagation was already stopped for this event - */ - public function isPropagationStopped() - { - return $this->propagationStopped; - } - - /** - * Stops the propagation of the event to further event listeners. - * - * If multiple event listeners are connected to the same event, no - * further event listener will be triggered once any trigger calls - * stopPropagation(). - */ - public function stopPropagation() - { - $this->propagationStopped = true; - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/EventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/EventDispatcher.php deleted file mode 100644 index bc79a958d..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/EventDispatcher.php +++ /dev/null @@ -1,236 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * @author Fabien Potencier - * @author Jordi Boggiano - * @author Jordan Alliot - * @author Nicolas Grekas - */ -class EventDispatcher implements EventDispatcherInterface -{ - private $listeners = array(); - private $sorted = array(); - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - if (null === $event) { - $event = new Event(); - } - - if ($listeners = $this->getListeners($eventName)) { - $this->doDispatch($listeners, $eventName, $event); - } - - return $event; - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - if (null !== $eventName) { - if (empty($this->listeners[$eventName])) { - return array(); - } - - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - - return $this->sorted[$eventName]; - } - - foreach ($this->listeners as $eventName => $eventListeners) { - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - } - - return array_filter($this->sorted); - } - - /** - * {@inheritdoc} - */ - public function getListenerPriority($eventName, $listener) - { - if (empty($this->listeners[$eventName])) { - return; - } - - if (is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) { - $listener[0] = $listener[0](); - } - - foreach ($this->listeners[$eventName] as $priority => $listeners) { - foreach ($listeners as $k => $v) { - if ($v !== $listener && is_array($v) && isset($v[0]) && $v[0] instanceof \Closure) { - $v[0] = $v[0](); - $this->listeners[$eventName][$priority][$k] = $v; - } - if ($v === $listener) { - return $priority; - } - } - } - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - if (null !== $eventName) { - return !empty($this->listeners[$eventName]); - } - - foreach ($this->listeners as $eventListeners) { - if ($eventListeners) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - $this->listeners[$eventName][$priority][] = $listener; - unset($this->sorted[$eventName]); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - if (empty($this->listeners[$eventName])) { - return; - } - - if (is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) { - $listener[0] = $listener[0](); - } - - foreach ($this->listeners[$eventName] as $priority => $listeners) { - foreach ($listeners as $k => $v) { - if ($v !== $listener && is_array($v) && isset($v[0]) && $v[0] instanceof \Closure) { - $v[0] = $v[0](); - } - if ($v === $listener) { - unset($listeners[$k], $this->sorted[$eventName]); - } else { - $listeners[$k] = $v; - } - } - - if ($listeners) { - $this->listeners[$eventName][$priority] = $listeners; - } else { - unset($this->listeners[$eventName][$priority]); - } - } - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->addListener($eventName, array($subscriber, $params)); - } elseif (is_string($params[0])) { - $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_array($params) && is_array($params[0])) { - foreach ($params as $listener) { - $this->removeListener($eventName, array($subscriber, $listener[0])); - } - } else { - $this->removeListener($eventName, array($subscriber, is_string($params) ? $params : $params[0])); - } - } - } - - /** - * Triggers the listeners of an event. - * - * This method can be overridden to add functionality that is executed - * for each listener. - * - * @param callable[] $listeners The event listeners - * @param string $eventName The name of the event to dispatch - * @param Event $event The event object to pass to the event handlers/listeners - */ - protected function doDispatch($listeners, $eventName, Event $event) - { - foreach ($listeners as $listener) { - if ($event->isPropagationStopped()) { - break; - } - \call_user_func($listener, $event, $eventName, $this); - } - } - - /** - * Sorts the internal list of listeners for the given event by priority. - * - * @param string $eventName The name of the event - */ - private function sortListeners($eventName) - { - krsort($this->listeners[$eventName]); - $this->sorted[$eventName] = array(); - - foreach ($this->listeners[$eventName] as $priority => $listeners) { - foreach ($listeners as $k => $listener) { - if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) { - $listener[0] = $listener[0](); - $this->listeners[$eventName][$priority][$k] = $listener; - } - $this->sorted[$eventName][] = $listener; - } - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/EventDispatcherInterface.php b/lib/silex/vendor/symfony/event-dispatcher/EventDispatcherInterface.php deleted file mode 100644 index d3d0cb8a4..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/EventDispatcherInterface.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Bernhard Schussek - */ -interface EventDispatcherInterface -{ - /** - * Dispatches an event to all registered listeners. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - * @param Event $event The event to pass to the event handlers/listeners - * If not supplied, an empty Event instance is created - * - * @return Event - */ - public function dispatch($eventName, Event $event = null); - - /** - * Adds an event listener that listens on the specified events. - * - * @param string $eventName The event to listen on - * @param callable $listener The listener - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - */ - public function addListener($eventName, $listener, $priority = 0); - - /** - * Adds an event subscriber. - * - * The subscriber is asked for all the events he is - * interested in and added as a listener for these events. - */ - public function addSubscriber(EventSubscriberInterface $subscriber); - - /** - * Removes an event listener from the specified events. - * - * @param string $eventName The event to remove a listener from - * @param callable $listener The listener to remove - */ - public function removeListener($eventName, $listener); - - public function removeSubscriber(EventSubscriberInterface $subscriber); - - /** - * Gets the listeners of a specific event or all listeners sorted by descending priority. - * - * @param string $eventName The name of the event - * - * @return array The event listeners for the specified event, or all event listeners by event name - */ - public function getListeners($eventName = null); - - /** - * Gets the listener priority for a specific event. - * - * Returns null if the event or the listener does not exist. - * - * @param string $eventName The name of the event - * @param callable $listener The listener - * - * @return int|null The event listener priority - */ - public function getListenerPriority($eventName, $listener); - - /** - * Checks whether an event has any registered listeners. - * - * @param string $eventName The name of the event - * - * @return bool true if the specified event has any listeners, false otherwise - */ - public function hasListeners($eventName = null); -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/EventSubscriberInterface.php b/lib/silex/vendor/symfony/event-dispatcher/EventSubscriberInterface.php deleted file mode 100644 index 8af778919..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/EventSubscriberInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * An EventSubscriber knows himself what events he is interested in. - * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes - * {@link getSubscribedEvents} and registers the subscriber as a listener for all - * returned events. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - */ -interface EventSubscriberInterface -{ - /** - * Returns an array of event names this subscriber wants to listen to. - * - * The array keys are event names and the value can be: - * - * * The method name to call (priority defaults to 0) - * * An array composed of the method name to call and the priority - * * An array of arrays composed of the method names to call and respective - * priorities, or 0 if unset - * - * For instance: - * - * * array('eventName' => 'methodName') - * * array('eventName' => array('methodName', $priority)) - * * array('eventName' => array(array('methodName1', $priority), array('methodName2'))) - * - * @return array The event names to listen to - */ - public static function getSubscribedEvents(); -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/GenericEvent.php b/lib/silex/vendor/symfony/event-dispatcher/GenericEvent.php deleted file mode 100644 index 95c99408d..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/GenericEvent.php +++ /dev/null @@ -1,175 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * Event encapsulation class. - * - * Encapsulates events thus decoupling the observer from the subject they encapsulate. - * - * @author Drak - */ -class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate -{ - protected $subject; - protected $arguments; - - /** - * Encapsulate an event with $subject and $args. - * - * @param mixed $subject The subject of the event, usually an object or a callable - * @param array $arguments Arguments to store in the event - */ - public function __construct($subject = null, array $arguments = array()) - { - $this->subject = $subject; - $this->arguments = $arguments; - } - - /** - * Getter for subject property. - * - * @return mixed $subject The observer subject - */ - public function getSubject() - { - return $this->subject; - } - - /** - * Get argument by key. - * - * @param string $key Key - * - * @return mixed Contents of array key - * - * @throws \InvalidArgumentException if key is not found - */ - public function getArgument($key) - { - if ($this->hasArgument($key)) { - return $this->arguments[$key]; - } - - throw new \InvalidArgumentException(sprintf('Argument "%s" not found.', $key)); - } - - /** - * Add argument to event. - * - * @param string $key Argument name - * @param mixed $value Value - * - * @return $this - */ - public function setArgument($key, $value) - { - $this->arguments[$key] = $value; - - return $this; - } - - /** - * Getter for all arguments. - * - * @return array - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * Set args property. - * - * @param array $args Arguments - * - * @return $this - */ - public function setArguments(array $args = array()) - { - $this->arguments = $args; - - return $this; - } - - /** - * Has argument. - * - * @param string $key Key of arguments array - * - * @return bool - */ - public function hasArgument($key) - { - return array_key_exists($key, $this->arguments); - } - - /** - * ArrayAccess for argument getter. - * - * @param string $key Array key - * - * @return mixed - * - * @throws \InvalidArgumentException if key does not exist in $this->args - */ - public function offsetGet($key) - { - return $this->getArgument($key); - } - - /** - * ArrayAccess for argument setter. - * - * @param string $key Array key to set - * @param mixed $value Value - */ - public function offsetSet($key, $value) - { - $this->setArgument($key, $value); - } - - /** - * ArrayAccess for unset argument. - * - * @param string $key Array key - */ - public function offsetUnset($key) - { - if ($this->hasArgument($key)) { - unset($this->arguments[$key]); - } - } - - /** - * ArrayAccess has argument. - * - * @param string $key Array key - * - * @return bool - */ - public function offsetExists($key) - { - return $this->hasArgument($key); - } - - /** - * IteratorAggregate for iterating over the object like an array. - * - * @return \ArrayIterator - */ - public function getIterator() - { - return new \ArrayIterator($this->arguments); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php deleted file mode 100644 index b3cf56c50..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * A read-only proxy for an event dispatcher. - * - * @author Bernhard Schussek - */ -class ImmutableEventDispatcher implements EventDispatcherInterface -{ - private $dispatcher; - - public function __construct(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - return $this->dispatcher->dispatch($eventName, $event); - } - - /** - * {@inheritdoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function getListenerPriority($eventName, $listener) - { - return $this->dispatcher->getListenerPriority($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/LICENSE b/lib/silex/vendor/symfony/event-dispatcher/LICENSE deleted file mode 100644 index 21d7fb9e2..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2018 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/event-dispatcher/README.md b/lib/silex/vendor/symfony/event-dispatcher/README.md deleted file mode 100644 index 185c3fecf..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/README.md +++ /dev/null @@ -1,15 +0,0 @@ -EventDispatcher Component -========================= - -The EventDispatcher component provides tools that allow your application -components to communicate with each other by dispatching events and listening to -them. - -Resources ---------- - - * [Documentation](https://symfony.com/doc/current/components/event_dispatcher/index.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md deleted file mode 100644 index bb42ee19c..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md +++ /dev/null @@ -1,23 +0,0 @@ -CHANGELOG -========= - -2.5.0 ------ - - * added Debug\TraceableEventDispatcher (originally in HttpKernel) - * changed Debug\TraceableEventDispatcherInterface to extend EventDispatcherInterface - * added RegisterListenersPass (originally in HttpKernel) - -2.1.0 ------ - - * added TraceableEventDispatcherInterface - * added ContainerAwareEventDispatcher - * added a reference to the EventDispatcher on the Event - * added a reference to the Event name on the event - * added fluid interface to the dispatch() method which now returns the Event - object - * added GenericEvent event class - * added the possibility for subscribers to subscribe several times for the - same event - * added ImmutableEventDispatcher diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php deleted file mode 100644 index 76f0e3877..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Lazily loads listeners and subscribers from the dependency injection - * container. - * - * @author Fabien Potencier - * @author Bernhard Schussek - * @author Jordan Alliot - */ -class ContainerAwareEventDispatcher extends EventDispatcher -{ - /** - * The container from where services are loaded. - * - * @var ContainerInterface - */ - private $container; - - /** - * The service IDs of the event listeners and subscribers. - * - * @var array - */ - private $listenerIds = array(); - - /** - * The services registered as listeners. - * - * @var array - */ - private $listeners = array(); - - /** - * Constructor. - * - * @param ContainerInterface $container A ContainerInterface instance - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * Adds a service as event listener. - * - * @param string $eventName Event for which the listener is added - * @param array $callback The service ID of the listener service & the method - * name that has to be called - * @param int $priority The higher this value, the earlier an event listener - * will be triggered in the chain. - * Defaults to 0. - * - * @throws \InvalidArgumentException - */ - public function addListenerService($eventName, $callback, $priority = 0) - { - if (!is_array($callback) || 2 !== count($callback)) { - throw new \InvalidArgumentException('Expected an array("service", "method") argument'); - } - - $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority); - } - - public function removeListener($eventName, $listener) - { - $this->lazyLoad($eventName); - - if (isset($this->listenerIds[$eventName])) { - foreach ($this->listenerIds[$eventName] as $i => $args) { - list($serviceId, $method, $priority) = $args; - $key = $serviceId.'.'.$method; - if (isset($this->listeners[$eventName][$key]) && $listener === array($this->listeners[$eventName][$key], $method)) { - unset($this->listeners[$eventName][$key]); - if (empty($this->listeners[$eventName])) { - unset($this->listeners[$eventName]); - } - unset($this->listenerIds[$eventName][$i]); - if (empty($this->listenerIds[$eventName])) { - unset($this->listenerIds[$eventName]); - } - } - } - } - - parent::removeListener($eventName, $listener); - } - - /** - * @see EventDispatcherInterface::hasListeners() - */ - public function hasListeners($eventName = null) - { - if (null === $eventName) { - return (bool) count($this->listenerIds) || (bool) count($this->listeners); - } - - if (isset($this->listenerIds[$eventName])) { - return true; - } - - return parent::hasListeners($eventName); - } - - /** - * @see EventDispatcherInterface::getListeners() - */ - public function getListeners($eventName = null) - { - if (null === $eventName) { - foreach ($this->listenerIds as $serviceEventName => $args) { - $this->lazyLoad($serviceEventName); - } - } else { - $this->lazyLoad($eventName); - } - - return parent::getListeners($eventName); - } - - /** - * Adds a service as event subscriber. - * - * @param string $serviceId The service ID of the subscriber service - * @param string $class The service's class name (which must implement EventSubscriberInterface) - */ - public function addSubscriberService($serviceId, $class) - { - foreach ($class::getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->listenerIds[$eventName][] = array($serviceId, $params, 0); - } elseif (is_string($params[0])) { - $this->listenerIds[$eventName][] = array($serviceId, $params[0], isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * {@inheritdoc} - * - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @throws \InvalidArgumentException if the service is not defined - */ - public function dispatch($eventName, Event $event = null) - { - $this->lazyLoad($eventName); - - return parent::dispatch($eventName, $event); - } - - public function getContainer() - { - return $this->container; - } - - /** - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - */ - protected function lazyLoad($eventName) - { - if (isset($this->listenerIds[$eventName])) { - foreach ($this->listenerIds[$eventName] as $args) { - list($serviceId, $method, $priority) = $args; - $listener = $this->container->get($serviceId); - - $key = $serviceId.'.'.$method; - if (!isset($this->listeners[$eventName][$key])) { - $this->addListener($eventName, array($listener, $method), $priority); - } elseif ($listener !== $this->listeners[$eventName][$key]) { - parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); - $this->addListener($eventName, array($listener, $method), $priority); - } - - $this->listeners[$eventName][$key] = $listener; - } - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php deleted file mode 100644 index e51aa2faf..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ /dev/null @@ -1,335 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\Stopwatch\Stopwatch; -use Psr\Log\LoggerInterface; - -/** - * Collects some data about event listeners. - * - * This event dispatcher delegates the dispatching to another one. - * - * @author Fabien Potencier - */ -class TraceableEventDispatcher implements TraceableEventDispatcherInterface -{ - protected $logger; - protected $stopwatch; - - private $called; - private $dispatcher; - private $wrappedListeners; - - /** - * 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(); - } - - /** - * {@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) - { - if (isset($this->wrappedListeners[$eventName])) { - foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) { - if ($wrappedListener->getWrappedListener() === $listener) { - $listener = $wrappedListener; - unset($this->wrappedListeners[$eventName][$index]); - break; - } - } - } - - 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->preProcess($eventName); - $this->preDispatch($eventName, $event); - - $e = $this->stopwatch->start($eventName, 'section'); - - $this->dispatcher->dispatch($eventName, $event); - - if ($e->isStarted()) { - $e->stop(); - } - - $this->postDispatch($eventName, $event); - $this->postProcess($eventName); - - return $event; - } - - /** - * {@inheritdoc} - */ - public function getCalledListeners() - { - $called = array(); - foreach ($this->called as $eventName => $listeners) { - foreach ($listeners as $listener) { - $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName); - $called[$eventName.'.'.$info['pretty']] = $info; - } - } - - return $called; - } - - /** - * {@inheritdoc} - */ - public function getNotCalledListeners() - { - try { - $allListeners = $this->getListeners(); - } catch (\Exception $e) { - if (null !== $this->logger) { - $this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e)); - } - - // unable to retrieve the uncalled listeners - return array(); - } - - $notCalled = array(); - foreach ($allListeners as $eventName => $listeners) { - foreach ($listeners as $listener) { - $called = false; - if (isset($this->called[$eventName])) { - foreach ($this->called[$eventName] as $l) { - if ($l->getWrappedListener() === $listener) { - $called = true; - - break; - } - } - } - - if (!$called) { - $info = $this->getListenerInfo($listener, $eventName); - $notCalled[$eventName.'.'.$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 - * - * @return mixed - */ - public function __call($method, $arguments) - { - return call_user_func_array(array($this->dispatcher, $method), $arguments); - } - - /** - * Called before dispatching the event. - * - * @param string $eventName The event name - * @param Event $event The event - */ - protected function preDispatch($eventName, Event $event) - { - } - - /** - * Called after dispatching the event. - * - * @param string $eventName The event name - * @param Event $event The event - */ - protected function postDispatch($eventName, Event $event) - { - } - - private function preProcess($eventName) - { - foreach ($this->dispatcher->getListeners($eventName) as $listener) { - $this->dispatcher->removeListener($eventName, $listener); - $info = $this->getListenerInfo($listener, $eventName); - $name = isset($info['class']) ? $info['class'] : $info['type']; - $wrappedListener = new WrappedListener($listener, $name, $this->stopwatch, $this); - $this->wrappedListeners[$eventName][] = $wrappedListener; - $this->dispatcher->addListener($eventName, $wrappedListener); - } - } - - private function postProcess($eventName) - { - unset($this->wrappedListeners[$eventName]); - $skipped = false; - foreach ($this->dispatcher->getListeners($eventName) as $listener) { - if (!$listener instanceof WrappedListener) { // #12845: a new listener was added during dispatch. - continue; - } - // Unwrap listener - $this->dispatcher->removeListener($eventName, $listener); - $this->dispatcher->addListener($eventName, $listener->getWrappedListener()); - - $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName); - if ($listener->wasCalled()) { - if (null !== $this->logger) { - $this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty'])); - } - - if (!isset($this->called[$eventName])) { - $this->called[$eventName] = new \SplObjectStorage(); - } - - $this->called[$eventName]->attach($listener); - } - - if (null !== $this->logger && $skipped) { - $this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName)); - } - - if ($listener->stoppedPropagation()) { - if (null !== $this->logger) { - $this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName)); - } - - $skipped = true; - } - } - } - - /** - * Returns information about the listener. - * - * @param object $listener The listener - * @param string $eventName The event name - * - * @return array Information about the listener - */ - private function getListenerInfo($listener, $eventName) - { - $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; - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php deleted file mode 100644 index 5483e8150..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * @author Fabien Potencier - */ -interface TraceableEventDispatcherInterface extends EventDispatcherInterface -{ - /** - * Gets the called listeners. - * - * @return array An array of called listeners - */ - public function getCalledListeners(); - - /** - * Gets the not called listeners. - * - * @return array An array of not called listeners - */ - public function getNotCalledListeners(); -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php deleted file mode 100644 index e16627d6a..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * @author Fabien Potencier - */ -class WrappedListener -{ - private $listener; - private $name; - private $called; - private $stoppedPropagation; - private $stopwatch; - private $dispatcher; - - public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null) - { - $this->listener = $listener; - $this->name = $name; - $this->stopwatch = $stopwatch; - $this->dispatcher = $dispatcher; - $this->called = false; - $this->stoppedPropagation = false; - } - - public function getWrappedListener() - { - return $this->listener; - } - - public function wasCalled() - { - return $this->called; - } - - public function stoppedPropagation() - { - return $this->stoppedPropagation; - } - - public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher) - { - $this->called = true; - - $e = $this->stopwatch->start($this->name, 'event_listener'); - - call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher); - - if ($e->isStarted()) { - $e->stop(); - } - - if ($event->isPropagationStopped()) { - $this->stoppedPropagation = true; - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php deleted file mode 100644 index 7e74a37aa..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; - -/** - * Compiler pass to register tagged services for an event dispatcher. - */ -class RegisterListenersPass implements CompilerPassInterface -{ - /** - * @var string - */ - protected $dispatcherService; - - /** - * @var string - */ - protected $listenerTag; - - /** - * @var string - */ - protected $subscriberTag; - - /** - * Constructor. - * - * @param string $dispatcherService Service name of the event dispatcher in processed container - * @param string $listenerTag Tag name used for listener - * @param string $subscriberTag Tag name used for subscribers - */ - public function __construct($dispatcherService = 'event_dispatcher', $listenerTag = 'kernel.event_listener', $subscriberTag = 'kernel.event_subscriber') - { - $this->dispatcherService = $dispatcherService; - $this->listenerTag = $listenerTag; - $this->subscriberTag = $subscriberTag; - } - - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { - return; - } - - $definition = $container->findDefinition($this->dispatcherService); - - foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) { - $def = $container->getDefinition($id); - if (!$def->isPublic()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $id)); - } - - if ($def->isAbstract()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $id)); - } - - foreach ($events as $event) { - $priority = isset($event['priority']) ? $event['priority'] : 0; - - if (!isset($event['event'])) { - throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag)); - } - - if (!isset($event['method'])) { - $event['method'] = 'on'.preg_replace_callback(array( - '/(?<=\b)[a-z]/i', - '/[^a-z0-9]/i', - ), function ($matches) { return strtoupper($matches[0]); }, $event['event']); - $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']); - } - - $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); - } - } - - foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) { - $def = $container->getDefinition($id); - if (!$def->isPublic()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id)); - } - - if ($def->isAbstract()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event subscribers are lazy-loaded.', $id)); - } - - // We must assume that the class value has been correctly filled, even if the service is created by a factory - $class = $container->getParameterBag()->resolveValue($def->getClass()); - - $refClass = new \ReflectionClass($class); - $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; - if (!$refClass->implementsInterface($interface)) { - throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); - } - - $definition->addMethodCall('addSubscriberService', array($id, $class)); - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php deleted file mode 100644 index dc39b05d5..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * Event is the base class for classes containing event data. - * - * This class contains no event data. It is used by events that do not pass - * state information to an event handler when an event is raised. - * - * You can call the method stopPropagation() to abort the execution of - * further listeners in your event listener. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * - * @api - */ -class Event -{ - /** - * @var bool Whether no further event listeners should be triggered - */ - private $propagationStopped = false; - - /** - * @var EventDispatcher Dispatcher that dispatched this event - */ - private $dispatcher; - - /** - * @var string This event's name - */ - private $name; - - /** - * Returns whether further event listeners should be triggered. - * - * @see Event::stopPropagation() - * - * @return bool Whether propagation was already stopped for this event. - * - * @api - */ - public function isPropagationStopped() - { - return $this->propagationStopped; - } - - /** - * Stops the propagation of the event to further event listeners. - * - * If multiple event listeners are connected to the same event, no - * further event listener will be triggered once any trigger calls - * stopPropagation(). - * - * @api - */ - public function stopPropagation() - { - $this->propagationStopped = true; - } - - /** - * Stores the EventDispatcher that dispatches this Event. - * - * @param EventDispatcherInterface $dispatcher - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. - * - * @api - */ - public function setDispatcher(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - /** - * Returns the EventDispatcher that dispatches this Event. - * - * @return EventDispatcherInterface - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. - * - * @api - */ - public function getDispatcher() - { - return $this->dispatcher; - } - - /** - * Gets the event's name. - * - * @return string - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. - * - * @api - */ - public function getName() - { - return $this->name; - } - - /** - * Sets the event's name property. - * - * @param string $name The event name. - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. - * - * @api - */ - public function setName($name) - { - $this->name = $name; - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php deleted file mode 100644 index 46c11100b..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * @author Fabien Potencier - * @author Jordi Boggiano - * @author Jordan Alliot - * - * @api - */ -class EventDispatcher implements EventDispatcherInterface -{ - private $listeners = array(); - private $sorted = array(); - - /** - * @see EventDispatcherInterface::dispatch() - * - * @api - */ - public function dispatch($eventName, Event $event = null) - { - if (null === $event) { - $event = new Event(); - } - - $event->setDispatcher($this); - $event->setName($eventName); - - if (!isset($this->listeners[$eventName])) { - return $event; - } - - $this->doDispatch($this->getListeners($eventName), $eventName, $event); - - return $event; - } - - /** - * @see EventDispatcherInterface::getListeners() - */ - public function getListeners($eventName = null) - { - if (null !== $eventName) { - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - - return $this->sorted[$eventName]; - } - - foreach ($this->listeners as $eventName => $eventListeners) { - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - } - - return array_filter($this->sorted); - } - - /** - * @see EventDispatcherInterface::hasListeners() - */ - public function hasListeners($eventName = null) - { - return (bool) count($this->getListeners($eventName)); - } - - /** - * @see EventDispatcherInterface::addListener() - * - * @api - */ - public function addListener($eventName, $listener, $priority = 0) - { - $this->listeners[$eventName][$priority][] = $listener; - unset($this->sorted[$eventName]); - } - - /** - * @see EventDispatcherInterface::removeListener() - */ - public function removeListener($eventName, $listener) - { - if (!isset($this->listeners[$eventName])) { - return; - } - - foreach ($this->listeners[$eventName] as $priority => $listeners) { - if (false !== ($key = array_search($listener, $listeners, true))) { - unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]); - } - } - } - - /** - * @see EventDispatcherInterface::addSubscriber() - * - * @api - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->addListener($eventName, array($subscriber, $params)); - } elseif (is_string($params[0])) { - $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * @see EventDispatcherInterface::removeSubscriber() - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_array($params) && is_array($params[0])) { - foreach ($params as $listener) { - $this->removeListener($eventName, array($subscriber, $listener[0])); - } - } else { - $this->removeListener($eventName, array($subscriber, is_string($params) ? $params : $params[0])); - } - } - } - - /** - * Triggers the listeners of an event. - * - * This method can be overridden to add functionality that is executed - * for each listener. - * - * @param callable[] $listeners The event listeners. - * @param string $eventName The name of the event to dispatch. - * @param Event $event The event object to pass to the event handlers/listeners. - */ - protected function doDispatch($listeners, $eventName, Event $event) - { - foreach ($listeners as $listener) { - call_user_func($listener, $event, $eventName, $this); - if ($event->isPropagationStopped()) { - break; - } - } - } - - /** - * Sorts the internal list of listeners for the given event by priority. - * - * @param string $eventName The name of the event. - */ - private function sortListeners($eventName) - { - $this->sorted[$eventName] = array(); - - if (isset($this->listeners[$eventName])) { - krsort($this->listeners[$eventName]); - $this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]); - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php deleted file mode 100644 index 9d9fc4d44..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Bernhard Schussek - * - * @api - */ -interface EventDispatcherInterface -{ - /** - * Dispatches an event to all registered listeners. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - * @param Event $event The event to pass to the event handlers/listeners. - * If not supplied, an empty Event instance is created. - * - * @return Event - * - * @api - */ - public function dispatch($eventName, Event $event = null); - - /** - * Adds an event listener that listens on the specified events. - * - * @param string $eventName The event to listen on - * @param callable $listener The listener - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - * - * @api - */ - public function addListener($eventName, $listener, $priority = 0); - - /** - * Adds an event subscriber. - * - * The subscriber is asked for all the events he is - * interested in and added as a listener for these events. - * - * @param EventSubscriberInterface $subscriber The subscriber. - * - * @api - */ - public function addSubscriber(EventSubscriberInterface $subscriber); - - /** - * Removes an event listener from the specified events. - * - * @param string $eventName The event to remove a listener from - * @param callable $listener The listener to remove - */ - public function removeListener($eventName, $listener); - - /** - * Removes an event subscriber. - * - * @param EventSubscriberInterface $subscriber The subscriber - */ - public function removeSubscriber(EventSubscriberInterface $subscriber); - - /** - * Gets the listeners of a specific event or all listeners sorted by descending priority. - * - * @param string $eventName The name of the event - * - * @return array The event listeners for the specified event, or all event listeners by event name - */ - public function getListeners($eventName = null); - - /** - * Checks whether an event has any registered listeners. - * - * @param string $eventName The name of the event - * - * @return bool true if the specified event has any listeners, false otherwise - */ - public function hasListeners($eventName = null); -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php deleted file mode 100644 index ff7e305cd..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * An EventSubscriber knows himself what events he is interested in. - * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes - * {@link getSubscribedEvents} and registers the subscriber as a listener for all - * returned events. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * - * @api - */ -interface EventSubscriberInterface -{ - /** - * Returns an array of event names this subscriber wants to listen to. - * - * The array keys are event names and the value can be: - * - * * The method name to call (priority defaults to 0) - * * An array composed of the method name to call and the priority - * * An array of arrays composed of the method names to call and respective - * priorities, or 0 if unset - * - * For instance: - * - * * array('eventName' => 'methodName') - * * array('eventName' => array('methodName', $priority)) - * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) - * - * @return array The event names to listen to - * - * @api - */ - public static function getSubscribedEvents(); -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php deleted file mode 100644 index a8955ca42..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * Event encapsulation class. - * - * Encapsulates events thus decoupling the observer from the subject they encapsulate. - * - * @author Drak - */ -class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate -{ - /** - * Event subject. - * - * @var mixed usually object or callable - */ - protected $subject; - - /** - * Array of arguments. - * - * @var array - */ - protected $arguments; - - /** - * Encapsulate an event with $subject and $args. - * - * @param mixed $subject The subject of the event, usually an object. - * @param array $arguments Arguments to store in the event. - */ - public function __construct($subject = null, array $arguments = array()) - { - $this->subject = $subject; - $this->arguments = $arguments; - } - - /** - * Getter for subject property. - * - * @return mixed $subject The observer subject. - */ - public function getSubject() - { - return $this->subject; - } - - /** - * Get argument by key. - * - * @param string $key Key. - * - * @throws \InvalidArgumentException If key is not found. - * - * @return mixed Contents of array key. - */ - public function getArgument($key) - { - if ($this->hasArgument($key)) { - return $this->arguments[$key]; - } - - throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName())); - } - - /** - * Add argument to event. - * - * @param string $key Argument name. - * @param mixed $value Value. - * - * @return GenericEvent - */ - public function setArgument($key, $value) - { - $this->arguments[$key] = $value; - - return $this; - } - - /** - * Getter for all arguments. - * - * @return array - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * Set args property. - * - * @param array $args Arguments. - * - * @return GenericEvent - */ - public function setArguments(array $args = array()) - { - $this->arguments = $args; - - return $this; - } - - /** - * Has argument. - * - * @param string $key Key of arguments array. - * - * @return bool - */ - public function hasArgument($key) - { - return array_key_exists($key, $this->arguments); - } - - /** - * ArrayAccess for argument getter. - * - * @param string $key Array key. - * - * @throws \InvalidArgumentException If key does not exist in $this->args. - * - * @return mixed - */ - public function offsetGet($key) - { - return $this->getArgument($key); - } - - /** - * ArrayAccess for argument setter. - * - * @param string $key Array key to set. - * @param mixed $value Value. - */ - public function offsetSet($key, $value) - { - $this->setArgument($key, $value); - } - - /** - * ArrayAccess for unset argument. - * - * @param string $key Array key. - */ - public function offsetUnset($key) - { - if ($this->hasArgument($key)) { - unset($this->arguments[$key]); - } - } - - /** - * ArrayAccess has argument. - * - * @param string $key Array key. - * - * @return bool - */ - public function offsetExists($key) - { - return $this->hasArgument($key); - } - - /** - * IteratorAggregate for iterating over the object like an array. - * - * @return \ArrayIterator - */ - public function getIterator() - { - return new \ArrayIterator($this->arguments); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php deleted file mode 100644 index 7ef9ece75..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * A read-only proxy for an event dispatcher. - * - * @author Bernhard Schussek - */ -class ImmutableEventDispatcher implements EventDispatcherInterface -{ - /** - * The proxied dispatcher. - * - * @var EventDispatcherInterface - */ - private $dispatcher; - - /** - * Creates an unmodifiable proxy for an event dispatcher. - * - * @param EventDispatcherInterface $dispatcher The proxied event dispatcher. - */ - public function __construct(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - return $this->dispatcher->dispatch($eventName, $event); - } - - /** - * {@inheritdoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE deleted file mode 100644 index 43028bc60..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md deleted file mode 100644 index 8031f4dd3..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md +++ /dev/null @@ -1,27 +0,0 @@ -EventDispatcher Component -========================= - -The Symfony EventDispatcher component implements the Mediator pattern in a -simple and effective way to make your projects truly extensible. - -```php -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; - -$dispatcher = new EventDispatcher(); - -$dispatcher->addListener('event_name', function (Event $event) { - // ... -}); - -$dispatcher->dispatch('event_name'); -``` - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/EventDispatcher/ - $ composer install - $ phpunit diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php deleted file mode 100644 index b9e419496..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php +++ /dev/null @@ -1,369 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - /* Some pseudo events */ - const preFoo = 'pre.foo'; - const postFoo = 'post.foo'; - const preBar = 'pre.bar'; - const postBar = 'post.bar'; - - /** - * @var EventDispatcher - */ - private $dispatcher; - - private $listener; - - protected function setUp() - { - $this->dispatcher = $this->createEventDispatcher(); - $this->listener = new TestEventListener(); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->listener = null; - } - - abstract protected function createEventDispatcher(); - - public function testInitialState() - { - $this->assertEquals(array(), $this->dispatcher->getListeners()); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - $this->assertFalse($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testAddListener() - { - $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo')); - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo')); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - $this->assertCount(1, $this->dispatcher->getListeners(self::preFoo)); - $this->assertCount(1, $this->dispatcher->getListeners(self::postFoo)); - $this->assertCount(2, $this->dispatcher->getListeners()); - } - - public function testGetListenersSortsByPriority() - { - $listener1 = new TestEventListener(); - $listener2 = new TestEventListener(); - $listener3 = new TestEventListener(); - $listener1->name = '1'; - $listener2->name = '2'; - $listener3->name = '3'; - - $this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10); - $this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10); - $this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo')); - - $expected = array( - array($listener2, 'preFoo'), - array($listener3, 'preFoo'), - array($listener1, 'preFoo'), - ); - - $this->assertSame($expected, $this->dispatcher->getListeners('pre.foo')); - } - - public function testGetAllListenersSortsByPriority() - { - $listener1 = new TestEventListener(); - $listener2 = new TestEventListener(); - $listener3 = new TestEventListener(); - $listener4 = new TestEventListener(); - $listener5 = new TestEventListener(); - $listener6 = new TestEventListener(); - - $this->dispatcher->addListener('pre.foo', $listener1, -10); - $this->dispatcher->addListener('pre.foo', $listener2); - $this->dispatcher->addListener('pre.foo', $listener3, 10); - $this->dispatcher->addListener('post.foo', $listener4, -10); - $this->dispatcher->addListener('post.foo', $listener5); - $this->dispatcher->addListener('post.foo', $listener6, 10); - - $expected = array( - 'pre.foo' => array($listener3, $listener2, $listener1), - 'post.foo' => array($listener6, $listener5, $listener4), - ); - - $this->assertSame($expected, $this->dispatcher->getListeners()); - } - - public function testDispatch() - { - $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo')); - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo')); - $this->dispatcher->dispatch(self::preFoo); - $this->assertTrue($this->listener->preFooInvoked); - $this->assertFalse($this->listener->postFooInvoked); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent')); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo)); - $event = new Event(); - $return = $this->dispatcher->dispatch(self::preFoo, $event); - $this->assertEquals('pre.foo', $event->getName()); - $this->assertSame($event, $return); - } - - public function testDispatchForClosure() - { - $invoked = 0; - $listener = function () use (&$invoked) { - $invoked++; - }; - $this->dispatcher->addListener('pre.foo', $listener); - $this->dispatcher->addListener('post.foo', $listener); - $this->dispatcher->dispatch(self::preFoo); - $this->assertEquals(1, $invoked); - } - - public function testStopEventPropagation() - { - $otherListener = new TestEventListener(); - - // postFoo() stops the propagation, so only one listener should - // be executed - // Manually set priority to enforce $this->listener to be called first - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10); - $this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo')); - $this->dispatcher->dispatch(self::postFoo); - $this->assertTrue($this->listener->postFooInvoked); - $this->assertFalse($otherListener->postFooInvoked); - } - - public function testDispatchByPriority() - { - $invoked = array(); - $listener1 = function () use (&$invoked) { - $invoked[] = '1'; - }; - $listener2 = function () use (&$invoked) { - $invoked[] = '2'; - }; - $listener3 = function () use (&$invoked) { - $invoked[] = '3'; - }; - $this->dispatcher->addListener('pre.foo', $listener1, -10); - $this->dispatcher->addListener('pre.foo', $listener2); - $this->dispatcher->addListener('pre.foo', $listener3, 10); - $this->dispatcher->dispatch(self::preFoo); - $this->assertEquals(array('3', '2', '1'), $invoked); - } - - public function testRemoveListener() - { - $this->dispatcher->addListener('pre.bar', $this->listener); - $this->assertTrue($this->dispatcher->hasListeners(self::preBar)); - $this->dispatcher->removeListener('pre.bar', $this->listener); - $this->assertFalse($this->dispatcher->hasListeners(self::preBar)); - $this->dispatcher->removeListener('notExists', $this->listener); - } - - public function testAddSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testAddSubscriberWithPriorities() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $eventSubscriber = new TestEventSubscriberWithPriorities(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $listeners = $this->dispatcher->getListeners('pre.foo'); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $listeners); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]); - } - - public function testAddSubscriberWithMultipleListeners() - { - $eventSubscriber = new TestEventSubscriberWithMultipleListeners(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $listeners = $this->dispatcher->getListeners('pre.foo'); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $listeners); - $this->assertEquals('preFoo2', $listeners[0][1]); - } - - public function testRemoveSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - $this->assertFalse($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testRemoveSubscriberWithPriorities() - { - $eventSubscriber = new TestEventSubscriberWithPriorities(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - } - - public function testRemoveSubscriberWithMultipleListeners() - { - $eventSubscriber = new TestEventSubscriberWithMultipleListeners(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $this->dispatcher->getListeners(self::preFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - } - - public function testEventReceivesTheDispatcherInstance() - { - $dispatcher = null; - $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) { - $dispatcher = $event->getDispatcher(); - }); - $this->dispatcher->dispatch('test'); - $this->assertSame($this->dispatcher, $dispatcher); - } - - public function testEventReceivesTheDispatcherInstanceAsArgument() - { - $listener = new TestWithDispatcher(); - $this->dispatcher->addListener('test', array($listener, 'foo')); - $this->assertNull($listener->name); - $this->assertNull($listener->dispatcher); - $this->dispatcher->dispatch('test'); - $this->assertEquals('test', $listener->name); - $this->assertSame($this->dispatcher, $listener->dispatcher); - } - - /** - * @see https://bugs.php.net/bug.php?id=62976 - * - * This bug affects: - * - The PHP 5.3 branch for versions < 5.3.18 - * - The PHP 5.4 branch for versions < 5.4.8 - * - The PHP 5.5 branch is not affected - */ - public function testWorkaroundForPhpBug62976() - { - $dispatcher = $this->createEventDispatcher(); - $dispatcher->addListener('bug.62976', new CallableClass()); - $dispatcher->removeListener('bug.62976', function () {}); - $this->assertTrue($dispatcher->hasListeners('bug.62976')); - } - - public function testHasListenersWhenAddedCallbackListenerIsRemoved() - { - $listener = function () {}; - $this->dispatcher->addListener('foo', $listener); - $this->dispatcher->removeListener('foo', $listener); - $this->assertFalse($this->dispatcher->hasListeners()); - } - - public function testGetListenersWhenAddedCallbackListenerIsRemoved() - { - $listener = function () {}; - $this->dispatcher->addListener('foo', $listener); - $this->dispatcher->removeListener('foo', $listener); - $this->assertSame(array(), $this->dispatcher->getListeners()); - } - - public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled() - { - $this->assertFalse($this->dispatcher->hasListeners('foo')); - $this->assertFalse($this->dispatcher->hasListeners()); - } -} - -class CallableClass -{ - public function __invoke() - { - } -} - -class TestEventListener -{ - public $preFooInvoked = false; - public $postFooInvoked = false; - - /* Listener methods */ - - public function preFoo(Event $e) - { - $this->preFooInvoked = true; - } - - public function postFoo(Event $e) - { - $this->postFooInvoked = true; - - $e->stopPropagation(); - } -} - -class TestWithDispatcher -{ - public $name; - public $dispatcher; - - public function foo(Event $e, $name, $dispatcher) - { - $this->name = $name; - $this->dispatcher = $dispatcher; - } -} - -class TestEventSubscriber implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo'); - } -} - -class TestEventSubscriberWithPriorities implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - 'pre.foo' => array('preFoo', 10), - 'post.foo' => array('postFoo'), - ); - } -} - -class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('pre.foo' => array( - array('preFoo1'), - array('preFoo2', 10), - )); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php deleted file mode 100644 index 6f2fbcb9d..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ /dev/null @@ -1,249 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\Scope; -use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest -{ - protected function createEventDispatcher() - { - $container = new Container(); - - return new ContainerAwareEventDispatcher($container); - } - - public function testAddAListenerService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testAddASubscriberService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.subscriber', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService'); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testPreventDuplicateListenerService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 5); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 10); - - $dispatcher->dispatch('onEvent', $event); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testTriggerAListenerServiceOutOfScope() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $container->leaveScope('scope'); - $dispatcher->dispatch('onEvent'); - } - - public function testReEnteringAScope() - { - $event = new Event(); - - $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service1 - ->expects($this->exactly(2)) - ->method('onEvent') - ->with($event) - ; - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service1, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - $dispatcher->dispatch('onEvent', $event); - - $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service2 - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container->enterScope('scope'); - $container->set('service.listener', $service2, 'scope'); - - $dispatcher->dispatch('onEvent', $event); - - $container->leaveScope('scope'); - - $dispatcher->dispatch('onEvent'); - } - - public function testHasListenersOnLazyLoad() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $event->setDispatcher($dispatcher); - $event->setName('onEvent'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $this->assertTrue($dispatcher->hasListeners()); - - if ($dispatcher->hasListeners('onEvent')) { - $dispatcher->dispatch('onEvent'); - } - } - - public function testGetListenersOnLazyLoad() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $listeners = $dispatcher->getListeners(); - - $this->assertTrue(isset($listeners['onEvent'])); - - $this->assertCount(1, $dispatcher->getListeners('onEvent')); - } - - public function testRemoveAfterDispatch() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', new Event()); - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } - - public function testRemoveBeforeDispatch() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } -} - -class Service -{ - public function onEvent(Event $e) - { - } -} - -class SubscriberService implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - 'onEvent' => array('onEvent'), - ); - } - - public function onEvent(Event $e) - { - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php deleted file mode 100644 index 24e60024f..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ /dev/null @@ -1,199 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests\Debug; - -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\Stopwatch\Stopwatch; - -class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - 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 testGetCalledListenersNested() - { - $tdispatcher = null; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('foo', function (Event $event, $eventName, $dispatcher) use (&$tdispatcher) { - $tdispatcher = $dispatcher; - $dispatcher->dispatch('bar'); - }); - $dispatcher->addListener('bar', function (Event $event) {}); - $dispatcher->dispatch('foo'); - $this->assertSame($dispatcher, $tdispatcher); - $this->assertCount(2, $dispatcher->getCalledListeners()); - } - - public function testLogger() - { - $logger = $this->getMock('Psr\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('Psr\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 testDispatchReusedEventNested() - { - $nestedCall = false; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('foo', function (Event $e) use ($dispatcher) { - $dispatcher->dispatch('bar', $e); - }); - $dispatcher->addListener('bar', function (Event $e) use (&$nestedCall) { - $nestedCall = true; - }); - - $this->assertFalse($nestedCall); - $dispatcher->dispatch('foo'); - $this->assertTrue($nestedCall); - } - - public function testListenerCanRemoveItselfWhenExecuted() - { - $eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $listener1 = function ($event, $eventName, EventDispatcherInterface $dispatcher) use (&$listener1) { - $dispatcher->removeListener('foo', $listener1); - }; - $eventDispatcher->addListener('foo', $listener1); - $eventDispatcher->addListener('foo', function () {}); - $eventDispatcher->dispatch('foo'); - - $this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed'); - } -} - -class EventSubscriber implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('foo' => 'call'); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php deleted file mode 100644 index 0fdd6372b..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ /dev/null @@ -1,200 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; - -class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase -{ - /** - * Tests that event subscribers not implementing EventSubscriberInterface - * trigger an exception. - * - * @expectedException \InvalidArgumentException - */ - public function testEventSubscriberWithoutInterface() - { - // one service, not implementing any interface - $services = array( - 'my_event_subscriber' => array(0 => array()), - ); - - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $definition->expects($this->atLeastOnce()) - ->method('isPublic') - ->will($this->returnValue(true)); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('stdClass')); - - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition') - ); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.event_listener here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->onConsecutiveCalls(array(), $services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($builder); - } - - public function testValidEventSubscriber() - { - $services = array( - 'my_event_subscriber' => array(0 => array()), - ); - - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $definition->expects($this->atLeastOnce()) - ->method('isPublic') - ->will($this->returnValue(true)); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService')); - - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition') - ); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.event_listener here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->onConsecutiveCalls(array(), $services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $builder->expects($this->atLeastOnce()) - ->method('findDefinition') - ->will($this->returnValue($definition)); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($builder); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must be public as event listeners are lazy-loaded. - */ - public function testPrivateEventListener() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_listener', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must be public as event subscribers are lazy-loaded. - */ - public function testPrivateEventSubscriber() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded. - */ - public function testAbstractEventListener() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must not be abstract as event subscribers are lazy-loaded. - */ - public function testAbstractEventSubscriber() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - public function testEventSubscriberResolvableClassName() - { - $container = new ContainerBuilder(); - - $container->setParameter('subscriber.class', 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'); - $container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - - $definition = $container->getDefinition('event_dispatcher'); - $expected_calls = array( - array( - 'addSubscriberService', - array( - 'foo', - 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService', - ), - ), - ); - $this->assertSame($expected_calls, $definition->getMethodCalls()); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class" - */ - public function testEventSubscriberUnresolvableClassName() - { - $container = new ContainerBuilder(); - $container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } -} - -class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php deleted file mode 100644 index 5faa5c8be..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\EventDispatcher; - -class EventDispatcherTest extends AbstractEventDispatcherTest -{ - protected function createEventDispatcher() - { - return new EventDispatcher(); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php deleted file mode 100644 index 4bd269722..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcher; - -/** - * Test class for Event. - */ -class EventTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Symfony\Component\EventDispatcher\Event - */ - protected $event; - - /** - * @var \Symfony\Component\EventDispatcher\EventDispatcher - */ - protected $dispatcher; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - $this->event = new Event(); - $this->dispatcher = new EventDispatcher(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - $this->event = null; - $this->dispatcher = null; - } - - public function testIsPropagationStopped() - { - $this->assertFalse($this->event->isPropagationStopped()); - } - - public function testStopPropagationAndIsPropagationStopped() - { - $this->event->stopPropagation(); - $this->assertTrue($this->event->isPropagationStopped()); - } - - /** - * @group legacy - */ - public function testLegacySetDispatcher() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->event->setDispatcher($this->dispatcher); - $this->assertSame($this->dispatcher, $this->event->getDispatcher()); - } - - /** - * @group legacy - */ - public function testLegacyGetDispatcher() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->assertNull($this->event->getDispatcher()); - } - - /** - * @group legacy - */ - public function testLegacyGetName() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->assertNull($this->event->getName()); - } - - /** - * @group legacy - */ - public function testLegacySetName() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->event->setName('foo'); - $this->assertEquals('foo', $this->event->getName()); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php deleted file mode 100644 index aebd82dab..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\GenericEvent; - -/** - * Test class for Event. - */ -class GenericEventTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var GenericEvent - */ - private $event; - - private $subject; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->subject = new \stdClass(); - $this->event = new GenericEvent($this->subject, array('name' => 'Event')); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->subject = null; - $this->event = null; - - parent::tearDown(); - } - - public function testConstruct() - { - $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event'))); - } - - /** - * Tests Event->getArgs(). - */ - public function testGetArguments() - { - // test getting all - $this->assertSame(array('name' => 'Event'), $this->event->getArguments()); - } - - public function testSetArguments() - { - $result = $this->event->setArguments(array('foo' => 'bar')); - $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event); - $this->assertSame($this->event, $result); - } - - public function testSetArgument() - { - $result = $this->event->setArgument('foo2', 'bar2'); - $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); - $this->assertEquals($this->event, $result); - } - - public function testGetArgument() - { - // test getting key - $this->assertEquals('Event', $this->event->getArgument('name')); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetArgException() - { - $this->event->getArgument('nameNotExist'); - } - - public function testOffsetGet() - { - // test getting key - $this->assertEquals('Event', $this->event['name']); - - // test getting invalid arg - $this->setExpectedException('InvalidArgumentException'); - $this->assertFalse($this->event['nameNotExist']); - } - - public function testOffsetSet() - { - $this->event['foo2'] = 'bar2'; - $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); - } - - public function testOffsetUnset() - { - unset($this->event['name']); - $this->assertAttributeSame(array(), 'arguments', $this->event); - } - - public function testOffsetIsset() - { - $this->assertTrue(isset($this->event['name'])); - $this->assertFalse(isset($this->event['nameNotExist'])); - } - - public function testHasArgument() - { - $this->assertTrue($this->event->hasArgument('name')); - $this->assertFalse($this->event->hasArgument('nameNotExist')); - } - - public function testGetSubject() - { - $this->assertSame($this->subject, $this->event->getSubject()); - } - - public function testHasIterator() - { - $data = array(); - foreach ($this->event as $key => $value) { - $data[$key] = $value; - } - $this->assertEquals(array('name' => 'Event'), $data); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php deleted file mode 100644 index 80a7e43be..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\ImmutableEventDispatcher; - -/** - * @author Bernhard Schussek - */ -class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $innerDispatcher; - - /** - * @var ImmutableEventDispatcher - */ - private $dispatcher; - - protected function setUp() - { - $this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher); - } - - public function testDispatchDelegates() - { - $event = new Event(); - - $this->innerDispatcher->expects($this->once()) - ->method('dispatch') - ->with('event', $event) - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->dispatch('event', $event)); - } - - public function testGetListenersDelegates() - { - $this->innerDispatcher->expects($this->once()) - ->method('getListeners') - ->with('event') - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->getListeners('event')); - } - - public function testHasListenersDelegates() - { - $this->innerDispatcher->expects($this->once()) - ->method('hasListeners') - ->with('event') - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->hasListeners('event')); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testAddListenerDisallowed() - { - $this->dispatcher->addListener('event', function () { return 'foo'; }); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testAddSubscriberDisallowed() - { - $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); - - $this->dispatcher->addSubscriber($subscriber); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRemoveListenerDisallowed() - { - $this->dispatcher->removeListener('event', function () { return 'foo'; }); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRemoveSubscriberDisallowed() - { - $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); - - $this->dispatcher->removeSubscriber($subscriber); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json deleted file mode 100644 index 1b1bd39ac..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "symfony/event-dispatcher", - "type": "library", - "description": "Symfony EventDispatcher Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/config": "~2.0,>=2.0.5", - "symfony/stopwatch": "~2.3", - "psr/log": "~1.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\EventDispatcher\\": "" } - }, - "target-dir": "Symfony/Component/EventDispatcher", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/exclude.txt b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/exclude.txt deleted file mode 100644 index 9010fbf2e..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/exclude.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -# The following source files are not re-distributed with the "build" of the application -# since they are used solely for constructing other files during the build process -# -Tests \ No newline at end of file diff --git a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist b/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist deleted file mode 100644 index b14fde575..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php deleted file mode 100644 index 9443f2166..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php +++ /dev/null @@ -1,442 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -abstract class AbstractEventDispatcherTest extends TestCase -{ - /* Some pseudo events */ - const preFoo = 'pre.foo'; - const postFoo = 'post.foo'; - const preBar = 'pre.bar'; - const postBar = 'post.bar'; - - /** - * @var EventDispatcher - */ - private $dispatcher; - - private $listener; - - protected function setUp() - { - $this->dispatcher = $this->createEventDispatcher(); - $this->listener = new TestEventListener(); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->listener = null; - } - - abstract protected function createEventDispatcher(); - - public function testInitialState() - { - $this->assertEquals(array(), $this->dispatcher->getListeners()); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - $this->assertFalse($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testAddListener() - { - $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo')); - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo')); - $this->assertTrue($this->dispatcher->hasListeners()); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - $this->assertCount(1, $this->dispatcher->getListeners(self::preFoo)); - $this->assertCount(1, $this->dispatcher->getListeners(self::postFoo)); - $this->assertCount(2, $this->dispatcher->getListeners()); - } - - public function testGetListenersSortsByPriority() - { - $listener1 = new TestEventListener(); - $listener2 = new TestEventListener(); - $listener3 = new TestEventListener(); - $listener1->name = '1'; - $listener2->name = '2'; - $listener3->name = '3'; - - $this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10); - $this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10); - $this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo')); - - $expected = array( - array($listener2, 'preFoo'), - array($listener3, 'preFoo'), - array($listener1, 'preFoo'), - ); - - $this->assertSame($expected, $this->dispatcher->getListeners('pre.foo')); - } - - public function testGetAllListenersSortsByPriority() - { - $listener1 = new TestEventListener(); - $listener2 = new TestEventListener(); - $listener3 = new TestEventListener(); - $listener4 = new TestEventListener(); - $listener5 = new TestEventListener(); - $listener6 = new TestEventListener(); - - $this->dispatcher->addListener('pre.foo', $listener1, -10); - $this->dispatcher->addListener('pre.foo', $listener2); - $this->dispatcher->addListener('pre.foo', $listener3, 10); - $this->dispatcher->addListener('post.foo', $listener4, -10); - $this->dispatcher->addListener('post.foo', $listener5); - $this->dispatcher->addListener('post.foo', $listener6, 10); - - $expected = array( - 'pre.foo' => array($listener3, $listener2, $listener1), - 'post.foo' => array($listener6, $listener5, $listener4), - ); - - $this->assertSame($expected, $this->dispatcher->getListeners()); - } - - public function testGetListenerPriority() - { - $listener1 = new TestEventListener(); - $listener2 = new TestEventListener(); - - $this->dispatcher->addListener('pre.foo', $listener1, -10); - $this->dispatcher->addListener('pre.foo', $listener2); - - $this->assertSame(-10, $this->dispatcher->getListenerPriority('pre.foo', $listener1)); - $this->assertSame(0, $this->dispatcher->getListenerPriority('pre.foo', $listener2)); - $this->assertNull($this->dispatcher->getListenerPriority('pre.bar', $listener2)); - $this->assertNull($this->dispatcher->getListenerPriority('pre.foo', function () {})); - } - - public function testDispatch() - { - $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo')); - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo')); - $this->dispatcher->dispatch(self::preFoo); - $this->assertTrue($this->listener->preFooInvoked); - $this->assertFalse($this->listener->postFooInvoked); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent')); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo)); - $event = new Event(); - $return = $this->dispatcher->dispatch(self::preFoo, $event); - $this->assertSame($event, $return); - } - - public function testDispatchForClosure() - { - $invoked = 0; - $listener = function () use (&$invoked) { - ++$invoked; - }; - $this->dispatcher->addListener('pre.foo', $listener); - $this->dispatcher->addListener('post.foo', $listener); - $this->dispatcher->dispatch(self::preFoo); - $this->assertEquals(1, $invoked); - } - - public function testStopEventPropagation() - { - $otherListener = new TestEventListener(); - - // postFoo() stops the propagation, so only one listener should - // be executed - // Manually set priority to enforce $this->listener to be called first - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10); - $this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo')); - $this->dispatcher->dispatch(self::postFoo); - $this->assertTrue($this->listener->postFooInvoked); - $this->assertFalse($otherListener->postFooInvoked); - } - - public function testDispatchByPriority() - { - $invoked = array(); - $listener1 = function () use (&$invoked) { - $invoked[] = '1'; - }; - $listener2 = function () use (&$invoked) { - $invoked[] = '2'; - }; - $listener3 = function () use (&$invoked) { - $invoked[] = '3'; - }; - $this->dispatcher->addListener('pre.foo', $listener1, -10); - $this->dispatcher->addListener('pre.foo', $listener2); - $this->dispatcher->addListener('pre.foo', $listener3, 10); - $this->dispatcher->dispatch(self::preFoo); - $this->assertEquals(array('3', '2', '1'), $invoked); - } - - public function testRemoveListener() - { - $this->dispatcher->addListener('pre.bar', $this->listener); - $this->assertTrue($this->dispatcher->hasListeners(self::preBar)); - $this->dispatcher->removeListener('pre.bar', $this->listener); - $this->assertFalse($this->dispatcher->hasListeners(self::preBar)); - $this->dispatcher->removeListener('notExists', $this->listener); - } - - public function testAddSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testAddSubscriberWithPriorities() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $eventSubscriber = new TestEventSubscriberWithPriorities(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $listeners = $this->dispatcher->getListeners('pre.foo'); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $listeners); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]); - } - - public function testAddSubscriberWithMultipleListeners() - { - $eventSubscriber = new TestEventSubscriberWithMultipleListeners(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $listeners = $this->dispatcher->getListeners('pre.foo'); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $listeners); - $this->assertEquals('preFoo2', $listeners[0][1]); - } - - public function testRemoveSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - $this->assertFalse($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testRemoveSubscriberWithPriorities() - { - $eventSubscriber = new TestEventSubscriberWithPriorities(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - } - - public function testRemoveSubscriberWithMultipleListeners() - { - $eventSubscriber = new TestEventSubscriberWithMultipleListeners(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $this->dispatcher->getListeners(self::preFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - } - - public function testEventReceivesTheDispatcherInstanceAsArgument() - { - $listener = new TestWithDispatcher(); - $this->dispatcher->addListener('test', array($listener, 'foo')); - $this->assertNull($listener->name); - $this->assertNull($listener->dispatcher); - $this->dispatcher->dispatch('test'); - $this->assertEquals('test', $listener->name); - $this->assertSame($this->dispatcher, $listener->dispatcher); - } - - /** - * @see https://bugs.php.net/bug.php?id=62976 - * - * This bug affects: - * - The PHP 5.3 branch for versions < 5.3.18 - * - The PHP 5.4 branch for versions < 5.4.8 - * - The PHP 5.5 branch is not affected - */ - public function testWorkaroundForPhpBug62976() - { - $dispatcher = $this->createEventDispatcher(); - $dispatcher->addListener('bug.62976', new CallableClass()); - $dispatcher->removeListener('bug.62976', function () {}); - $this->assertTrue($dispatcher->hasListeners('bug.62976')); - } - - public function testHasListenersWhenAddedCallbackListenerIsRemoved() - { - $listener = function () {}; - $this->dispatcher->addListener('foo', $listener); - $this->dispatcher->removeListener('foo', $listener); - $this->assertFalse($this->dispatcher->hasListeners()); - } - - public function testGetListenersWhenAddedCallbackListenerIsRemoved() - { - $listener = function () {}; - $this->dispatcher->addListener('foo', $listener); - $this->dispatcher->removeListener('foo', $listener); - $this->assertSame(array(), $this->dispatcher->getListeners()); - } - - public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled() - { - $this->assertFalse($this->dispatcher->hasListeners('foo')); - $this->assertFalse($this->dispatcher->hasListeners()); - } - - public function testHasListenersIsLazy() - { - $called = 0; - $listener = array(function () use (&$called) { ++$called; }, 'onFoo'); - $this->dispatcher->addListener('foo', $listener); - $this->assertTrue($this->dispatcher->hasListeners()); - $this->assertTrue($this->dispatcher->hasListeners('foo')); - $this->assertSame(0, $called); - } - - public function testDispatchLazyListener() - { - $called = 0; - $factory = function () use (&$called) { - ++$called; - - return new TestWithDispatcher(); - }; - $this->dispatcher->addListener('foo', array($factory, 'foo')); - $this->assertSame(0, $called); - $this->dispatcher->dispatch('foo', new Event()); - $this->dispatcher->dispatch('foo', new Event()); - $this->assertSame(1, $called); - } - - public function testRemoveFindsLazyListeners() - { - $test = new TestWithDispatcher(); - $factory = function () use ($test) { return $test; }; - - $this->dispatcher->addListener('foo', array($factory, 'foo')); - $this->assertTrue($this->dispatcher->hasListeners('foo')); - $this->dispatcher->removeListener('foo', array($test, 'foo')); - $this->assertFalse($this->dispatcher->hasListeners('foo')); - - $this->dispatcher->addListener('foo', array($test, 'foo')); - $this->assertTrue($this->dispatcher->hasListeners('foo')); - $this->dispatcher->removeListener('foo', array($factory, 'foo')); - $this->assertFalse($this->dispatcher->hasListeners('foo')); - } - - public function testPriorityFindsLazyListeners() - { - $test = new TestWithDispatcher(); - $factory = function () use ($test) { return $test; }; - - $this->dispatcher->addListener('foo', array($factory, 'foo'), 3); - $this->assertSame(3, $this->dispatcher->getListenerPriority('foo', array($test, 'foo'))); - $this->dispatcher->removeListener('foo', array($factory, 'foo')); - - $this->dispatcher->addListener('foo', array($test, 'foo'), 5); - $this->assertSame(5, $this->dispatcher->getListenerPriority('foo', array($factory, 'foo'))); - } - - public function testGetLazyListeners() - { - $test = new TestWithDispatcher(); - $factory = function () use ($test) { return $test; }; - - $this->dispatcher->addListener('foo', array($factory, 'foo'), 3); - $this->assertSame(array(array($test, 'foo')), $this->dispatcher->getListeners('foo')); - - $this->dispatcher->removeListener('foo', array($test, 'foo')); - $this->dispatcher->addListener('bar', array($factory, 'foo'), 3); - $this->assertSame(array('bar' => array(array($test, 'foo'))), $this->dispatcher->getListeners()); - } -} - -class CallableClass -{ - public function __invoke() - { - } -} - -class TestEventListener -{ - public $preFooInvoked = false; - public $postFooInvoked = false; - - /* Listener methods */ - - public function preFoo(Event $e) - { - $this->preFooInvoked = true; - } - - public function postFoo(Event $e) - { - $this->postFooInvoked = true; - - $e->stopPropagation(); - } -} - -class TestWithDispatcher -{ - public $name; - public $dispatcher; - - public function foo(Event $e, $name, $dispatcher) - { - $this->name = $name; - $this->dispatcher = $dispatcher; - } -} - -class TestEventSubscriber implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo'); - } -} - -class TestEventSubscriberWithPriorities implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - 'pre.foo' => array('preFoo', 10), - 'post.foo' => array('postFoo'), - ); - } -} - -class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('pre.foo' => array( - array('preFoo1'), - array('preFoo2', 10), - )); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php deleted file mode 100644 index 9d5eecc54..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ /dev/null @@ -1,210 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * @group legacy - */ -class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest -{ - protected function createEventDispatcher() - { - $container = new Container(); - - return new ContainerAwareEventDispatcher($container); - } - - public function testAddAListenerService() - { - $event = new Event(); - - $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testAddASubscriberService() - { - $event = new Event(); - - $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\SubscriberService')->getMock(); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $service - ->expects($this->once()) - ->method('onEventWithPriority') - ->with($event) - ; - - $service - ->expects($this->once()) - ->method('onEventNested') - ->with($event) - ; - - $container = new Container(); - $container->set('service.subscriber', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService'); - - $dispatcher->dispatch('onEvent', $event); - $dispatcher->dispatch('onEventWithPriority', $event); - $dispatcher->dispatch('onEventNested', $event); - } - - public function testPreventDuplicateListenerService() - { - $event = new Event(); - - $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 5); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 10); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testHasListenersOnLazyLoad() - { - $event = new Event(); - - $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $this->assertTrue($dispatcher->hasListeners()); - - if ($dispatcher->hasListeners('onEvent')) { - $dispatcher->dispatch('onEvent'); - } - } - - public function testGetListenersOnLazyLoad() - { - $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $listeners = $dispatcher->getListeners(); - - $this->assertArrayHasKey('onEvent', $listeners); - - $this->assertCount(1, $dispatcher->getListeners('onEvent')); - } - - public function testRemoveAfterDispatch() - { - $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', new Event()); - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } - - public function testRemoveBeforeDispatch() - { - $service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock(); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } -} - -class Service -{ - public function onEvent(Event $e) - { - } -} - -class SubscriberService implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - 'onEvent' => 'onEvent', - 'onEventWithPriority' => array('onEventWithPriority', 10), - 'onEventNested' => array(array('onEventNested')), - ); - } - - public function onEvent(Event $e) - { - } - - public function onEventWithPriority(Event $e) - { - } - - public function onEventNested(Event $e) - { - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php deleted file mode 100644 index 53a3421af..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests\Debug; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\Stopwatch\Stopwatch; - -class TraceableEventDispatcherTest extends TestCase -{ - 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 testGetListenerPriority() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $tdispatcher->addListener('foo', function () {}, 123); - - $listeners = $dispatcher->getListeners('foo'); - $this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0])); - - // Verify that priority is preserved when listener is removed and re-added - // in preProcess() and postProcess(). - $tdispatcher->dispatch('foo', new Event()); - $listeners = $dispatcher->getListeners('foo'); - $this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0])); - } - - public function testGetListenerPriorityWhileDispatching() - { - $tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $priorityWhileDispatching = null; - - $listener = function () use ($tdispatcher, &$priorityWhileDispatching, &$listener) { - $priorityWhileDispatching = $tdispatcher->getListenerPriority('bar', $listener); - }; - - $tdispatcher->addListener('bar', $listener, 5); - $tdispatcher->dispatch('bar'); - $this->assertSame(5, $priorityWhileDispatching); - } - - 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() - { - $tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $tdispatcher->addListener('foo', function () {}, 5); - - $listeners = $tdispatcher->getNotCalledListeners(); - $this->assertArrayHasKey('stub', $listeners['foo.closure']); - unset($listeners['foo.closure']['stub']); - $this->assertEquals(array(), $tdispatcher->getCalledListeners()); - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners); - - $tdispatcher->dispatch('foo'); - - $listeners = $tdispatcher->getCalledListeners(); - $this->assertArrayHasKey('stub', $listeners['foo.closure']); - unset($listeners['foo.closure']['stub']); - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners); - $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); - } - - public function testClearCalledListeners() - { - $tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $tdispatcher->addListener('foo', function () {}, 5); - - $tdispatcher->dispatch('foo'); - $tdispatcher->reset(); - - $listeners = $tdispatcher->getNotCalledListeners(); - $this->assertArrayHasKey('stub', $listeners['foo.closure']); - unset($listeners['foo.closure']['stub']); - $this->assertEquals(array(), $tdispatcher->getCalledListeners()); - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners); - } - - public function testGetCalledListenersNested() - { - $tdispatcher = null; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('foo', function (Event $event, $eventName, $dispatcher) use (&$tdispatcher) { - $tdispatcher = $dispatcher; - $dispatcher->dispatch('bar'); - }); - $dispatcher->addListener('bar', function (Event $event) {}); - $dispatcher->dispatch('foo'); - $this->assertSame($dispatcher, $tdispatcher); - $this->assertCount(2, $dispatcher->getCalledListeners()); - } - - public function testLogger() - { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $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 "{event}" to listener "{listener}".', array('event' => 'foo', 'listener' => 'closure')); - $logger->expects($this->at(1))->method('debug')->with('Notified event "{event}" to listener "{listener}".', array('event' => 'foo', 'listener' => 'closure')); - - $tdispatcher->dispatch('foo'); - } - - public function testLoggerWithStoppedEvent() - { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $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 "{event}" to listener "{listener}".', array('event' => 'foo', 'listener' => 'closure')); - $logger->expects($this->at(1))->method('debug')->with('Listener "{listener}" stopped propagation of the event "{event}".', array('event' => 'foo', 'listener' => 'closure')); - $logger->expects($this->at(2))->method('debug')->with('Listener "{listener}" was not called for event "{event}".', array('event' => 'foo', 'listener' => 'closure')); - - $tdispatcher->dispatch('foo'); - } - - public function testDispatchCallListeners() - { - $called = array(); - - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo1'; }, 10); - $tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo2'; }, 20); - - $tdispatcher->dispatch('foo'); - - $this->assertSame(array('foo2', 'foo1'), $called); - } - - public function testDispatchNested() - { - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $loop = 1; - $dispatchedEvents = 0; - $dispatcher->addListener('foo', $listener1 = function () use ($dispatcher, &$loop) { - ++$loop; - if (2 == $loop) { - $dispatcher->dispatch('foo'); - } - }); - $dispatcher->addListener('foo', function () use (&$dispatchedEvents) { - ++$dispatchedEvents; - }); - - $dispatcher->dispatch('foo'); - - $this->assertSame(2, $dispatchedEvents); - } - - public function testDispatchReusedEventNested() - { - $nestedCall = false; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('foo', function (Event $e) use ($dispatcher) { - $dispatcher->dispatch('bar', $e); - }); - $dispatcher->addListener('bar', function (Event $e) use (&$nestedCall) { - $nestedCall = true; - }); - - $this->assertFalse($nestedCall); - $dispatcher->dispatch('foo'); - $this->assertTrue($nestedCall); - } - - public function testListenerCanRemoveItselfWhenExecuted() - { - $eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $listener1 = function ($event, $eventName, EventDispatcherInterface $dispatcher) use (&$listener1) { - $dispatcher->removeListener('foo', $listener1); - }; - $eventDispatcher->addListener('foo', $listener1); - $eventDispatcher->addListener('foo', function () {}); - $eventDispatcher->dispatch('foo'); - - $this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed'); - } -} - -class EventSubscriber implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('foo' => 'call'); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php deleted file mode 100644 index dbb1aa5c5..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ /dev/null @@ -1,179 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; - -class RegisterListenersPassTest extends TestCase -{ - /** - * Tests that event subscribers not implementing EventSubscriberInterface - * trigger an exception. - * - * @expectedException \InvalidArgumentException - */ - public function testEventSubscriberWithoutInterface() - { - // one service, not implementing any interface - $services = array( - 'my_event_subscriber' => array(0 => array()), - ); - - $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('stdClass')); - - $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock(); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.event_listener here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->onConsecutiveCalls(array(), $services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($builder); - } - - public function testValidEventSubscriber() - { - $services = array( - 'my_event_subscriber' => array(0 => array()), - ); - - $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService')); - - $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition'))->getMock(); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.event_listener here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->onConsecutiveCalls(array(), $services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $builder->expects($this->atLeastOnce()) - ->method('findDefinition') - ->will($this->returnValue($definition)); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($builder); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" tagged "kernel.event_listener" must not be abstract. - */ - public function testAbstractEventListener() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" tagged "kernel.event_subscriber" must not be abstract. - */ - public function testAbstractEventSubscriber() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - public function testEventSubscriberResolvableClassName() - { - $container = new ContainerBuilder(); - - $container->setParameter('subscriber.class', 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'); - $container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - - $definition = $container->getDefinition('event_dispatcher'); - $expectedCalls = array( - array( - 'addListener', - array( - 'event', - array(new ServiceClosureArgument(new Reference('foo')), 'onEvent'), - 0, - ), - ), - ); - $this->assertEquals($expectedCalls, $definition->getMethodCalls()); - } - - public function testHotPathEvents() - { - $container = new ContainerBuilder(); - - $container->register('foo', SubscriberService::class)->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - (new RegisterListenersPass())->setHotPathEvents(array('event'))->process($container); - - $this->assertTrue($container->getDefinition('foo')->hasTag('container.hot_path')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class" - */ - public function testEventSubscriberUnresolvableClassName() - { - $container = new ContainerBuilder(); - $container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } -} - -class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - 'event' => 'onEvent', - ); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/EventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/EventDispatcherTest.php deleted file mode 100644 index 5faa5c8be..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/EventDispatcherTest.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\EventDispatcher; - -class EventDispatcherTest extends AbstractEventDispatcherTest -{ - protected function createEventDispatcher() - { - return new EventDispatcher(); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/EventTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/EventTest.php deleted file mode 100644 index 5be2ea09f..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/EventTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; - -/** - * Test class for Event. - */ -class EventTest extends TestCase -{ - /** - * @var \Symfony\Component\EventDispatcher\Event - */ - protected $event; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - $this->event = new Event(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - $this->event = null; - } - - public function testIsPropagationStopped() - { - $this->assertFalse($this->event->isPropagationStopped()); - } - - public function testStopPropagationAndIsPropagationStopped() - { - $this->event->stopPropagation(); - $this->assertTrue($this->event->isPropagationStopped()); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/GenericEventTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/GenericEventTest.php deleted file mode 100644 index 9cf68c987..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/GenericEventTest.php +++ /dev/null @@ -1,140 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\GenericEvent; - -/** - * Test class for Event. - */ -class GenericEventTest extends TestCase -{ - /** - * @var GenericEvent - */ - private $event; - - private $subject; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->subject = new \stdClass(); - $this->event = new GenericEvent($this->subject, array('name' => 'Event')); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->subject = null; - $this->event = null; - - parent::tearDown(); - } - - public function testConstruct() - { - $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event'))); - } - - /** - * Tests Event->getArgs(). - */ - public function testGetArguments() - { - // test getting all - $this->assertSame(array('name' => 'Event'), $this->event->getArguments()); - } - - public function testSetArguments() - { - $result = $this->event->setArguments(array('foo' => 'bar')); - $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event); - $this->assertSame($this->event, $result); - } - - public function testSetArgument() - { - $result = $this->event->setArgument('foo2', 'bar2'); - $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); - $this->assertEquals($this->event, $result); - } - - public function testGetArgument() - { - // test getting key - $this->assertEquals('Event', $this->event->getArgument('name')); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetArgException() - { - $this->event->getArgument('nameNotExist'); - } - - public function testOffsetGet() - { - // test getting key - $this->assertEquals('Event', $this->event['name']); - - // test getting invalid arg - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException'); - $this->assertFalse($this->event['nameNotExist']); - } - - public function testOffsetSet() - { - $this->event['foo2'] = 'bar2'; - $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); - } - - public function testOffsetUnset() - { - unset($this->event['name']); - $this->assertAttributeSame(array(), 'arguments', $this->event); - } - - public function testOffsetIsset() - { - $this->assertArrayHasKey('name', $this->event); - $this->assertArrayNotHasKey('nameNotExist', $this->event); - } - - public function testHasArgument() - { - $this->assertTrue($this->event->hasArgument('name')); - $this->assertFalse($this->event->hasArgument('nameNotExist')); - } - - public function testGetSubject() - { - $this->assertSame($this->subject, $this->event->getSubject()); - } - - public function testHasIterator() - { - $data = array(); - foreach ($this->event as $key => $value) { - $data[$key] = $value; - } - $this->assertEquals(array('name' => 'Event'), $data); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php b/lib/silex/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php deleted file mode 100644 index 04f2861e3..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\ImmutableEventDispatcher; - -/** - * @author Bernhard Schussek - */ -class ImmutableEventDispatcherTest extends TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $innerDispatcher; - - /** - * @var ImmutableEventDispatcher - */ - private $dispatcher; - - protected function setUp() - { - $this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher); - } - - public function testDispatchDelegates() - { - $event = new Event(); - - $this->innerDispatcher->expects($this->once()) - ->method('dispatch') - ->with('event', $event) - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->dispatch('event', $event)); - } - - public function testGetListenersDelegates() - { - $this->innerDispatcher->expects($this->once()) - ->method('getListeners') - ->with('event') - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->getListeners('event')); - } - - public function testHasListenersDelegates() - { - $this->innerDispatcher->expects($this->once()) - ->method('hasListeners') - ->with('event') - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->hasListeners('event')); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testAddListenerDisallowed() - { - $this->dispatcher->addListener('event', function () { return 'foo'; }); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testAddSubscriberDisallowed() - { - $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); - - $this->dispatcher->addSubscriber($subscriber); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRemoveListenerDisallowed() - { - $this->dispatcher->removeListener('event', function () { return 'foo'; }); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRemoveSubscriberDisallowed() - { - $subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock(); - - $this->dispatcher->removeSubscriber($subscriber); - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/composer.json b/lib/silex/vendor/symfony/event-dispatcher/composer.json deleted file mode 100644 index 75b881b91..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/composer.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "symfony/event-dispatcher", - "type": "library", - "description": "Symfony EventDispatcher Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "require-dev": { - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/dependency-injection": "<3.3" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/event-dispatcher/phpunit.xml.dist b/lib/silex/vendor/symfony/event-dispatcher/phpunit.xml.dist deleted file mode 100644 index b3ad1bdf5..000000000 --- a/lib/silex/vendor/symfony/event-dispatcher/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/symfony/http-foundation/.gitignore b/lib/silex/vendor/symfony/http-foundation/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/http-foundation/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/http-foundation/AcceptHeader.php b/lib/silex/vendor/symfony/http-foundation/AcceptHeader.php deleted file mode 100644 index d1740266b..000000000 --- a/lib/silex/vendor/symfony/http-foundation/AcceptHeader.php +++ /dev/null @@ -1,168 +0,0 @@ - - * - * 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 - */ -class AcceptHeader -{ - /** - * @var AcceptHeaderItem[] - */ - private $items = array(); - - /** - * @var bool - */ - private $sorted = true; - - /** - * @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 self - */ - 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 bool - */ - 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. - * - * @return $this - */ - 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 self - */ - 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 (AcceptHeaderItem $a, AcceptHeaderItem $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/lib/silex/vendor/symfony/http-foundation/AcceptHeaderItem.php b/lib/silex/vendor/symfony/http-foundation/AcceptHeaderItem.php deleted file mode 100644 index c69dbbba3..000000000 --- a/lib/silex/vendor/symfony/http-foundation/AcceptHeaderItem.php +++ /dev/null @@ -1,209 +0,0 @@ - - * - * 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 - */ -class AcceptHeaderItem -{ - private $value; - private $quality = 1.0; - private $index = 0; - private $attributes = array(); - - /** - * @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 self - */ - 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 $this - */ - 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 $this - */ - 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 $this - */ - 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 bool - */ - 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 $this - */ - public function setAttribute($name, $value) - { - if ('q' === $name) { - $this->quality = (float) $value; - } else { - $this->attributes[$name] = (string) $value; - } - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/ApacheRequest.php b/lib/silex/vendor/symfony/http-foundation/ApacheRequest.php deleted file mode 100644 index 84803ebae..000000000 --- a/lib/silex/vendor/symfony/http-foundation/ApacheRequest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Request represents an HTTP request from an Apache server. - * - * @author Fabien Potencier - */ -class ApacheRequest extends Request -{ - /** - * {@inheritdoc} - */ - protected function prepareRequestUri() - { - return $this->server->get('REQUEST_URI'); - } - - /** - * {@inheritdoc} - */ - protected function prepareBaseUrl() - { - $baseUrl = $this->server->get('SCRIPT_NAME'); - - if (false === strpos($this->server->get('REQUEST_URI'), $baseUrl)) { - // assume mod_rewrite - return rtrim(dirname($baseUrl), '/\\'); - } - - return $baseUrl; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/BinaryFileResponse.php b/lib/silex/vendor/symfony/http-foundation/BinaryFileResponse.php deleted file mode 100644 index 101022304..000000000 --- a/lib/silex/vendor/symfony/http-foundation/BinaryFileResponse.php +++ /dev/null @@ -1,359 +0,0 @@ - - * - * 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 - * @author stealth35 - * @author Igor Wiedler - * @author Jordan Alliot - * @author Sergey Linnik - */ -class BinaryFileResponse extends Response -{ - protected static $trustXSendfileTypeHeader = false; - - /** - * @var File - */ - protected $file; - protected $offset; - protected $maxlen; - protected $deleteFileAfterSend = false; - - /** - * @param \SplFileInfo|string $file The file to stream - * @param int $status The response status code - * @param array $headers An array of response headers - * @param bool $public Files are public by default - * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename - * @param bool $autoEtag Whether the ETag header should be automatically set - * @param bool $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(); - } - } - - /** - * @param \SplFileInfo|string $file The file to stream - * @param int $status The response status code - * @param array $headers An array of response headers - * @param bool $public Files are public by default - * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename - * @param bool $autoEtag Whether the ETag header should be automatically set - * @param bool $autoLastModified Whether the Last-Modified header should be automatically set - * - * @return static - */ - 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 - * @param string $contentDisposition - * @param bool $autoEtag - * @param bool $autoLastModified - * - * @return $this - * - * @throws FileException - */ - public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) - { - if (!$file instanceof File) { - if ($file instanceof \SplFileInfo) { - $file = new File($file->getPathname()); - } else { - $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(base64_encode(hash_file('sha256', $this->file->getPathname(), true))); - - 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 UTF-8 encoded 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 - * - * @return $this - */ - public function setContentDisposition($disposition, $filename = '', $filenameFallback = '') - { - if ('' === $filename) { - $filename = $this->file->getFilename(); - } - - if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) { - $encoding = mb_detect_encoding($filename, null, true) ?: '8bit'; - - for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) { - $char = mb_substr($filename, $i, 1, $encoding); - - if ('%' === $char || ord($char) < 32 || ord($char) > 126) { - $filenameFallback .= '_'; - } else { - $filenameFallback .= $char; - } - } - } - - $dispositionHeader = $this->headers->makeDisposition($disposition, $filename, $filenameFallback); - $this->headers->set('Content-Disposition', $dispositionHeader); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function prepare(Request $request) - { - 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->ensureIEOverSSLCompatibility($request); - - $this->offset = 0; - $this->maxlen = -1; - - if (false === $fileSize = $this->file->getSize()) { - return $this; - } - $this->headers->set('Content-Length', $fileSize); - - if (!$this->headers->has('Accept-Ranges')) { - // Only accept ranges on safe HTTP methods - $this->headers->set('Accept-Ranges', $request->isMethodSafe(false) ? 'bytes' : 'none'); - } - - 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(); - // Fall back to scheme://path for stream wrapped locations. - if (false === $path) { - $path = $this->file->getPathname(); - } - if ('x-accel-redirect' === strtolower($type)) { - // Do X-Accel-Mapping substitutions. - // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect - foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { - $mapping = explode('=', $mapping, 2); - - if (2 === count($mapping)) { - $pathPrefix = trim($mapping[0]); - $location = 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->hasValidIfRangeHeader($request->headers->get('If-Range'))) { - $range = $request->headers->get('Range'); - - list($start, $end) = explode('-', substr($range, 6), 2) + array(0); - - $end = ('' === $end) ? $fileSize - 1 : (int) $end; - - if ('' === $start) { - $start = $fileSize - $end; - $end = $fileSize - 1; - } else { - $start = (int) $start; - } - - if ($start <= $end) { - if ($start < 0 || $end > $fileSize - 1) { - $this->setStatusCode(416); - $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); - } elseif (0 !== $start || $end !== $fileSize - 1) { - $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; - $this->offset = $start; - - $this->setStatusCode(206); - $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); - $this->headers->set('Content-Length', $end - $start + 1); - } - } - } - } - - return $this; - } - - private function hasValidIfRangeHeader($header) - { - if ($this->getEtag() === $header) { - return true; - } - - if (null === $lastModified = $this->getLastModified()) { - return false; - } - - return $lastModified->format('D, d M Y H:i:s').' GMT' === $header; - } - - /** - * Sends the file. - * - * {@inheritdoc} - */ - public function sendContent() - { - if (!$this->isSuccessful()) { - return parent::sendContent(); - } - - if (0 === $this->maxlen) { - return $this; - } - - $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); - - if ($this->deleteFileAfterSend) { - unlink($this->file->getPathname()); - } - - return $this; - } - - /** - * {@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; - } - - /** - * If this is set to true, the file will be unlinked after the request is send - * Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used. - * - * @param bool $shouldDelete - * - * @return $this - */ - public function deleteFileAfterSend($shouldDelete) - { - $this->deleteFileAfterSend = $shouldDelete; - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/CHANGELOG.md b/lib/silex/vendor/symfony/http-foundation/CHANGELOG.md deleted file mode 100644 index ee5b6cecf..000000000 --- a/lib/silex/vendor/symfony/http-foundation/CHANGELOG.md +++ /dev/null @@ -1,159 +0,0 @@ -CHANGELOG -========= - -3.4.0 ------ - - * implemented PHP 7.0's `SessionUpdateTimestampHandlerInterface` with a new - `AbstractSessionHandler` base class and a new `StrictSessionHandler` wrapper - * deprecated the `WriteCheckSessionHandler`, `NativeSessionHandler` and `NativeProxy` classes - * deprecated setting session save handlers that do not implement `\SessionHandlerInterface` in `NativeSessionStorage::setSaveHandler()` - * deprecated using `MongoDbSessionHandler` with the legacy mongo extension; use it with the mongodb/mongodb package and ext-mongodb instead - * deprecated `MemcacheSessionHandler`; use `MemcachedSessionHandler` instead - -3.3.0 ------ - - * the `Request::setTrustedProxies()` method takes a new `$trustedHeaderSet` argument, - see http://symfony.com/doc/current/components/http_foundation/trusting_proxies.html for more info, - * deprecated the `Request::setTrustedHeaderName()` and `Request::getTrustedHeaderName()` methods, - * added `File\Stream`, to be passed to `BinaryFileResponse` when the size of the served file is unknown, - disabling `Range` and `Content-Length` handling, switching to chunked encoding instead - * added the `Cookie::fromString()` method that allows to create a cookie from a - raw header string - -3.1.0 ------ - - * Added support for creating `JsonResponse` with a string of JSON data - -3.0.0 ------ - - * The precedence of parameters returned from `Request::get()` changed from "GET, PATH, BODY" to "PATH, GET, BODY" - -2.8.0 ------ - - * Finding deep items in `ParameterBag::get()` is deprecated since version 2.8 and - will be removed in 3.0. - -2.6.0 ------ - - * PdoSessionHandler changes - - implemented different session locking strategies to prevent loss of data by concurrent access to the same session - - [BC BREAK] save session data in a binary column without base64_encode - - [BC BREAK] added lifetime column to the session table which allows to have different lifetimes for each session - - implemented lazy connections that are only opened when a session is used by either passing a dsn string - explicitly or falling back to session.save_path ini setting - - added a createTable method that initializes a correctly defined table depending on the database vendor - -2.5.0 ------ - - * added `JsonResponse::setEncodingOptions()` & `JsonResponse::getEncodingOptions()` for easier manipulation - of the options used while encoding data to JSON format. - -2.4.0 ------ - - * added RequestStack - * added Request::getEncodings() - * added accessors methods to session handlers - -2.3.0 ------ - - * added support for ranges of IPs in trusted proxies - * `UploadedFile::isValid` now returns false if the file was not uploaded via HTTP (in a non-test mode) - * Improved error-handling of `\Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler` - to ensure the supplied PDO handler throws Exceptions on error (as the class expects). Added related test cases - to verify that Exceptions are properly thrown when the PDO queries fail. - -2.2.0 ------ - - * fixed the Request::create() precedence (URI information always take precedence now) - * added Request::getTrustedProxies() - * deprecated Request::isProxyTrusted() - * [BC BREAK] JsonResponse does not turn a top level empty array to an object anymore, use an ArrayObject to enforce objects - * added a IpUtils class to check if an IP belongs to a CIDR - * 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, and Request::getHttpMethodParameterOverride() to check if it is supported) - * Request::splitHttpAcceptHeader() method is deprecated and will be removed in 2.3 - * Deprecated Flashbag::count() and \Countable interface, will be removed in 2.3 - -2.1.0 ------ - - * added Request::getSchemeAndHttpHost() and Request::getUserInfo() - * added a fluent interface to the Response class - * added Request::isProxyTrusted() - * added JsonResponse - * added a getTargetUrl method to RedirectResponse - * added support for streamed responses - * made Response::prepare() method the place to enforce HTTP specification - * [BC BREAK] moved management of the locale from the Session class to the Request class - * added a generic access to the PHP built-in filter mechanism: ParameterBag::filter() - * made FileBinaryMimeTypeGuesser command configurable - * added Request::getUser() and Request::getPassword() - * added support for the PATCH method in Request - * removed the ContentTypeMimeTypeGuesser class as it is deprecated and never used on PHP 5.3 - * added ResponseHeaderBag::makeDisposition() (implements RFC 6266) - * made mimetype to extension conversion configurable - * [BC BREAK] Moved all session related classes and interfaces into own namespace, as - `Symfony\Component\HttpFoundation\Session` and renamed classes accordingly. - Session handlers are located in the subnamespace `Symfony\Component\HttpFoundation\Session\Handler`. - * SessionHandlers must implement `\SessionHandlerInterface` or extend from the - `Symfony\Component\HttpFoundation\Storage\Handler\NativeSessionHandler` base class. - * Added internal storage driver proxy mechanism for forward compatibility with - PHP 5.4 `\SessionHandler` class. - * Added session handlers for custom Memcache, Memcached and Null session save handlers. - * [BC BREAK] Removed `NativeSessionStorage` and replaced with `NativeFileSessionHandler`. - * [BC BREAK] `SessionStorageInterface` methods removed: `write()`, `read()` and - `remove()`. Added `getBag()`, `registerBag()`. The `NativeSessionStorage` class - is a mediator for the session storage internals including the session handlers - which do the real work of participating in the internal PHP session workflow. - * [BC BREAK] Introduced mock implementations of `SessionStorage` to enable unit - and functional testing without starting real PHP sessions. Removed - `ArraySessionStorage`, and replaced with `MockArraySessionStorage` for unit - tests; removed `FilesystemSessionStorage`, and replaced with`MockFileSessionStorage` - for functional tests. These do not interact with global session ini - configuration values, session functions or `$_SESSION` superglobal. This means - they can be configured directly allowing multiple instances to work without - conflicting in the same PHP process. - * [BC BREAK] Removed the `close()` method from the `Session` class, as this is - now redundant. - * Deprecated the following methods from the Session class: `setFlash()`, `setFlashes()` - `getFlash()`, `hasFlash()`, and `removeFlash()`. Use `getFlashBag()` instead - which returns a `FlashBagInterface`. - * `Session->clear()` now only clears session attributes as before it cleared - flash messages and attributes. `Session->getFlashBag()->all()` clears flashes now. - * Session data is now managed by `SessionBagInterface` to better encapsulate - session data. - * Refactored session attribute and flash messages system to their own - `SessionBagInterface` implementations. - * Added `FlashBag`. Flashes expire when retrieved by `get()` or `all()`. This - implementation is ESI compatible. - * Added `AutoExpireFlashBag` (default) to replicate Symfony 2.0.x auto expire - behaviour of messages auto expiring after one page page load. Messages must - be retrieved by `get()` or `all()`. - * Added `Symfony\Component\HttpFoundation\Attribute\AttributeBag` to replicate - attributes storage behaviour from 2.0.x (default). - * Added `Symfony\Component\HttpFoundation\Attribute\NamespacedAttributeBag` for - namespace session attributes. - * Flash API can stores messages in an array so there may be multiple messages - per flash type. The old `Session` class API remains without BC break as it - will allow single messages as before. - * Added basic session meta-data to the session to record session create time, - last updated time, and the lifetime of the session cookie that was provided - to the client. - * Request::getClientIp() method doesn't take a parameter anymore but bases - itself on the trustProxy parameter. - * Added isMethod() to Request object. - * [BC BREAK] The methods `getPathInfo()`, `getBaseUrl()` and `getBasePath()` of - a `Request` now all return a raw value (vs a urldecoded value before). Any call - to one of these methods must be checked and wrapped in a `rawurldecode()` if - needed. diff --git a/lib/silex/vendor/symfony/http-foundation/Cookie.php b/lib/silex/vendor/symfony/http-foundation/Cookie.php deleted file mode 100644 index 4519a6ada..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Cookie.php +++ /dev/null @@ -1,289 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Represents a cookie. - * - * @author Johannes M. Schmitt - */ -class Cookie -{ - protected $name; - protected $value; - protected $domain; - protected $expire; - protected $path; - protected $secure; - protected $httpOnly; - private $raw; - private $sameSite; - - const SAMESITE_LAX = 'lax'; - const SAMESITE_STRICT = 'strict'; - - /** - * Creates cookie from raw header string. - * - * @param string $cookie - * @param bool $decode - * - * @return static - */ - public static function fromString($cookie, $decode = false) - { - $data = array( - 'expires' => 0, - 'path' => '/', - 'domain' => null, - 'secure' => false, - 'httponly' => false, - 'raw' => !$decode, - 'samesite' => null, - ); - foreach (explode(';', $cookie) as $part) { - if (false === strpos($part, '=')) { - $key = trim($part); - $value = true; - } else { - list($key, $value) = explode('=', trim($part), 2); - $key = trim($key); - $value = trim($value); - } - if (!isset($data['name'])) { - $data['name'] = $decode ? urldecode($key) : $key; - $data['value'] = true === $value ? null : ($decode ? urldecode($value) : $value); - continue; - } - switch ($key = strtolower($key)) { - case 'name': - case 'value': - break; - case 'max-age': - $data['expires'] = time() + (int) $value; - break; - default: - $data[$key] = $value; - break; - } - } - - return new static($data['name'], $data['value'], $data['expires'], $data['path'], $data['domain'], $data['secure'], $data['httponly'], $data['raw'], $data['samesite']); - } - - /** - * @param string $name The name of the cookie - * @param string|null $value The value of the cookie - * @param int|string|\DateTimeInterface $expire The time the cookie expires - * @param string $path The path on the server in which the cookie will be available on - * @param string|null $domain The domain that the cookie is available to - * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client - * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol - * @param bool $raw Whether the cookie value should be sent with no url encoding - * @param string|null $sameSite Whether the cookie will be available for cross-site requests - * - * @throws \InvalidArgumentException - */ - public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true, $raw = false, $sameSite = null) - { - // from PHP source code - if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { - throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name)); - } - - if (empty($name)) { - throw new \InvalidArgumentException('The cookie name cannot be empty.'); - } - - // convert expiration time to a Unix timestamp - if ($expire instanceof \DateTimeInterface) { - $expire = $expire->format('U'); - } elseif (!is_numeric($expire)) { - $expire = strtotime($expire); - - if (false === $expire) { - throw new \InvalidArgumentException('The cookie expiration time is not valid.'); - } - } - - $this->name = $name; - $this->value = $value; - $this->domain = $domain; - $this->expire = 0 < $expire ? (int) $expire : 0; - $this->path = empty($path) ? '/' : $path; - $this->secure = (bool) $secure; - $this->httpOnly = (bool) $httpOnly; - $this->raw = (bool) $raw; - - if (null !== $sameSite) { - $sameSite = strtolower($sameSite); - } - - if (!in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) { - throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.'); - } - - $this->sameSite = $sameSite; - } - - /** - * Returns the cookie as a string. - * - * @return string The cookie - */ - public function __toString() - { - $str = ($this->isRaw() ? $this->getName() : urlencode($this->getName())).'='; - - if ('' === (string) $this->getValue()) { - $str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; max-age=-31536001'; - } else { - $str .= $this->isRaw() ? $this->getValue() : rawurlencode($this->getValue()); - - if (0 !== $this->getExpiresTime()) { - $str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()).'; max-age='.$this->getMaxAge(); - } - } - - if ($this->getPath()) { - $str .= '; path='.$this->getPath(); - } - - if ($this->getDomain()) { - $str .= '; domain='.$this->getDomain(); - } - - if (true === $this->isSecure()) { - $str .= '; secure'; - } - - if (true === $this->isHttpOnly()) { - $str .= '; httponly'; - } - - if (null !== $this->getSameSite()) { - $str .= '; samesite='.$this->getSameSite(); - } - - return $str; - } - - /** - * Gets the name of the cookie. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Gets the value of the cookie. - * - * @return string|null - */ - public function getValue() - { - return $this->value; - } - - /** - * Gets the domain that the cookie is available to. - * - * @return string|null - */ - public function getDomain() - { - return $this->domain; - } - - /** - * Gets the time the cookie expires. - * - * @return int - */ - public function getExpiresTime() - { - return $this->expire; - } - - /** - * Gets the max-age attribute. - * - * @return int - */ - public function getMaxAge() - { - return 0 !== $this->expire ? $this->expire - time() : 0; - } - - /** - * Gets the path on the server in which the cookie will be available on. - * - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client. - * - * @return bool - */ - public function isSecure() - { - return $this->secure; - } - - /** - * Checks whether the cookie will be made accessible only through the HTTP protocol. - * - * @return bool - */ - public function isHttpOnly() - { - return $this->httpOnly; - } - - /** - * Whether this cookie is about to be cleared. - * - * @return bool - */ - public function isCleared() - { - return $this->expire < time(); - } - - /** - * Checks if the cookie value should be sent with no url encoding. - * - * @return bool - */ - public function isRaw() - { - return $this->raw; - } - - /** - * Gets the SameSite attribute. - * - * @return string|null - */ - public function getSameSite() - { - return $this->sameSite; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php b/lib/silex/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php deleted file mode 100644 index 5fcf5b426..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Exception/ConflictingHeadersException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Exception; - -/** - * The HTTP request contains headers with conflicting information. - * - * @author Magnus Nordlander - */ -class ConflictingHeadersException extends \UnexpectedValueException implements RequestExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/http-foundation/Exception/RequestExceptionInterface.php b/lib/silex/vendor/symfony/http-foundation/Exception/RequestExceptionInterface.php deleted file mode 100644 index 478d0dc7e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Exception/RequestExceptionInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Exception; - -/** - * Interface for Request exceptions. - * - * Exceptions implementing this interface should trigger an HTTP 400 response in the application code. - */ -interface RequestExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php b/lib/silex/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php deleted file mode 100644 index ae7a5f133..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Exception/SuspiciousOperationException.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Exception; - -/** - * Raised when a user has performed an operation that should be considered - * suspicious from a security perspective. - */ -class SuspiciousOperationException extends \UnexpectedValueException implements RequestExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/http-foundation/ExpressionRequestMatcher.php b/lib/silex/vendor/symfony/http-foundation/ExpressionRequestMatcher.php deleted file mode 100644 index e9c8441ce..000000000 --- a/lib/silex/vendor/symfony/http-foundation/ExpressionRequestMatcher.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * 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\ExpressionLanguage\ExpressionLanguage; - -/** - * ExpressionRequestMatcher uses an expression to match a Request. - * - * @author Fabien Potencier - */ -class ExpressionRequestMatcher extends RequestMatcher -{ - private $language; - private $expression; - - public function setExpression(ExpressionLanguage $language, $expression) - { - $this->language = $language; - $this->expression = $expression; - } - - public function matches(Request $request) - { - if (!$this->language) { - throw new \LogicException('Unable to match the request as the expression language is not available.'); - } - - return $this->language->evaluate($this->expression, array( - 'request' => $request, - 'method' => $request->getMethod(), - 'path' => rawurldecode($request->getPathInfo()), - 'host' => $request->getHost(), - 'ip' => $request->getClientIp(), - 'attributes' => $request->attributes->all(), - )) && parent::matches($request); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php b/lib/silex/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php deleted file mode 100644 index 3b8e41d4a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/Exception/AccessDeniedException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when the access on a file was denied. - * - * @author Bernhard Schussek - */ -class AccessDeniedException extends FileException -{ - /** - * @param string $path The path to the accessed file - */ - public function __construct($path) - { - parent::__construct(sprintf('The file %s could not be accessed', $path)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/Exception/FileException.php b/lib/silex/vendor/symfony/http-foundation/File/Exception/FileException.php deleted file mode 100644 index fad5133e1..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/Exception/FileException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when an error occurred in the component File. - * - * @author Bernhard Schussek - */ -class FileException extends \RuntimeException -{ -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php b/lib/silex/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php deleted file mode 100644 index bfcc37ec6..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/Exception/FileNotFoundException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when a file was not found. - * - * @author Bernhard Schussek - */ -class FileNotFoundException extends FileException -{ - /** - * @param string $path The path to the file that was not found - */ - public function __construct($path) - { - parent::__construct(sprintf('The file "%s" does not exist', $path)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php b/lib/silex/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php deleted file mode 100644 index 0444b8778..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/Exception/UnexpectedTypeException.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -class UnexpectedTypeException extends FileException -{ - public function __construct($value, $expectedType) - { - parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/Exception/UploadException.php b/lib/silex/vendor/symfony/http-foundation/File/Exception/UploadException.php deleted file mode 100644 index 7074e7653..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/Exception/UploadException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when an error occurred during file upload. - * - * @author Bernhard Schussek - */ -class UploadException extends FileException -{ -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/File.php b/lib/silex/vendor/symfony/http-foundation/File/File.php deleted file mode 100644 index e2a67684f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/File.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File; - -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; - -/** - * A file in the file system. - * - * @author Bernhard Schussek - */ -class File extends \SplFileInfo -{ - /** - * Constructs a new file from the given path. - * - * @param string $path The path to the file - * @param bool $checkPath Whether to check the path or not - * - * @throws FileNotFoundException If the given path is not a file - */ - public function __construct($path, $checkPath = true) - { - if ($checkPath && !is_file($path)) { - throw new FileNotFoundException($path); - } - - parent::__construct($path); - } - - /** - * Returns the extension based on the mime type. - * - * If the mime type is unknown, returns null. - * - * This method uses the mime type as guessed by getMimeType() - * to guess the file extension. - * - * @return string|null The guessed extension or null if it cannot be guessed - * - * @see ExtensionGuesser - * @see getMimeType() - */ - public function guessExtension() - { - $type = $this->getMimeType(); - $guesser = ExtensionGuesser::getInstance(); - - return $guesser->guess($type); - } - - /** - * Returns the mime type of the file. - * - * The mime type is guessed using a MimeTypeGuesser instance, which uses finfo(), - * mime_content_type() and the system binary "file" (in this order), depending on - * which of those are available. - * - * @return string|null The guessed mime type (e.g. "application/pdf") - * - * @see MimeTypeGuesser - */ - public function getMimeType() - { - $guesser = MimeTypeGuesser::getInstance(); - - return $guesser->guess($this->getPathname()); - } - - /** - * Moves the file to a new location. - * - * @param string $directory The destination folder - * @param string $name The new file name - * - * @return self A File object representing the new file - * - * @throws FileException if the target file could not be created - */ - public function move($directory, $name = null) - { - $target = $this->getTargetFile($directory, $name); - - if (!@rename($this->getPathname(), $target)) { - $error = error_get_last(); - throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); - } - - @chmod($target, 0666 & ~umask()); - - return $target; - } - - protected function getTargetFile($directory, $name = null) - { - if (!is_dir($directory)) { - if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) { - throw new FileException(sprintf('Unable to create the "%s" directory', $directory)); - } - } elseif (!is_writable($directory)) { - throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); - } - - $target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); - - return new self($target, false); - } - - /** - * 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/lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php b/lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php deleted file mode 100644 index 263fb321c..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesser.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * A singleton mime type to file extension guesser. - * - * A default guesser is provided. - * You can register custom guessers by calling the register() - * method on the singleton instance: - * - * $guesser = ExtensionGuesser::getInstance(); - * $guesser->register(new MyCustomExtensionGuesser()); - * - * The last registered guesser is preferred over previously registered ones. - */ -class ExtensionGuesser implements ExtensionGuesserInterface -{ - /** - * The singleton instance. - * - * @var ExtensionGuesser - */ - private static $instance = null; - - /** - * All registered ExtensionGuesserInterface instances. - * - * @var array - */ - protected $guessers = array(); - - /** - * Returns the singleton instance. - * - * @return self - */ - public static function getInstance() - { - if (null === self::$instance) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Registers all natively provided extension guessers. - */ - private function __construct() - { - $this->register(new MimeTypeExtensionGuesser()); - } - - /** - * Registers a new extension guesser. - * - * When guessing, this guesser is preferred over previously registered ones. - */ - public function register(ExtensionGuesserInterface $guesser) - { - array_unshift($this->guessers, $guesser); - } - - /** - * Tries to guess the extension. - * - * The mime type is passed to each registered mime type guesser in reverse order - * of their registration (last registered is queried first). Once a guesser - * returns a value that is not NULL, this method terminates and returns the - * value. - * - * @param string $mimeType The mime type - * - * @return string The guessed extension or NULL, if none could be guessed - */ - public function guess($mimeType) - { - foreach ($this->guessers as $guesser) { - if (null !== $extension = $guesser->guess($mimeType)) { - return $extension; - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php b/lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php deleted file mode 100644 index d19a0e537..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/MimeType/ExtensionGuesserInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * Guesses the file extension corresponding to a given mime type. - */ -interface ExtensionGuesserInterface -{ - /** - * Makes a best guess for a file extension, given a mime type. - * - * @param string $mimeType The mime type - * - * @return string The guessed extension or NULL, if none could be guessed - */ - public function guess($mimeType); -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php b/lib/silex/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php deleted file mode 100644 index c2ac6768c..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type with the binary "file" (only available on *nix). - * - * @author Bernhard Schussek - */ -class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface -{ - private $cmd; - - /** - * The $cmd pattern must contain a "%s" string that will be replaced - * with the file name to guess. - * - * The command output must start with the mime type of the file. - * - * @param string $cmd The command to run to get the mime type of a file - */ - public function __construct($cmd = 'file -b --mime %s 2>/dev/null') - { - $this->cmd = $cmd; - } - - /** - * Returns whether this guesser is supported on the current OS. - * - * @return bool - */ - public static function isSupported() - { - return '\\' !== DIRECTORY_SEPARATOR && function_exists('passthru') && function_exists('escapeshellarg'); - } - - /** - * {@inheritdoc} - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!self::isSupported()) { - return; - } - - ob_start(); - - // need to use --mime instead of -i. see #6641 - passthru(sprintf($this->cmd, escapeshellarg($path)), $return); - if ($return > 0) { - ob_end_clean(); - - return; - } - - $type = trim(ob_get_clean()); - - if (!preg_match('#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i', $type, $match)) { - // it's not a type, but an error message - return; - } - - return $match[1]; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php b/lib/silex/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php deleted file mode 100644 index 9b42835e4..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/MimeType/FileinfoMimeTypeGuesser.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type using the PECL extension FileInfo. - * - * @author Bernhard Schussek - */ -class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface -{ - private $magicFile; - - /** - * @param string $magicFile A magic file to use with the finfo instance - * - * @see http://www.php.net/manual/en/function.finfo-open.php - */ - public function __construct($magicFile = null) - { - $this->magicFile = $magicFile; - } - - /** - * Returns whether this guesser is supported on the current OS/PHP setup. - * - * @return bool - */ - public static function isSupported() - { - return function_exists('finfo_open'); - } - - /** - * {@inheritdoc} - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!self::isSupported()) { - return; - } - - if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) { - return; - } - - return $finfo->file($path); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php b/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php deleted file mode 100644 index 896c135a5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeExtensionGuesser.php +++ /dev/null @@ -1,807 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * Provides a best-guess mapping of mime type to file extension. - */ -class MimeTypeExtensionGuesser implements ExtensionGuesserInterface -{ - /** - * A map of mime types and their default extensions. - * - * This list has been placed under the public domain by the Apache HTTPD project. - * This list has been updated from upstream on 2013-04-23. - * - * @see http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types - */ - protected $defaultExtensions = array( - 'application/andrew-inset' => 'ez', - 'application/applixware' => 'aw', - 'application/atom+xml' => 'atom', - 'application/atomcat+xml' => 'atomcat', - 'application/atomsvc+xml' => 'atomsvc', - 'application/ccxml+xml' => 'ccxml', - 'application/cdmi-capability' => 'cdmia', - 'application/cdmi-container' => 'cdmic', - 'application/cdmi-domain' => 'cdmid', - 'application/cdmi-object' => 'cdmio', - 'application/cdmi-queue' => 'cdmiq', - 'application/cu-seeme' => 'cu', - 'application/davmount+xml' => 'davmount', - 'application/docbook+xml' => 'dbk', - 'application/dssc+der' => 'dssc', - 'application/dssc+xml' => 'xdssc', - 'application/ecmascript' => 'ecma', - 'application/emma+xml' => 'emma', - 'application/epub+zip' => 'epub', - 'application/exi' => 'exi', - 'application/font-tdpfr' => 'pfr', - 'application/gml+xml' => 'gml', - 'application/gpx+xml' => 'gpx', - 'application/gxf' => 'gxf', - 'application/hyperstudio' => 'stk', - 'application/inkml+xml' => 'ink', - 'application/ipfix' => 'ipfix', - 'application/java-archive' => 'jar', - 'application/java-serialized-object' => 'ser', - 'application/java-vm' => 'class', - 'application/javascript' => 'js', - 'application/json' => 'json', - 'application/jsonml+json' => 'jsonml', - 'application/lost+xml' => 'lostxml', - 'application/mac-binhex40' => 'hqx', - 'application/mac-compactpro' => 'cpt', - 'application/mads+xml' => 'mads', - 'application/marc' => 'mrc', - 'application/marcxml+xml' => 'mrcx', - 'application/mathematica' => 'ma', - 'application/mathml+xml' => 'mathml', - 'application/mbox' => 'mbox', - 'application/mediaservercontrol+xml' => 'mscml', - 'application/metalink+xml' => 'metalink', - 'application/metalink4+xml' => 'meta4', - 'application/mets+xml' => 'mets', - 'application/mods+xml' => 'mods', - 'application/mp21' => 'm21', - 'application/mp4' => 'mp4s', - 'application/msword' => 'doc', - 'application/mxf' => 'mxf', - 'application/octet-stream' => 'bin', - 'application/oda' => 'oda', - 'application/oebps-package+xml' => 'opf', - 'application/ogg' => 'ogx', - 'application/omdoc+xml' => 'omdoc', - 'application/onenote' => 'onetoc', - 'application/oxps' => 'oxps', - 'application/patch-ops-error+xml' => 'xer', - 'application/pdf' => 'pdf', - 'application/pgp-encrypted' => 'pgp', - 'application/pgp-signature' => 'asc', - 'application/pics-rules' => 'prf', - 'application/pkcs10' => 'p10', - 'application/pkcs7-mime' => 'p7m', - 'application/pkcs7-signature' => 'p7s', - 'application/pkcs8' => 'p8', - 'application/pkix-attr-cert' => 'ac', - 'application/pkix-cert' => 'cer', - 'application/pkix-crl' => 'crl', - 'application/pkix-pkipath' => 'pkipath', - 'application/pkixcmp' => 'pki', - 'application/pls+xml' => 'pls', - 'application/postscript' => 'ai', - 'application/prs.cww' => 'cww', - 'application/pskc+xml' => 'pskcxml', - 'application/rdf+xml' => 'rdf', - 'application/reginfo+xml' => 'rif', - 'application/relax-ng-compact-syntax' => 'rnc', - 'application/resource-lists+xml' => 'rl', - 'application/resource-lists-diff+xml' => 'rld', - 'application/rls-services+xml' => 'rs', - 'application/rpki-ghostbusters' => 'gbr', - 'application/rpki-manifest' => 'mft', - 'application/rpki-roa' => 'roa', - 'application/rsd+xml' => 'rsd', - 'application/rss+xml' => 'rss', - 'application/rtf' => 'rtf', - 'application/sbml+xml' => 'sbml', - 'application/scvp-cv-request' => 'scq', - 'application/scvp-cv-response' => 'scs', - 'application/scvp-vp-request' => 'spq', - 'application/scvp-vp-response' => 'spp', - 'application/sdp' => 'sdp', - 'application/set-payment-initiation' => 'setpay', - 'application/set-registration-initiation' => 'setreg', - 'application/shf+xml' => 'shf', - 'application/smil+xml' => 'smi', - 'application/sparql-query' => 'rq', - 'application/sparql-results+xml' => 'srx', - 'application/srgs' => 'gram', - 'application/srgs+xml' => 'grxml', - 'application/sru+xml' => 'sru', - 'application/ssdl+xml' => 'ssdl', - 'application/ssml+xml' => 'ssml', - 'application/tei+xml' => 'tei', - 'application/thraud+xml' => 'tfi', - 'application/timestamped-data' => 'tsd', - 'application/vnd.3gpp.pic-bw-large' => 'plb', - 'application/vnd.3gpp.pic-bw-small' => 'psb', - 'application/vnd.3gpp.pic-bw-var' => 'pvb', - 'application/vnd.3gpp2.tcap' => 'tcap', - 'application/vnd.3m.post-it-notes' => 'pwn', - 'application/vnd.accpac.simply.aso' => 'aso', - 'application/vnd.accpac.simply.imp' => 'imp', - 'application/vnd.acucobol' => 'acu', - 'application/vnd.acucorp' => 'atc', - 'application/vnd.adobe.air-application-installer-package+zip' => 'air', - 'application/vnd.adobe.formscentral.fcdt' => 'fcdt', - 'application/vnd.adobe.fxp' => 'fxp', - 'application/vnd.adobe.xdp+xml' => 'xdp', - 'application/vnd.adobe.xfdf' => 'xfdf', - 'application/vnd.ahead.space' => 'ahead', - 'application/vnd.airzip.filesecure.azf' => 'azf', - 'application/vnd.airzip.filesecure.azs' => 'azs', - 'application/vnd.amazon.ebook' => 'azw', - 'application/vnd.americandynamics.acc' => 'acc', - 'application/vnd.amiga.ami' => 'ami', - 'application/vnd.android.package-archive' => 'apk', - 'application/vnd.anser-web-certificate-issue-initiation' => 'cii', - 'application/vnd.anser-web-funds-transfer-initiation' => 'fti', - 'application/vnd.antix.game-component' => 'atx', - 'application/vnd.apple.installer+xml' => 'mpkg', - 'application/vnd.apple.mpegurl' => 'm3u8', - 'application/vnd.aristanetworks.swi' => 'swi', - 'application/vnd.astraea-software.iota' => 'iota', - 'application/vnd.audiograph' => 'aep', - 'application/vnd.blueice.multipass' => 'mpm', - 'application/vnd.bmi' => 'bmi', - 'application/vnd.businessobjects' => 'rep', - 'application/vnd.chemdraw+xml' => 'cdxml', - 'application/vnd.chipnuts.karaoke-mmd' => 'mmd', - 'application/vnd.cinderella' => 'cdy', - 'application/vnd.claymore' => 'cla', - 'application/vnd.cloanto.rp9' => 'rp9', - 'application/vnd.clonk.c4group' => 'c4g', - 'application/vnd.cluetrust.cartomobile-config' => 'c11amc', - 'application/vnd.cluetrust.cartomobile-config-pkg' => 'c11amz', - 'application/vnd.commonspace' => 'csp', - 'application/vnd.contact.cmsg' => 'cdbcmsg', - 'application/vnd.cosmocaller' => 'cmc', - 'application/vnd.crick.clicker' => 'clkx', - 'application/vnd.crick.clicker.keyboard' => 'clkk', - 'application/vnd.crick.clicker.palette' => 'clkp', - 'application/vnd.crick.clicker.template' => 'clkt', - 'application/vnd.crick.clicker.wordbank' => 'clkw', - 'application/vnd.criticaltools.wbs+xml' => 'wbs', - 'application/vnd.ctc-posml' => 'pml', - 'application/vnd.cups-ppd' => 'ppd', - 'application/vnd.curl.car' => 'car', - 'application/vnd.curl.pcurl' => 'pcurl', - 'application/vnd.dart' => 'dart', - 'application/vnd.data-vision.rdz' => 'rdz', - 'application/vnd.dece.data' => 'uvf', - 'application/vnd.dece.ttml+xml' => 'uvt', - 'application/vnd.dece.unspecified' => 'uvx', - 'application/vnd.dece.zip' => 'uvz', - 'application/vnd.denovo.fcselayout-link' => 'fe_launch', - 'application/vnd.dna' => 'dna', - 'application/vnd.dolby.mlp' => 'mlp', - 'application/vnd.dpgraph' => 'dpg', - 'application/vnd.dreamfactory' => 'dfac', - 'application/vnd.ds-keypoint' => 'kpxx', - 'application/vnd.dvb.ait' => 'ait', - 'application/vnd.dvb.service' => 'svc', - 'application/vnd.dynageo' => 'geo', - 'application/vnd.ecowin.chart' => 'mag', - 'application/vnd.enliven' => 'nml', - 'application/vnd.epson.esf' => 'esf', - 'application/vnd.epson.msf' => 'msf', - 'application/vnd.epson.quickanime' => 'qam', - 'application/vnd.epson.salt' => 'slt', - 'application/vnd.epson.ssf' => 'ssf', - 'application/vnd.eszigno3+xml' => 'es3', - 'application/vnd.ezpix-album' => 'ez2', - 'application/vnd.ezpix-package' => 'ez3', - 'application/vnd.fdf' => 'fdf', - 'application/vnd.fdsn.mseed' => 'mseed', - 'application/vnd.fdsn.seed' => 'seed', - 'application/vnd.flographit' => 'gph', - 'application/vnd.fluxtime.clip' => 'ftc', - 'application/vnd.framemaker' => 'fm', - 'application/vnd.frogans.fnc' => 'fnc', - 'application/vnd.frogans.ltf' => 'ltf', - 'application/vnd.fsc.weblaunch' => 'fsc', - 'application/vnd.fujitsu.oasys' => 'oas', - 'application/vnd.fujitsu.oasys2' => 'oa2', - 'application/vnd.fujitsu.oasys3' => 'oa3', - 'application/vnd.fujitsu.oasysgp' => 'fg5', - 'application/vnd.fujitsu.oasysprs' => 'bh2', - 'application/vnd.fujixerox.ddd' => 'ddd', - 'application/vnd.fujixerox.docuworks' => 'xdw', - 'application/vnd.fujixerox.docuworks.binder' => 'xbd', - 'application/vnd.fuzzysheet' => 'fzs', - 'application/vnd.genomatix.tuxedo' => 'txd', - 'application/vnd.geogebra.file' => 'ggb', - 'application/vnd.geogebra.tool' => 'ggt', - 'application/vnd.geometry-explorer' => 'gex', - 'application/vnd.geonext' => 'gxt', - 'application/vnd.geoplan' => 'g2w', - 'application/vnd.geospace' => 'g3w', - 'application/vnd.gmx' => 'gmx', - 'application/vnd.google-earth.kml+xml' => 'kml', - 'application/vnd.google-earth.kmz' => 'kmz', - 'application/vnd.grafeq' => 'gqf', - 'application/vnd.groove-account' => 'gac', - 'application/vnd.groove-help' => 'ghf', - 'application/vnd.groove-identity-message' => 'gim', - 'application/vnd.groove-injector' => 'grv', - 'application/vnd.groove-tool-message' => 'gtm', - 'application/vnd.groove-tool-template' => 'tpl', - 'application/vnd.groove-vcard' => 'vcg', - 'application/vnd.hal+xml' => 'hal', - 'application/vnd.handheld-entertainment+xml' => 'zmm', - 'application/vnd.hbci' => 'hbci', - 'application/vnd.hhe.lesson-player' => 'les', - 'application/vnd.hp-hpgl' => 'hpgl', - 'application/vnd.hp-hpid' => 'hpid', - 'application/vnd.hp-hps' => 'hps', - 'application/vnd.hp-jlyt' => 'jlt', - 'application/vnd.hp-pcl' => 'pcl', - 'application/vnd.hp-pclxl' => 'pclxl', - 'application/vnd.hydrostatix.sof-data' => 'sfd-hdstx', - 'application/vnd.ibm.minipay' => 'mpy', - 'application/vnd.ibm.modcap' => 'afp', - 'application/vnd.ibm.rights-management' => 'irm', - 'application/vnd.ibm.secure-container' => 'sc', - 'application/vnd.iccprofile' => 'icc', - 'application/vnd.igloader' => 'igl', - 'application/vnd.immervision-ivp' => 'ivp', - 'application/vnd.immervision-ivu' => 'ivu', - 'application/vnd.insors.igm' => 'igm', - 'application/vnd.intercon.formnet' => 'xpw', - 'application/vnd.intergeo' => 'i2g', - 'application/vnd.intu.qbo' => 'qbo', - 'application/vnd.intu.qfx' => 'qfx', - 'application/vnd.ipunplugged.rcprofile' => 'rcprofile', - 'application/vnd.irepository.package+xml' => 'irp', - 'application/vnd.is-xpr' => 'xpr', - 'application/vnd.isac.fcs' => 'fcs', - 'application/vnd.jam' => 'jam', - 'application/vnd.jcp.javame.midlet-rms' => 'rms', - 'application/vnd.jisp' => 'jisp', - 'application/vnd.joost.joda-archive' => 'joda', - 'application/vnd.kahootz' => 'ktz', - 'application/vnd.kde.karbon' => 'karbon', - 'application/vnd.kde.kchart' => 'chrt', - 'application/vnd.kde.kformula' => 'kfo', - 'application/vnd.kde.kivio' => 'flw', - 'application/vnd.kde.kontour' => 'kon', - 'application/vnd.kde.kpresenter' => 'kpr', - 'application/vnd.kde.kspread' => 'ksp', - 'application/vnd.kde.kword' => 'kwd', - 'application/vnd.kenameaapp' => 'htke', - 'application/vnd.kidspiration' => 'kia', - 'application/vnd.kinar' => 'kne', - 'application/vnd.koan' => 'skp', - 'application/vnd.kodak-descriptor' => 'sse', - 'application/vnd.las.las+xml' => 'lasxml', - 'application/vnd.llamagraphics.life-balance.desktop' => 'lbd', - 'application/vnd.llamagraphics.life-balance.exchange+xml' => 'lbe', - 'application/vnd.lotus-1-2-3' => '123', - 'application/vnd.lotus-approach' => 'apr', - 'application/vnd.lotus-freelance' => 'pre', - 'application/vnd.lotus-notes' => 'nsf', - 'application/vnd.lotus-organizer' => 'org', - 'application/vnd.lotus-screencam' => 'scm', - 'application/vnd.lotus-wordpro' => 'lwp', - 'application/vnd.macports.portpkg' => 'portpkg', - 'application/vnd.mcd' => 'mcd', - 'application/vnd.medcalcdata' => 'mc1', - 'application/vnd.mediastation.cdkey' => 'cdkey', - 'application/vnd.mfer' => 'mwf', - 'application/vnd.mfmp' => 'mfm', - 'application/vnd.micrografx.flo' => 'flo', - 'application/vnd.micrografx.igx' => 'igx', - 'application/vnd.mif' => 'mif', - 'application/vnd.mobius.daf' => 'daf', - 'application/vnd.mobius.dis' => 'dis', - 'application/vnd.mobius.mbk' => 'mbk', - 'application/vnd.mobius.mqy' => 'mqy', - 'application/vnd.mobius.msl' => 'msl', - 'application/vnd.mobius.plc' => 'plc', - 'application/vnd.mobius.txf' => 'txf', - 'application/vnd.mophun.application' => 'mpn', - 'application/vnd.mophun.certificate' => 'mpc', - 'application/vnd.mozilla.xul+xml' => 'xul', - 'application/vnd.ms-artgalry' => 'cil', - 'application/vnd.ms-cab-compressed' => 'cab', - 'application/vnd.ms-excel' => 'xls', - 'application/vnd.ms-excel.addin.macroenabled.12' => 'xlam', - 'application/vnd.ms-excel.sheet.binary.macroenabled.12' => 'xlsb', - 'application/vnd.ms-excel.sheet.macroenabled.12' => 'xlsm', - 'application/vnd.ms-excel.template.macroenabled.12' => 'xltm', - 'application/vnd.ms-fontobject' => 'eot', - 'application/vnd.ms-htmlhelp' => 'chm', - 'application/vnd.ms-ims' => 'ims', - 'application/vnd.ms-lrm' => 'lrm', - 'application/vnd.ms-officetheme' => 'thmx', - 'application/vnd.ms-pki.seccat' => 'cat', - 'application/vnd.ms-pki.stl' => 'stl', - 'application/vnd.ms-powerpoint' => 'ppt', - 'application/vnd.ms-powerpoint.addin.macroenabled.12' => 'ppam', - 'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 'pptm', - 'application/vnd.ms-powerpoint.slide.macroenabled.12' => 'sldm', - 'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 'ppsm', - 'application/vnd.ms-powerpoint.template.macroenabled.12' => 'potm', - 'application/vnd.ms-project' => 'mpp', - 'application/vnd.ms-word.document.macroenabled.12' => 'docm', - 'application/vnd.ms-word.template.macroenabled.12' => 'dotm', - 'application/vnd.ms-works' => 'wps', - 'application/vnd.ms-wpl' => 'wpl', - 'application/vnd.ms-xpsdocument' => 'xps', - 'application/vnd.mseq' => 'mseq', - 'application/vnd.musician' => 'mus', - 'application/vnd.muvee.style' => 'msty', - 'application/vnd.mynfc' => 'taglet', - 'application/vnd.neurolanguage.nlu' => 'nlu', - 'application/vnd.nitf' => 'ntf', - 'application/vnd.noblenet-directory' => 'nnd', - 'application/vnd.noblenet-sealer' => 'nns', - 'application/vnd.noblenet-web' => 'nnw', - 'application/vnd.nokia.n-gage.data' => 'ngdat', - 'application/vnd.nokia.n-gage.symbian.install' => 'n-gage', - 'application/vnd.nokia.radio-preset' => 'rpst', - 'application/vnd.nokia.radio-presets' => 'rpss', - 'application/vnd.novadigm.edm' => 'edm', - 'application/vnd.novadigm.edx' => 'edx', - 'application/vnd.novadigm.ext' => 'ext', - 'application/vnd.oasis.opendocument.chart' => 'odc', - 'application/vnd.oasis.opendocument.chart-template' => 'otc', - 'application/vnd.oasis.opendocument.database' => 'odb', - 'application/vnd.oasis.opendocument.formula' => 'odf', - 'application/vnd.oasis.opendocument.formula-template' => 'odft', - 'application/vnd.oasis.opendocument.graphics' => 'odg', - 'application/vnd.oasis.opendocument.graphics-template' => 'otg', - 'application/vnd.oasis.opendocument.image' => 'odi', - 'application/vnd.oasis.opendocument.image-template' => 'oti', - 'application/vnd.oasis.opendocument.presentation' => 'odp', - 'application/vnd.oasis.opendocument.presentation-template' => 'otp', - 'application/vnd.oasis.opendocument.spreadsheet' => 'ods', - 'application/vnd.oasis.opendocument.spreadsheet-template' => 'ots', - 'application/vnd.oasis.opendocument.text' => 'odt', - 'application/vnd.oasis.opendocument.text-master' => 'odm', - 'application/vnd.oasis.opendocument.text-template' => 'ott', - 'application/vnd.oasis.opendocument.text-web' => 'oth', - 'application/vnd.olpc-sugar' => 'xo', - 'application/vnd.oma.dd2+xml' => 'dd2', - 'application/vnd.openofficeorg.extension' => 'oxt', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', - 'application/vnd.openxmlformats-officedocument.presentationml.slide' => 'sldx', - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'ppsx', - 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'potx', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'xltx', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'dotx', - 'application/vnd.osgeo.mapguide.package' => 'mgp', - 'application/vnd.osgi.dp' => 'dp', - 'application/vnd.osgi.subsystem' => 'esa', - 'application/vnd.palm' => 'pdb', - 'application/vnd.pawaafile' => 'paw', - 'application/vnd.pg.format' => 'str', - 'application/vnd.pg.osasli' => 'ei6', - 'application/vnd.picsel' => 'efif', - 'application/vnd.pmi.widget' => 'wg', - 'application/vnd.pocketlearn' => 'plf', - 'application/vnd.powerbuilder6' => 'pbd', - 'application/vnd.previewsystems.box' => 'box', - 'application/vnd.proteus.magazine' => 'mgz', - 'application/vnd.publishare-delta-tree' => 'qps', - 'application/vnd.pvi.ptid1' => 'ptid', - 'application/vnd.quark.quarkxpress' => 'qxd', - 'application/vnd.realvnc.bed' => 'bed', - 'application/vnd.recordare.musicxml' => 'mxl', - 'application/vnd.recordare.musicxml+xml' => 'musicxml', - 'application/vnd.rig.cryptonote' => 'cryptonote', - 'application/vnd.rim.cod' => 'cod', - 'application/vnd.rn-realmedia' => 'rm', - 'application/vnd.rn-realmedia-vbr' => 'rmvb', - 'application/vnd.route66.link66+xml' => 'link66', - 'application/vnd.sailingtracker.track' => 'st', - 'application/vnd.seemail' => 'see', - 'application/vnd.sema' => 'sema', - 'application/vnd.semd' => 'semd', - 'application/vnd.semf' => 'semf', - 'application/vnd.shana.informed.formdata' => 'ifm', - 'application/vnd.shana.informed.formtemplate' => 'itp', - 'application/vnd.shana.informed.interchange' => 'iif', - 'application/vnd.shana.informed.package' => 'ipk', - 'application/vnd.simtech-mindmapper' => 'twd', - 'application/vnd.smaf' => 'mmf', - 'application/vnd.smart.teacher' => 'teacher', - 'application/vnd.solent.sdkm+xml' => 'sdkm', - 'application/vnd.spotfire.dxp' => 'dxp', - 'application/vnd.spotfire.sfs' => 'sfs', - 'application/vnd.stardivision.calc' => 'sdc', - 'application/vnd.stardivision.draw' => 'sda', - 'application/vnd.stardivision.impress' => 'sdd', - 'application/vnd.stardivision.math' => 'smf', - 'application/vnd.stardivision.writer' => 'sdw', - 'application/vnd.stardivision.writer-global' => 'sgl', - 'application/vnd.stepmania.package' => 'smzip', - 'application/vnd.stepmania.stepchart' => 'sm', - 'application/vnd.sun.xml.calc' => 'sxc', - 'application/vnd.sun.xml.calc.template' => 'stc', - 'application/vnd.sun.xml.draw' => 'sxd', - 'application/vnd.sun.xml.draw.template' => 'std', - 'application/vnd.sun.xml.impress' => 'sxi', - 'application/vnd.sun.xml.impress.template' => 'sti', - 'application/vnd.sun.xml.math' => 'sxm', - 'application/vnd.sun.xml.writer' => 'sxw', - 'application/vnd.sun.xml.writer.global' => 'sxg', - 'application/vnd.sun.xml.writer.template' => 'stw', - 'application/vnd.sus-calendar' => 'sus', - 'application/vnd.svd' => 'svd', - 'application/vnd.symbian.install' => 'sis', - 'application/vnd.syncml+xml' => 'xsm', - 'application/vnd.syncml.dm+wbxml' => 'bdm', - 'application/vnd.syncml.dm+xml' => 'xdm', - 'application/vnd.tao.intent-module-archive' => 'tao', - 'application/vnd.tcpdump.pcap' => 'pcap', - 'application/vnd.tmobile-livetv' => 'tmo', - 'application/vnd.trid.tpt' => 'tpt', - 'application/vnd.triscape.mxs' => 'mxs', - 'application/vnd.trueapp' => 'tra', - 'application/vnd.ufdl' => 'ufd', - 'application/vnd.uiq.theme' => 'utz', - 'application/vnd.umajin' => 'umj', - 'application/vnd.unity' => 'unityweb', - 'application/vnd.uoml+xml' => 'uoml', - 'application/vnd.vcx' => 'vcx', - 'application/vnd.visio' => 'vsd', - 'application/vnd.visionary' => 'vis', - 'application/vnd.vsf' => 'vsf', - 'application/vnd.wap.wbxml' => 'wbxml', - 'application/vnd.wap.wmlc' => 'wmlc', - 'application/vnd.wap.wmlscriptc' => 'wmlsc', - 'application/vnd.webturbo' => 'wtb', - 'application/vnd.wolfram.player' => 'nbp', - 'application/vnd.wordperfect' => 'wpd', - 'application/vnd.wqd' => 'wqd', - 'application/vnd.wt.stf' => 'stf', - 'application/vnd.xara' => 'xar', - 'application/vnd.xfdl' => 'xfdl', - 'application/vnd.yamaha.hv-dic' => 'hvd', - 'application/vnd.yamaha.hv-script' => 'hvs', - 'application/vnd.yamaha.hv-voice' => 'hvp', - 'application/vnd.yamaha.openscoreformat' => 'osf', - 'application/vnd.yamaha.openscoreformat.osfpvg+xml' => 'osfpvg', - 'application/vnd.yamaha.smaf-audio' => 'saf', - 'application/vnd.yamaha.smaf-phrase' => 'spf', - 'application/vnd.yellowriver-custom-menu' => 'cmp', - 'application/vnd.zul' => 'zir', - 'application/vnd.zzazz.deck+xml' => 'zaz', - 'application/voicexml+xml' => 'vxml', - 'application/widget' => 'wgt', - 'application/winhlp' => 'hlp', - 'application/wsdl+xml' => 'wsdl', - 'application/wspolicy+xml' => 'wspolicy', - 'application/x-7z-compressed' => '7z', - 'application/x-abiword' => 'abw', - 'application/x-ace-compressed' => 'ace', - 'application/x-apple-diskimage' => 'dmg', - 'application/x-authorware-bin' => 'aab', - 'application/x-authorware-map' => 'aam', - 'application/x-authorware-seg' => 'aas', - 'application/x-bcpio' => 'bcpio', - 'application/x-bittorrent' => 'torrent', - 'application/x-blorb' => 'blb', - 'application/x-bzip' => 'bz', - 'application/x-bzip2' => 'bz2', - 'application/x-cbr' => 'cbr', - 'application/x-cdlink' => 'vcd', - 'application/x-cfs-compressed' => 'cfs', - 'application/x-chat' => 'chat', - 'application/x-chess-pgn' => 'pgn', - 'application/x-conference' => 'nsc', - 'application/x-cpio' => 'cpio', - 'application/x-csh' => 'csh', - 'application/x-debian-package' => 'deb', - 'application/x-dgc-compressed' => 'dgc', - 'application/x-director' => 'dir', - 'application/x-doom' => 'wad', - 'application/x-dtbncx+xml' => 'ncx', - 'application/x-dtbook+xml' => 'dtb', - 'application/x-dtbresource+xml' => 'res', - 'application/x-dvi' => 'dvi', - 'application/x-envoy' => 'evy', - 'application/x-eva' => 'eva', - 'application/x-font-bdf' => 'bdf', - 'application/x-font-ghostscript' => 'gsf', - 'application/x-font-linux-psf' => 'psf', - 'application/x-font-otf' => 'otf', - 'application/x-font-pcf' => 'pcf', - 'application/x-font-snf' => 'snf', - 'application/x-font-ttf' => 'ttf', - 'application/x-font-type1' => 'pfa', - 'application/x-font-woff' => 'woff', - 'application/x-freearc' => 'arc', - 'application/x-futuresplash' => 'spl', - 'application/x-gca-compressed' => 'gca', - 'application/x-glulx' => 'ulx', - 'application/x-gnumeric' => 'gnumeric', - 'application/x-gramps-xml' => 'gramps', - 'application/x-gtar' => 'gtar', - 'application/x-hdf' => 'hdf', - 'application/x-install-instructions' => 'install', - 'application/x-iso9660-image' => 'iso', - 'application/x-java-jnlp-file' => 'jnlp', - 'application/x-latex' => 'latex', - 'application/x-lzh-compressed' => 'lzh', - 'application/x-mie' => 'mie', - 'application/x-mobipocket-ebook' => 'prc', - 'application/x-ms-application' => 'application', - 'application/x-ms-shortcut' => 'lnk', - 'application/x-ms-wmd' => 'wmd', - 'application/x-ms-wmz' => 'wmz', - 'application/x-ms-xbap' => 'xbap', - 'application/x-msaccess' => 'mdb', - 'application/x-msbinder' => 'obd', - 'application/x-mscardfile' => 'crd', - 'application/x-msclip' => 'clp', - 'application/x-msdownload' => 'exe', - 'application/x-msmediaview' => 'mvb', - 'application/x-msmetafile' => 'wmf', - 'application/x-msmoney' => 'mny', - 'application/x-mspublisher' => 'pub', - 'application/x-msschedule' => 'scd', - 'application/x-msterminal' => 'trm', - 'application/x-mswrite' => 'wri', - 'application/x-netcdf' => 'nc', - 'application/x-nzb' => 'nzb', - 'application/x-pkcs12' => 'p12', - 'application/x-pkcs7-certificates' => 'p7b', - 'application/x-pkcs7-certreqresp' => 'p7r', - 'application/x-rar-compressed' => 'rar', - 'application/x-rar' => 'rar', - 'application/x-research-info-systems' => 'ris', - 'application/x-sh' => 'sh', - 'application/x-shar' => 'shar', - 'application/x-shockwave-flash' => 'swf', - 'application/x-silverlight-app' => 'xap', - 'application/x-sql' => 'sql', - 'application/x-stuffit' => 'sit', - 'application/x-stuffitx' => 'sitx', - 'application/x-subrip' => 'srt', - 'application/x-sv4cpio' => 'sv4cpio', - 'application/x-sv4crc' => 'sv4crc', - 'application/x-t3vm-image' => 't3', - 'application/x-tads' => 'gam', - 'application/x-tar' => 'tar', - 'application/x-tcl' => 'tcl', - 'application/x-tex' => 'tex', - 'application/x-tex-tfm' => 'tfm', - 'application/x-texinfo' => 'texinfo', - 'application/x-tgif' => 'obj', - 'application/x-ustar' => 'ustar', - 'application/x-wais-source' => 'src', - 'application/x-x509-ca-cert' => 'der', - 'application/x-xfig' => 'fig', - 'application/x-xliff+xml' => 'xlf', - 'application/x-xpinstall' => 'xpi', - 'application/x-xz' => 'xz', - 'application/x-zmachine' => 'z1', - 'application/xaml+xml' => 'xaml', - 'application/xcap-diff+xml' => 'xdf', - 'application/xenc+xml' => 'xenc', - 'application/xhtml+xml' => 'xhtml', - 'application/xml' => 'xml', - 'application/xml-dtd' => 'dtd', - 'application/xop+xml' => 'xop', - 'application/xproc+xml' => 'xpl', - 'application/xslt+xml' => 'xslt', - 'application/xspf+xml' => 'xspf', - 'application/xv+xml' => 'mxml', - 'application/yang' => 'yang', - 'application/yin+xml' => 'yin', - 'application/zip' => 'zip', - 'audio/adpcm' => 'adp', - 'audio/basic' => 'au', - 'audio/midi' => 'mid', - 'audio/mp4' => 'mp4a', - 'audio/mpeg' => 'mpga', - 'audio/ogg' => 'oga', - 'audio/s3m' => 's3m', - 'audio/silk' => 'sil', - 'audio/vnd.dece.audio' => 'uva', - 'audio/vnd.digital-winds' => 'eol', - 'audio/vnd.dra' => 'dra', - 'audio/vnd.dts' => 'dts', - 'audio/vnd.dts.hd' => 'dtshd', - 'audio/vnd.lucent.voice' => 'lvp', - 'audio/vnd.ms-playready.media.pya' => 'pya', - 'audio/vnd.nuera.ecelp4800' => 'ecelp4800', - 'audio/vnd.nuera.ecelp7470' => 'ecelp7470', - 'audio/vnd.nuera.ecelp9600' => 'ecelp9600', - 'audio/vnd.rip' => 'rip', - 'audio/webm' => 'weba', - 'audio/x-aac' => 'aac', - 'audio/x-aiff' => 'aif', - 'audio/x-caf' => 'caf', - 'audio/x-flac' => 'flac', - 'audio/x-matroska' => 'mka', - 'audio/x-mpegurl' => 'm3u', - 'audio/x-ms-wax' => 'wax', - 'audio/x-ms-wma' => 'wma', - 'audio/x-pn-realaudio' => 'ram', - 'audio/x-pn-realaudio-plugin' => 'rmp', - 'audio/x-wav' => 'wav', - 'audio/xm' => 'xm', - 'chemical/x-cdx' => 'cdx', - 'chemical/x-cif' => 'cif', - 'chemical/x-cmdf' => 'cmdf', - 'chemical/x-cml' => 'cml', - 'chemical/x-csml' => 'csml', - 'chemical/x-xyz' => 'xyz', - 'image/bmp' => 'bmp', - 'image/x-ms-bmp' => 'bmp', - 'image/cgm' => 'cgm', - 'image/g3fax' => 'g3', - 'image/gif' => 'gif', - 'image/ief' => 'ief', - 'image/jpeg' => 'jpeg', - 'image/pjpeg' => 'jpeg', - 'image/ktx' => 'ktx', - 'image/png' => 'png', - 'image/prs.btif' => 'btif', - 'image/sgi' => 'sgi', - 'image/svg+xml' => 'svg', - 'image/tiff' => 'tiff', - 'image/vnd.adobe.photoshop' => 'psd', - 'image/vnd.dece.graphic' => 'uvi', - 'image/vnd.dvb.subtitle' => 'sub', - 'image/vnd.djvu' => 'djvu', - 'image/vnd.dwg' => 'dwg', - 'image/vnd.dxf' => 'dxf', - 'image/vnd.fastbidsheet' => 'fbs', - 'image/vnd.fpx' => 'fpx', - 'image/vnd.fst' => 'fst', - 'image/vnd.fujixerox.edmics-mmr' => 'mmr', - 'image/vnd.fujixerox.edmics-rlc' => 'rlc', - 'image/vnd.ms-modi' => 'mdi', - 'image/vnd.ms-photo' => 'wdp', - 'image/vnd.net-fpx' => 'npx', - 'image/vnd.wap.wbmp' => 'wbmp', - 'image/vnd.xiff' => 'xif', - 'image/webp' => 'webp', - 'image/x-3ds' => '3ds', - 'image/x-cmu-raster' => 'ras', - 'image/x-cmx' => 'cmx', - 'image/x-freehand' => 'fh', - 'image/x-icon' => 'ico', - 'image/x-mrsid-image' => 'sid', - 'image/x-pcx' => 'pcx', - 'image/x-pict' => 'pic', - 'image/x-portable-anymap' => 'pnm', - 'image/x-portable-bitmap' => 'pbm', - 'image/x-portable-graymap' => 'pgm', - 'image/x-portable-pixmap' => 'ppm', - 'image/x-rgb' => 'rgb', - 'image/x-tga' => 'tga', - 'image/x-xbitmap' => 'xbm', - 'image/x-xpixmap' => 'xpm', - 'image/x-xwindowdump' => 'xwd', - 'message/rfc822' => 'eml', - 'model/iges' => 'igs', - 'model/mesh' => 'msh', - 'model/vnd.collada+xml' => 'dae', - 'model/vnd.dwf' => 'dwf', - 'model/vnd.gdl' => 'gdl', - 'model/vnd.gtw' => 'gtw', - 'model/vnd.mts' => 'mts', - 'model/vnd.vtu' => 'vtu', - 'model/vrml' => 'wrl', - 'model/x3d+binary' => 'x3db', - 'model/x3d+vrml' => 'x3dv', - 'model/x3d+xml' => 'x3d', - 'text/cache-manifest' => 'appcache', - 'text/calendar' => 'ics', - 'text/css' => 'css', - 'text/csv' => 'csv', - 'text/html' => 'html', - 'text/n3' => 'n3', - 'text/plain' => 'txt', - 'text/prs.lines.tag' => 'dsc', - 'text/richtext' => 'rtx', - 'text/rtf' => 'rtf', - 'text/sgml' => 'sgml', - 'text/tab-separated-values' => 'tsv', - 'text/troff' => 't', - 'text/turtle' => 'ttl', - 'text/uri-list' => 'uri', - 'text/vcard' => 'vcard', - 'text/vnd.curl' => 'curl', - 'text/vnd.curl.dcurl' => 'dcurl', - 'text/vnd.curl.scurl' => 'scurl', - 'text/vnd.curl.mcurl' => 'mcurl', - 'text/vnd.dvb.subtitle' => 'sub', - 'text/vnd.fly' => 'fly', - 'text/vnd.fmi.flexstor' => 'flx', - 'text/vnd.graphviz' => 'gv', - 'text/vnd.in3d.3dml' => '3dml', - 'text/vnd.in3d.spot' => 'spot', - 'text/vnd.sun.j2me.app-descriptor' => 'jad', - 'text/vnd.wap.wml' => 'wml', - 'text/vnd.wap.wmlscript' => 'wmls', - 'text/vtt' => 'vtt', - 'text/x-asm' => 's', - 'text/x-c' => 'c', - 'text/x-fortran' => 'f', - 'text/x-pascal' => 'p', - 'text/x-java-source' => 'java', - 'text/x-opml' => 'opml', - 'text/x-nfo' => 'nfo', - 'text/x-setext' => 'etx', - 'text/x-sfv' => 'sfv', - 'text/x-uuencode' => 'uu', - 'text/x-vcalendar' => 'vcs', - 'text/x-vcard' => 'vcf', - 'video/3gpp' => '3gp', - 'video/3gpp2' => '3g2', - 'video/h261' => 'h261', - 'video/h263' => 'h263', - 'video/h264' => 'h264', - 'video/jpeg' => 'jpgv', - 'video/jpm' => 'jpm', - 'video/mj2' => 'mj2', - 'video/mp4' => 'mp4', - 'video/mpeg' => 'mpeg', - 'video/ogg' => 'ogv', - 'video/quicktime' => 'qt', - 'video/vnd.dece.hd' => 'uvh', - 'video/vnd.dece.mobile' => 'uvm', - 'video/vnd.dece.pd' => 'uvp', - 'video/vnd.dece.sd' => 'uvs', - 'video/vnd.dece.video' => 'uvv', - 'video/vnd.dvb.file' => 'dvb', - 'video/vnd.fvt' => 'fvt', - 'video/vnd.mpegurl' => 'mxu', - 'video/vnd.ms-playready.media.pyv' => 'pyv', - 'video/vnd.uvvu.mp4' => 'uvu', - 'video/vnd.vivo' => 'viv', - 'video/webm' => 'webm', - 'video/x-f4v' => 'f4v', - 'video/x-fli' => 'fli', - 'video/x-flv' => 'flv', - 'video/x-m4v' => 'm4v', - 'video/x-matroska' => 'mkv', - 'video/x-mng' => 'mng', - 'video/x-ms-asf' => 'asf', - 'video/x-ms-vob' => 'vob', - 'video/x-ms-wm' => 'wm', - 'video/x-ms-wmv' => 'wmv', - 'video/x-ms-wmx' => 'wmx', - 'video/x-ms-wvx' => 'wvx', - 'video/x-msvideo' => 'avi', - 'video/x-sgi-movie' => 'movie', - 'video/x-smv' => 'smv', - 'x-conference/x-cooltalk' => 'ice', - ); - - /** - * {@inheritdoc} - */ - public function guess($mimeType) - { - return isset($this->defaultExtensions[$mimeType]) ? $this->defaultExtensions[$mimeType] : null; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php b/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php deleted file mode 100644 index e3ef45ef6..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * A singleton mime type guesser. - * - * By default, all mime type guessers provided by the framework are installed - * (if available on the current OS/PHP setup). - * - * You can register custom guessers by calling the register() method on the - * singleton instance. Custom guessers are always called before any default ones. - * - * $guesser = MimeTypeGuesser::getInstance(); - * $guesser->register(new MyCustomMimeTypeGuesser()); - * - * If you want to change the order of the default guessers, just re-register your - * preferred one as a custom one. The last registered guesser is preferred over - * previously registered ones. - * - * Re-registering a built-in guesser also allows you to configure it: - * - * $guesser = MimeTypeGuesser::getInstance(); - * $guesser->register(new FileinfoMimeTypeGuesser('/path/to/magic/file')); - * - * @author Bernhard Schussek - */ -class MimeTypeGuesser implements MimeTypeGuesserInterface -{ - /** - * The singleton instance. - * - * @var MimeTypeGuesser - */ - private static $instance = null; - - /** - * All registered MimeTypeGuesserInterface instances. - * - * @var array - */ - protected $guessers = array(); - - /** - * Returns the singleton instance. - * - * @return self - */ - public static function getInstance() - { - if (null === self::$instance) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Resets the singleton instance. - */ - public static function reset() - { - self::$instance = null; - } - - /** - * Registers all natively provided mime type guessers. - */ - private function __construct() - { - if (FileBinaryMimeTypeGuesser::isSupported()) { - $this->register(new FileBinaryMimeTypeGuesser()); - } - - if (FileinfoMimeTypeGuesser::isSupported()) { - $this->register(new FileinfoMimeTypeGuesser()); - } - } - - /** - * Registers a new mime type guesser. - * - * When guessing, this guesser is preferred over previously registered ones. - */ - public function register(MimeTypeGuesserInterface $guesser) - { - array_unshift($this->guessers, $guesser); - } - - /** - * Tries to guess the mime type of the given file. - * - * The file is passed to each registered mime type guesser in reverse order - * of their registration (last registered is queried first). Once a guesser - * returns a value that is not NULL, this method terminates and returns the - * value. - * - * @param string $path The path to the file - * - * @return string The mime type or NULL, if none could be guessed - * - * @throws \LogicException - * @throws FileNotFoundException - * @throws AccessDeniedException - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!$this->guessers) { - $msg = 'Unable to guess the mime type as no guessers are available'; - if (!FileinfoMimeTypeGuesser::isSupported()) { - $msg .= ' (Did you enable the php_fileinfo extension?)'; - } - throw new \LogicException($msg); - } - - foreach ($this->guessers as $guesser) { - if (null !== $mimeType = $guesser->guess($path)) { - return $mimeType; - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php b/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php deleted file mode 100644 index f8c3ad228..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesserInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type of a file. - * - * @author Bernhard Schussek - */ -interface MimeTypeGuesserInterface -{ - /** - * Guesses the mime type of the file with the given path. - * - * @param string $path The path to the file - * - * @return string The mime type or NULL, if none could be guessed - * - * @throws FileNotFoundException If the file does not exist - * @throws AccessDeniedException If the file could not be read - */ - public function guess($path); -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/Stream.php b/lib/silex/vendor/symfony/http-foundation/File/Stream.php deleted file mode 100644 index 69ae74c11..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/Stream.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File; - -/** - * A PHP stream of unknown size. - * - * @author Nicolas Grekas - */ -class Stream extends File -{ - /** - * {@inheritdoc} - */ - public function getSize() - { - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/File/UploadedFile.php b/lib/silex/vendor/symfony/http-foundation/File/UploadedFile.php deleted file mode 100644 index 082d8d534..000000000 --- a/lib/silex/vendor/symfony/http-foundation/File/UploadedFile.php +++ /dev/null @@ -1,266 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File; - -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; - -/** - * A file uploaded through a form. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - * @author Fabien Potencier - */ -class UploadedFile extends File -{ - private $test = false; - private $originalName; - private $mimeType; - private $size; - private $error; - - /** - * Accepts the information of the uploaded file as provided by the PHP global $_FILES. - * - * The file object is only created when the uploaded file is valid (i.e. when the - * isValid() method returns true). Otherwise the only methods that could be called - * on an UploadedFile instance are: - * - * * getClientOriginalName, - * * getClientMimeType, - * * isValid, - * * getError. - * - * Calling any other method on an non-valid instance will cause an unpredictable result. - * - * @param string $path The full temporary path to the file - * @param string $originalName The original file name of the uploaded file - * @param string|null $mimeType The type of the file as provided by PHP; null defaults to application/octet-stream - * @param int|null $size The file size provided by the uploader - * @param int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK - * @param bool $test Whether the test mode is active - * Local files are used in test mode hence the code should not enforce HTTP uploads - * - * @throws FileException If file_uploads is disabled - * @throws FileNotFoundException If the file does not exist - */ - public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false) - { - $this->originalName = $this->getName($originalName); - $this->mimeType = $mimeType ?: 'application/octet-stream'; - $this->size = $size; - $this->error = $error ?: UPLOAD_ERR_OK; - $this->test = (bool) $test; - - parent::__construct($path, UPLOAD_ERR_OK === $this->error); - } - - /** - * Returns the original file name. - * - * It is extracted from the request from which the file has been uploaded. - * Then it should not be considered as a safe value. - * - * @return string|null The original name - */ - public function getClientOriginalName() - { - return $this->originalName; - } - - /** - * Returns the original file extension. - * - * It is extracted from the original file name that was uploaded. - * Then it 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. - * - * The client mime type is extracted from the request from which the file - * was uploaded, so it should not be considered as a safe value. - * - * For a trusted mime type, use getMimeType() instead (which guesses the mime - * type based on the file content). - * - * @return string|null The mime type - * - * @see getMimeType() - */ - public function getClientMimeType() - { - return $this->mimeType; - } - - /** - * Returns the extension based on the client mime type. - * - * If the mime type is unknown, returns null. - * - * This method uses the mime type as guessed by getClientMimeType() - * to guess the file extension. As such, the extension returned - * by this method cannot be trusted. - * - * For a trusted extension, use guessExtension() instead (which guesses - * the extension based on the guessed mime type for the file). - * - * @return string|null The guessed extension or null if it cannot be guessed - * - * @see guessExtension() - * @see getClientMimeType() - */ - public function guessClientExtension() - { - $type = $this->getClientMimeType(); - $guesser = ExtensionGuesser::getInstance(); - - return $guesser->guess($type); - } - - /** - * Returns the file size. - * - * It is extracted from the request from which the file has been uploaded. - * Then it should not be considered as a safe value. - * - * @return int|null The file size - */ - public function getClientSize() - { - return $this->size; - } - - /** - * Returns the upload error. - * - * If the upload was successful, the constant UPLOAD_ERR_OK is returned. - * Otherwise one of the other UPLOAD_ERR_XXX constants is returned. - * - * @return int The upload error - */ - public function getError() - { - return $this->error; - } - - /** - * Returns whether the file was uploaded successfully. - * - * @return bool True if the file has been uploaded with HTTP and no error occurred - */ - public function isValid() - { - $isOk = UPLOAD_ERR_OK === $this->error; - - return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); - } - - /** - * Moves the file to a new location. - * - * @param string $directory The destination folder - * @param string $name The new file name - * - * @return File A File object representing the new file - * - * @throws FileException if, for any reason, the file could not have been moved - */ - public function move($directory, $name = null) - { - if ($this->isValid()) { - if ($this->test) { - return parent::move($directory, $name); - } - - $target = $this->getTargetFile($directory, $name); - - if (!@move_uploaded_file($this->getPathname(), $target)) { - $error = error_get_last(); - throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); - } - - @chmod($target, 0666 & ~umask()); - - return $target; - } - - throw new FileException($this->getErrorMessage()); - } - - /** - * Returns the maximum size of an uploaded file as configured in php.ini. - * - * @return int The maximum size of an uploaded file in bytes - */ - public static function getMaxFilesize() - { - $iniMax = strtolower(ini_get('upload_max_filesize')); - - if ('' === $iniMax) { - return PHP_INT_MAX; - } - - $max = ltrim($iniMax, '+'); - if (0 === strpos($max, '0x')) { - $max = intval($max, 16); - } elseif (0 === strpos($max, '0')) { - $max = intval($max, 8); - } else { - $max = (int) $max; - } - - switch (substr($iniMax, -1)) { - case 't': $max *= 1024; - // no break - case 'g': $max *= 1024; - // no break - case 'm': $max *= 1024; - // no break - case 'k': $max *= 1024; - } - - return $max; - } - - /** - * Returns an informative upload error message. - * - * @return string The error message regarding the specified error code - */ - public function getErrorMessage() - { - static $errors = array( - UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).', - UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.', - UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.', - UPLOAD_ERR_NO_FILE => 'No file was uploaded.', - UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.', - UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.', - UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.', - ); - - $errorCode = $this->error; - $maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0; - $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; - - return sprintf($message, $this->getClientOriginalName(), $maxFilesize); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/FileBag.php b/lib/silex/vendor/symfony/http-foundation/FileBag.php deleted file mode 100644 index 5edd0e621..000000000 --- a/lib/silex/vendor/symfony/http-foundation/FileBag.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * 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\UploadedFile; - -/** - * FileBag is a container for uploaded files. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - */ -class FileBag extends ParameterBag -{ - private static $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type'); - - /** - * @param array $parameters An array of HTTP files - */ - public function __construct(array $parameters = array()) - { - $this->replace($parameters); - } - - /** - * {@inheritdoc} - */ - public function replace(array $files = array()) - { - $this->parameters = array(); - $this->add($files); - } - - /** - * {@inheritdoc} - */ - public function set($key, $value) - { - if (!is_array($value) && !$value instanceof UploadedFile) { - throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.'); - } - - parent::set($key, $this->convertFileInformation($value)); - } - - /** - * {@inheritdoc} - */ - public function add(array $files = array()) - { - foreach ($files as $key => $file) { - $this->set($key, $file); - } - } - - /** - * Converts uploaded files to UploadedFile instances. - * - * @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information - * - * @return UploadedFile[]|UploadedFile|null A (multi-dimensional) array of UploadedFile instances - */ - protected function convertFileInformation($file) - { - if ($file instanceof UploadedFile) { - return $file; - } - - $file = $this->fixPhpFilesArray($file); - if (is_array($file)) { - $keys = array_keys($file); - sort($keys); - - if ($keys == self::$fileKeys) { - if (UPLOAD_ERR_NO_FILE == $file['error']) { - $file = null; - } else { - $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']); - } - } else { - $file = array_map(array($this, 'convertFileInformation'), $file); - if (array_keys($keys) === $keys) { - $file = array_filter($file); - } - } - } - - return $file; - } - - /** - * Fixes a malformed PHP $_FILES array. - * - * PHP has a bug that the format of the $_FILES array differs, depending on - * whether the uploaded file fields had normal field names or array-like - * field names ("normal" vs. "parent[child]"). - * - * This method fixes the array to look like the "normal" $_FILES array. - * - * It's safe to pass an already converted array, in which case this method - * just returns the original array unmodified. - * - * @return array - */ - protected function fixPhpFilesArray($data) - { - if (!is_array($data)) { - return $data; - } - - $keys = array_keys($data); - sort($keys); - - if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) { - return $data; - } - - $files = $data; - foreach (self::$fileKeys as $k) { - unset($files[$k]); - } - - foreach ($data['name'] as $key => $name) { - $files[$key] = $this->fixPhpFilesArray(array( - 'error' => $data['error'][$key], - 'name' => $name, - 'type' => $data['type'][$key], - 'tmp_name' => $data['tmp_name'][$key], - 'size' => $data['size'][$key], - )); - } - - return $files; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/HeaderBag.php b/lib/silex/vendor/symfony/http-foundation/HeaderBag.php deleted file mode 100644 index 7aaa52ae5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/HeaderBag.php +++ /dev/null @@ -1,331 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * HeaderBag is a container for HTTP headers. - * - * @author Fabien Potencier - */ -class HeaderBag implements \IteratorAggregate, \Countable -{ - protected $headers = array(); - protected $cacheControl = array(); - - /** - * @param array $headers An array of HTTP headers - */ - public function __construct(array $headers = array()) - { - foreach ($headers as $key => $values) { - $this->set($key, $values); - } - } - - /** - * Returns the headers as a string. - * - * @return string The headers - */ - public function __toString() - { - if (!$headers = $this->all()) { - return ''; - } - - ksort($headers); - $max = max(array_map('strlen', array_keys($headers))) + 1; - $content = ''; - foreach ($headers as $name => $values) { - $name = implode('-', array_map('ucfirst', explode('-', $name))); - foreach ($values as $value) { - $content .= sprintf("%-{$max}s %s\r\n", $name.':', $value); - } - } - - return $content; - } - - /** - * Returns the headers. - * - * @return array An array of headers - */ - public function all() - { - return $this->headers; - } - - /** - * Returns the parameter keys. - * - * @return array An array of parameter keys - */ - public function keys() - { - return array_keys($this->all()); - } - - /** - * Replaces the current HTTP headers by a new set. - * - * @param array $headers An array of HTTP headers - */ - public function replace(array $headers = array()) - { - $this->headers = array(); - $this->add($headers); - } - - /** - * Adds new headers the current HTTP headers set. - * - * @param array $headers An array of HTTP headers - */ - public function add(array $headers) - { - foreach ($headers as $key => $values) { - $this->set($key, $values); - } - } - - /** - * Returns a header value by name. - * - * @param string $key The header name - * @param string|string[] $default The default value - * @param bool $first Whether to return the first value or all header values - * - * @return string|string[] The first header value or default value if $first is true, an array of values otherwise - */ - public function get($key, $default = null, $first = true) - { - $key = str_replace('_', '-', strtolower($key)); - $headers = $this->all(); - - if (!array_key_exists($key, $headers)) { - if (null === $default) { - return $first ? null : array(); - } - - return $first ? $default : array($default); - } - - if ($first) { - return \count($headers[$key]) ? $headers[$key][0] : $default; - } - - return $headers[$key]; - } - - /** - * Sets a header by name. - * - * @param string $key The key - * @param string|string[] $values The value or an array of values - * @param bool $replace Whether to replace the actual value or not (true by default) - */ - public function set($key, $values, $replace = true) - { - $key = str_replace('_', '-', strtolower($key)); - - if (\is_array($values)) { - $values = array_values($values); - - if (true === $replace || !isset($this->headers[$key])) { - $this->headers[$key] = $values; - } else { - $this->headers[$key] = array_merge($this->headers[$key], $values); - } - } else { - if (true === $replace || !isset($this->headers[$key])) { - $this->headers[$key] = array($values); - } else { - $this->headers[$key][] = $values; - } - } - - if ('cache-control' === $key) { - $this->cacheControl = $this->parseCacheControl(implode(', ', $this->headers[$key])); - } - } - - /** - * Returns true if the HTTP header is defined. - * - * @param string $key The HTTP header - * - * @return bool true if the parameter exists, false otherwise - */ - public function has($key) - { - return array_key_exists(str_replace('_', '-', strtolower($key)), $this->all()); - } - - /** - * Returns true if the given HTTP header contains the given value. - * - * @param string $key The HTTP header name - * @param string $value The HTTP value - * - * @return bool true if the value is contained in the header, false otherwise - */ - public function contains($key, $value) - { - return in_array($value, $this->get($key, null, false)); - } - - /** - * Removes a header. - * - * @param string $key The HTTP header name - */ - public function remove($key) - { - $key = str_replace('_', '-', strtolower($key)); - - unset($this->headers[$key]); - - if ('cache-control' === $key) { - $this->cacheControl = array(); - } - } - - /** - * Returns the HTTP header value converted to a date. - * - * @param string $key The parameter key - * @param \DateTime $default The default value - * - * @return null|\DateTime The parsed DateTime or the default value if the header does not exist - * - * @throws \RuntimeException When the HTTP header is not parseable - */ - public function getDate($key, \DateTime $default = null) - { - if (null === $value = $this->get($key)) { - return $default; - } - - if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { - throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value)); - } - - return $date; - } - - /** - * Adds a custom Cache-Control directive. - * - * @param string $key The Cache-Control directive name - * @param mixed $value The Cache-Control directive value - */ - public function addCacheControlDirective($key, $value = true) - { - $this->cacheControl[$key] = $value; - - $this->set('Cache-Control', $this->getCacheControlHeader()); - } - - /** - * Returns true if the Cache-Control directive is defined. - * - * @param string $key The Cache-Control directive - * - * @return bool true if the directive exists, false otherwise - */ - public function hasCacheControlDirective($key) - { - return array_key_exists($key, $this->cacheControl); - } - - /** - * Returns a Cache-Control directive value by name. - * - * @param string $key The directive name - * - * @return mixed|null The directive value if defined, null otherwise - */ - public function getCacheControlDirective($key) - { - return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; - } - - /** - * Removes a Cache-Control directive. - * - * @param string $key The Cache-Control directive - */ - public function removeCacheControlDirective($key) - { - unset($this->cacheControl[$key]); - - $this->set('Cache-Control', $this->getCacheControlHeader()); - } - - /** - * Returns an iterator for headers. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->headers); - } - - /** - * Returns the number of headers. - * - * @return int The number of headers - */ - public function count() - { - return count($this->headers); - } - - protected function getCacheControlHeader() - { - $parts = array(); - ksort($this->cacheControl); - foreach ($this->cacheControl as $key => $value) { - if (true === $value) { - $parts[] = $key; - } else { - if (preg_match('#[^a-zA-Z0-9._-]#', $value)) { - $value = '"'.$value.'"'; - } - - $parts[] = "$key=$value"; - } - } - - return implode(', ', $parts); - } - - /** - * Parses a Cache-Control HTTP header. - * - * @param string $header The value of the Cache-Control HTTP header - * - * @return array An array representing the attribute values - */ - protected function parseCacheControl($header) - { - $cacheControl = array(); - preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER); - foreach ($matches as $match) { - $cacheControl[strtolower($match[1])] = isset($match[3]) ? $match[3] : (isset($match[2]) ? $match[2] : true); - } - - return $cacheControl; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/IpUtils.php b/lib/silex/vendor/symfony/http-foundation/IpUtils.php deleted file mode 100644 index 86d135b2d..000000000 --- a/lib/silex/vendor/symfony/http-foundation/IpUtils.php +++ /dev/null @@ -1,156 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Http utility functions. - * - * @author Fabien Potencier - */ -class IpUtils -{ - private static $checkedIps = array(); - - /** - * This class should not be instantiated. - */ - private function __construct() - { - } - - /** - * Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets. - * - * @param string $requestIp IP to check - * @param string|array $ips List of IPs or subnets (can be a string if only a single one) - * - * @return bool Whether the IP is valid - */ - public static function checkIp($requestIp, $ips) - { - if (!is_array($ips)) { - $ips = array($ips); - } - - $method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4'; - - foreach ($ips as $ip) { - if (self::$method($requestIp, $ip)) { - return true; - } - } - - return false; - } - - /** - * Compares two IPv4 addresses. - * In case a subnet is given, it checks if it contains the request IP. - * - * @param string $requestIp IPv4 address to check - * @param string $ip IPv4 address or subnet in CIDR notation - * - * @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet - */ - public static function checkIp4($requestIp, $ip) - { - $cacheKey = $requestIp.'-'.$ip; - if (isset(self::$checkedIps[$cacheKey])) { - return self::$checkedIps[$cacheKey]; - } - - if (!filter_var($requestIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - return self::$checkedIps[$cacheKey] = false; - } - - if (false !== strpos($ip, '/')) { - list($address, $netmask) = explode('/', $ip, 2); - - if ('0' === $netmask) { - return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); - } - - if ($netmask < 0 || $netmask > 32) { - return self::$checkedIps[$cacheKey] = false; - } - } else { - $address = $ip; - $netmask = 32; - } - - if (false === ip2long($address)) { - return self::$checkedIps[$cacheKey] = false; - } - - return self::$checkedIps[$cacheKey] = 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask); - } - - /** - * Compares two IPv6 addresses. - * In case a subnet is given, it checks if it contains the request IP. - * - * @author David Soria Parra - * - * @see https://github.com/dsp/v6tools - * - * @param string $requestIp IPv6 address to check - * @param string $ip IPv6 address or subnet in CIDR notation - * - * @return bool Whether the IP is valid - * - * @throws \RuntimeException When IPV6 support is not enabled - */ - public static function checkIp6($requestIp, $ip) - { - $cacheKey = $requestIp.'-'.$ip; - if (isset(self::$checkedIps[$cacheKey])) { - return self::$checkedIps[$cacheKey]; - } - - 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 ('0' === $netmask) { - return (bool) unpack('n*', @inet_pton($address)); - } - - if ($netmask < 1 || $netmask > 128) { - return self::$checkedIps[$cacheKey] = false; - } - } else { - $address = $ip; - $netmask = 128; - } - - $bytesAddr = unpack('n*', @inet_pton($address)); - $bytesTest = unpack('n*', @inet_pton($requestIp)); - - if (!$bytesAddr || !$bytesTest) { - return self::$checkedIps[$cacheKey] = false; - } - - for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) { - $left = $netmask - 16 * ($i - 1); - $left = ($left <= 16) ? $left : 16; - $mask = ~(0xffff >> $left) & 0xffff; - if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) { - return self::$checkedIps[$cacheKey] = false; - } - } - - return self::$checkedIps[$cacheKey] = true; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/JsonResponse.php b/lib/silex/vendor/symfony/http-foundation/JsonResponse.php deleted file mode 100644 index 137ac33c4..000000000 --- a/lib/silex/vendor/symfony/http-foundation/JsonResponse.php +++ /dev/null @@ -1,220 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Response represents an HTTP response in JSON format. - * - * Note that this class does not force the returned JSON content to be an - * object. It is however recommended that you do return an object as it - * protects yourself against XSSI and JSON-JavaScript Hijacking. - * - * @see https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines#Always_return_JSON_with_an_Object_on_the_outside - * - * @author Igor Wiedler - */ -class JsonResponse extends Response -{ - protected $data; - protected $callback; - - // Encode <, >, ', &, and " characters in the JSON, making it also safe to be embedded into HTML. - // 15 === JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT - const DEFAULT_ENCODING_OPTIONS = 15; - - protected $encodingOptions = self::DEFAULT_ENCODING_OPTIONS; - - /** - * @param mixed $data The response data - * @param int $status The response status code - * @param array $headers An array of response headers - * @param bool $json If the data is already a JSON string - */ - public function __construct($data = null, $status = 200, $headers = array(), $json = false) - { - parent::__construct('', $status, $headers); - - if (null === $data) { - $data = new \ArrayObject(); - } - - $json ? $this->setJson($data) : $this->setData($data); - } - - /** - * Factory method for chainability. - * - * Example: - * - * return JsonResponse::create($data, 200) - * ->setSharedMaxAge(300); - * - * @param mixed $data The json response data - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return static - */ - public static function create($data = null, $status = 200, $headers = array()) - { - return new static($data, $status, $headers); - } - - /** - * Make easier the creation of JsonResponse from raw json. - */ - public static function fromJsonString($data = null, $status = 200, $headers = array()) - { - return new static($data, $status, $headers, true); - } - - /** - * Sets the JSONP callback. - * - * @param string|null $callback The JSONP callback or null to use none - * - * @return $this - * - * @throws \InvalidArgumentException When the callback name is not valid - */ - public function setCallback($callback = null) - { - if (null !== $callback) { - // partially taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/ - // partially taken from https://github.com/willdurand/JsonpCallbackValidator - // JsonpCallbackValidator is released under the MIT License. See https://github.com/willdurand/JsonpCallbackValidator/blob/v1.1.0/LICENSE for details. - // (c) William Durand - $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*(?:\[(?:"(?:\\\.|[^"\\\])*"|\'(?:\\\.|[^\'\\\])*\'|\d+)\])*?$/u'; - $reserved = array( - 'break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', - 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', - 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false', - ); - $parts = explode('.', $callback); - foreach ($parts as $part) { - if (!preg_match($pattern, $part) || in_array($part, $reserved, true)) { - throw new \InvalidArgumentException('The callback name is not valid.'); - } - } - } - - $this->callback = $callback; - - return $this->update(); - } - - /** - * Sets a raw string containing a JSON document to be sent. - * - * @param string $json - * - * @return $this - * - * @throws \InvalidArgumentException - */ - public function setJson($json) - { - $this->data = $json; - - return $this->update(); - } - - /** - * Sets the data to be sent as JSON. - * - * @param mixed $data - * - * @return $this - * - * @throws \InvalidArgumentException - */ - public function setData($data = array()) - { - if (defined('HHVM_VERSION')) { - // HHVM does not trigger any warnings and let exceptions - // thrown from a JsonSerializable object pass through. - // If only PHP did the same... - $data = json_encode($data, $this->encodingOptions); - } else { - if (!interface_exists('JsonSerializable', false)) { - set_error_handler(function () { return false; }); - try { - $data = @json_encode($data, $this->encodingOptions); - } finally { - restore_error_handler(); - } - } else { - try { - $data = json_encode($data, $this->encodingOptions); - } catch (\Exception $e) { - if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) { - throw $e->getPrevious() ?: $e; - } - throw $e; - } - } - } - - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(json_last_error_msg()); - } - - return $this->setJson($data); - } - - /** - * Returns options used while encoding data to JSON. - * - * @return int - */ - public function getEncodingOptions() - { - return $this->encodingOptions; - } - - /** - * Sets options used while encoding data to JSON. - * - * @param int $encodingOptions - * - * @return $this - */ - public function setEncodingOptions($encodingOptions) - { - $this->encodingOptions = (int) $encodingOptions; - - return $this->setData(json_decode($this->data)); - } - - /** - * Updates the content and headers according to the JSON data and callback. - * - * @return $this - */ - protected function update() - { - if (null !== $this->callback) { - // Not using application/javascript for compatibility reasons with older browsers. - $this->headers->set('Content-Type', 'text/javascript'); - - return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data)); - } - - // Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback) - // in order to not overwrite a custom definition. - if (!$this->headers->has('Content-Type') || 'text/javascript' === $this->headers->get('Content-Type')) { - $this->headers->set('Content-Type', 'application/json'); - } - - return $this->setContent($this->data); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/LICENSE b/lib/silex/vendor/symfony/http-foundation/LICENSE deleted file mode 100644 index 21d7fb9e2..000000000 --- a/lib/silex/vendor/symfony/http-foundation/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2018 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/http-foundation/ParameterBag.php b/lib/silex/vendor/symfony/http-foundation/ParameterBag.php deleted file mode 100644 index 257ef8bce..000000000 --- a/lib/silex/vendor/symfony/http-foundation/ParameterBag.php +++ /dev/null @@ -1,234 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ParameterBag is a container for key/value pairs. - * - * @author Fabien Potencier - */ -class ParameterBag implements \IteratorAggregate, \Countable -{ - /** - * Parameter storage. - */ - protected $parameters; - - /** - * @param array $parameters An array of parameters - */ - public function __construct(array $parameters = array()) - { - $this->parameters = $parameters; - } - - /** - * Returns the parameters. - * - * @return array An array of parameters - */ - public function all() - { - return $this->parameters; - } - - /** - * Returns the parameter keys. - * - * @return array An array of parameter keys - */ - public function keys() - { - return array_keys($this->parameters); - } - - /** - * Replaces the current parameters by a new set. - * - * @param array $parameters An array of parameters - */ - public function replace(array $parameters = array()) - { - $this->parameters = $parameters; - } - - /** - * Adds parameters. - * - * @param array $parameters An array of parameters - */ - public function add(array $parameters = array()) - { - $this->parameters = array_replace($this->parameters, $parameters); - } - - /** - * Returns a parameter by name. - * - * @param string $key The key - * @param mixed $default The default value if the parameter key does not exist - * - * @return mixed - */ - public function get($key, $default = null) - { - return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default; - } - - /** - * Sets a parameter by name. - * - * @param string $key The key - * @param mixed $value The value - */ - public function set($key, $value) - { - $this->parameters[$key] = $value; - } - - /** - * Returns true if the parameter is defined. - * - * @param string $key The key - * - * @return bool true if the parameter exists, false otherwise - */ - public function has($key) - { - return array_key_exists($key, $this->parameters); - } - - /** - * Removes a parameter. - * - * @param string $key The key - */ - public function remove($key) - { - unset($this->parameters[$key]); - } - - /** - * Returns the alphabetic characters of the parameter value. - * - * @param string $key The parameter key - * @param string $default The default value if the parameter key does not exist - * - * @return string The filtered value - */ - public function getAlpha($key, $default = '') - { - return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default)); - } - - /** - * Returns the alphabetic characters and digits of the parameter value. - * - * @param string $key The parameter key - * @param string $default The default value if the parameter key does not exist - * - * @return string The filtered value - */ - public function getAlnum($key, $default = '') - { - return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default)); - } - - /** - * Returns the digits of the parameter value. - * - * @param string $key The parameter key - * @param string $default The default value if the parameter key does not exist - * - * @return string The filtered value - */ - public function getDigits($key, $default = '') - { - // we need to remove - and + because they're allowed in the filter - return str_replace(array('-', '+'), '', $this->filter($key, $default, FILTER_SANITIZE_NUMBER_INT)); - } - - /** - * Returns the parameter value converted to integer. - * - * @param string $key The parameter key - * @param int $default The default value if the parameter key does not exist - * - * @return int The filtered value - */ - public function getInt($key, $default = 0) - { - return (int) $this->get($key, $default); - } - - /** - * Returns the parameter value converted to boolean. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * - * @return bool The filtered value - */ - public function getBoolean($key, $default = false) - { - return $this->filter($key, $default, FILTER_VALIDATE_BOOLEAN); - } - - /** - * Filter key. - * - * @param string $key Key - * @param mixed $default Default = null - * @param int $filter FILTER_* constant - * @param mixed $options Filter options - * - * @see http://php.net/manual/en/function.filter-var.php - * - * @return mixed - */ - public function filter($key, $default = null, $filter = FILTER_DEFAULT, $options = array()) - { - $value = $this->get($key, $default); - - // Always turn $options into an array - this allows filter_var option shortcuts. - if (!is_array($options) && $options) { - $options = array('flags' => $options); - } - - // Add a convenience check for arrays. - if (is_array($value) && !isset($options['flags'])) { - $options['flags'] = FILTER_REQUIRE_ARRAY; - } - - return filter_var($value, $filter, $options); - } - - /** - * Returns an iterator for parameters. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->parameters); - } - - /** - * Returns the number of parameters. - * - * @return int The number of parameters - */ - public function count() - { - return count($this->parameters); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/README.md b/lib/silex/vendor/symfony/http-foundation/README.md deleted file mode 100644 index 8907f0b96..000000000 --- a/lib/silex/vendor/symfony/http-foundation/README.md +++ /dev/null @@ -1,14 +0,0 @@ -HttpFoundation Component -======================== - -The HttpFoundation component defines an object-oriented layer for the HTTP -specification. - -Resources ---------- - - * [Documentation](https://symfony.com/doc/current/components/http_foundation/index.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/lib/silex/vendor/symfony/http-foundation/RedirectResponse.php b/lib/silex/vendor/symfony/http-foundation/RedirectResponse.php deleted file mode 100644 index 01681dcdf..000000000 --- a/lib/silex/vendor/symfony/http-foundation/RedirectResponse.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * RedirectResponse represents an HTTP response doing a redirect. - * - * @author Fabien Potencier - */ -class RedirectResponse extends Response -{ - protected $targetUrl; - - /** - * Creates a redirect response so that it conforms to the rules defined for a redirect status code. - * - * @param string $url The URL to redirect to. The URL should be a full URL, with schema etc., - * but practically every browser redirects on paths only as well - * @param int $status The status code (302 by default) - * @param array $headers The headers (Location is always set to the given URL) - * - * @throws \InvalidArgumentException - * - * @see http://tools.ietf.org/html/rfc2616#section-10.3 - */ - public function __construct($url, $status = 302, $headers = array()) - { - parent::__construct('', $status, $headers); - - $this->setTargetUrl($url); - - if (!$this->isRedirect()) { - throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); - } - - if (301 == $status && !array_key_exists('cache-control', $headers)) { - $this->headers->remove('cache-control'); - } - } - - /** - * Factory method for chainability. - * - * @param string $url The url to redirect to - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return static - */ - public static function create($url = '', $status = 302, $headers = array()) - { - return new static($url, $status, $headers); - } - - /** - * Returns the target URL. - * - * @return string target URL - */ - public function getTargetUrl() - { - return $this->targetUrl; - } - - /** - * Sets the redirect target of this response. - * - * @param string $url The URL to redirect to - * - * @return $this - * - * @throws \InvalidArgumentException - */ - public function setTargetUrl($url) - { - if (empty($url)) { - throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); - } - - $this->targetUrl = $url; - - $this->setContent( - sprintf(' - - - - - - Redirecting to %1$s - - - Redirecting to %1$s. - -', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'))); - - $this->headers->set('Location', $url); - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Request.php b/lib/silex/vendor/symfony/http-foundation/Request.php deleted file mode 100644 index be55069e4..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Request.php +++ /dev/null @@ -1,2154 +0,0 @@ - - * - * 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\Exception\ConflictingHeadersException; -use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException; -use Symfony\Component\HttpFoundation\Session\SessionInterface; - -/** - * Request represents an HTTP request. - * - * The methods dealing with URL accept / return a raw path (% encoded): - * * getBasePath - * * getBaseUrl - * * getPathInfo - * * getRequestUri - * * getUri - * * getUriForPath - * - * @author Fabien Potencier - */ -class Request -{ - const HEADER_FORWARDED = 0b00001; // When using RFC 7239 - const HEADER_X_FORWARDED_FOR = 0b00010; - const HEADER_X_FORWARDED_HOST = 0b00100; - const HEADER_X_FORWARDED_PROTO = 0b01000; - const HEADER_X_FORWARDED_PORT = 0b10000; - const HEADER_X_FORWARDED_ALL = 0b11110; // All "X-Forwarded-*" headers - const HEADER_X_FORWARDED_AWS_ELB = 0b11010; // AWS ELB doesn't send X-Forwarded-Host - - /** @deprecated since version 3.3, to be removed in 4.0 */ - const HEADER_CLIENT_IP = self::HEADER_X_FORWARDED_FOR; - /** @deprecated since version 3.3, to be removed in 4.0 */ - const HEADER_CLIENT_HOST = self::HEADER_X_FORWARDED_HOST; - /** @deprecated since version 3.3, to be removed in 4.0 */ - const HEADER_CLIENT_PROTO = self::HEADER_X_FORWARDED_PROTO; - /** @deprecated since version 3.3, to be removed in 4.0 */ - const HEADER_CLIENT_PORT = self::HEADER_X_FORWARDED_PORT; - - const METHOD_HEAD = 'HEAD'; - const METHOD_GET = 'GET'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_PATCH = 'PATCH'; - const METHOD_DELETE = 'DELETE'; - const METHOD_PURGE = 'PURGE'; - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - - /** - * @var string[] - */ - protected static $trustedProxies = array(); - - /** - * @var string[] - */ - protected static $trustedHostPatterns = array(); - - /** - * @var string[] - */ - protected static $trustedHosts = array(); - - /** - * Names for headers that can be trusted when - * using trusted proxies. - * - * The FORWARDED header is the standard as of rfc7239. - * - * The other headers are non-standard, but widely used - * by popular reverse proxies (like Apache mod_proxy or Amazon EC2). - * - * @deprecated since version 3.3, to be removed in 4.0 - */ - protected static $trustedHeaders = array( - self::HEADER_FORWARDED => 'FORWARDED', - 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; - - /** - * Custom parameters. - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - */ - public $attributes; - - /** - * Request body parameters ($_POST). - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - */ - public $request; - - /** - * Query string parameters ($_GET). - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - */ - public $query; - - /** - * Server and execution environment parameters ($_SERVER). - * - * @var \Symfony\Component\HttpFoundation\ServerBag - */ - public $server; - - /** - * Uploaded files ($_FILES). - * - * @var \Symfony\Component\HttpFoundation\FileBag - */ - public $files; - - /** - * Cookies ($_COOKIE). - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - */ - public $cookies; - - /** - * Headers (taken from the $_SERVER). - * - * @var \Symfony\Component\HttpFoundation\HeaderBag - */ - public $headers; - - /** - * @var string|resource - */ - protected $content; - - /** - * @var array - */ - protected $languages; - - /** - * @var array - */ - protected $charsets; - - /** - * @var array - */ - protected $encodings; - - /** - * @var array - */ - protected $acceptableContentTypes; - - /** - * @var string - */ - protected $pathInfo; - - /** - * @var string - */ - protected $requestUri; - - /** - * @var string - */ - protected $baseUrl; - - /** - * @var string - */ - protected $basePath; - - /** - * @var string - */ - protected $method; - - /** - * @var string - */ - protected $format; - - /** - * @var \Symfony\Component\HttpFoundation\Session\SessionInterface - */ - protected $session; - - /** - * @var string - */ - protected $locale; - - /** - * @var string - */ - protected $defaultLocale = 'en'; - - /** - * @var array - */ - protected static $formats; - - protected static $requestFactory; - - private $isHostValid = true; - private $isForwardedValid = true; - - private static $trustedHeaderSet = -1; - - /** @deprecated since version 3.3, to be removed in 4.0 */ - private static $trustedHeaderNames = array( - self::HEADER_FORWARDED => 'FORWARDED', - 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', - ); - - private static $forwardedParams = array( - self::HEADER_X_FORWARDED_FOR => 'for', - self::HEADER_X_FORWARDED_HOST => 'host', - self::HEADER_X_FORWARDED_PROTO => 'proto', - self::HEADER_X_FORWARDED_PORT => 'host', - ); - - /** - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * @param string|resource $content The raw body data - */ - public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content); - } - - /** - * Sets the parameters for this request. - * - * This method also re-initializes all properties. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * @param string|resource $content The raw body data - */ - public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - $this->request = new ParameterBag($request); - $this->query = new ParameterBag($query); - $this->attributes = new ParameterBag($attributes); - $this->cookies = new ParameterBag($cookies); - $this->files = new FileBag($files); - $this->server = new ServerBag($server); - $this->headers = new HeaderBag($this->server->getHeaders()); - - $this->content = $content; - $this->languages = null; - $this->charsets = null; - $this->encodings = null; - $this->acceptableContentTypes = null; - $this->pathInfo = null; - $this->requestUri = null; - $this->baseUrl = null; - $this->basePath = null; - $this->method = null; - $this->format = null; - } - - /** - * Creates a new request with values from PHP's super globals. - * - * @return static - */ - public static function createFromGlobals() - { - // With the php's bug #66606, the php's built-in web server - // stores the Content-Type and Content-Length header values in - // HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields. - $server = $_SERVER; - if ('cli-server' === PHP_SAPI) { - if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) { - $server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH']; - } - if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) { - $server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE']; - } - } - - $request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server); - - 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); - $request->request = new ParameterBag($data); - } - - return $request; - } - - /** - * Creates a Request based on a given URI and configuration. - * - * The information contained in the URI always take precedence - * over the other information (server and parameters). - * - * @param string $uri The URI - * @param string $method The HTTP method - * @param array $parameters The query (GET) or request (POST) parameters - * @param array $cookies The request cookies ($_COOKIE) - * @param array $files The request files ($_FILES) - * @param array $server The server parameters ($_SERVER) - * @param string|resource $content The raw body data - * - * @return static - */ - public static function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null) - { - $server = array_replace(array( - 'SERVER_NAME' => 'localhost', - 'SERVER_PORT' => 80, - 'HTTP_HOST' => 'localhost', - 'HTTP_USER_AGENT' => 'Symfony/3.X', - 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', - 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', - 'REMOTE_ADDR' => '127.0.0.1', - 'SCRIPT_NAME' => '', - 'SCRIPT_FILENAME' => '', - 'SERVER_PROTOCOL' => 'HTTP/1.1', - 'REQUEST_TIME' => time(), - ), $server); - - $server['PATH_INFO'] = ''; - $server['REQUEST_METHOD'] = strtoupper($method); - - $components = parse_url($uri); - if (isset($components['host'])) { - $server['SERVER_NAME'] = $components['host']; - $server['HTTP_HOST'] = $components['host']; - } - - if (isset($components['scheme'])) { - if ('https' === $components['scheme']) { - $server['HTTPS'] = 'on'; - $server['SERVER_PORT'] = 443; - } else { - unset($server['HTTPS']); - $server['SERVER_PORT'] = 80; - } - } - - if (isset($components['port'])) { - $server['SERVER_PORT'] = $components['port']; - $server['HTTP_HOST'] = $server['HTTP_HOST'].':'.$components['port']; - } - - if (isset($components['user'])) { - $server['PHP_AUTH_USER'] = $components['user']; - } - - if (isset($components['pass'])) { - $server['PHP_AUTH_PW'] = $components['pass']; - } - - if (!isset($components['path'])) { - $components['path'] = '/'; - } - - switch (strtoupper($method)) { - case 'POST': - case 'PUT': - case 'DELETE': - if (!isset($server['CONTENT_TYPE'])) { - $server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; - } - // no break - case 'PATCH': - $request = $parameters; - $query = array(); - break; - default: - $request = array(); - $query = $parameters; - break; - } - - $queryString = ''; - if (isset($components['query'])) { - parse_str(html_entity_decode($components['query']), $qs); - - if ($query) { - $query = array_replace($qs, $query); - $queryString = http_build_query($query, '', '&'); - } else { - $query = $qs; - $queryString = $components['query']; - } - } elseif ($query) { - $queryString = http_build_query($query, '', '&'); - } - - $server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : ''); - $server['QUERY_STRING'] = $queryString; - - return self::createRequestFromFactory($query, $request, array(), $cookies, $files, $server, $content); - } - - /** - * Sets a callable able to create a Request instance. - * - * This is mainly useful when you need to override the Request class - * to keep BC with an existing system. It should not be used for any - * other purpose. - * - * @param callable|null $callable A PHP callable - */ - public static function setFactory($callable) - { - self::$requestFactory = $callable; - } - - /** - * Clones a request and overrides some of its parameters. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * - * @return static - */ - public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) - { - $dup = clone $this; - if (null !== $query) { - $dup->query = new ParameterBag($query); - } - if (null !== $request) { - $dup->request = new ParameterBag($request); - } - if (null !== $attributes) { - $dup->attributes = new ParameterBag($attributes); - } - if (null !== $cookies) { - $dup->cookies = new ParameterBag($cookies); - } - if (null !== $files) { - $dup->files = new FileBag($files); - } - if (null !== $server) { - $dup->server = new ServerBag($server); - $dup->headers = new HeaderBag($dup->server->getHeaders()); - } - $dup->languages = null; - $dup->charsets = null; - $dup->encodings = null; - $dup->acceptableContentTypes = null; - $dup->pathInfo = null; - $dup->requestUri = null; - $dup->baseUrl = null; - $dup->basePath = null; - $dup->method = null; - $dup->format = null; - - if (!$dup->get('_format') && $this->get('_format')) { - $dup->attributes->set('_format', $this->get('_format')); - } - - if (!$dup->getRequestFormat(null)) { - $dup->setRequestFormat($this->getRequestFormat(null)); - } - - return $dup; - } - - /** - * Clones the current request. - * - * Note that the session is not cloned as duplicated requests - * are most of the time sub-requests of the main one. - */ - public function __clone() - { - $this->query = clone $this->query; - $this->request = clone $this->request; - $this->attributes = clone $this->attributes; - $this->cookies = clone $this->cookies; - $this->files = clone $this->files; - $this->server = clone $this->server; - $this->headers = clone $this->headers; - } - - /** - * Returns the request as a string. - * - * @return string The request - */ - public function __toString() - { - try { - $content = $this->getContent(); - } catch (\LogicException $e) { - return trigger_error($e, E_USER_ERROR); - } - - $cookieHeader = ''; - $cookies = array(); - - foreach ($this->cookies as $k => $v) { - $cookies[] = $k.'='.$v; - } - - if (!empty($cookies)) { - $cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n"; - } - - return - sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n". - $this->headers. - $cookieHeader."\r\n". - $content; - } - - /** - * Overrides the PHP global variables according to this request instance. - * - * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE. - * $_FILES is never overridden, see rfc1867 - */ - public function overrideGlobals() - { - $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), null, '&'))); - - $_GET = $this->query->all(); - $_POST = $this->request->all(); - $_SERVER = $this->server->all(); - $_COOKIE = $this->cookies->all(); - - foreach ($this->headers->all() as $key => $value) { - $key = strtoupper(str_replace('-', '_', $key)); - if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) { - $_SERVER[$key] = implode(', ', $value); - } else { - $_SERVER['HTTP_'.$key] = implode(', ', $value); - } - } - - $request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE); - - $requestOrder = ini_get('request_order') ?: ini_get('variables_order'); - $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp'; - - $_REQUEST = array(); - foreach (str_split($requestOrder) as $order) { - $_REQUEST = array_merge($_REQUEST, $request[$order]); - } - } - - /** - * 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 - * @param int $trustedHeaderSet A bit field of Request::HEADER_*, to set which headers to trust from your proxies - * - * @throws \InvalidArgumentException When $trustedHeaderSet is invalid - */ - public static function setTrustedProxies(array $proxies/*, int $trustedHeaderSet*/) - { - self::$trustedProxies = $proxies; - - if (2 > func_num_args()) { - @trigger_error(sprintf('The %s() method expects a bit field of Request::HEADER_* as second argument since Symfony 3.3. Defining it will be required in 4.0. ', __METHOD__), E_USER_DEPRECATED); - - return; - } - $trustedHeaderSet = (int) func_get_arg(1); - - foreach (self::$trustedHeaderNames as $header => $name) { - self::$trustedHeaders[$header] = $header & $trustedHeaderSet ? $name : null; - } - self::$trustedHeaderSet = $trustedHeaderSet; - } - - /** - * Gets the list of trusted proxies. - * - * @return array An array of trusted proxies - */ - public static function getTrustedProxies() - { - return self::$trustedProxies; - } - - /** - * Gets the set of trusted headers from trusted proxies. - * - * @return int A bit field of Request::HEADER_* that defines which headers are trusted from your proxies - */ - public static function getTrustedHeaderSet() - { - return self::$trustedHeaderSet; - } - - /** - * Sets a list of trusted host patterns. - * - * You should only list the hosts you manage using regexs. - * - * @param array $hostPatterns A list of trusted host patterns - */ - public static function setTrustedHosts(array $hostPatterns) - { - self::$trustedHostPatterns = array_map(function ($hostPattern) { - return sprintf('#%s#i', $hostPattern); - }, $hostPatterns); - // we need to reset trusted hosts on trusted host patterns change - self::$trustedHosts = array(); - } - - /** - * Gets the list of trusted host patterns. - * - * @return array An array of trusted host patterns - */ - public static function getTrustedHosts() - { - return self::$trustedHostPatterns; - } - - /** - * 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 getHost()) - * * Request::HEADER_CLIENT_PORT: defaults to X-Forwarded-Port (see getPort()) - * * Request::HEADER_CLIENT_PROTO: defaults to X-Forwarded-Proto (see getScheme() and isSecure()) - * * Request::HEADER_FORWARDED: defaults to Forwarded (see RFC 7239) - * - * 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 - * - * @throws \InvalidArgumentException - * - * @deprecated since version 3.3, to be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead. - */ - public static function setTrustedHeaderName($key, $value) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.', __METHOD__), E_USER_DEPRECATED); - - if ('forwarded' === $key) { - $key = self::HEADER_FORWARDED; - } elseif ('client_ip' === $key) { - $key = self::HEADER_CLIENT_IP; - } elseif ('client_host' === $key) { - $key = self::HEADER_CLIENT_HOST; - } elseif ('client_proto' === $key) { - $key = self::HEADER_CLIENT_PROTO; - } elseif ('client_port' === $key) { - $key = self::HEADER_CLIENT_PORT; - } elseif (!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; - - if (null !== $value) { - self::$trustedHeaderNames[$key] = $value; - self::$trustedHeaderSet |= $key; - } else { - self::$trustedHeaderSet &= ~$key; - } - } - - /** - * Gets the trusted proxy header name. - * - * @param string $key The header key - * - * @return string The header name - * - * @throws \InvalidArgumentException - * - * @deprecated since version 3.3, to be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead. - */ - public static function getTrustedHeaderName($key) - { - if (2 > func_num_args() || func_get_arg(1)) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead.', __METHOD__), E_USER_DEPRECATED); - } - - if (!array_key_exists($key, self::$trustedHeaders)) { - throw new \InvalidArgumentException(sprintf('Unable to get the trusted header name for key "%s".', $key)); - } - - return self::$trustedHeaders[$key]; - } - - /** - * Normalizes a query string. - * - * It builds a normalized query string, where keys/value pairs are alphabetized, - * have consistent escaping and unneeded delimiters are removed. - * - * @param string $qs Query string - * - * @return string A normalized query string for the Request - */ - public static function normalizeQueryString($qs) - { - if ('' == $qs) { - return ''; - } - - $parts = array(); - $order = array(); - - foreach (explode('&', $qs) as $param) { - if ('' === $param || '=' === $param[0]) { - // Ignore useless delimiters, e.g. "x=y&". - // Also ignore pairs with empty key, even if there was a value, e.g. "=value", as such nameless values cannot be retrieved anyway. - // PHP also does not include them when building _GET. - continue; - } - - $keyValuePair = explode('=', $param, 2); - - // GET parameters, that are submitted from a HTML form, encode spaces as "+" by default (as defined in enctype application/x-www-form-urlencoded). - // PHP also converts "+" to spaces when filling the global _GET or when using the function parse_str. This is why we use urldecode and then normalize to - // RFC 3986 with rawurlencode. - $parts[] = isset($keyValuePair[1]) ? - rawurlencode(urldecode($keyValuePair[0])).'='.rawurlencode(urldecode($keyValuePair[1])) : - rawurlencode(urldecode($keyValuePair[0])); - $order[] = urldecode($keyValuePair[0]); - } - - array_multisort($order, SORT_ASC, $parts); - - 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. - * If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered - * and used to send a "PUT" or "DELETE" request via the _method request parameter. - * If these methods are not protected against CSRF, this presents a possible vulnerability. - * - * The HTTP method can only be overridden when the real HTTP method is POST. - */ - public static function enableHttpMethodParameterOverride() - { - self::$httpMethodParameterOverride = true; - } - - /** - * Checks whether support for the _method request parameter is enabled. - * - * @return bool True when the _method request parameter is enabled, false otherwise - */ - public static function getHttpMethodParameterOverride() - { - return self::$httpMethodParameterOverride; - } - - /** - * Gets a "parameter" value from any bag. - * - * This method is mainly useful for libraries that want to provide some flexibility. If you don't need the - * flexibility in controllers, it is better to explicitly get request parameters from the appropriate - * public property instead (attributes, query, request). - * - * Order of precedence: PATH (routing placeholders or custom attributes), GET, BODY - * - * @param string $key The key - * @param mixed $default The default value if the parameter key does not exist - * - * @return mixed - */ - public function get($key, $default = null) - { - if ($this !== $result = $this->attributes->get($key, $this)) { - return $result; - } - - if ($this !== $result = $this->query->get($key, $this)) { - return $result; - } - - if ($this !== $result = $this->request->get($key, $this)) { - return $result; - } - - return $default; - } - - /** - * Gets the Session. - * - * @return SessionInterface|null The session - */ - public function getSession() - { - return $this->session; - } - - /** - * Whether the request contains a Session which was started in one of the - * previous requests. - * - * @return bool - */ - public function hasPreviousSession() - { - // the check for $this->session avoids malicious users trying to fake a session cookie with proper name - return $this->hasSession() && $this->cookies->has($this->session->getName()); - } - - /** - * Whether the request contains a Session object. - * - * 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 bool true when the Request contains a Session object, false otherwise - */ - public function hasSession() - { - return null !== $this->session; - } - - /** - * Sets the Session. - * - * @param SessionInterface $session The Session - */ - public function setSession(SessionInterface $session) - { - $this->session = $session; - } - - /** - * Returns the client IP addresses. - * - * In the returned array the most trusted IP address is first, and the - * least trusted one last. The "real" client IP address is the last one, - * but this is also the least trusted one. Trusted proxies are stripped. - * - * Use this method carefully; you should use getClientIp() instead. - * - * @return array The client IP addresses - * - * @see getClientIp() - */ - public function getClientIps() - { - $ip = $this->server->get('REMOTE_ADDR'); - - if (!$this->isFromTrustedProxy()) { - return array($ip); - } - - return $this->getTrustedValues(self::HEADER_CLIENT_IP, $ip) ?: array($ip); - } - - /** - * 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 the $trustedHeaderSet - * argument of the Request::setTrustedProxies() method instead. - * - * @return string|null The client IP address - * - * @see getClientIps() - * @see http://en.wikipedia.org/wiki/X-Forwarded-For - */ - public function getClientIp() - { - $ipAddresses = $this->getClientIps(); - - return $ipAddresses[0]; - } - - /** - * Returns current script name. - * - * @return string - */ - public function getScriptName() - { - return $this->server->get('SCRIPT_NAME', $this->server->get('ORIG_SCRIPT_NAME', '')); - } - - /** - * Returns the path being requested relative to the executed script. - * - * The path info always starts with a /. - * - * Suppose this request is instantiated from /mysite on localhost: - * - * * http://localhost/mysite returns an empty string - * * http://localhost/mysite/about returns '/about' - * * http://localhost/mysite/enco%20ded returns '/enco%20ded' - * * http://localhost/mysite/about?var=1 returns '/about' - * - * @return string The raw path (i.e. not urldecoded) - */ - public function getPathInfo() - { - if (null === $this->pathInfo) { - $this->pathInfo = $this->preparePathInfo(); - } - - return $this->pathInfo; - } - - /** - * Returns the root path from which this request is executed. - * - * Suppose that an index.php file instantiates this request object: - * - * * http://localhost/index.php returns an empty string - * * http://localhost/index.php/page returns an empty string - * * http://localhost/web/index.php returns '/web' - * * http://localhost/we%20b/index.php returns '/we%20b' - * - * @return string The raw path (i.e. not urldecoded) - */ - public function getBasePath() - { - if (null === $this->basePath) { - $this->basePath = $this->prepareBasePath(); - } - - return $this->basePath; - } - - /** - * Returns the root URL from which this request is executed. - * - * The base URL never ends with a /. - * - * This is similar to getBasePath(), except that it also includes the - * script filename (e.g. index.php) if one exists. - * - * @return string The raw URL (i.e. not urldecoded) - */ - public function getBaseUrl() - { - if (null === $this->baseUrl) { - $this->baseUrl = $this->prepareBaseUrl(); - } - - return $this->baseUrl; - } - - /** - * Gets the request's scheme. - * - * @return string - */ - public function getScheme() - { - return $this->isSecure() ? 'https' : 'http'; - } - - /** - * 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 via the $trustedHeaderSet argument of the - * Request::setTrustedProxies() method instead. - * - * @return int|string can be a string if fetched from the server bag - */ - public function getPort() - { - if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_PORT)) { - $host = $host[0]; - } elseif ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_HOST)) { - $host = $host[0]; - } elseif (!$host = $this->headers->get('HOST')) { - return $this->server->get('SERVER_PORT'); - } - - if ('[' === $host[0]) { - $pos = strpos($host, ':', strrpos($host, ']')); - } else { - $pos = strrpos($host, ':'); - } - - if (false !== $pos) { - return (int) substr($host, $pos + 1); - } - - return 'https' === $this->getScheme() ? 443 : 80; - } - - /** - * Returns the user. - * - * @return string|null - */ - public function getUser() - { - return $this->headers->get('PHP_AUTH_USER'); - } - - /** - * Returns the password. - * - * @return string|null - */ - public function getPassword() - { - return $this->headers->get('PHP_AUTH_PW'); - } - - /** - * Gets the user info. - * - * @return string A user name and, optionally, scheme-specific information about how to gain authorization to access the server - */ - public function getUserInfo() - { - $userinfo = $this->getUser(); - - $pass = $this->getPassword(); - if ('' != $pass) { - $userinfo .= ":$pass"; - } - - return $userinfo; - } - - /** - * Returns the HTTP host being requested. - * - * The port name will be appended to the host if it's non-standard. - * - * @return string - */ - public function getHttpHost() - { - $scheme = $this->getScheme(); - $port = $this->getPort(); - - if (('http' == $scheme && 80 == $port) || ('https' == $scheme && 443 == $port)) { - return $this->getHost(); - } - - return $this->getHost().':'.$port; - } - - /** - * Returns the requested URI (path and query string). - * - * @return string The raw URI (i.e. not URI decoded) - */ - public function getRequestUri() - { - if (null === $this->requestUri) { - $this->requestUri = $this->prepareRequestUri(); - } - - return $this->requestUri; - } - - /** - * 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().'://'.$this->getHttpHost(); - } - - /** - * Generates a normalized URI (URL) for the Request. - * - * @return string A normalized URI (URL) for the Request - * - * @see getQueryString() - */ - public function getUri() - { - if (null !== $qs = $this->getQueryString()) { - $qs = '?'.$qs; - } - - return $this->getSchemeAndHttpHost().$this->getBaseUrl().$this->getPathInfo().$qs; - } - - /** - * Generates a normalized URI for the given path. - * - * @param string $path A path to use instead of the current one - * - * @return string The normalized URI for the path - */ - public function getUriForPath($path) - { - return $this->getSchemeAndHttpHost().$this->getBaseUrl().$path; - } - - /** - * Returns the path as relative reference from the current Request path. - * - * Only the URIs path component (no schema, host etc.) is relevant and must be given. - * Both paths must be absolute and not contain relative parts. - * Relative URLs from one resource to another are useful when generating self-contained downloadable document archives. - * Furthermore, they can be used to reduce the link size in documents. - * - * Example target paths, given a base path of "/a/b/c/d": - * - "/a/b/c/d" -> "" - * - "/a/b/c/" -> "./" - * - "/a/b/" -> "../" - * - "/a/b/c/other" -> "other" - * - "/a/x/y" -> "../../x/y" - * - * @param string $path The target path - * - * @return string The relative target path - */ - public function getRelativeUriForPath($path) - { - // be sure that we are dealing with an absolute path - if (!isset($path[0]) || '/' !== $path[0]) { - return $path; - } - - if ($path === $basePath = $this->getPathInfo()) { - return ''; - } - - $sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath); - $targetDirs = explode('/', isset($path[0]) && '/' === $path[0] ? substr($path, 1) : $path); - array_pop($sourceDirs); - $targetFile = array_pop($targetDirs); - - foreach ($sourceDirs as $i => $dir) { - if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) { - unset($sourceDirs[$i], $targetDirs[$i]); - } else { - break; - } - } - - $targetDirs[] = $targetFile; - $path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs); - - // A reference to the same base directory or an empty subdirectory must be prefixed with "./". - // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used - // as the first segment of a relative-path reference, as it would be mistaken for a scheme name - // (see http://tools.ietf.org/html/rfc3986#section-4.2). - return !isset($path[0]) || '/' === $path[0] - || false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos) - ? "./$path" : $path; - } - - /** - * Generates the normalized query string for the Request. - * - * It builds a normalized query string, where keys/value pairs are alphabetized - * and have consistent escaping. - * - * @return string|null A normalized query string for the Request - */ - public function getQueryString() - { - $qs = static::normalizeQueryString($this->server->get('QUERY_STRING')); - - return '' === $qs ? null : $qs; - } - - /** - * Checks whether the request is secure or not. - * - * This method can read the client protocol 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 the $trustedHeaderSet - * argument of the Request::setTrustedProxies() method instead. - * - * @return bool - */ - public function isSecure() - { - if ($this->isFromTrustedProxy() && $proto = $this->getTrustedValues(self::HEADER_CLIENT_PROTO)) { - return in_array(strtolower($proto[0]), array('https', 'on', 'ssl', '1'), true); - } - - $https = $this->server->get('HTTPS'); - - return !empty($https) && 'off' !== strtolower($https); - } - - /** - * Returns the host name. - * - * This method can read the client host name 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 the $trustedHeaderSet argument of the - * Request::setTrustedProxies() method instead. - * - * @return string - * - * @throws SuspiciousOperationException when the host name is invalid or not trusted - */ - public function getHost() - { - if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_HOST)) { - $host = $host[0]; - } elseif (!$host = $this->headers->get('HOST')) { - if (!$host = $this->server->get('SERVER_NAME')) { - $host = $this->server->get('SERVER_ADDR', ''); - } - } - - // trim and remove port number from host - // host is lowercase as per RFC 952/2181 - $host = strtolower(preg_replace('/:\d+$/', '', trim($host))); - - // as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user) - // check that it does not contain forbidden characters (see RFC 952 and RFC 2181) - // use preg_replace() instead of preg_match() to prevent DoS attacks with long host names - if ($host && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) { - if (!$this->isHostValid) { - return ''; - } - $this->isHostValid = false; - - throw new SuspiciousOperationException(sprintf('Invalid Host "%s".', $host)); - } - - if (count(self::$trustedHostPatterns) > 0) { - // to avoid host header injection attacks, you should provide a list of trusted host patterns - - if (in_array($host, self::$trustedHosts)) { - return $host; - } - - foreach (self::$trustedHostPatterns as $pattern) { - if (preg_match($pattern, $host)) { - self::$trustedHosts[] = $host; - - return $host; - } - } - - if (!$this->isHostValid) { - return ''; - } - $this->isHostValid = false; - - throw new SuspiciousOperationException(sprintf('Untrusted Host "%s".', $host)); - } - - return $host; - } - - /** - * Sets the request method. - * - * @param string $method - */ - public function setMethod($method) - { - $this->method = null; - $this->server->set('REQUEST_METHOD', $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 - * - * @see getRealMethod() - */ - public function getMethod() - { - if (null === $this->method) { - $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET')); - - if ('POST' === $this->method) { - 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. - * - * @param string $format The format - * - * @return string The associated mime type (null if not found) - */ - public function getMimeType($format) - { - if (null === static::$formats) { - static::initializeFormats(); - } - - return isset(static::$formats[$format]) ? static::$formats[$format][0] : null; - } - - /** - * Gets the mime types associated with the format. - * - * @param string $format The format - * - * @return array The associated mime types - */ - public static function getMimeTypes($format) - { - if (null === static::$formats) { - static::initializeFormats(); - } - - return isset(static::$formats[$format]) ? static::$formats[$format] : array(); - } - - /** - * Gets the format associated with the mime type. - * - * @param string $mimeType The associated mime type - * - * @return string|null The format (null if not found) - */ - public function getFormat($mimeType) - { - $canonicalMimeType = null; - if (false !== $pos = strpos($mimeType, ';')) { - $canonicalMimeType = substr($mimeType, 0, $pos); - } - - if (null === static::$formats) { - static::initializeFormats(); - } - - foreach (static::$formats as $format => $mimeTypes) { - if (in_array($mimeType, (array) $mimeTypes)) { - return $format; - } - if (null !== $canonicalMimeType && in_array($canonicalMimeType, (array) $mimeTypes)) { - return $format; - } - } - } - - /** - * Associates a format with mime types. - * - * @param string $format The format - * @param string|array $mimeTypes The associated mime types (the preferred one must be the first as it will be used as the content type) - */ - public function setFormat($format, $mimeTypes) - { - if (null === static::$formats) { - static::initializeFormats(); - } - - static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes); - } - - /** - * Gets the request format. - * - * Here is the process to determine the format: - * - * * format defined by the user (with setRequestFormat()) - * * _format request attribute - * * $default - * - * @param string $default The default format - * - * @return string The request format - */ - public function getRequestFormat($default = 'html') - { - if (null === $this->format) { - $this->format = $this->attributes->get('_format'); - } - - return null === $this->format ? $default : $this->format; - } - - /** - * Sets the request format. - * - * @param string $format The request format - */ - public function setRequestFormat($format) - { - $this->format = $format; - } - - /** - * Gets the format associated with the request. - * - * @return string|null The format (null if no content type is present) - */ - public function getContentType() - { - return $this->getFormat($this->headers->get('CONTENT_TYPE')); - } - - /** - * Sets the default locale. - * - * @param string $locale - */ - public function setDefaultLocale($locale) - { - $this->defaultLocale = $locale; - - if (null === $this->locale) { - $this->setPhpDefaultLocale($locale); - } - } - - /** - * Get the default locale. - * - * @return string - */ - public function getDefaultLocale() - { - return $this->defaultLocale; - } - - /** - * Sets the locale. - * - * @param string $locale - */ - public function setLocale($locale) - { - $this->setPhpDefaultLocale($this->locale = $locale); - } - - /** - * Get the locale. - * - * @return string - */ - public function getLocale() - { - return null === $this->locale ? $this->defaultLocale : $this->locale; - } - - /** - * Checks if the request method is of specified type. - * - * @param string $method Uppercase request method (GET, POST etc) - * - * @return bool - */ - public function isMethod($method) - { - return $this->getMethod() === strtoupper($method); - } - - /** - * Checks whether or not the method is safe. - * - * @see https://tools.ietf.org/html/rfc7231#section-4.2.1 - * - * @param bool $andCacheable Adds the additional condition that the method should be cacheable. True by default. - * - * @return bool - */ - public function isMethodSafe(/* $andCacheable = true */) - { - if (!func_num_args() || func_get_arg(0)) { - // This deprecation should be turned into a BadMethodCallException in 4.0 (without adding the argument in the signature) - // then setting $andCacheable to false should be deprecated in 4.1 - @trigger_error('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since Symfony 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.', E_USER_DEPRECATED); - - return in_array($this->getMethod(), array('GET', 'HEAD')); - } - - return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE')); - } - - /** - * Checks whether or not the method is idempotent. - * - * @return bool - */ - public function isMethodIdempotent() - { - return in_array($this->getMethod(), array('HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE')); - } - - /** - * Checks whether the method is cacheable or not. - * - * @see https://tools.ietf.org/html/rfc7231#section-4.2.3 - * - * @return bool - */ - public function isMethodCacheable() - { - return in_array($this->getMethod(), array('GET', 'HEAD')); - } - - /** - * Returns the protocol version. - * - * If the application is behind a proxy, the protocol version used in the - * requests between the client and the proxy and between the proxy and the - * server might be different. This returns the former (from the "Via" header) - * if the proxy is trusted (see "setTrustedProxies()"), otherwise it returns - * the latter (from the "SERVER_PROTOCOL" server parameter). - * - * @return string - */ - public function getProtocolVersion() - { - if ($this->isFromTrustedProxy()) { - preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via'), $matches); - - if ($matches) { - return 'HTTP/'.$matches[2]; - } - } - - return $this->server->get('SERVER_PROTOCOL'); - } - - /** - * Returns the request body content. - * - * @param bool $asResource If true, a resource will be returned - * - * @return string|resource The request body content or a resource to read the body stream - * - * @throws \LogicException - */ - public function getContent($asResource = false) - { - $currentContentIsResource = is_resource($this->content); - if (\PHP_VERSION_ID < 50600 && false === $this->content) { - throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.'); - } - - if (true === $asResource) { - if ($currentContentIsResource) { - rewind($this->content); - - return $this->content; - } - - // Content passed in parameter (test) - if (is_string($this->content)) { - $resource = fopen('php://temp', 'r+'); - fwrite($resource, $this->content); - rewind($resource); - - return $resource; - } - - $this->content = false; - - return fopen('php://input', 'rb'); - } - - if ($currentContentIsResource) { - rewind($this->content); - - return stream_get_contents($this->content); - } - - if (null === $this->content || false === $this->content) { - $this->content = file_get_contents('php://input'); - } - - return $this->content; - } - - /** - * Gets the Etags. - * - * @return array The entity tags - */ - public function getETags() - { - return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY); - } - - /** - * @return bool - */ - public function isNoCache() - { - return $this->headers->hasCacheControlDirective('no-cache') || 'no-cache' == $this->headers->get('Pragma'); - } - - /** - * Returns the preferred language. - * - * @param array $locales An array of ordered available locales - * - * @return string|null The preferred locale - */ - public function getPreferredLanguage(array $locales = null) - { - $preferredLanguages = $this->getLanguages(); - - if (empty($locales)) { - return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null; - } - - if (!$preferredLanguages) { - return $locales[0]; - } - - $extendedPreferredLanguages = array(); - foreach ($preferredLanguages as $language) { - $extendedPreferredLanguages[] = $language; - if (false !== $position = strpos($language, '_')) { - $superLanguage = substr($language, 0, $position); - if (!in_array($superLanguage, $preferredLanguages)) { - $extendedPreferredLanguages[] = $superLanguage; - } - } - } - - $preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales)); - - return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0]; - } - - /** - * Gets a list of languages acceptable by the client browser. - * - * @return array Languages ordered in the user browser preferences - */ - public function getLanguages() - { - if (null !== $this->languages) { - return $this->languages; - } - - $languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all(); - $this->languages = array(); - foreach ($languages as $lang => $acceptHeaderItem) { - if (false !== strpos($lang, '-')) { - $codes = explode('-', $lang); - if ('i' === $codes[0]) { - // Language not listed in ISO 639 that are not variants - // of any listed language, which can be registered with the - // i-prefix, such as i-cherokee - if (count($codes) > 1) { - $lang = $codes[1]; - } - } else { - for ($i = 0, $max = count($codes); $i < $max; ++$i) { - if (0 === $i) { - $lang = strtolower($codes[0]); - } else { - $lang .= '_'.strtoupper($codes[$i]); - } - } - } - } - - $this->languages[] = $lang; - } - - return $this->languages; - } - - /** - * Gets a list of charsets acceptable by the client browser. - * - * @return array List of charsets in preferable order - */ - public function getCharsets() - { - if (null !== $this->charsets) { - return $this->charsets; - } - - return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all()); - } - - /** - * Gets a list of encodings acceptable by the client browser. - * - * @return array List of encodings in preferable order - */ - public function getEncodings() - { - if (null !== $this->encodings) { - return $this->encodings; - } - - return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all()); - } - - /** - * Gets a list of content types acceptable by the client browser. - * - * @return array List of content types in preferable order - */ - public function getAcceptableContentTypes() - { - if (null !== $this->acceptableContentTypes) { - return $this->acceptableContentTypes; - } - - return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all()); - } - - /** - * Returns true if the request is a XMLHttpRequest. - * - * It works if your JavaScript library sets an X-Requested-With HTTP header. - * It is known to work with common JavaScript frameworks: - * - * @see http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript - * - * @return bool true if the request is an XMLHttpRequest, false otherwise - */ - public function isXmlHttpRequest() - { - return 'XMLHttpRequest' == $this->headers->get('X-Requested-With'); - } - - /* - * The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24) - * - * Code subject to the new BSD license (http://framework.zend.com/license/new-bsd). - * - * Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - */ - - protected function prepareRequestUri() - { - $requestUri = ''; - - if ($this->headers->has('X_ORIGINAL_URL')) { - // IIS with Microsoft Rewrite Module - $requestUri = $this->headers->get('X_ORIGINAL_URL'); - $this->headers->remove('X_ORIGINAL_URL'); - $this->server->remove('HTTP_X_ORIGINAL_URL'); - $this->server->remove('UNENCODED_URL'); - $this->server->remove('IIS_WasUrlRewritten'); - } elseif ($this->headers->has('X_REWRITE_URL')) { - // IIS with ISAPI_Rewrite - $requestUri = $this->headers->get('X_REWRITE_URL'); - $this->headers->remove('X_REWRITE_URL'); - } elseif ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) { - // IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem) - $requestUri = $this->server->get('UNENCODED_URL'); - $this->server->remove('UNENCODED_URL'); - $this->server->remove('IIS_WasUrlRewritten'); - } elseif ($this->server->has('REQUEST_URI')) { - $requestUri = $this->server->get('REQUEST_URI'); - // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path - $schemeAndHttpHost = $this->getSchemeAndHttpHost(); - if (0 === strpos($requestUri, $schemeAndHttpHost)) { - $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); - } - } elseif ($this->server->has('ORIG_PATH_INFO')) { - // IIS 5.0, PHP as CGI - $requestUri = $this->server->get('ORIG_PATH_INFO'); - if ('' != $this->server->get('QUERY_STRING')) { - $requestUri .= '?'.$this->server->get('QUERY_STRING'); - } - $this->server->remove('ORIG_PATH_INFO'); - } - - // normalize the request URI to ease creating sub-requests from this request - $this->server->set('REQUEST_URI', $requestUri); - - return $requestUri; - } - - /** - * Prepares the base URL. - * - * @return string - */ - protected function prepareBaseUrl() - { - $filename = basename($this->server->get('SCRIPT_FILENAME')); - - if (basename($this->server->get('SCRIPT_NAME')) === $filename) { - $baseUrl = $this->server->get('SCRIPT_NAME'); - } elseif (basename($this->server->get('PHP_SELF')) === $filename) { - $baseUrl = $this->server->get('PHP_SELF'); - } elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) { - $baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); // 1and1 shared hosting compatibility - } else { - // Backtrack up the script_filename to find the portion matching - // php_self - $path = $this->server->get('PHP_SELF', ''); - $file = $this->server->get('SCRIPT_FILENAME', ''); - $segs = explode('/', trim($file, '/')); - $segs = array_reverse($segs); - $index = 0; - $last = count($segs); - $baseUrl = ''; - do { - $seg = $segs[$index]; - $baseUrl = '/'.$seg.$baseUrl; - ++$index; - } while ($last > $index && (false !== $pos = strpos($path, $baseUrl)) && 0 != $pos); - } - - // Does the baseUrl have anything in common with the request_uri? - $requestUri = $this->getRequestUri(); - if ('' !== $requestUri && '/' !== $requestUri[0]) { - $requestUri = '/'.$requestUri; - } - - if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) { - // full $baseUrl matches - return $prefix; - } - - if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/'.DIRECTORY_SEPARATOR).'/')) { - // directory portion of $baseUrl matches - return rtrim($prefix, '/'.DIRECTORY_SEPARATOR); - } - - $truncatedRequestUri = $requestUri; - if (false !== $pos = strpos($requestUri, '?')) { - $truncatedRequestUri = substr($requestUri, 0, $pos); - } - - $basename = basename($baseUrl); - if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) { - // no match whatsoever; set it blank - return ''; - } - - // If using mod_rewrite or ISAPI_Rewrite strip the script filename - // out of baseUrl. $pos !== 0 makes sure it is not matching a value - // from PATH_INFO or QUERY_STRING - if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) { - $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); - } - - return rtrim($baseUrl, '/'.DIRECTORY_SEPARATOR); - } - - /** - * Prepares the base path. - * - * @return string base path - */ - protected function prepareBasePath() - { - $baseUrl = $this->getBaseUrl(); - if (empty($baseUrl)) { - return ''; - } - - $filename = basename($this->server->get('SCRIPT_FILENAME')); - if (basename($baseUrl) === $filename) { - $basePath = dirname($baseUrl); - } else { - $basePath = $baseUrl; - } - - if ('\\' === DIRECTORY_SEPARATOR) { - $basePath = str_replace('\\', '/', $basePath); - } - - return rtrim($basePath, '/'); - } - - /** - * Prepares the path info. - * - * @return string path info - */ - protected function preparePathInfo() - { - if (null === ($requestUri = $this->getRequestUri())) { - return '/'; - } - - // Remove the query string from REQUEST_URI - if (false !== $pos = strpos($requestUri, '?')) { - $requestUri = substr($requestUri, 0, $pos); - } - if ('' !== $requestUri && '/' !== $requestUri[0]) { - $requestUri = '/'.$requestUri; - } - - if (null === ($baseUrl = $this->getBaseUrl())) { - return $requestUri; - } - - $pathInfo = substr($requestUri, strlen($baseUrl)); - if (false === $pathInfo || '' === $pathInfo) { - // If substr() returns false then PATH_INFO is set to an empty string - return '/'; - } - - return (string) $pathInfo; - } - - /** - * Initializes HTTP request formats. - */ - protected static function initializeFormats() - { - static::$formats = array( - 'html' => array('text/html', 'application/xhtml+xml'), - 'txt' => array('text/plain'), - 'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'), - 'css' => array('text/css'), - 'json' => array('application/json', 'application/x-json'), - 'jsonld' => array('application/ld+json'), - 'xml' => array('text/xml', 'application/xml', 'application/x-xml'), - 'rdf' => array('application/rdf+xml'), - 'atom' => array('application/atom+xml'), - 'rss' => array('application/rss+xml'), - 'form' => array('application/x-www-form-urlencoded'), - ); - } - - /** - * Sets the default PHP locale. - * - * @param string $locale - */ - private function setPhpDefaultLocale($locale) - { - // if either the class Locale doesn't exist, or an exception is thrown when - // setting the default locale, the intl module is not installed, and - // the call can be ignored: - try { - if (class_exists('Locale', false)) { - \Locale::setDefault($locale); - } - } catch (\Exception $e) { - } - } - - /* - * Returns the prefix as encoded in the string when the string starts with - * the given prefix, false otherwise. - * - * @param string $string The urlencoded string - * @param string $prefix The prefix not encoded - * - * @return string|false The prefix as it is encoded in $string, or false - */ - private function getUrlencodedPrefix($string, $prefix) - { - if (0 !== strpos(rawurldecode($string), $prefix)) { - return false; - } - - $len = strlen($prefix); - - if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $len), $string, $match)) { - return $match[0]; - } - - return false; - } - - private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - if (self::$requestFactory) { - $request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content); - - if (!$request instanceof self) { - throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.'); - } - - return $request; - } - - return new static($query, $request, $attributes, $cookies, $files, $server, $content); - } - - /** - * Indicates whether this request originated from a trusted proxy. - * - * This can be useful to determine whether or not to trust the - * contents of a proxy-specific header. - * - * @return bool true if the request came from a trusted proxy, false otherwise - */ - public function isFromTrustedProxy() - { - return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies); - } - - private function getTrustedValues($type, $ip = null) - { - $clientValues = array(); - $forwardedValues = array(); - - if (self::$trustedHeaders[$type] && $this->headers->has(self::$trustedHeaders[$type])) { - foreach (explode(',', $this->headers->get(self::$trustedHeaders[$type])) as $v) { - $clientValues[] = (self::HEADER_CLIENT_PORT === $type ? '0.0.0.0:' : '').trim($v); - } - } - - if (self::$trustedHeaders[self::HEADER_FORWARDED] && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED])) { - $forwardedValues = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]); - $forwardedValues = preg_match_all(sprintf('{(?:%s)=(?:"?\[?)([a-zA-Z0-9\.:_\-/]*+)}', self::$forwardedParams[$type]), $forwardedValues, $matches) ? $matches[1] : array(); - } - - if (null !== $ip) { - $clientValues = $this->normalizeAndFilterClientIps($clientValues, $ip); - $forwardedValues = $this->normalizeAndFilterClientIps($forwardedValues, $ip); - } - - if ($forwardedValues === $clientValues || !$clientValues) { - return $forwardedValues; - } - - if (!$forwardedValues) { - return $clientValues; - } - - if (!$this->isForwardedValid) { - return null !== $ip ? array('0.0.0.0', $ip) : array(); - } - $this->isForwardedValid = false; - - throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::$trustedHeaders[self::HEADER_FORWARDED], self::$trustedHeaders[$type])); - } - - private function normalizeAndFilterClientIps(array $clientIps, $ip) - { - if (!$clientIps) { - return array(); - } - $clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from - $firstTrustedIp = null; - - foreach ($clientIps as $key => $clientIp) { - // Remove port (unfortunately, it does happen) - if (preg_match('{((?:\d+\.){3}\d+)\:\d+}', $clientIp, $match)) { - $clientIps[$key] = $clientIp = $match[1]; - } - - if (!filter_var($clientIp, FILTER_VALIDATE_IP)) { - unset($clientIps[$key]); - - continue; - } - - if (IpUtils::checkIp($clientIp, self::$trustedProxies)) { - unset($clientIps[$key]); - - // Fallback to this when the client IP falls into the range of trusted proxies - if (null === $firstTrustedIp) { - $firstTrustedIp = $clientIp; - } - } - } - - // Now the IP chain contains only untrusted proxies and the client IP - return $clientIps ? array_reverse($clientIps) : array($firstTrustedIp); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/RequestMatcher.php b/lib/silex/vendor/symfony/http-foundation/RequestMatcher.php deleted file mode 100644 index 076d077c7..000000000 --- a/lib/silex/vendor/symfony/http-foundation/RequestMatcher.php +++ /dev/null @@ -1,178 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * RequestMatcher compares a pre-defined set of checks against a Request instance. - * - * @author Fabien Potencier - */ -class RequestMatcher implements RequestMatcherInterface -{ - /** - * @var string|null - */ - private $path; - - /** - * @var string|null - */ - private $host; - - /** - * @var string[] - */ - private $methods = array(); - - /** - * @var string[] - */ - private $ips = array(); - - /** - * @var array - */ - private $attributes = array(); - - /** - * @var string[] - */ - private $schemes = array(); - - /** - * @param string|null $path - * @param string|null $host - * @param string|string[]|null $methods - * @param string|string[]|null $ips - * @param array $attributes - * @param string|string[]|null $schemes - */ - public function __construct($path = null, $host = null, $methods = null, $ips = null, array $attributes = array(), $schemes = null) - { - $this->matchPath($path); - $this->matchHost($host); - $this->matchMethod($methods); - $this->matchIps($ips); - $this->matchScheme($schemes); - - foreach ($attributes as $k => $v) { - $this->matchAttribute($k, $v); - } - } - - /** - * Adds a check for the HTTP scheme. - * - * @param string|string[]|null $scheme An HTTP scheme or an array of HTTP schemes - */ - public function matchScheme($scheme) - { - $this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : array(); - } - - /** - * Adds a check for the URL host name. - * - * @param string|null $regexp A Regexp - */ - public function matchHost($regexp) - { - $this->host = $regexp; - } - - /** - * Adds a check for the URL path info. - * - * @param string|null $regexp A Regexp - */ - public function matchPath($regexp) - { - $this->path = $regexp; - } - - /** - * Adds a check for the client IP. - * - * @param string $ip A specific IP address or a range specified using IP/netmask like 192.168.1.0/24 - */ - public function matchIp($ip) - { - $this->matchIps($ip); - } - - /** - * Adds a check for the client IP. - * - * @param string|string[]|null $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24 - */ - public function matchIps($ips) - { - $this->ips = null !== $ips ? (array) $ips : array(); - } - - /** - * Adds a check for the HTTP method. - * - * @param string|string[]|null $method An HTTP method or an array of HTTP methods - */ - public function matchMethod($method) - { - $this->methods = null !== $method ? array_map('strtoupper', (array) $method) : array(); - } - - /** - * Adds a check for request attribute. - * - * @param string $key The request attribute name - * @param string $regexp A Regexp - */ - public function matchAttribute($key, $regexp) - { - $this->attributes[$key] = $regexp; - } - - /** - * {@inheritdoc} - */ - public function matches(Request $request) - { - if ($this->schemes && !in_array($request->getScheme(), $this->schemes, true)) { - return false; - } - - if ($this->methods && !in_array($request->getMethod(), $this->methods, true)) { - return false; - } - - foreach ($this->attributes as $key => $pattern) { - if (!preg_match('{'.$pattern.'}', $request->attributes->get($key))) { - return false; - } - } - - if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getPathInfo()))) { - return false; - } - - if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getHost())) { - return false; - } - - if (IpUtils::checkIp($request->getClientIp(), $this->ips)) { - return true; - } - - // Note to future implementors: add additional checks above the - // foreach above or else your check might not be run! - return 0 === count($this->ips); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/RequestMatcherInterface.php b/lib/silex/vendor/symfony/http-foundation/RequestMatcherInterface.php deleted file mode 100644 index c26db3e6f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/RequestMatcherInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * RequestMatcherInterface is an interface for strategies to match a Request. - * - * @author Fabien Potencier - */ -interface RequestMatcherInterface -{ - /** - * Decides whether the rule(s) implemented by the strategy matches the supplied request. - * - * @return bool true if the request matches, false otherwise - */ - public function matches(Request $request); -} diff --git a/lib/silex/vendor/symfony/http-foundation/RequestStack.php b/lib/silex/vendor/symfony/http-foundation/RequestStack.php deleted file mode 100644 index 3d9cfd0c6..000000000 --- a/lib/silex/vendor/symfony/http-foundation/RequestStack.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Request stack that controls the lifecycle of requests. - * - * @author Benjamin Eberlei - */ -class RequestStack -{ - /** - * @var Request[] - */ - private $requests = array(); - - /** - * Pushes a Request on the stack. - * - * This method should generally not be called directly as the stack - * management should be taken care of by the application itself. - */ - public function push(Request $request) - { - $this->requests[] = $request; - } - - /** - * Pops the current request from the stack. - * - * This operation lets the current request go out of scope. - * - * This method should generally not be called directly as the stack - * management should be taken care of by the application itself. - * - * @return Request|null - */ - public function pop() - { - if (!$this->requests) { - return; - } - - return array_pop($this->requests); - } - - /** - * @return Request|null - */ - public function getCurrentRequest() - { - return end($this->requests) ?: null; - } - - /** - * Gets the master Request. - * - * Be warned that making your code aware of the master request - * might make it un-compatible with other features of your framework - * like ESI support. - * - * @return Request|null - */ - public function getMasterRequest() - { - if (!$this->requests) { - return; - } - - return $this->requests[0]; - } - - /** - * Returns the parent request of the current. - * - * Be warned that making your code aware of the parent request - * might make it un-compatible with other features of your framework - * like ESI support. - * - * If current Request is the master request, it returns null. - * - * @return Request|null - */ - public function getParentRequest() - { - $pos = count($this->requests) - 2; - - if (!isset($this->requests[$pos])) { - return; - } - - return $this->requests[$pos]; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Response.php b/lib/silex/vendor/symfony/http-foundation/Response.php deleted file mode 100644 index cf1325afe..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Response.php +++ /dev/null @@ -1,1298 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Response represents an HTTP response. - * - * @author Fabien Potencier - */ -class Response -{ - const HTTP_CONTINUE = 100; - const HTTP_SWITCHING_PROTOCOLS = 101; - const HTTP_PROCESSING = 102; // RFC2518 - const HTTP_OK = 200; - const HTTP_CREATED = 201; - const HTTP_ACCEPTED = 202; - const HTTP_NON_AUTHORITATIVE_INFORMATION = 203; - const HTTP_NO_CONTENT = 204; - const HTTP_RESET_CONTENT = 205; - const HTTP_PARTIAL_CONTENT = 206; - const HTTP_MULTI_STATUS = 207; // RFC4918 - const HTTP_ALREADY_REPORTED = 208; // RFC5842 - const HTTP_IM_USED = 226; // RFC3229 - const HTTP_MULTIPLE_CHOICES = 300; - const HTTP_MOVED_PERMANENTLY = 301; - const HTTP_FOUND = 302; - const HTTP_SEE_OTHER = 303; - const HTTP_NOT_MODIFIED = 304; - const HTTP_USE_PROXY = 305; - const HTTP_RESERVED = 306; - const HTTP_TEMPORARY_REDIRECT = 307; - const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238 - const HTTP_BAD_REQUEST = 400; - const HTTP_UNAUTHORIZED = 401; - const HTTP_PAYMENT_REQUIRED = 402; - const HTTP_FORBIDDEN = 403; - const HTTP_NOT_FOUND = 404; - const HTTP_METHOD_NOT_ALLOWED = 405; - const HTTP_NOT_ACCEPTABLE = 406; - const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; - const HTTP_REQUEST_TIMEOUT = 408; - const HTTP_CONFLICT = 409; - const HTTP_GONE = 410; - const HTTP_LENGTH_REQUIRED = 411; - const HTTP_PRECONDITION_FAILED = 412; - const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; - const HTTP_REQUEST_URI_TOO_LONG = 414; - const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; - const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; - const HTTP_EXPECTATION_FAILED = 417; - const HTTP_I_AM_A_TEAPOT = 418; // RFC2324 - const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540 - const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918 - const HTTP_LOCKED = 423; // RFC4918 - const HTTP_FAILED_DEPENDENCY = 424; // RFC4918 - const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817 - const HTTP_UPGRADE_REQUIRED = 426; // RFC2817 - const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 - const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 - const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 - const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; - const HTTP_INTERNAL_SERVER_ERROR = 500; - const HTTP_NOT_IMPLEMENTED = 501; - const HTTP_BAD_GATEWAY = 502; - const HTTP_SERVICE_UNAVAILABLE = 503; - const HTTP_GATEWAY_TIMEOUT = 504; - const HTTP_VERSION_NOT_SUPPORTED = 505; - const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295 - const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918 - const HTTP_LOOP_DETECTED = 508; // RFC5842 - const HTTP_NOT_EXTENDED = 510; // RFC2774 - const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585 - - /** - * @var \Symfony\Component\HttpFoundation\ResponseHeaderBag - */ - public $headers; - - /** - * @var string - */ - protected $content; - - /** - * @var string - */ - protected $version; - - /** - * @var int - */ - protected $statusCode; - - /** - * @var string - */ - protected $statusText; - - /** - * @var string - */ - protected $charset; - - /** - * Status codes translation table. - * - * The list of codes is complete according to the - * {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry} - * (last updated 2016-03-01). - * - * Unless otherwise noted, the status code is defined in RFC2616. - * - * @var array - */ - public static $statusTexts = array( - 100 => 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', // RFC2518 - 103 => 'Early Hints', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', // RFC4918 - 208 => 'Already Reported', // RFC5842 - 226 => 'IM Used', // RFC3229 - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - 308 => 'Permanent Redirect', // RFC7238 - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Payload Too Large', - 414 => 'URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Range Not Satisfiable', - 417 => 'Expectation Failed', - 418 => 'I\'m a teapot', // RFC2324 - 421 => 'Misdirected Request', // RFC7540 - 422 => 'Unprocessable Entity', // RFC4918 - 423 => 'Locked', // RFC4918 - 424 => 'Failed Dependency', // RFC4918 - 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 - 426 => 'Upgrade Required', // RFC2817 - 428 => 'Precondition Required', // RFC6585 - 429 => 'Too Many Requests', // RFC6585 - 431 => 'Request Header Fields Too Large', // RFC6585 - 451 => 'Unavailable For Legal Reasons', // RFC7725 - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 506 => 'Variant Also Negotiates', // RFC2295 - 507 => 'Insufficient Storage', // RFC4918 - 508 => 'Loop Detected', // RFC5842 - 510 => 'Not Extended', // RFC2774 - 511 => 'Network Authentication Required', // RFC6585 - ); - - /** - * @param mixed $content The response content, see setContent() - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @throws \InvalidArgumentException When the HTTP status code is not valid - */ - public function __construct($content = '', $status = 200, $headers = array()) - { - $this->headers = new ResponseHeaderBag($headers); - $this->setContent($content); - $this->setStatusCode($status); - $this->setProtocolVersion('1.0'); - } - - /** - * Factory method for chainability. - * - * Example: - * - * return Response::create($body, 200) - * ->setSharedMaxAge(300); - * - * @param mixed $content The response content, see setContent() - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return static - */ - public static function create($content = '', $status = 200, $headers = array()) - { - return new static($content, $status, $headers); - } - - /** - * Returns the Response as an HTTP string. - * - * The string representation of the Response is the same as the - * one that will be sent to the client only if the prepare() method - * has been called before. - * - * @return string The Response as an HTTP string - * - * @see prepare() - */ - public function __toString() - { - return - sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n". - $this->headers."\r\n". - $this->getContent(); - } - - /** - * Clones the current Response instance. - */ - public function __clone() - { - $this->headers = clone $this->headers; - } - - /** - * Prepares the Response before it is sent to the client. - * - * This method tweaks the Response to ensure that it is - * compliant with RFC 2616. Most of the changes are based on - * the Request that is "associated" with this Response. - * - * @return $this - */ - public function prepare(Request $request) - { - $headers = $this->headers; - - if ($this->isInformational() || $this->isEmpty()) { - $this->setContent(null); - $headers->remove('Content-Type'); - $headers->remove('Content-Length'); - } else { - // Content-type based on the Request - if (!$headers->has('Content-Type')) { - $format = $request->getRequestFormat(); - if (null !== $format && $mimeType = $request->getMimeType($format)) { - $headers->set('Content-Type', $mimeType); - } - } - - // Fix Content-Type - $charset = $this->charset ?: 'UTF-8'; - if (!$headers->has('Content-Type')) { - $headers->set('Content-Type', 'text/html; charset='.$charset); - } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { - // add the charset - $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); - } - - // Fix Content-Length - if ($headers->has('Transfer-Encoding')) { - $headers->remove('Content-Length'); - } - - if ($request->isMethod('HEAD')) { - // cf. RFC2616 14.13 - $length = $headers->get('Content-Length'); - $this->setContent(null); - if ($length) { - $headers->set('Content-Length', $length); - } - } - } - - // Fix protocol - if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { - $this->setProtocolVersion('1.1'); - } - - // Check if we need to send extra expire info headers - if ('1.0' == $this->getProtocolVersion() && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) { - $this->headers->set('pragma', 'no-cache'); - $this->headers->set('expires', -1); - } - - $this->ensureIEOverSSLCompatibility($request); - - return $this; - } - - /** - * Sends HTTP headers. - * - * @return $this - */ - public function sendHeaders() - { - // headers have already been sent by the developer - if (headers_sent()) { - return $this; - } - - // headers - foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) { - foreach ($values as $value) { - header($name.': '.$value, false, $this->statusCode); - } - } - - // status - header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode); - - // cookies - foreach ($this->headers->getCookies() as $cookie) { - if ($cookie->isRaw()) { - setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } else { - setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - } - - return $this; - } - - /** - * Sends content for the current web response. - * - * @return $this - */ - public function sendContent() - { - echo $this->content; - - return $this; - } - - /** - * Sends HTTP headers and content. - * - * @return $this - */ - public function send() - { - $this->sendHeaders(); - $this->sendContent(); - - if (function_exists('fastcgi_finish_request')) { - fastcgi_finish_request(); - } elseif ('cli' !== PHP_SAPI) { - static::closeOutputBuffers(0, true); - } - - return $this; - } - - /** - * Sets the response content. - * - * Valid types are strings, numbers, null, and objects that implement a __toString() method. - * - * @param mixed $content Content that can be cast to string - * - * @return $this - * - * @throws \UnexpectedValueException - */ - public function setContent($content) - { - if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) { - throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content))); - } - - $this->content = (string) $content; - - return $this; - } - - /** - * Gets the current response content. - * - * @return string Content - */ - public function getContent() - { - return $this->content; - } - - /** - * Sets the HTTP protocol version (1.0 or 1.1). - * - * @param string $version The HTTP protocol version - * - * @return $this - * - * @final since version 3.2 - */ - public function setProtocolVersion($version) - { - $this->version = $version; - - return $this; - } - - /** - * Gets the HTTP protocol version. - * - * @return string The HTTP protocol version - * - * @final since version 3.2 - */ - public function getProtocolVersion() - { - return $this->version; - } - - /** - * Sets the response status code. - * - * If the status text is null it will be automatically populated for the known - * status codes and left empty otherwise. - * - * @param int $code HTTP status code - * @param mixed $text HTTP status text - * - * @return $this - * - * @throws \InvalidArgumentException When the HTTP status code is not valid - * - * @final since version 3.2 - */ - public function setStatusCode($code, $text = null) - { - $this->statusCode = $code = (int) $code; - if ($this->isInvalid()) { - throw new \InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code)); - } - - if (null === $text) { - $this->statusText = isset(self::$statusTexts[$code]) ? self::$statusTexts[$code] : 'unknown status'; - - return $this; - } - - if (false === $text) { - $this->statusText = ''; - - return $this; - } - - $this->statusText = $text; - - return $this; - } - - /** - * Retrieves the status code for the current web response. - * - * @return int Status code - * - * @final since version 3.2 - */ - public function getStatusCode() - { - return $this->statusCode; - } - - /** - * Sets the response charset. - * - * @param string $charset Character set - * - * @return $this - * - * @final since version 3.2 - */ - public function setCharset($charset) - { - $this->charset = $charset; - - return $this; - } - - /** - * Retrieves the response charset. - * - * @return string Character set - * - * @final since version 3.2 - */ - public function getCharset() - { - return $this->charset; - } - - /** - * Returns true if the response is worth caching under any circumstance. - * - * Responses marked "private" with an explicit Cache-Control directive are - * considered uncacheable. - * - * Responses with neither a freshness lifetime (Expires, max-age) nor cache - * validator (Last-Modified, ETag) are considered uncacheable. - * - * @return bool true if the response is worth caching, false otherwise - * - * @final since version 3.3 - */ - public function isCacheable() - { - if (!in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) { - return false; - } - - if ($this->headers->hasCacheControlDirective('no-store') || $this->headers->getCacheControlDirective('private')) { - return false; - } - - return $this->isValidateable() || $this->isFresh(); - } - - /** - * Returns true if the response is "fresh". - * - * Fresh responses may be served from cache without any interaction with the - * origin. A response is considered fresh when it includes a Cache-Control/max-age - * indicator or Expires header and the calculated age is less than the freshness lifetime. - * - * @return bool true if the response is fresh, false otherwise - * - * @final since version 3.3 - */ - public function isFresh() - { - return $this->getTtl() > 0; - } - - /** - * Returns true if the response includes headers that can be used to validate - * the response with the origin server using a conditional GET request. - * - * @return bool true if the response is validateable, false otherwise - * - * @final since version 3.3 - */ - public function isValidateable() - { - return $this->headers->has('Last-Modified') || $this->headers->has('ETag'); - } - - /** - * Marks the response as "private". - * - * It makes the response ineligible for serving other clients. - * - * @return $this - * - * @final since version 3.2 - */ - public function setPrivate() - { - $this->headers->removeCacheControlDirective('public'); - $this->headers->addCacheControlDirective('private'); - - return $this; - } - - /** - * Marks the response as "public". - * - * It makes the response eligible for serving other clients. - * - * @return $this - * - * @final since version 3.2 - */ - public function setPublic() - { - $this->headers->addCacheControlDirective('public'); - $this->headers->removeCacheControlDirective('private'); - - return $this; - } - - /** - * Marks the response as "immutable". - * - * @param bool $immutable enables or disables the immutable directive - * - * @return $this - * - * @final - */ - public function setImmutable($immutable = true) - { - if ($immutable) { - $this->headers->addCacheControlDirective('immutable'); - } else { - $this->headers->removeCacheControlDirective('immutable'); - } - - return $this; - } - - /** - * Returns true if the response is marked as "immutable". - * - * @return bool returns true if the response is marked as "immutable"; otherwise false - * - * @final - */ - public function isImmutable() - { - return $this->headers->hasCacheControlDirective('immutable'); - } - - /** - * Returns true if the response must be revalidated by caches. - * - * This method indicates that the response must not be served stale by a - * cache in any circumstance without first revalidating with the origin. - * When present, the TTL of the response should not be overridden to be - * greater than the value provided by the origin. - * - * @return bool true if the response must be revalidated by a cache, false otherwise - * - * @final since version 3.3 - */ - public function mustRevalidate() - { - return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->hasCacheControlDirective('proxy-revalidate'); - } - - /** - * Returns the Date header as a DateTime instance. - * - * @return \DateTime A \DateTime instance - * - * @throws \RuntimeException When the header is not parseable - * - * @final since version 3.2 - */ - public function getDate() - { - return $this->headers->getDate('Date'); - } - - /** - * Sets the Date header. - * - * @return $this - * - * @final since version 3.2 - */ - public function setDate(\DateTime $date) - { - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT'); - - return $this; - } - - /** - * Returns the age of the response. - * - * @return int The age of the response in seconds - * - * @final since version 3.2 - */ - public function getAge() - { - if (null !== $age = $this->headers->get('Age')) { - return (int) $age; - } - - return max(time() - $this->getDate()->format('U'), 0); - } - - /** - * Marks the response stale by setting the Age header to be equal to the maximum age of the response. - * - * @return $this - */ - public function expire() - { - if ($this->isFresh()) { - $this->headers->set('Age', $this->getMaxAge()); - } - - return $this; - } - - /** - * Returns the value of the Expires header as a DateTime instance. - * - * @return \DateTime|null A DateTime instance or null if the header does not exist - * - * @final since version 3.2 - */ - public function getExpires() - { - try { - return $this->headers->getDate('Expires'); - } catch (\RuntimeException $e) { - // according to RFC 2616 invalid date formats (e.g. "0" and "-1") must be treated as in the past - return \DateTime::createFromFormat(DATE_RFC2822, 'Sat, 01 Jan 00 00:00:00 +0000'); - } - } - - /** - * Sets the Expires HTTP header with a DateTime instance. - * - * Passing null as value will remove the header. - * - * @param \DateTime|null $date A \DateTime instance or null to remove the header - * - * @return $this - * - * @final since version 3.2 - */ - public function setExpires(\DateTime $date = null) - { - if (null === $date) { - $this->headers->remove('Expires'); - } else { - $date = clone $date; - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Expires', $date->format('D, d M Y H:i:s').' GMT'); - } - - return $this; - } - - /** - * Returns the number of seconds after the time specified in the response's Date - * header when the response should no longer be considered fresh. - * - * First, it checks for a s-maxage directive, then a max-age directive, and then it falls - * back on an expires header. It returns null when no maximum age can be established. - * - * @return int|null Number of seconds - * - * @final since version 3.2 - */ - public function getMaxAge() - { - if ($this->headers->hasCacheControlDirective('s-maxage')) { - return (int) $this->headers->getCacheControlDirective('s-maxage'); - } - - if ($this->headers->hasCacheControlDirective('max-age')) { - return (int) $this->headers->getCacheControlDirective('max-age'); - } - - if (null !== $this->getExpires()) { - return $this->getExpires()->format('U') - $this->getDate()->format('U'); - } - } - - /** - * Sets the number of seconds after which the response should no longer be considered fresh. - * - * This methods sets the Cache-Control max-age directive. - * - * @param int $value Number of seconds - * - * @return $this - * - * @final since version 3.2 - */ - public function setMaxAge($value) - { - $this->headers->addCacheControlDirective('max-age', $value); - - return $this; - } - - /** - * Sets the number of seconds after which the response should no longer be considered fresh by shared caches. - * - * This methods sets the Cache-Control s-maxage directive. - * - * @param int $value Number of seconds - * - * @return $this - * - * @final since version 3.2 - */ - public function setSharedMaxAge($value) - { - $this->setPublic(); - $this->headers->addCacheControlDirective('s-maxage', $value); - - return $this; - } - - /** - * Returns the response's time-to-live in seconds. - * - * It returns null when no freshness information is present in the response. - * - * When the responses TTL is <= 0, the response may not be served from cache without first - * revalidating with the origin. - * - * @return int|null The TTL in seconds - * - * @final since version 3.2 - */ - public function getTtl() - { - if (null !== $maxAge = $this->getMaxAge()) { - return $maxAge - $this->getAge(); - } - } - - /** - * Sets the response's time-to-live for shared caches. - * - * This method adjusts the Cache-Control/s-maxage directive. - * - * @param int $seconds Number of seconds - * - * @return $this - * - * @final since version 3.2 - */ - public function setTtl($seconds) - { - $this->setSharedMaxAge($this->getAge() + $seconds); - - return $this; - } - - /** - * Sets the response's time-to-live for private/client caches. - * - * This method adjusts the Cache-Control/max-age directive. - * - * @param int $seconds Number of seconds - * - * @return $this - * - * @final since version 3.2 - */ - public function setClientTtl($seconds) - { - $this->setMaxAge($this->getAge() + $seconds); - - return $this; - } - - /** - * Returns the Last-Modified HTTP header as a DateTime instance. - * - * @return \DateTime|null A DateTime instance or null if the header does not exist - * - * @throws \RuntimeException When the HTTP header is not parseable - * - * @final since version 3.2 - */ - public function getLastModified() - { - return $this->headers->getDate('Last-Modified'); - } - - /** - * Sets the Last-Modified HTTP header with a DateTime instance. - * - * Passing null as value will remove the header. - * - * @param \DateTime|null $date A \DateTime instance or null to remove the header - * - * @return $this - * - * @final since version 3.2 - */ - public function setLastModified(\DateTime $date = null) - { - if (null === $date) { - $this->headers->remove('Last-Modified'); - } else { - $date = clone $date; - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT'); - } - - return $this; - } - - /** - * Returns the literal value of the ETag HTTP header. - * - * @return string|null The ETag HTTP header or null if it does not exist - * - * @final since version 3.2 - */ - public function getEtag() - { - return $this->headers->get('ETag'); - } - - /** - * Sets the ETag value. - * - * @param string|null $etag The ETag unique identifier or null to remove the header - * @param bool $weak Whether you want a weak ETag or not - * - * @return $this - * - * @final since version 3.2 - */ - public function setEtag($etag = null, $weak = false) - { - if (null === $etag) { - $this->headers->remove('Etag'); - } else { - if (0 !== strpos($etag, '"')) { - $etag = '"'.$etag.'"'; - } - - $this->headers->set('ETag', (true === $weak ? 'W/' : '').$etag); - } - - return $this; - } - - /** - * Sets the response's cache headers (validation and/or expiration). - * - * Available options are: etag, last_modified, max_age, s_maxage, private, public and immutable. - * - * @param array $options An array of cache options - * - * @return $this - * - * @throws \InvalidArgumentException - * - * @final since version 3.3 - */ - public function setCache(array $options) - { - if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'))) { - throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff)))); - } - - if (isset($options['etag'])) { - $this->setEtag($options['etag']); - } - - if (isset($options['last_modified'])) { - $this->setLastModified($options['last_modified']); - } - - if (isset($options['max_age'])) { - $this->setMaxAge($options['max_age']); - } - - if (isset($options['s_maxage'])) { - $this->setSharedMaxAge($options['s_maxage']); - } - - if (isset($options['public'])) { - if ($options['public']) { - $this->setPublic(); - } else { - $this->setPrivate(); - } - } - - if (isset($options['private'])) { - if ($options['private']) { - $this->setPrivate(); - } else { - $this->setPublic(); - } - } - - if (isset($options['immutable'])) { - $this->setImmutable((bool) $options['immutable']); - } - - return $this; - } - - /** - * Modifies the response so that it conforms to the rules defined for a 304 status code. - * - * This sets the status, removes the body, and discards any headers - * that MUST NOT be included in 304 responses. - * - * @return $this - * - * @see http://tools.ietf.org/html/rfc2616#section-10.3.5 - * - * @final since version 3.3 - */ - public function setNotModified() - { - $this->setStatusCode(304); - $this->setContent(null); - - // remove headers that MUST NOT be included with 304 Not Modified responses - foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) { - $this->headers->remove($header); - } - - return $this; - } - - /** - * Returns true if the response includes a Vary header. - * - * @return bool true if the response includes a Vary header, false otherwise - * - * @final since version 3.2 - */ - public function hasVary() - { - return null !== $this->headers->get('Vary'); - } - - /** - * Returns an array of header names given in the Vary header. - * - * @return array An array of Vary names - * - * @final since version 3.2 - */ - public function getVary() - { - if (!$vary = $this->headers->get('Vary', null, false)) { - return array(); - } - - $ret = array(); - foreach ($vary as $item) { - $ret = array_merge($ret, preg_split('/[\s,]+/', $item)); - } - - return $ret; - } - - /** - * Sets the Vary header. - * - * @param string|array $headers - * @param bool $replace Whether to replace the actual value or not (true by default) - * - * @return $this - * - * @final since version 3.2 - */ - public function setVary($headers, $replace = true) - { - $this->headers->set('Vary', $headers, $replace); - - return $this; - } - - /** - * Determines if the Response validators (ETag, Last-Modified) match - * a conditional value specified in the Request. - * - * If the Response is not modified, it sets the status code to 304 and - * removes the actual content by calling the setNotModified() method. - * - * @return bool true if the Response validators match the Request, false otherwise - * - * @final since version 3.3 - */ - public function isNotModified(Request $request) - { - if (!$request->isMethodCacheable()) { - return false; - } - - $notModified = false; - $lastModified = $this->headers->get('Last-Modified'); - $modifiedSince = $request->headers->get('If-Modified-Since'); - - if ($etags = $request->getETags()) { - $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags); - } - - if ($modifiedSince && $lastModified) { - $notModified = strtotime($modifiedSince) >= strtotime($lastModified) && (!$etags || $notModified); - } - - if ($notModified) { - $this->setNotModified(); - } - - return $notModified; - } - - /** - * Is response invalid? - * - * @return bool - * - * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - * - * @final since version 3.2 - */ - public function isInvalid() - { - return $this->statusCode < 100 || $this->statusCode >= 600; - } - - /** - * Is response informative? - * - * @return bool - * - * @final since version 3.3 - */ - public function isInformational() - { - return $this->statusCode >= 100 && $this->statusCode < 200; - } - - /** - * Is response successful? - * - * @return bool - * - * @final since version 3.2 - */ - public function isSuccessful() - { - return $this->statusCode >= 200 && $this->statusCode < 300; - } - - /** - * Is the response a redirect? - * - * @return bool - * - * @final since version 3.2 - */ - public function isRedirection() - { - return $this->statusCode >= 300 && $this->statusCode < 400; - } - - /** - * Is there a client error? - * - * @return bool - * - * @final since version 3.2 - */ - public function isClientError() - { - return $this->statusCode >= 400 && $this->statusCode < 500; - } - - /** - * Was there a server side error? - * - * @return bool - * - * @final since version 3.3 - */ - public function isServerError() - { - return $this->statusCode >= 500 && $this->statusCode < 600; - } - - /** - * Is the response OK? - * - * @return bool - * - * @final since version 3.2 - */ - public function isOk() - { - return 200 === $this->statusCode; - } - - /** - * Is the response forbidden? - * - * @return bool - * - * @final since version 3.2 - */ - public function isForbidden() - { - return 403 === $this->statusCode; - } - - /** - * Is the response a not found error? - * - * @return bool - * - * @final since version 3.2 - */ - public function isNotFound() - { - return 404 === $this->statusCode; - } - - /** - * Is the response a redirect of some form? - * - * @param string $location - * - * @return bool - * - * @final since version 3.2 - */ - public function isRedirect($location = null) - { - return in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location')); - } - - /** - * Is the response empty? - * - * @return bool - * - * @final since version 3.2 - */ - public function isEmpty() - { - return in_array($this->statusCode, array(204, 304)); - } - - /** - * Cleans or flushes output buffers up to target level. - * - * Resulting level can be greater than target level if a non-removable buffer has been encountered. - * - * @param int $targetLevel The target output buffering level - * @param bool $flush Whether to flush or clean the buffers - * - * @final since version 3.3 - */ - public static function closeOutputBuffers($targetLevel, $flush) - { - $status = ob_get_status(true); - $level = count($status); - // PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3 - $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; - - while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) { - if ($flush) { - ob_end_flush(); - } else { - ob_end_clean(); - } - } - } - - /** - * Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9. - * - * @see http://support.microsoft.com/kb/323308 - * - * @final since version 3.3 - */ - protected function ensureIEOverSSLCompatibility(Request $request) - { - if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) { - if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) { - $this->headers->remove('Cache-Control'); - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/ResponseHeaderBag.php b/lib/silex/vendor/symfony/http-foundation/ResponseHeaderBag.php deleted file mode 100644 index 11a859326..000000000 --- a/lib/silex/vendor/symfony/http-foundation/ResponseHeaderBag.php +++ /dev/null @@ -1,340 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ResponseHeaderBag is a container for Response HTTP headers. - * - * @author Fabien Potencier - */ -class ResponseHeaderBag extends HeaderBag -{ - const COOKIES_FLAT = 'flat'; - const COOKIES_ARRAY = 'array'; - - const DISPOSITION_ATTACHMENT = 'attachment'; - const DISPOSITION_INLINE = 'inline'; - - protected $computedCacheControl = array(); - protected $cookies = array(); - protected $headerNames = array(); - - public function __construct(array $headers = array()) - { - parent::__construct($headers); - - if (!isset($this->headers['cache-control'])) { - $this->set('Cache-Control', ''); - } - - /* RFC2616 - 14.18 says all Responses need to have a Date */ - if (!isset($this->headers['date'])) { - $this->initDate(); - } - } - - /** - * Returns the headers, with original capitalizations. - * - * @return array An array of headers - */ - public function allPreserveCase() - { - $headers = array(); - foreach ($this->all() as $name => $value) { - $headers[isset($this->headerNames[$name]) ? $this->headerNames[$name] : $name] = $value; - } - - return $headers; - } - - public function allPreserveCaseWithoutCookies() - { - $headers = $this->allPreserveCase(); - if (isset($this->headerNames['set-cookie'])) { - unset($headers[$this->headerNames['set-cookie']]); - } - - return $headers; - } - - /** - * {@inheritdoc} - */ - public function replace(array $headers = array()) - { - $this->headerNames = array(); - - parent::replace($headers); - - if (!isset($this->headers['cache-control'])) { - $this->set('Cache-Control', ''); - } - - if (!isset($this->headers['date'])) { - $this->initDate(); - } - } - - /** - * {@inheritdoc} - */ - public function all() - { - $headers = parent::all(); - foreach ($this->getCookies() as $cookie) { - $headers['set-cookie'][] = (string) $cookie; - } - - return $headers; - } - - /** - * {@inheritdoc} - */ - public function set($key, $values, $replace = true) - { - $uniqueKey = str_replace('_', '-', strtolower($key)); - - if ('set-cookie' === $uniqueKey) { - if ($replace) { - $this->cookies = array(); - } - foreach ((array) $values as $cookie) { - $this->setCookie(Cookie::fromString($cookie)); - } - $this->headerNames[$uniqueKey] = $key; - - return; - } - - $this->headerNames[$uniqueKey] = $key; - - parent::set($key, $values, $replace); - - // ensure the cache-control header has sensible defaults - if (\in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'), true)) { - $computed = $this->computeCacheControlValue(); - $this->headers['cache-control'] = array($computed); - $this->headerNames['cache-control'] = 'Cache-Control'; - $this->computedCacheControl = $this->parseCacheControl($computed); - } - } - - /** - * {@inheritdoc} - */ - public function remove($key) - { - $uniqueKey = str_replace('_', '-', strtolower($key)); - unset($this->headerNames[$uniqueKey]); - - if ('set-cookie' === $uniqueKey) { - $this->cookies = array(); - - return; - } - - parent::remove($key); - - if ('cache-control' === $uniqueKey) { - $this->computedCacheControl = array(); - } - - if ('date' === $uniqueKey) { - $this->initDate(); - } - } - - /** - * {@inheritdoc} - */ - public function hasCacheControlDirective($key) - { - return array_key_exists($key, $this->computedCacheControl); - } - - /** - * {@inheritdoc} - */ - public function getCacheControlDirective($key) - { - return array_key_exists($key, $this->computedCacheControl) ? $this->computedCacheControl[$key] : null; - } - - public function setCookie(Cookie $cookie) - { - $this->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; - $this->headerNames['set-cookie'] = 'Set-Cookie'; - } - - /** - * Removes a cookie from the array, but does not unset it in the browser. - * - * @param string $name - * @param string $path - * @param string $domain - */ - public function removeCookie($name, $path = '/', $domain = null) - { - if (null === $path) { - $path = '/'; - } - - unset($this->cookies[$domain][$path][$name]); - - if (empty($this->cookies[$domain][$path])) { - unset($this->cookies[$domain][$path]); - - if (empty($this->cookies[$domain])) { - unset($this->cookies[$domain]); - } - } - - if (empty($this->cookies)) { - unset($this->headerNames['set-cookie']); - } - } - - /** - * Returns an array with all cookies. - * - * @param string $format - * - * @return array - * - * @throws \InvalidArgumentException When the $format is invalid - */ - public function getCookies($format = self::COOKIES_FLAT) - { - if (!in_array($format, array(self::COOKIES_FLAT, self::COOKIES_ARRAY))) { - throw new \InvalidArgumentException(sprintf('Format "%s" invalid (%s).', $format, implode(', ', array(self::COOKIES_FLAT, self::COOKIES_ARRAY)))); - } - - if (self::COOKIES_ARRAY === $format) { - return $this->cookies; - } - - $flattenedCookies = array(); - foreach ($this->cookies as $path) { - foreach ($path as $cookies) { - foreach ($cookies as $cookie) { - $flattenedCookies[] = $cookie; - } - } - } - - return $flattenedCookies; - } - - /** - * Clears a cookie in the browser. - * - * @param string $name - * @param string $path - * @param string $domain - * @param bool $secure - * @param bool $httpOnly - */ - public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true) - { - $this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly)); - } - - /** - * Generates a HTTP Content-Disposition field-value. - * - * @param string $disposition One of "inline" or "attachment" - * @param string $filename A unicode string - * @param string $filenameFallback A string containing only ASCII characters that - * is semantically equivalent to $filename. If the filename is already ASCII, - * it can be omitted, or just copied from $filename - * - * @return string A string suitable for use as a Content-Disposition field-value - * - * @throws \InvalidArgumentException - * - * @see RFC 6266 - */ - public function makeDisposition($disposition, $filename, $filenameFallback = '') - { - if (!in_array($disposition, array(self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE))) { - throw new \InvalidArgumentException(sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE)); - } - - if ('' == $filenameFallback) { - $filenameFallback = $filename; - } - - // filenameFallback is not ASCII. - if (!preg_match('/^[\x20-\x7e]*$/', $filenameFallback)) { - throw new \InvalidArgumentException('The filename fallback must only contain ASCII characters.'); - } - - // percent characters aren't safe in fallback. - if (false !== strpos($filenameFallback, '%')) { - throw new \InvalidArgumentException('The filename fallback cannot contain the "%" character.'); - } - - // path separators aren't allowed in either. - if (false !== strpos($filename, '/') || false !== strpos($filename, '\\') || false !== strpos($filenameFallback, '/') || false !== strpos($filenameFallback, '\\')) { - throw new \InvalidArgumentException('The filename and the fallback cannot contain the "/" and "\\" characters.'); - } - - $output = sprintf('%s; filename="%s"', $disposition, str_replace('"', '\\"', $filenameFallback)); - - if ($filename !== $filenameFallback) { - $output .= sprintf("; filename*=utf-8''%s", rawurlencode($filename)); - } - - return $output; - } - - /** - * Returns the calculated value of the cache-control header. - * - * This considers several other headers and calculates or modifies the - * cache-control header to a sensible, conservative value. - * - * @return string - */ - protected function computeCacheControlValue() - { - if (!$this->cacheControl && !$this->has('ETag') && !$this->has('Last-Modified') && !$this->has('Expires')) { - return 'no-cache, private'; - } - - if (!$this->cacheControl) { - // conservative by default - return 'private, must-revalidate'; - } - - $header = $this->getCacheControlHeader(); - if (isset($this->cacheControl['public']) || isset($this->cacheControl['private'])) { - return $header; - } - - // public if s-maxage is defined, private otherwise - if (!isset($this->cacheControl['s-maxage'])) { - return $header.', private'; - } - - return $header; - } - - private function initDate() - { - $now = \DateTime::createFromFormat('U', time()); - $now->setTimezone(new \DateTimeZone('UTC')); - $this->set('Date', $now->format('D, d M Y H:i:s').' GMT'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/ServerBag.php b/lib/silex/vendor/symfony/http-foundation/ServerBag.php deleted file mode 100644 index 19d2022ef..000000000 --- a/lib/silex/vendor/symfony/http-foundation/ServerBag.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ServerBag is a container for HTTP headers from the $_SERVER variable. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - * @author Robert Kiss - */ -class ServerBag extends ParameterBag -{ - /** - * Gets the HTTP headers. - * - * @return array - */ - public function getHeaders() - { - $headers = array(); - $contentHeaders = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); - foreach ($this->parameters as $key => $value) { - if (0 === strpos($key, 'HTTP_')) { - $headers[substr($key, 5)] = $value; - } - // CONTENT_* are not prefixed with HTTP_ - elseif (isset($contentHeaders[$key])) { - $headers[$key] = $value; - } - } - - if (isset($this->parameters['PHP_AUTH_USER'])) { - $headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER']; - $headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : ''; - } else { - /* - * php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default - * For this workaround to work, add these lines to your .htaccess file: - * RewriteCond %{HTTP:Authorization} ^(.+)$ - * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - * - * A sample .htaccess file: - * RewriteEngine On - * RewriteCond %{HTTP:Authorization} ^(.+)$ - * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - * RewriteCond %{REQUEST_FILENAME} !-f - * RewriteRule ^(.*)$ app.php [QSA,L] - */ - - $authorizationHeader = null; - if (isset($this->parameters['HTTP_AUTHORIZATION'])) { - $authorizationHeader = $this->parameters['HTTP_AUTHORIZATION']; - } elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) { - $authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION']; - } - - if (null !== $authorizationHeader) { - if (0 === stripos($authorizationHeader, 'basic ')) { - // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic - $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2); - if (2 == count($exploded)) { - list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; - } - } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) { - // In some circumstances PHP_AUTH_DIGEST needs to be set - $headers['PHP_AUTH_DIGEST'] = $authorizationHeader; - $this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader; - } elseif (0 === stripos($authorizationHeader, 'bearer ')) { - /* - * XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables, - * I'll just set $headers['AUTHORIZATION'] here. - * http://php.net/manual/en/reserved.variables.server.php - */ - $headers['AUTHORIZATION'] = $authorizationHeader; - } - } - } - - if (isset($headers['AUTHORIZATION'])) { - return $headers; - } - - // PHP_AUTH_USER/PHP_AUTH_PW - if (isset($headers['PHP_AUTH_USER'])) { - $headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']); - } elseif (isset($headers['PHP_AUTH_DIGEST'])) { - $headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST']; - } - - return $headers; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php b/lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php deleted file mode 100644 index ea1fda290..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Attribute; - -/** - * This class relates to session attribute storage. - */ -class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable -{ - private $name = 'attributes'; - private $storageKey; - - protected $attributes = array(); - - /** - * @param string $storageKey The key used to store attributes in the session - */ - public function __construct($storageKey = '_sf2_attributes') - { - $this->storageKey = $storageKey; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$attributes) - { - $this->attributes = &$attributes; - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - return array_key_exists($name, $this->attributes); - } - - /** - * {@inheritdoc} - */ - public function get($name, $default = null) - { - return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default; - } - - /** - * {@inheritdoc} - */ - public function set($name, $value) - { - $this->attributes[$name] = $value; - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->attributes; - } - - /** - * {@inheritdoc} - */ - public function replace(array $attributes) - { - $this->attributes = array(); - foreach ($attributes as $key => $value) { - $this->set($key, $value); - } - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - $retval = null; - if (array_key_exists($name, $this->attributes)) { - $retval = $this->attributes[$name]; - unset($this->attributes[$name]); - } - - return $retval; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $return = $this->attributes; - $this->attributes = array(); - - return $return; - } - - /** - * Returns an iterator for attributes. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->attributes); - } - - /** - * Returns the number of attributes. - * - * @return int The number of attributes - */ - public function count() - { - return count($this->attributes); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php b/lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php deleted file mode 100644 index 0d8d17991..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Attribute; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * Attributes store. - * - * @author Drak - */ -interface AttributeBagInterface extends SessionBagInterface -{ - /** - * Checks if an attribute is defined. - * - * @param string $name The attribute name - * - * @return bool true if the attribute is defined, false otherwise - */ - public function has($name); - - /** - * Returns an attribute. - * - * @param string $name The attribute name - * @param mixed $default The default value if not found - * - * @return mixed - */ - public function get($name, $default = null); - - /** - * Sets an attribute. - * - * @param string $name - * @param mixed $value - */ - public function set($name, $value); - - /** - * Returns attributes. - * - * @return array Attributes - */ - public function all(); - - /** - * Sets attributes. - * - * @param array $attributes Attributes - */ - public function replace(array $attributes); - - /** - * Removes an attribute. - * - * @param string $name - * - * @return mixed The removed value or null when it does not exist - */ - public function remove($name); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php b/lib/silex/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php deleted file mode 100644 index abbf37ee7..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Attribute/NamespacedAttributeBag.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Attribute; - -/** - * This class provides structured storage of session attributes using - * a name spacing character in the key. - * - * @author Drak - */ -class NamespacedAttributeBag extends AttributeBag -{ - private $namespaceCharacter; - - /** - * @param string $storageKey Session storage key - * @param string $namespaceCharacter Namespace character to use in keys - */ - public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter = '/') - { - $this->namespaceCharacter = $namespaceCharacter; - parent::__construct($storageKey); - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - // reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is - $attributes = $this->resolveAttributePath($name); - $name = $this->resolveKey($name); - - if (null === $attributes) { - return false; - } - - return array_key_exists($name, $attributes); - } - - /** - * {@inheritdoc} - */ - public function get($name, $default = null) - { - // reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is - $attributes = $this->resolveAttributePath($name); - $name = $this->resolveKey($name); - - if (null === $attributes) { - return $default; - } - - return array_key_exists($name, $attributes) ? $attributes[$name] : $default; - } - - /** - * {@inheritdoc} - */ - public function set($name, $value) - { - $attributes = &$this->resolveAttributePath($name, true); - $name = $this->resolveKey($name); - $attributes[$name] = $value; - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - $retval = null; - $attributes = &$this->resolveAttributePath($name); - $name = $this->resolveKey($name); - if (null !== $attributes && array_key_exists($name, $attributes)) { - $retval = $attributes[$name]; - unset($attributes[$name]); - } - - return $retval; - } - - /** - * Resolves a path in attributes property and returns it as a reference. - * - * This method allows structured namespacing of session attributes. - * - * @param string $name Key name - * @param bool $writeContext Write context, default false - * - * @return array - */ - protected function &resolveAttributePath($name, $writeContext = false) - { - $array = &$this->attributes; - $name = (0 === strpos($name, $this->namespaceCharacter)) ? substr($name, 1) : $name; - - // Check if there is anything to do, else return - if (!$name) { - return $array; - } - - $parts = explode($this->namespaceCharacter, $name); - if (count($parts) < 2) { - if (!$writeContext) { - return $array; - } - - $array[$parts[0]] = array(); - - return $array; - } - - unset($parts[count($parts) - 1]); - - foreach ($parts as $part) { - if (null !== $array && !array_key_exists($part, $array)) { - $array[$part] = $writeContext ? array() : null; - } - - $array = &$array[$part]; - } - - return $array; - } - - /** - * Resolves the key from the name. - * - * This is the last part in a dot separated string. - * - * @param string $name - * - * @return string - */ - protected function resolveKey($name) - { - if (false !== $pos = strrpos($name, $this->namespaceCharacter)) { - $name = substr($name, $pos + 1); - } - - return $name; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php b/lib/silex/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php deleted file mode 100644 index 77521c247..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Flash/AutoExpireFlashBag.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Flash; - -/** - * AutoExpireFlashBag flash message container. - * - * @author Drak - */ -class AutoExpireFlashBag implements FlashBagInterface -{ - private $name = 'flashes'; - private $flashes = array('display' => array(), 'new' => array()); - private $storageKey; - - /** - * @param string $storageKey The key used to store flashes in the session - */ - public function __construct($storageKey = '_symfony_flashes') - { - $this->storageKey = $storageKey; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$flashes) - { - $this->flashes = &$flashes; - - // The logic: messages from the last request will be stored in new, so we move them to previous - // This request we will show what is in 'display'. What is placed into 'new' this time round will - // be moved to display next time round. - $this->flashes['display'] = array_key_exists('new', $this->flashes) ? $this->flashes['new'] : array(); - $this->flashes['new'] = array(); - } - - /** - * {@inheritdoc} - */ - public function add($type, $message) - { - $this->flashes['new'][$type][] = $message; - } - - /** - * {@inheritdoc} - */ - public function peek($type, array $default = array()) - { - return $this->has($type) ? $this->flashes['display'][$type] : $default; - } - - /** - * {@inheritdoc} - */ - public function peekAll() - { - return array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : array(); - } - - /** - * {@inheritdoc} - */ - public function get($type, array $default = array()) - { - $return = $default; - - if (!$this->has($type)) { - return $return; - } - - if (isset($this->flashes['display'][$type])) { - $return = $this->flashes['display'][$type]; - unset($this->flashes['display'][$type]); - } - - return $return; - } - - /** - * {@inheritdoc} - */ - public function all() - { - $return = $this->flashes['display']; - $this->flashes['display'] = array(); - - return $return; - } - - /** - * {@inheritdoc} - */ - public function setAll(array $messages) - { - $this->flashes['new'] = $messages; - } - - /** - * {@inheritdoc} - */ - public function set($type, $messages) - { - $this->flashes['new'][$type] = (array) $messages; - } - - /** - * {@inheritdoc} - */ - public function has($type) - { - return array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type]; - } - - /** - * {@inheritdoc} - */ - public function keys() - { - return array_keys($this->flashes['display']); - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - return $this->all(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBag.php b/lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBag.php deleted file mode 100644 index 12fb740c5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBag.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Flash; - -/** - * FlashBag flash message container. - * - * @author Drak - */ -class FlashBag implements FlashBagInterface -{ - private $name = 'flashes'; - private $flashes = array(); - private $storageKey; - - /** - * @param string $storageKey The key used to store flashes in the session - */ - public function __construct($storageKey = '_symfony_flashes') - { - $this->storageKey = $storageKey; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$flashes) - { - $this->flashes = &$flashes; - } - - /** - * {@inheritdoc} - */ - public function add($type, $message) - { - $this->flashes[$type][] = $message; - } - - /** - * {@inheritdoc} - */ - public function peek($type, array $default = array()) - { - return $this->has($type) ? $this->flashes[$type] : $default; - } - - /** - * {@inheritdoc} - */ - public function peekAll() - { - return $this->flashes; - } - - /** - * {@inheritdoc} - */ - public function get($type, array $default = array()) - { - if (!$this->has($type)) { - return $default; - } - - $return = $this->flashes[$type]; - - unset($this->flashes[$type]); - - return $return; - } - - /** - * {@inheritdoc} - */ - public function all() - { - $return = $this->peekAll(); - $this->flashes = array(); - - return $return; - } - - /** - * {@inheritdoc} - */ - public function set($type, $messages) - { - $this->flashes[$type] = (array) $messages; - } - - /** - * {@inheritdoc} - */ - public function setAll(array $messages) - { - $this->flashes = $messages; - } - - /** - * {@inheritdoc} - */ - public function has($type) - { - return array_key_exists($type, $this->flashes) && $this->flashes[$type]; - } - - /** - * {@inheritdoc} - */ - public function keys() - { - return array_keys($this->flashes); - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - return $this->all(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBagInterface.php b/lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBagInterface.php deleted file mode 100644 index 80e97f17c..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Flash/FlashBagInterface.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Flash; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * FlashBagInterface. - * - * @author Drak - */ -interface FlashBagInterface extends SessionBagInterface -{ - /** - * Adds a flash message for type. - * - * @param string $type - * @param string $message - */ - public function add($type, $message); - - /** - * Registers a message for a given type. - * - * @param string $type - * @param string|array $message - */ - public function set($type, $message); - - /** - * Gets flash messages for a given type. - * - * @param string $type Message category type - * @param array $default Default value if $type does not exist - * - * @return array - */ - public function peek($type, array $default = array()); - - /** - * Gets all flash messages. - * - * @return array - */ - public function peekAll(); - - /** - * Gets and clears flash from the stack. - * - * @param string $type - * @param array $default Default value if $type does not exist - * - * @return array - */ - public function get($type, array $default = array()); - - /** - * Gets and clears flashes from the stack. - * - * @return array - */ - public function all(); - - /** - * Sets all flash messages. - */ - public function setAll(array $messages); - - /** - * Has flash messages for a given type? - * - * @param string $type - * - * @return bool - */ - public function has($type); - - /** - * Returns a list of all defined types. - * - * @return array - */ - public function keys(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Session.php b/lib/silex/vendor/symfony/http-foundation/Session/Session.php deleted file mode 100644 index a46cffbb8..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Session.php +++ /dev/null @@ -1,273 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * @author Fabien Potencier - * @author Drak - */ -class Session implements SessionInterface, \IteratorAggregate, \Countable -{ - protected $storage; - - private $flashName; - private $attributeName; - private $data = array(); - private $hasBeenStarted; - - /** - * @param SessionStorageInterface $storage A SessionStorageInterface instance - * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) - * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) - */ - public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) - { - $this->storage = $storage ?: new NativeSessionStorage(); - - $attributes = $attributes ?: new AttributeBag(); - $this->attributeName = $attributes->getName(); - $this->registerBag($attributes); - - $flashes = $flashes ?: new FlashBag(); - $this->flashName = $flashes->getName(); - $this->registerBag($flashes); - } - - /** - * {@inheritdoc} - */ - public function start() - { - return $this->storage->start(); - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - return $this->getAttributeBag()->has($name); - } - - /** - * {@inheritdoc} - */ - public function get($name, $default = null) - { - return $this->getAttributeBag()->get($name, $default); - } - - /** - * {@inheritdoc} - */ - public function set($name, $value) - { - $this->getAttributeBag()->set($name, $value); - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->getAttributeBag()->all(); - } - - /** - * {@inheritdoc} - */ - public function replace(array $attributes) - { - $this->getAttributeBag()->replace($attributes); - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - return $this->getAttributeBag()->remove($name); - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $this->getAttributeBag()->clear(); - } - - /** - * {@inheritdoc} - */ - public function isStarted() - { - return $this->storage->isStarted(); - } - - /** - * Returns an iterator for attributes. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->getAttributeBag()->all()); - } - - /** - * Returns the number of attributes. - * - * @return int The number of attributes - */ - public function count() - { - return count($this->getAttributeBag()->all()); - } - - /** - * @return bool - * - * @internal - */ - public function hasBeenStarted() - { - return $this->hasBeenStarted; - } - - /** - * @return bool - * - * @internal - */ - public function isEmpty() - { - foreach ($this->data as &$data) { - if (!empty($data)) { - return false; - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function invalidate($lifetime = null) - { - $this->storage->clear(); - - return $this->migrate(true, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function migrate($destroy = false, $lifetime = null) - { - return $this->storage->regenerate($destroy, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function save() - { - $this->storage->save(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->storage->getId(); - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - $this->storage->setId($id); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->storage->getName(); - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->storage->setName($name); - } - - /** - * {@inheritdoc} - */ - public function getMetadataBag() - { - return $this->storage->getMetadataBag(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->hasBeenStarted)); - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - return $this->storage->getBag($name)->getBag(); - } - - /** - * Gets the flashbag interface. - * - * @return FlashBagInterface - */ - public function getFlashBag() - { - return $this->getBag($this->flashName); - } - - /** - * Gets the attributebag interface. - * - * Note that this method was added to help with IDE autocompletion. - * - * @return AttributeBagInterface - */ - private function getAttributeBag() - { - return $this->getBag($this->attributeName); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/SessionBagInterface.php b/lib/silex/vendor/symfony/http-foundation/Session/SessionBagInterface.php deleted file mode 100644 index 8e37d06d6..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/SessionBagInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -/** - * Session Bag store. - * - * @author Drak - */ -interface SessionBagInterface -{ - /** - * Gets this bag's name. - * - * @return string - */ - public function getName(); - - /** - * Initializes the Bag. - */ - public function initialize(array &$array); - - /** - * Gets the storage key for this bag. - * - * @return string - */ - public function getStorageKey(); - - /** - * Clears out data from bag. - * - * @return mixed Whatever data was contained - */ - public function clear(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/SessionBagProxy.php b/lib/silex/vendor/symfony/http-foundation/Session/SessionBagProxy.php deleted file mode 100644 index 307836d5f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/SessionBagProxy.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -/** - * @author Nicolas Grekas - * - * @internal - */ -final class SessionBagProxy implements SessionBagInterface -{ - private $bag; - private $data; - private $hasBeenStarted; - - public function __construct(SessionBagInterface $bag, array &$data, &$hasBeenStarted) - { - $this->bag = $bag; - $this->data = &$data; - $this->hasBeenStarted = &$hasBeenStarted; - } - - /** - * @return SessionBagInterface - */ - public function getBag() - { - return $this->bag; - } - - /** - * @return bool - */ - public function isEmpty() - { - return empty($this->data[$this->bag->getStorageKey()]); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->bag->getName(); - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$array) - { - $this->hasBeenStarted = true; - $this->data[$this->bag->getStorageKey()] = &$array; - - $this->bag->initialize($array); - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->bag->getStorageKey(); - } - - /** - * {@inheritdoc} - */ - public function clear() - { - return $this->bag->clear(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/SessionInterface.php b/lib/silex/vendor/symfony/http-foundation/Session/SessionInterface.php deleted file mode 100644 index 95fca857e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/SessionInterface.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; - -/** - * Interface for the session. - * - * @author Drak - */ -interface SessionInterface -{ - /** - * Starts the session storage. - * - * @return bool True if session started - * - * @throws \RuntimeException if session fails to start - */ - public function start(); - - /** - * Returns the session ID. - * - * @return string The session ID - */ - public function getId(); - - /** - * Sets the session ID. - * - * @param string $id - */ - public function setId($id); - - /** - * Returns the session name. - * - * @return mixed The session name - */ - public function getName(); - - /** - * Sets the session name. - * - * @param string $name - */ - public function setName($name); - - /** - * Invalidates the current session. - * - * Clears all session attributes and flashes and regenerates the - * session and deletes the old session from persistence. - * - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return bool True if session invalidated, false if error - */ - public function invalidate($lifetime = null); - - /** - * Migrates the current session to a new session id while maintaining all - * session attributes. - * - * @param bool $destroy Whether to delete the old session or leave it to garbage collection - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return bool True if session migrated, false if error - */ - public function migrate($destroy = false, $lifetime = null); - - /** - * Force the session to be saved and closed. - * - * This method is generally not required for real sessions as - * the session will be automatically saved at the end of - * code execution. - */ - public function save(); - - /** - * Checks if an attribute is defined. - * - * @param string $name The attribute name - * - * @return bool true if the attribute is defined, false otherwise - */ - public function has($name); - - /** - * Returns an attribute. - * - * @param string $name The attribute name - * @param mixed $default The default value if not found - * - * @return mixed - */ - public function get($name, $default = null); - - /** - * Sets an attribute. - * - * @param string $name - * @param mixed $value - */ - public function set($name, $value); - - /** - * Returns attributes. - * - * @return array Attributes - */ - public function all(); - - /** - * Sets attributes. - * - * @param array $attributes Attributes - */ - public function replace(array $attributes); - - /** - * Removes an attribute. - * - * @param string $name - * - * @return mixed The removed value or null when it does not exist - */ - public function remove($name); - - /** - * Clears all attributes. - */ - public function clear(); - - /** - * Checks if the session was started. - * - * @return bool - */ - public function isStarted(); - - /** - * Registers a SessionBagInterface with the session. - */ - public function registerBag(SessionBagInterface $bag); - - /** - * Gets a bag instance by name. - * - * @param string $name - * - * @return SessionBagInterface - */ - public function getBag($name); - - /** - * Gets session meta. - * - * @return MetadataBag - */ - public function getMetadataBag(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php deleted file mode 100644 index 6ae135581..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/AbstractSessionHandler.php +++ /dev/null @@ -1,168 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * This abstract session handler provides a generic implementation - * of the PHP 7.0 SessionUpdateTimestampHandlerInterface, - * enabling strict and lazy session handling. - * - * @author Nicolas Grekas - */ -abstract class AbstractSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface -{ - private $sessionName; - private $prefetchId; - private $prefetchData; - private $newSessionId; - private $igbinaryEmptyData; - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - $this->sessionName = $sessionName; - if (!headers_sent() && !ini_get('session.cache_limiter') && '0' !== ini_get('session.cache_limiter')) { - header(sprintf('Cache-Control: max-age=%d, private, must-revalidate', 60 * (int) ini_get('session.cache_expire'))); - } - - return true; - } - - /** - * @param string $sessionId - * - * @return string - */ - abstract protected function doRead($sessionId); - - /** - * @param string $sessionId - * @param string $data - * - * @return bool - */ - abstract protected function doWrite($sessionId, $data); - - /** - * @param string $sessionId - * - * @return bool - */ - abstract protected function doDestroy($sessionId); - - /** - * {@inheritdoc} - */ - public function validateId($sessionId) - { - $this->prefetchData = $this->read($sessionId); - $this->prefetchId = $sessionId; - - return '' !== $this->prefetchData; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - if (null !== $this->prefetchId) { - $prefetchId = $this->prefetchId; - $prefetchData = $this->prefetchData; - $this->prefetchId = $this->prefetchData = null; - - if ($prefetchId === $sessionId || '' === $prefetchData) { - $this->newSessionId = '' === $prefetchData ? $sessionId : null; - - return $prefetchData; - } - } - - $data = $this->doRead($sessionId); - $this->newSessionId = '' === $data ? $sessionId : null; - if (\PHP_VERSION_ID < 70000) { - $this->prefetchData = $data; - } - - return $data; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - if (\PHP_VERSION_ID < 70000 && $this->prefetchData) { - $readData = $this->prefetchData; - $this->prefetchData = null; - - if ($readData === $data) { - return $this->updateTimestamp($sessionId, $data); - } - } - if (null === $this->igbinaryEmptyData) { - // see https://github.com/igbinary/igbinary/issues/146 - $this->igbinaryEmptyData = \function_exists('igbinary_serialize') ? igbinary_serialize(array()) : ''; - } - if ('' === $data || $this->igbinaryEmptyData === $data) { - return $this->destroy($sessionId); - } - $this->newSessionId = null; - - return $this->doWrite($sessionId, $data); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - if (\PHP_VERSION_ID < 70000) { - $this->prefetchData = null; - } - if (!headers_sent() && ini_get('session.use_cookies')) { - if (!$this->sessionName) { - throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', get_class($this))); - } - $sessionCookie = sprintf(' %s=', urlencode($this->sessionName)); - $sessionCookieWithId = sprintf('%s%s;', $sessionCookie, urlencode($sessionId)); - $sessionCookieFound = false; - $otherCookies = array(); - foreach (headers_list() as $h) { - if (0 !== stripos($h, 'Set-Cookie:')) { - continue; - } - if (11 === strpos($h, $sessionCookie, 11)) { - $sessionCookieFound = true; - - if (11 !== strpos($h, $sessionCookieWithId, 11)) { - $otherCookies[] = $h; - } - } else { - $otherCookies[] = $h; - } - } - if ($sessionCookieFound) { - header_remove('Set-Cookie'); - foreach ($otherCookies as $h) { - header($h, false); - } - } else { - setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly')); - } - } - - return $this->newSessionId === $sessionId || $this->doDestroy($sessionId); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php deleted file mode 100644 index 90726beb0..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcacheSessionHandler.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -@trigger_error(sprintf('The class %s is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler instead.', MemcacheSessionHandler::class), E_USER_DEPRECATED); - -/** - * @author Drak - * - * @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler instead. - */ -class MemcacheSessionHandler implements \SessionHandlerInterface -{ - private $memcache; - - /** - * @var int Time to live in seconds - */ - private $ttl; - - /** - * @var string Key prefix for shared environments - */ - private $prefix; - - /** - * Constructor. - * - * List of available options: - * * prefix: The prefix to use for the memcache keys in order to avoid collision - * * expiretime: The time to live in seconds - * - * @param \Memcache $memcache A \Memcache instance - * @param array $options An associative array of Memcache options - * - * @throws \InvalidArgumentException When unsupported options are passed - */ - public function __construct(\Memcache $memcache, array $options = array()) - { - if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime'))) { - throw new \InvalidArgumentException(sprintf( - 'The following options are not supported "%s"', implode(', ', $diff) - )); - } - - $this->memcache = $memcache; - $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400; - $this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s'; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return $this->memcache->get($this->prefix.$sessionId) ?: ''; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return $this->memcache->set($this->prefix.$sessionId, $data, 0, time() + $this->ttl); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - $this->memcache->delete($this->prefix.$sessionId); - - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // not required here because memcache will auto expire the records anyhow. - return true; - } - - /** - * Return a Memcache instance. - * - * @return \Memcache - */ - protected function getMemcache() - { - return $this->memcache; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php deleted file mode 100644 index 9f4ef7028..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Memcached based session storage handler based on the Memcached class - * provided by the PHP memcached extension. - * - * @see http://php.net/memcached - * - * @author Drak - */ -class MemcachedSessionHandler extends AbstractSessionHandler -{ - private $memcached; - - /** - * @var int Time to live in seconds - */ - private $ttl; - - /** - * @var string Key prefix for shared environments - */ - private $prefix; - - /** - * Constructor. - * - * List of available options: - * * prefix: The prefix to use for the memcached keys in order to avoid collision - * * expiretime: The time to live in seconds. - * - * @param \Memcached $memcached A \Memcached instance - * @param array $options An associative array of Memcached options - * - * @throws \InvalidArgumentException When unsupported options are passed - */ - public function __construct(\Memcached $memcached, array $options = array()) - { - $this->memcached = $memcached; - - if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime'))) { - throw new \InvalidArgumentException(sprintf( - 'The following options are not supported "%s"', implode(', ', $diff) - )); - } - - $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400; - $this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s'; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - protected function doRead($sessionId) - { - return $this->memcached->get($this->prefix.$sessionId) ?: ''; - } - - /** - * {@inheritdoc} - */ - public function updateTimestamp($sessionId, $data) - { - return $this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl); - } - - /** - * {@inheritdoc} - */ - protected function doWrite($sessionId, $data) - { - return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl); - } - - /** - * {@inheritdoc} - */ - protected function doDestroy($sessionId) - { - $result = $this->memcached->delete($this->prefix.$sessionId); - - return $result || \Memcached::RES_NOTFOUND == $this->memcached->getResultCode(); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // not required here because memcached will auto expire the records anyhow. - return true; - } - - /** - * Return a Memcached instance. - * - * @return \Memcached - */ - protected function getMemcached() - { - return $this->memcached; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php deleted file mode 100644 index 7d3fa218a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ /dev/null @@ -1,255 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Session handler using the mongodb/mongodb package and MongoDB driver extension. - * - * @author Markus Bachmann - * - * @see https://packagist.org/packages/mongodb/mongodb - * @see http://php.net/manual/en/set.mongodb.php - */ -class MongoDbSessionHandler extends AbstractSessionHandler -{ - private $mongo; - - /** - * @var \MongoCollection - */ - private $collection; - - /** - * @var array - */ - private $options; - - /** - * 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] - * * expiry_field: The field name for storing the expiry-timestamp [default: expires_at]. - * - * It is strongly recommended to put an index on the `expiry_field` for - * garbage-collection. Alternatively it's possible to automatically expire - * the sessions in the database as described below: - * - * A TTL collections can be used on MongoDB 2.2+ to cleanup expired sessions - * automatically. Such an index can for example look like this: - * - * db..ensureIndex( - * { "": 1 }, - * { "expireAfterSeconds": 0 } - * ) - * - * More details on: http://docs.mongodb.org/manual/tutorial/expire-data/ - * - * If you use such an index, you can drop `gc_probability` to 0 since - * no garbage-collection is required. - * - * @param \MongoDB\Client $mongo A MongoDB\Client instance - * @param array $options An associative array of field options - * - * @throws \InvalidArgumentException When MongoClient or Mongo instance not provided - * @throws \InvalidArgumentException When "database" or "collection" not provided - */ - public function __construct($mongo, array $options) - { - if ($mongo instanceof \MongoClient || $mongo instanceof \Mongo) { - @trigger_error(sprintf('Using %s with the legacy mongo extension is deprecated as of 3.4 and will be removed in 4.0. Use it with the mongodb/mongodb package and ext-mongodb instead.', __CLASS__), E_USER_DEPRECATED); - } - - if (!($mongo instanceof \MongoDB\Client || $mongo instanceof \MongoClient || $mongo instanceof \Mongo)) { - throw new \InvalidArgumentException('MongoClient or Mongo instance required'); - } - - if (!isset($options['database']) || !isset($options['collection'])) { - throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler'); - } - - $this->mongo = $mongo; - - $this->options = array_merge(array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'expiry_field' => 'expires_at', - ), $options); - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - protected function doDestroy($sessionId) - { - $methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteOne' : 'remove'; - - $this->getCollection()->$methodName(array( - $this->options['id_field'] => $sessionId, - )); - - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - $methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteMany' : 'remove'; - - $this->getCollection()->$methodName(array( - $this->options['expiry_field'] => array('$lt' => $this->createDateTime()), - )); - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doWrite($sessionId, $data) - { - $expiry = $this->createDateTime(time() + (int) ini_get('session.gc_maxlifetime')); - - $fields = array( - $this->options['time_field'] => $this->createDateTime(), - $this->options['expiry_field'] => $expiry, - ); - - $options = array('upsert' => true); - - if ($this->mongo instanceof \MongoDB\Client) { - $fields[$this->options['data_field']] = new \MongoDB\BSON\Binary($data, \MongoDB\BSON\Binary::TYPE_OLD_BINARY); - } else { - $fields[$this->options['data_field']] = new \MongoBinData($data, \MongoBinData::BYTE_ARRAY); - $options['multiple'] = false; - } - - $methodName = $this->mongo instanceof \MongoDB\Client ? 'updateOne' : 'update'; - - $this->getCollection()->$methodName( - array($this->options['id_field'] => $sessionId), - array('$set' => $fields), - $options - ); - - return true; - } - - /** - * {@inheritdoc} - */ - public function updateTimestamp($sessionId, $data) - { - $expiry = $this->createDateTime(time() + (int) ini_get('session.gc_maxlifetime')); - - if ($this->mongo instanceof \MongoDB\Client) { - $methodName = 'updateOne'; - $options = array(); - } else { - $methodName = 'update'; - $options = array('multiple' => false); - } - - $this->getCollection()->$methodName( - array($this->options['id_field'] => $sessionId), - array('$set' => array( - $this->options['time_field'] => $this->createDateTime(), - $this->options['expiry_field'] => $expiry, - )), - $options - ); - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doRead($sessionId) - { - $dbData = $this->getCollection()->findOne(array( - $this->options['id_field'] => $sessionId, - $this->options['expiry_field'] => array('$gte' => $this->createDateTime()), - )); - - if (null === $dbData) { - return ''; - } - - if ($dbData[$this->options['data_field']] instanceof \MongoDB\BSON\Binary) { - return $dbData[$this->options['data_field']]->getData(); - } - - return $dbData[$this->options['data_field']]->bin; - } - - /** - * Return a "MongoCollection" instance. - * - * @return \MongoCollection - */ - private function getCollection() - { - if (null === $this->collection) { - $this->collection = $this->mongo->selectCollection($this->options['database'], $this->options['collection']); - } - - return $this->collection; - } - - /** - * Return a Mongo instance. - * - * @return \Mongo|\MongoClient|\MongoDB\Client - */ - protected function getMongo() - { - return $this->mongo; - } - - /** - * Create a date object using the class appropriate for the current mongo connection. - * - * Return an instance of a MongoDate or \MongoDB\BSON\UTCDateTime - * - * @param int $seconds An integer representing UTC seconds since Jan 1 1970. Defaults to now. - * - * @return \MongoDate|\MongoDB\BSON\UTCDateTime - */ - private function createDateTime($seconds = null) - { - if (null === $seconds) { - $seconds = time(); - } - - if ($this->mongo instanceof \MongoDB\Client) { - return new \MongoDB\BSON\UTCDateTime($seconds * 1000); - } - - return new \MongoDate($seconds); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php deleted file mode 100644 index 4e9704bd5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Native session handler using PHP's built in file storage. - * - * @author Drak - */ -class NativeFileSessionHandler extends NativeSessionHandler -{ - /** - * @param string $savePath Path of directory to save session files - * Default null will leave setting as defined by PHP. - * '/path', 'N;/path', or 'N;octal-mode;/path - * - * @see http://php.net/session.configuration.php#ini.session.save-path for further details. - * - * @throws \InvalidArgumentException On invalid $savePath - * @throws \RuntimeException When failing to create the save directory - */ - public function __construct($savePath = null) - { - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - $baseDir = $savePath; - - if ($count = substr_count($savePath, ';')) { - if ($count > 2) { - throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'', $savePath)); - } - - // characters after last ';' are the path - $baseDir = ltrim(strrchr($savePath, ';'), ';'); - } - - if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) { - throw new \RuntimeException(sprintf('Session Storage was not able to create directory "%s"', $baseDir)); - } - - ini_set('session.save_path', $savePath); - ini_set('session.save_handler', 'files'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php deleted file mode 100644 index 9be4528ae..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NativeSessionHandler.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * @deprecated since version 3.4, to be removed in 4.0. Use \SessionHandler instead. - * @see http://php.net/sessionhandler - */ -class NativeSessionHandler extends \SessionHandler -{ - public function __construct() - { - @trigger_error('The '.__NAMESPACE__.'\NativeSessionHandler class is deprecated since Symfony 3.4 and will be removed in 4.0. Use the \SessionHandler class instead.', E_USER_DEPRECATED); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NullSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NullSessionHandler.php deleted file mode 100644 index 8d193155b..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/NullSessionHandler.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Can be used in unit testing or in a situations where persisted sessions are not desired. - * - * @author Drak - */ -class NullSessionHandler extends AbstractSessionHandler -{ - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function validateId($sessionId) - { - return true; - } - - /** - * {@inheritdoc} - */ - protected function doRead($sessionId) - { - return ''; - } - - /** - * {@inheritdoc} - */ - public function updateTimestamp($sessionId, $data) - { - return true; - } - - /** - * {@inheritdoc} - */ - protected function doWrite($sessionId, $data) - { - return true; - } - - /** - * {@inheritdoc} - */ - protected function doDestroy($sessionId) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php deleted file mode 100644 index 2e1692b6f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php +++ /dev/null @@ -1,812 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Session handler using a PDO connection to read and write data. - * - * It works with MySQL, PostgreSQL, Oracle, SQL Server and SQLite and implements - * different locking strategies to handle concurrent access to the same session. - * Locking is necessary to prevent loss of data due to race conditions and to keep - * the session data consistent between read() and write(). With locking, requests - * for the same session will wait until the other one finished writing. For this - * reason it's best practice to close a session as early as possible to improve - * concurrency. PHPs internal files session handler also implements locking. - * - * Attention: Since SQLite does not support row level locks but locks the whole database, - * it means only one session can be accessed at a time. Even different sessions would wait - * for another to finish. So saving session in SQLite should only be considered for - * development or prototypes. - * - * Session data is a binary string that can contain non-printable characters like the null byte. - * For this reason it must be saved in a binary column in the database like BLOB in MySQL. - * Saving it in a character column could corrupt the data. You can use createTable() - * to initialize a correctly defined table. - * - * @see http://php.net/sessionhandlerinterface - * - * @author Fabien Potencier - * @author Michael Williams - * @author Tobias Schultze - */ -class PdoSessionHandler extends AbstractSessionHandler -{ - /** - * No locking is done. This means sessions are prone to loss of data due to - * race conditions of concurrent requests to the same session. The last session - * write will win in this case. It might be useful when you implement your own - * logic to deal with this like an optimistic approach. - */ - const LOCK_NONE = 0; - - /** - * Creates an application-level lock on a session. The disadvantage is that the - * lock is not enforced by the database and thus other, unaware parts of the - * application could still concurrently modify the session. The advantage is it - * does not require a transaction. - * This mode is not available for SQLite and not yet implemented for oci and sqlsrv. - */ - const LOCK_ADVISORY = 1; - - /** - * Issues a real row lock. Since it uses a transaction between opening and - * closing a session, you have to be careful when you use same database connection - * that you also use for your application logic. This mode is the default because - * it's the only reliable solution across DBMSs. - */ - const LOCK_TRANSACTIONAL = 2; - - /** - * @var \PDO|null PDO instance or null when not connected yet - */ - private $pdo; - - /** - * @var string|null|false DSN string or null for session.save_path or false when lazy connection disabled - */ - private $dsn = false; - - /** - * @var string Database driver - */ - private $driver; - - /** - * @var string Table name - */ - private $table = 'sessions'; - - /** - * @var string Column for session id - */ - private $idCol = 'sess_id'; - - /** - * @var string Column for session data - */ - private $dataCol = 'sess_data'; - - /** - * @var string Column for lifetime - */ - private $lifetimeCol = 'sess_lifetime'; - - /** - * @var string Column for timestamp - */ - private $timeCol = 'sess_time'; - - /** - * @var string Username when lazy-connect - */ - private $username = ''; - - /** - * @var string Password when lazy-connect - */ - private $password = ''; - - /** - * @var array Connection options when lazy-connect - */ - private $connectionOptions = array(); - - /** - * @var int The strategy for locking, see constants - */ - private $lockMode = self::LOCK_TRANSACTIONAL; - - /** - * It's an array to support multiple reads before closing which is manual, non-standard usage. - * - * @var \PDOStatement[] An array of statements to release advisory locks - */ - private $unlockStatements = array(); - - /** - * @var bool True when the current session exists but expired according to session.gc_maxlifetime - */ - private $sessionExpired = false; - - /** - * @var bool Whether a transaction is active - */ - private $inTransaction = false; - - /** - * @var bool Whether gc() has been called - */ - private $gcCalled = false; - - /** - * You can either pass an existing database connection as PDO instance or - * pass a DSN string that will be used to lazy-connect to the database - * when the session is actually used. Furthermore it's possible to pass null - * which will then use the session.save_path ini setting as PDO DSN parameter. - * - * List of available options: - * * db_table: The name of the table [default: sessions] - * * db_id_col: The column where to store the session id [default: sess_id] - * * db_data_col: The column where to store the session data [default: sess_data] - * * db_lifetime_col: The column where to store the lifetime [default: sess_lifetime] - * * db_time_col: The column where to store the timestamp [default: sess_time] - * * db_username: The username when lazy-connect [default: ''] - * * db_password: The password when lazy-connect [default: ''] - * * db_connection_options: An array of driver-specific connection options [default: array()] - * * lock_mode: The strategy for locking, see constants [default: LOCK_TRANSACTIONAL] - * - * @param \PDO|string|null $pdoOrDsn A \PDO instance or DSN string or null - * @param array $options An associative array of options - * - * @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION - */ - public function __construct($pdoOrDsn = null, array $options = array()) - { - if ($pdoOrDsn instanceof \PDO) { - if (\PDO::ERRMODE_EXCEPTION !== $pdoOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) { - throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); - } - - $this->pdo = $pdoOrDsn; - $this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - } else { - $this->dsn = $pdoOrDsn; - } - - $this->table = isset($options['db_table']) ? $options['db_table'] : $this->table; - $this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol; - $this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol; - $this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol; - $this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol; - $this->username = isset($options['db_username']) ? $options['db_username'] : $this->username; - $this->password = isset($options['db_password']) ? $options['db_password'] : $this->password; - $this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions; - $this->lockMode = isset($options['lock_mode']) ? $options['lock_mode'] : $this->lockMode; - } - - /** - * Creates the table to store sessions which can be called once for setup. - * - * Session ID is saved in a column of maximum length 128 because that is enough even - * for a 512 bit configured session.hash_function like Whirlpool. Session data is - * saved in a BLOB. One could also use a shorter inlined varbinary column - * if one was sure the data fits into it. - * - * @throws \PDOException When the table already exists - * @throws \DomainException When an unsupported PDO driver is used - */ - public function createTable() - { - // connect if we are not yet - $this->getConnection(); - - switch ($this->driver) { - case 'mysql': - // We use varbinary for the ID column because it prevents unwanted conversions: - // - character set conversions between server and client - // - trailing space removal - // - case-insensitivity - // - language processing like é == e - $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol MEDIUMINT NOT NULL, $this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8_bin, ENGINE = InnoDB"; - break; - case 'sqlite': - $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - case 'pgsql': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->dataCol BYTEA NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - case 'oci': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - case 'sqlsrv': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->dataCol VARBINARY(MAX) NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - default: - throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver)); - } - - try { - $this->pdo->exec($sql); - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - } - - /** - * Returns true when the current session exists but expired according to session.gc_maxlifetime. - * - * Can be used to distinguish between a new session and one that expired due to inactivity. - * - * @return bool Whether current session expired - */ - public function isSessionExpired() - { - return $this->sessionExpired; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - $this->sessionExpired = false; - - if (null === $this->pdo) { - $this->connect($this->dsn ?: $savePath); - } - - return parent::open($savePath, $sessionName); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - try { - return parent::read($sessionId); - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // We delay gc() to close() so that it is executed outside the transactional and blocking read-write process. - // This way, pruning expired sessions does not block them from being started while the current session is used. - $this->gcCalled = true; - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doDestroy($sessionId) - { - // delete the record associated with this id - $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doWrite($sessionId, $data) - { - $maxlifetime = (int) ini_get('session.gc_maxlifetime'); - - try { - // We use a single MERGE SQL query when supported by the database. - $mergeStmt = $this->getMergeStatement($sessionId, $data, $maxlifetime); - if (null !== $mergeStmt) { - $mergeStmt->execute(); - - return true; - } - - $updateStmt = $this->getUpdateStatement($sessionId, $data, $maxlifetime); - $updateStmt->execute(); - - // When MERGE is not supported, like in Postgres < 9.5, we have to use this approach that can result in - // duplicate key errors when the same session is written simultaneously (given the LOCK_NONE behavior). - // We can just catch such an error and re-execute the update. This is similar to a serializable - // transaction with retry logic on serialization failures but without the overhead and without possible - // false positives due to longer gap locking. - if (!$updateStmt->rowCount()) { - try { - $insertStmt = $this->getInsertStatement($sessionId, $data, $maxlifetime); - $insertStmt->execute(); - } catch (\PDOException $e) { - // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys - if (0 === strpos($e->getCode(), '23')) { - $updateStmt->execute(); - } else { - throw $e; - } - } - } - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function updateTimestamp($sessionId, $data) - { - $maxlifetime = (int) ini_get('session.gc_maxlifetime'); - - try { - $updateStmt = $this->pdo->prepare( - "UPDATE $this->table SET $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id" - ); - $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); - $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $updateStmt->execute(); - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - $this->commit(); - - while ($unlockStmt = array_shift($this->unlockStatements)) { - $unlockStmt->execute(); - } - - if ($this->gcCalled) { - $this->gcCalled = false; - - // delete the session records that have expired - if ('mysql' === $this->driver) { - $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol < :time"; - } else { - $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol < :time - $this->timeCol"; - } - - $stmt = $this->pdo->prepare($sql); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - } - - if (false !== $this->dsn) { - $this->pdo = null; // only close lazy-connection - } - - return true; - } - - /** - * Lazy-connects to the database. - * - * @param string $dsn DSN string - */ - private function connect($dsn) - { - $this->pdo = new \PDO($dsn, $this->username, $this->password, $this->connectionOptions); - $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - } - - /** - * Helper method to begin a transaction. - * - * Since SQLite does not support row level locks, we have to acquire a reserved lock - * on the database immediately. Because of https://bugs.php.net/42766 we have to create - * such a transaction manually which also means we cannot use PDO::commit or - * PDO::rollback or PDO::inTransaction for SQLite. - * - * Also MySQLs default isolation, REPEATABLE READ, causes deadlock for different sessions - * due to http://www.mysqlperformanceblog.com/2013/12/12/one-more-innodb-gap-lock-to-avoid/ . - * So we change it to READ COMMITTED. - */ - private function beginTransaction() - { - if (!$this->inTransaction) { - if ('sqlite' === $this->driver) { - $this->pdo->exec('BEGIN IMMEDIATE TRANSACTION'); - } else { - if ('mysql' === $this->driver) { - $this->pdo->exec('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); - } - $this->pdo->beginTransaction(); - } - $this->inTransaction = true; - } - } - - /** - * Helper method to commit a transaction. - */ - private function commit() - { - if ($this->inTransaction) { - try { - // commit read-write transaction which also releases the lock - if ('sqlite' === $this->driver) { - $this->pdo->exec('COMMIT'); - } else { - $this->pdo->commit(); - } - $this->inTransaction = false; - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - } - } - - /** - * Helper method to rollback a transaction. - */ - private function rollback() - { - // We only need to rollback if we are in a transaction. Otherwise the resulting - // error would hide the real problem why rollback was called. We might not be - // in a transaction when not using the transactional locking behavior or when - // two callbacks (e.g. destroy and write) are invoked that both fail. - if ($this->inTransaction) { - if ('sqlite' === $this->driver) { - $this->pdo->exec('ROLLBACK'); - } else { - $this->pdo->rollBack(); - } - $this->inTransaction = false; - } - } - - /** - * Reads the session data in respect to the different locking strategies. - * - * We need to make sure we do not return session data that is already considered garbage according - * to the session.gc_maxlifetime setting because gc() is called after read() and only sometimes. - * - * @param string $sessionId Session ID - * - * @return string The session data - */ - protected function doRead($sessionId) - { - if (self::LOCK_ADVISORY === $this->lockMode) { - $this->unlockStatements[] = $this->doAdvisoryLock($sessionId); - } - - $selectSql = $this->getSelectSql(); - $selectStmt = $this->pdo->prepare($selectSql); - $selectStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - - do { - $selectStmt->execute(); - $sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM); - - if ($sessionRows) { - if ($sessionRows[0][1] + $sessionRows[0][2] < time()) { - $this->sessionExpired = true; - - return ''; - } - - return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0]; - } - - if (!ini_get('session.use_strict_mode') && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { - // In strict mode, session fixation is not possible: new sessions always start with a unique - // random id, so that concurrency is not possible and this code path can be skipped. - // Exclusive-reading of non-existent rows does not block, so we need to do an insert to block - // until other connections to the session are committed. - try { - $insertStmt = $this->getInsertStatement($sessionId, '', 0); - $insertStmt->execute(); - } catch (\PDOException $e) { - // Catch duplicate key error because other connection created the session already. - // It would only not be the case when the other connection destroyed the session. - if (0 === strpos($e->getCode(), '23')) { - // Retrieve finished session data written by concurrent connection by restarting the loop. - // We have to start a new transaction as a failed query will mark the current transaction as - // aborted in PostgreSQL and disallow further queries within it. - $this->rollback(); - $this->beginTransaction(); - continue; - } - - throw $e; - } - } - - return ''; - } while (true); - } - - /** - * Executes an application-level lock on the database. - * - * @param string $sessionId Session ID - * - * @return \PDOStatement The statement that needs to be executed later to release the lock - * - * @throws \DomainException When an unsupported PDO driver is used - * - * @todo implement missing advisory locks - * - for oci using DBMS_LOCK.REQUEST - * - for sqlsrv using sp_getapplock with LockOwner = Session - */ - private function doAdvisoryLock($sessionId) - { - switch ($this->driver) { - case 'mysql': - // should we handle the return value? 0 on timeout, null on error - // we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout - $stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)'); - $stmt->bindValue(':key', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - - $releaseStmt = $this->pdo->prepare('DO RELEASE_LOCK(:key)'); - $releaseStmt->bindValue(':key', $sessionId, \PDO::PARAM_STR); - - return $releaseStmt; - case 'pgsql': - // Obtaining an exclusive session level advisory lock requires an integer key. - // When session.sid_bits_per_character > 4, the session id can contain non-hex-characters. - // So we cannot just use hexdec(). - if (4 === \PHP_INT_SIZE) { - $sessionInt1 = $this->convertStringToInt($sessionId); - $sessionInt2 = $this->convertStringToInt(substr($sessionId, 4, 4)); - - $stmt = $this->pdo->prepare('SELECT pg_advisory_lock(:key1, :key2)'); - $stmt->bindValue(':key1', $sessionInt1, \PDO::PARAM_INT); - $stmt->bindValue(':key2', $sessionInt2, \PDO::PARAM_INT); - $stmt->execute(); - - $releaseStmt = $this->pdo->prepare('SELECT pg_advisory_unlock(:key1, :key2)'); - $releaseStmt->bindValue(':key1', $sessionInt1, \PDO::PARAM_INT); - $releaseStmt->bindValue(':key2', $sessionInt2, \PDO::PARAM_INT); - } else { - $sessionBigInt = $this->convertStringToInt($sessionId); - - $stmt = $this->pdo->prepare('SELECT pg_advisory_lock(:key)'); - $stmt->bindValue(':key', $sessionBigInt, \PDO::PARAM_INT); - $stmt->execute(); - - $releaseStmt = $this->pdo->prepare('SELECT pg_advisory_unlock(:key)'); - $releaseStmt->bindValue(':key', $sessionBigInt, \PDO::PARAM_INT); - } - - return $releaseStmt; - case 'sqlite': - throw new \DomainException('SQLite does not support advisory locks.'); - default: - throw new \DomainException(sprintf('Advisory locks are currently not implemented for PDO driver "%s".', $this->driver)); - } - } - - /** - * Encodes the first 4 (when PHP_INT_SIZE == 4) or 8 characters of the string as an integer. - * - * Keep in mind, PHP integers are signed. - * - * @param string $string - * - * @return int - */ - private function convertStringToInt($string) - { - if (4 === \PHP_INT_SIZE) { - return (ord($string[3]) << 24) + (ord($string[2]) << 16) + (ord($string[1]) << 8) + ord($string[0]); - } - - $int1 = (ord($string[7]) << 24) + (ord($string[6]) << 16) + (ord($string[5]) << 8) + ord($string[4]); - $int2 = (ord($string[3]) << 24) + (ord($string[2]) << 16) + (ord($string[1]) << 8) + ord($string[0]); - - return $int2 + ($int1 << 32); - } - - /** - * Return a locking or nonlocking SQL query to read session information. - * - * @return string The SQL string - * - * @throws \DomainException When an unsupported PDO driver is used - */ - private function getSelectSql() - { - if (self::LOCK_TRANSACTIONAL === $this->lockMode) { - $this->beginTransaction(); - - switch ($this->driver) { - case 'mysql': - case 'oci': - case 'pgsql': - return "SELECT $this->dataCol, $this->lifetimeCol, $this->timeCol FROM $this->table WHERE $this->idCol = :id FOR UPDATE"; - case 'sqlsrv': - return "SELECT $this->dataCol, $this->lifetimeCol, $this->timeCol FROM $this->table WITH (UPDLOCK, ROWLOCK) WHERE $this->idCol = :id"; - case 'sqlite': - // we already locked when starting transaction - break; - default: - throw new \DomainException(sprintf('Transactional locks are currently not implemented for PDO driver "%s".', $this->driver)); - } - } - - return "SELECT $this->dataCol, $this->lifetimeCol, $this->timeCol FROM $this->table WHERE $this->idCol = :id"; - } - - /** - * Returns an insert statement supported by the database for writing session data. - * - * @param string $sessionId Session ID - * @param string $sessionData Encoded session data - * @param int $maxlifetime session.gc_maxlifetime - * - * @return \PDOStatement The insert statement - */ - private function getInsertStatement($sessionId, $sessionData, $maxlifetime) - { - switch ($this->driver) { - case 'oci': - $data = fopen('php://memory', 'r+'); - fwrite($data, $sessionData); - rewind($data); - $sql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, EMPTY_BLOB(), :lifetime, :time) RETURNING $this->dataCol into :data"; - break; - default: - $data = $sessionData; - $sql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; - break; - } - - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $stmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - - return $stmt; - } - - /** - * Returns an update statement supported by the database for writing session data. - * - * @param string $sessionId Session ID - * @param string $sessionData Encoded session data - * @param int $maxlifetime session.gc_maxlifetime - * - * @return \PDOStatement The update statement - */ - private function getUpdateStatement($sessionId, $sessionData, $maxlifetime) - { - switch ($this->driver) { - case 'oci': - $data = fopen('php://memory', 'r+'); - fwrite($data, $sessionData); - rewind($data); - $sql = "UPDATE $this->table SET $this->dataCol = EMPTY_BLOB(), $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id RETURNING $this->dataCol into :data"; - break; - default: - $data = $sessionData; - $sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"; - break; - } - - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $stmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - - return $stmt; - } - - /** - * Returns a merge/upsert (i.e. insert or update) statement when supported by the database for writing session data. - * - * @param string $sessionId Session ID - * @param string $data Encoded session data - * @param int $maxlifetime session.gc_maxlifetime - * - * @return \PDOStatement|null The merge statement or null when not supported - */ - private function getMergeStatement($sessionId, $data, $maxlifetime) - { - switch (true) { - case 'mysql' === $this->driver: - $mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". - "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)"; - break; - case 'sqlsrv' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): - // MERGE is only available since SQL Server 2008 and must be terminated by semicolon - // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx - $mergeSql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;"; - break; - case 'sqlite' === $this->driver: - $mergeSql = "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; - break; - case 'pgsql' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '9.5', '>='): - $mergeSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". - "ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)"; - break; - default: - // MERGE is not supported with LOBs: http://www.oracle.com/technetwork/articles/fuecks-lobs-095315.html - return null; - } - - $mergeStmt = $this->pdo->prepare($mergeSql); - - if ('sqlsrv' === $this->driver) { - $mergeStmt->bindParam(1, $sessionId, \PDO::PARAM_STR); - $mergeStmt->bindParam(2, $sessionId, \PDO::PARAM_STR); - $mergeStmt->bindParam(3, $data, \PDO::PARAM_LOB); - $mergeStmt->bindParam(4, $maxlifetime, \PDO::PARAM_INT); - $mergeStmt->bindValue(5, time(), \PDO::PARAM_INT); - $mergeStmt->bindParam(6, $data, \PDO::PARAM_LOB); - $mergeStmt->bindParam(7, $maxlifetime, \PDO::PARAM_INT); - $mergeStmt->bindValue(8, time(), \PDO::PARAM_INT); - } else { - $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $mergeStmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $mergeStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); - $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); - } - - return $mergeStmt; - } - - /** - * Return a PDO instance. - * - * @return \PDO - */ - protected function getConnection() - { - if (null === $this->pdo) { - $this->connect($this->dsn ?: ini_get('session.save_path')); - } - - return $this->pdo; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php deleted file mode 100644 index 228119297..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Adds basic `SessionUpdateTimestampHandlerInterface` behaviors to another `SessionHandlerInterface`. - * - * @author Nicolas Grekas - */ -class StrictSessionHandler extends AbstractSessionHandler -{ - private $handler; - private $doDestroy; - - public function __construct(\SessionHandlerInterface $handler) - { - if ($handler instanceof \SessionUpdateTimestampHandlerInterface) { - throw new \LogicException(sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".', get_class($handler), self::class)); - } - - $this->handler = $handler; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - parent::open($savePath, $sessionName); - - return $this->handler->open($savePath, $sessionName); - } - - /** - * {@inheritdoc} - */ - protected function doRead($sessionId) - { - return $this->handler->read($sessionId); - } - - /** - * {@inheritdoc} - */ - public function updateTimestamp($sessionId, $data) - { - return $this->write($sessionId, $data); - } - - /** - * {@inheritdoc} - */ - protected function doWrite($sessionId, $data) - { - return $this->handler->write($sessionId, $data); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - $this->doDestroy = true; - $destroyed = parent::destroy($sessionId); - - return $this->doDestroy ? $this->doDestroy($sessionId) : $destroyed; - } - - /** - * {@inheritdoc} - */ - protected function doDestroy($sessionId) - { - $this->doDestroy = false; - - return $this->handler->destroy($sessionId); - } - - /** - * {@inheritdoc} - */ - public function close() - { - return $this->handler->close(); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - return $this->handler->gc($maxlifetime); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php deleted file mode 100644 index 1541ec4e0..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Handler/WriteCheckSessionHandler.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.', WriteCheckSessionHandler::class), E_USER_DEPRECATED); - -/** - * Wraps another SessionHandlerInterface to only write the session when it has been modified. - * - * @author Adrien Brault - * - * @deprecated since version 3.4, to be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead. - */ -class WriteCheckSessionHandler implements \SessionHandlerInterface -{ - private $wrappedSessionHandler; - - /** - * @var array sessionId => session - */ - private $readSessions; - - public function __construct(\SessionHandlerInterface $wrappedSessionHandler) - { - $this->wrappedSessionHandler = $wrappedSessionHandler; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return $this->wrappedSessionHandler->close(); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return $this->wrappedSessionHandler->destroy($sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - return $this->wrappedSessionHandler->gc($maxlifetime); - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return $this->wrappedSessionHandler->open($savePath, $sessionName); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - $session = $this->wrappedSessionHandler->read($sessionId); - - $this->readSessions[$sessionId] = $session; - - return $session; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) { - return true; - } - - return $this->wrappedSessionHandler->write($sessionId, $data); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php deleted file mode 100644 index 6f59af486..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php +++ /dev/null @@ -1,168 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * Metadata container. - * - * Adds metadata to the session. - * - * @author Drak - */ -class MetadataBag implements SessionBagInterface -{ - const CREATED = 'c'; - const UPDATED = 'u'; - const LIFETIME = 'l'; - - /** - * @var string - */ - private $name = '__metadata'; - - /** - * @var string - */ - private $storageKey; - - /** - * @var array - */ - protected $meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0); - - /** - * Unix timestamp. - * - * @var int - */ - private $lastUsed; - - /** - * @var int - */ - private $updateThreshold; - - /** - * @param string $storageKey The key used to store bag in the session - * @param int $updateThreshold The time to wait between two UPDATED updates - */ - public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0) - { - $this->storageKey = $storageKey; - $this->updateThreshold = $updateThreshold; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$array) - { - $this->meta = &$array; - - if (isset($array[self::CREATED])) { - $this->lastUsed = $this->meta[self::UPDATED]; - - $timeStamp = time(); - if ($timeStamp - $array[self::UPDATED] >= $this->updateThreshold) { - $this->meta[self::UPDATED] = $timeStamp; - } - } else { - $this->stampCreated(); - } - } - - /** - * Gets the lifetime that the session cookie was set with. - * - * @return int - */ - public function getLifetime() - { - return $this->meta[self::LIFETIME]; - } - - /** - * Stamps a new session's metadata. - * - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - */ - public function stampNew($lifetime = null) - { - $this->stampCreated($lifetime); - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * Gets the created timestamp metadata. - * - * @return int Unix timestamp - */ - public function getCreated() - { - return $this->meta[self::CREATED]; - } - - /** - * Gets the last used metadata. - * - * @return int Unix timestamp - */ - public function getLastUsed() - { - return $this->lastUsed; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // nothing to do - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * Sets name. - * - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - private function stampCreated($lifetime = null) - { - $timeStamp = time(); - $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp; - $this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php deleted file mode 100644 index 027f4efff..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php +++ /dev/null @@ -1,256 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * MockArraySessionStorage mocks the session for unit tests. - * - * No PHP session is actually started since a session can be initialized - * and shutdown only once per PHP execution cycle. - * - * When doing functional testing, you should use MockFileSessionStorage instead. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - * @author Drak - */ -class MockArraySessionStorage implements SessionStorageInterface -{ - /** - * @var string - */ - protected $id = ''; - - /** - * @var string - */ - protected $name; - - /** - * @var bool - */ - protected $started = false; - - /** - * @var bool - */ - protected $closed = false; - - /** - * @var array - */ - protected $data = array(); - - /** - * @var MetadataBag - */ - protected $metadataBag; - - /** - * @var array|SessionBagInterface[] - */ - protected $bags = array(); - - /** - * @param string $name Session name - * @param MetadataBag $metaBag MetadataBag instance - */ - public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null) - { - $this->name = $name; - $this->setMetadataBag($metaBag); - } - - public function setSessionData(array $array) - { - $this->data = $array; - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - if (empty($this->id)) { - $this->id = $this->generateId(); - } - - $this->loadSession(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (!$this->started) { - $this->start(); - } - - $this->metadataBag->stampNew($lifetime); - $this->id = $this->generateId(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - if ($this->started) { - throw new \LogicException('Cannot set session ID after the session has started.'); - } - - $this->id = $id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function save() - { - if (!$this->started || $this->closed) { - throw new \RuntimeException('Trying to save a session that was not started yet or was already closed'); - } - // nothing to do since we don't persist the session data - $this->closed = false; - $this->started = false; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // clear out the session - $this->data = array(); - - // reconnect the bags to the session - $this->loadSession(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->bags[$bag->getName()] = $bag; - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); - } - - if (!$this->started) { - $this->start(); - } - - return $this->bags[$name]; - } - - /** - * {@inheritdoc} - */ - public function isStarted() - { - return $this->started; - } - - public function setMetadataBag(MetadataBag $bag = null) - { - if (null === $bag) { - $bag = new MetadataBag(); - } - - $this->metadataBag = $bag; - } - - /** - * Gets the MetadataBag. - * - * @return MetadataBag - */ - public function getMetadataBag() - { - return $this->metadataBag; - } - - /** - * Generates a session ID. - * - * This doesn't need to be particularly cryptographically secure since this is just - * a mock. - * - * @return string - */ - protected function generateId() - { - return hash('sha256', uniqid('ss_mock_', true)); - } - - protected function loadSession() - { - $bags = array_merge($this->bags, array($this->metadataBag)); - - foreach ($bags as $bag) { - $key = $bag->getStorageKey(); - $this->data[$key] = isset($this->data[$key]) ? $this->data[$key] : array(); - $bag->initialize($this->data[$key]); - } - - $this->started = true; - $this->closed = false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php deleted file mode 100644 index 14f427007..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -/** - * MockFileSessionStorage is used to mock sessions for - * functional testing when done in a single PHP process. - * - * No PHP session is actually started since a session can be initialized - * and shutdown only once per PHP execution cycle and this class does - * not pollute any session related globals, including session_*() functions - * or session.* PHP ini directives. - * - * @author Drak - */ -class MockFileSessionStorage extends MockArraySessionStorage -{ - private $savePath; - - /** - * @param string $savePath Path of directory to save session files - * @param string $name Session name - * @param MetadataBag $metaBag MetadataBag instance - */ - public function __construct($savePath = null, $name = 'MOCKSESSID', MetadataBag $metaBag = null) - { - if (null === $savePath) { - $savePath = sys_get_temp_dir(); - } - - if (!is_dir($savePath) && !@mkdir($savePath, 0777, true) && !is_dir($savePath)) { - throw new \RuntimeException(sprintf('Session Storage was not able to create directory "%s"', $savePath)); - } - - $this->savePath = $savePath; - - parent::__construct($name, $metaBag); - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - if (!$this->id) { - $this->id = $this->generateId(); - } - - $this->read(); - - $this->started = true; - - return true; - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (!$this->started) { - $this->start(); - } - - if ($destroy) { - $this->destroy(); - } - - return parent::regenerate($destroy, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function save() - { - if (!$this->started) { - throw new \RuntimeException('Trying to save a session that was not started yet or was already closed'); - } - - $data = $this->data; - - foreach ($this->bags as $bag) { - if (empty($data[$key = $bag->getStorageKey()])) { - unset($data[$key]); - } - } - if (array($key = $this->metadataBag->getStorageKey()) === array_keys($data)) { - unset($data[$key]); - } - - try { - if ($data) { - file_put_contents($this->getFilePath(), serialize($data)); - } else { - $this->destroy(); - } - } finally { - $this->data = $data; - } - - // this is needed for Silex, where the session object is re-used across requests - // in functional tests. In Symfony, the container is rebooted, so we don't have - // this issue - $this->started = false; - } - - /** - * Deletes a session from persistent storage. - * Deliberately leaves session data in memory intact. - */ - private function destroy() - { - if (is_file($this->getFilePath())) { - unlink($this->getFilePath()); - } - } - - /** - * Calculate path to file. - * - * @return string File path - */ - private function getFilePath() - { - return $this->savePath.'/'.$this->id.'.mocksess'; - } - - /** - * Reads session from storage and loads session. - */ - private function read() - { - $filePath = $this->getFilePath(); - $this->data = is_readable($filePath) && is_file($filePath) ? unserialize(file_get_contents($filePath)) : array(); - - $this->loadSession(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php deleted file mode 100644 index 0dfad9acb..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php +++ /dev/null @@ -1,445 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * This provides a base class for session attribute storage. - * - * @author Drak - */ -class NativeSessionStorage implements SessionStorageInterface -{ - /** - * @var SessionBagInterface[] - */ - protected $bags = array(); - - /** - * @var bool - */ - protected $started = false; - - /** - * @var bool - */ - protected $closed = false; - - /** - * @var AbstractProxy|\SessionHandlerInterface - */ - protected $saveHandler; - - /** - * @var MetadataBag - */ - protected $metadataBag; - - /** - * Depending on how you want the storage driver to behave you probably - * want to override this constructor entirely. - * - * List of options for $options array with their defaults. - * - * @see http://php.net/session.configuration for options - * but we omit 'session.' from the beginning of the keys for convenience. - * - * ("auto_start", is not supported as it tells PHP to start a session before - * PHP starts to execute user-land code. Setting during runtime has no effect). - * - * cache_limiter, "" (use "0" to prevent headers from being sent entirely). - * cache_expire, "0" - * cookie_domain, "" - * cookie_httponly, "" - * cookie_lifetime, "0" - * cookie_path, "/" - * cookie_secure, "" - * entropy_file, "" - * entropy_length, "0" - * gc_divisor, "100" - * gc_maxlifetime, "1440" - * gc_probability, "1" - * hash_bits_per_character, "4" - * hash_function, "0" - * lazy_write, "1" - * name, "PHPSESSID" - * referer_check, "" - * serialize_handler, "php" - * use_strict_mode, "0" - * use_cookies, "1" - * use_only_cookies, "1" - * use_trans_sid, "0" - * upload_progress.enabled, "1" - * upload_progress.cleanup, "1" - * upload_progress.prefix, "upload_progress_" - * upload_progress.name, "PHP_SESSION_UPLOAD_PROGRESS" - * upload_progress.freq, "1%" - * upload_progress.min-freq, "1" - * url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset=" - * sid_length, "32" - * sid_bits_per_character, "5" - * trans_sid_hosts, $_SERVER['HTTP_HOST'] - * trans_sid_tags, "a=href,area=href,frame=src,form=" - * - * @param array $options Session configuration options - * @param \SessionHandlerInterface|null $handler - * @param MetadataBag $metaBag MetadataBag - */ - public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null) - { - $options += array( - 'cache_limiter' => '', - 'cache_expire' => 0, - 'use_cookies' => 1, - 'lazy_write' => 1, - ); - - session_register_shutdown(); - - $this->setMetadataBag($metaBag); - $this->setOptions($options); - $this->setSaveHandler($handler); - } - - /** - * Gets the save handler instance. - * - * @return AbstractProxy|\SessionHandlerInterface - */ - public function getSaveHandler() - { - return $this->saveHandler; - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - if (\PHP_SESSION_ACTIVE === session_status()) { - throw new \RuntimeException('Failed to start the session: already started by PHP.'); - } - - if (ini_get('session.use_cookies') && headers_sent($file, $line)) { - throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line)); - } - - // ok to try and start the session - if (!session_start()) { - throw new \RuntimeException('Failed to start the session'); - } - - $this->loadSession(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->saveHandler->getId(); - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - $this->saveHandler->setId($id); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->saveHandler->getName(); - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->saveHandler->setName($name); - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - // Cannot regenerate the session ID for non-active sessions. - if (\PHP_SESSION_ACTIVE !== session_status()) { - return false; - } - - if (headers_sent()) { - return false; - } - - if (null !== $lifetime) { - ini_set('session.cookie_lifetime', $lifetime); - } - - if ($destroy) { - $this->metadataBag->stampNew(); - } - - $isRegenerated = session_regenerate_id($destroy); - - // The reference to $_SESSION in session bags is lost in PHP7 and we need to re-create it. - // @see https://bugs.php.net/bug.php?id=70013 - $this->loadSession(); - - return $isRegenerated; - } - - /** - * {@inheritdoc} - */ - public function save() - { - $session = $_SESSION; - - foreach ($this->bags as $bag) { - if (empty($_SESSION[$key = $bag->getStorageKey()])) { - unset($_SESSION[$key]); - } - } - if (array($key = $this->metadataBag->getStorageKey()) === array_keys($_SESSION)) { - unset($_SESSION[$key]); - } - - // Register custom error handler to catch a possible failure warning during session write - set_error_handler(function ($errno, $errstr, $errfile, $errline) { - throw new \ErrorException($errstr, $errno, E_WARNING, $errfile, $errline); - }, E_WARNING); - - try { - $e = null; - session_write_close(); - } catch (\ErrorException $e) { - } finally { - restore_error_handler(); - $_SESSION = $session; - } - if (null !== $e) { - // The default PHP error message is not very helpful, as it does not give any information on the current save handler. - // Therefore, we catch this error and trigger a warning with a better error message - $handler = $this->getSaveHandler(); - if ($handler instanceof SessionHandlerProxy) { - $handler = $handler->getHandler(); - } - - trigger_error(sprintf('session_write_close(): Failed to write session data with %s handler', get_class($handler)), E_USER_WARNING); - } - - $this->closed = true; - $this->started = false; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // clear out the session - $_SESSION = array(); - - // reconnect the bags to the session - $this->loadSession(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - if ($this->started) { - throw new \LogicException('Cannot register a bag when the session is already started.'); - } - - $this->bags[$bag->getName()] = $bag; - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); - } - - if (!$this->started && $this->saveHandler->isActive()) { - $this->loadSession(); - } elseif (!$this->started) { - $this->start(); - } - - return $this->bags[$name]; - } - - public function setMetadataBag(MetadataBag $metaBag = null) - { - if (null === $metaBag) { - $metaBag = new MetadataBag(); - } - - $this->metadataBag = $metaBag; - } - - /** - * Gets the MetadataBag. - * - * @return MetadataBag - */ - public function getMetadataBag() - { - return $this->metadataBag; - } - - /** - * {@inheritdoc} - */ - public function isStarted() - { - return $this->started; - } - - /** - * Sets session.* ini variables. - * - * For convenience we omit 'session.' from the beginning of the keys. - * Explicitly ignores other ini keys. - * - * @param array $options Session ini directives array(key => value) - * - * @see http://php.net/session.configuration - */ - public function setOptions(array $options) - { - if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) { - return; - } - - $validOptions = array_flip(array( - 'cache_limiter', 'cache_expire', 'cookie_domain', 'cookie_httponly', - 'cookie_lifetime', 'cookie_path', 'cookie_secure', - 'entropy_file', 'entropy_length', 'gc_divisor', - 'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character', - 'hash_function', 'lazy_write', 'name', 'referer_check', - 'serialize_handler', 'use_strict_mode', 'use_cookies', - 'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled', - 'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name', - 'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags', - 'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags', - )); - - foreach ($options as $key => $value) { - if (isset($validOptions[$key])) { - ini_set('session.'.$key, $value); - } - } - } - - /** - * Registers session save handler as a PHP session handler. - * - * To use internal PHP session save handlers, override this method using ini_set with - * session.save_handler and session.save_path e.g. - * - * ini_set('session.save_handler', 'files'); - * ini_set('session.save_path', '/tmp'); - * - * or pass in a \SessionHandler instance which configures session.save_handler in the - * constructor, for a template see NativeFileSessionHandler or use handlers in - * composer package drak/native-session - * - * @see http://php.net/session-set-save-handler - * @see http://php.net/sessionhandlerinterface - * @see http://php.net/sessionhandler - * @see http://github.com/drak/NativeSession - * - * @param \SessionHandlerInterface|null $saveHandler - * - * @throws \InvalidArgumentException - */ - public function setSaveHandler($saveHandler = null) - { - if (!$saveHandler instanceof AbstractProxy && - !$saveHandler instanceof \SessionHandlerInterface && - null !== $saveHandler) { - throw new \InvalidArgumentException('Must be instance of AbstractProxy; implement \SessionHandlerInterface; or be null.'); - } - - // Wrap $saveHandler in proxy and prevent double wrapping of proxy - if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { - $saveHandler = new SessionHandlerProxy($saveHandler); - } elseif (!$saveHandler instanceof AbstractProxy) { - $saveHandler = new SessionHandlerProxy(new StrictSessionHandler(new \SessionHandler())); - } - $this->saveHandler = $saveHandler; - - if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) { - return; - } - - if ($this->saveHandler instanceof SessionHandlerProxy) { - session_set_save_handler($this->saveHandler->getHandler(), false); - } elseif ($this->saveHandler instanceof \SessionHandlerInterface) { - session_set_save_handler($this->saveHandler, false); - } - } - - /** - * Load the session with attributes. - * - * After starting the session, PHP retrieves the session from whatever handlers - * are set to (either PHP's internal, or a custom save handler set with session_set_save_handler()). - * PHP takes the return value from the read() handler, unserializes it - * and populates $_SESSION with the result automatically. - */ - protected function loadSession(array &$session = null) - { - if (null === $session) { - $session = &$_SESSION; - } - - $bags = array_merge($this->bags, array($this->metadataBag)); - - foreach ($bags as $bag) { - $key = $bag->getStorageKey(); - $session[$key] = isset($session[$key]) ? $session[$key] : array(); - $bag->initialize($session[$key]); - } - - $this->started = true; - $this->closed = false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorage.php deleted file mode 100644 index 662ed5015..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/PhpBridgeSessionStorage.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -/** - * Allows session to be started by PHP and managed by Symfony. - * - * @author Drak - */ -class PhpBridgeSessionStorage extends NativeSessionStorage -{ - /** - * @param \SessionHandlerInterface|null $handler - * @param MetadataBag $metaBag MetadataBag - */ - public function __construct($handler = null, MetadataBag $metaBag = null) - { - $this->setMetadataBag($metaBag); - $this->setSaveHandler($handler); - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - $this->loadSession(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags and nothing else that may be set - // since the purpose of this driver is to share a handler - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // reconnect the bags to the session - $this->loadSession(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php deleted file mode 100644 index 09c92483c..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; - -/** - * @author Drak - */ -abstract class AbstractProxy -{ - /** - * Flag if handler wraps an internal PHP session handler (using \SessionHandler). - * - * @var bool - */ - protected $wrapper = false; - - /** - * @var string - */ - protected $saveHandlerName; - - /** - * Gets the session.save_handler name. - * - * @return string - */ - public function getSaveHandlerName() - { - return $this->saveHandlerName; - } - - /** - * Is this proxy handler and instance of \SessionHandlerInterface. - * - * @return bool - */ - public function isSessionHandlerInterface() - { - return $this instanceof \SessionHandlerInterface; - } - - /** - * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. - * - * @return bool - */ - public function isWrapper() - { - return $this->wrapper; - } - - /** - * Has a session started? - * - * @return bool - */ - public function isActive() - { - return \PHP_SESSION_ACTIVE === session_status(); - } - - /** - * Gets the session ID. - * - * @return string - */ - public function getId() - { - return session_id(); - } - - /** - * Sets the session ID. - * - * @param string $id - * - * @throws \LogicException - */ - public function setId($id) - { - if ($this->isActive()) { - throw new \LogicException('Cannot change the ID of an active session'); - } - - session_id($id); - } - - /** - * Gets the session name. - * - * @return string - */ - public function getName() - { - return session_name(); - } - - /** - * Sets the session name. - * - * @param string $name - * - * @throws \LogicException - */ - public function setName($name) - { - if ($this->isActive()) { - throw new \LogicException('Cannot change the name of an active session'); - } - - session_name($name); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php deleted file mode 100644 index 082eed143..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/NativeProxy.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; - -@trigger_error('The '.__NAMESPACE__.'\NativeProxy class is deprecated since Symfony 3.4 and will be removed in 4.0. Use your session handler implementation directly.', E_USER_DEPRECATED); - -/** - * This proxy is built-in session handlers in PHP 5.3.x. - * - * @deprecated since version 3.4, to be removed in 4.0. Use your session handler implementation directly. - * - * @author Drak - */ -class NativeProxy extends AbstractProxy -{ - public function __construct() - { - // this makes an educated guess as to what the handler is since it should already be set. - $this->saveHandlerName = ini_get('session.save_handler'); - } - - /** - * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. - * - * @return bool False - */ - public function isWrapper() - { - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php deleted file mode 100644 index 53c1209a1..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; - -/** - * @author Drak - */ -class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface -{ - protected $handler; - - public function __construct(\SessionHandlerInterface $handler) - { - $this->handler = $handler; - $this->wrapper = ($handler instanceof \SessionHandler); - $this->saveHandlerName = $this->wrapper ? ini_get('session.save_handler') : 'user'; - } - - /** - * @return \SessionHandlerInterface - */ - public function getHandler() - { - return $this->handler; - } - - // \SessionHandlerInterface - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return (bool) $this->handler->open($savePath, $sessionName); - } - - /** - * {@inheritdoc} - */ - public function close() - { - return (bool) $this->handler->close(); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return (string) $this->handler->read($sessionId); - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return (bool) $this->handler->write($sessionId, $data); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return (bool) $this->handler->destroy($sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - return (bool) $this->handler->gc($maxlifetime); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Session/Storage/SessionStorageInterface.php b/lib/silex/vendor/symfony/http-foundation/Session/Storage/SessionStorageInterface.php deleted file mode 100644 index 66e8b33dd..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Session/Storage/SessionStorageInterface.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * StorageInterface. - * - * @author Fabien Potencier - * @author Drak - */ -interface SessionStorageInterface -{ - /** - * Starts the session. - * - * @return bool True if started - * - * @throws \RuntimeException if something goes wrong starting the session - */ - public function start(); - - /** - * Checks if the session is started. - * - * @return bool True if started, false otherwise - */ - public function isStarted(); - - /** - * Returns the session ID. - * - * @return string The session ID or empty - */ - public function getId(); - - /** - * Sets the session ID. - * - * @param string $id - */ - public function setId($id); - - /** - * Returns the session name. - * - * @return mixed The session name - */ - public function getName(); - - /** - * Sets the session name. - * - * @param string $name - */ - public function setName($name); - - /** - * Regenerates id that represents this storage. - * - * This method must invoke session_regenerate_id($destroy) unless - * this interface is used for a storage object designed for unit - * or functional testing where a real PHP session would interfere - * with testing. - * - * Note regenerate+destroy should not clear the session data in memory - * only delete the session data from persistent storage. - * - * Care: When regenerating the session ID no locking is involved in PHP's - * session design. See https://bugs.php.net/bug.php?id=61470 for a discussion. - * So you must make sure the regenerated session is saved BEFORE sending the - * headers with the new ID. Symfony's HttpKernel offers a listener for this. - * See Symfony\Component\HttpKernel\EventListener\SaveSessionListener. - * Otherwise session data could get lost again for concurrent requests with the - * new ID. One result could be that you get logged out after just logging in. - * - * @param bool $destroy Destroy session when regenerating? - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return bool True if session regenerated, false if error - * - * @throws \RuntimeException If an error occurs while regenerating this storage - */ - public function regenerate($destroy = false, $lifetime = null); - - /** - * Force the session to be saved and closed. - * - * This method must invoke session_write_close() unless this interface is - * used for a storage object design for unit or functional testing where - * a real PHP session would interfere with testing, in which case - * it should actually persist the session data if required. - * - * @throws \RuntimeException if the session is saved without being started, or if the session - * is already closed - */ - public function save(); - - /** - * Clear all session data in memory. - */ - public function clear(); - - /** - * Gets a SessionBagInterface by name. - * - * @param string $name - * - * @return SessionBagInterface - * - * @throws \InvalidArgumentException If the bag does not exist - */ - public function getBag($name); - - /** - * Registers a SessionBagInterface for use. - */ - public function registerBag(SessionBagInterface $bag); - - /** - * @return MetadataBag - */ - public function getMetadataBag(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/StreamedResponse.php b/lib/silex/vendor/symfony/http-foundation/StreamedResponse.php deleted file mode 100644 index 92868d33e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/StreamedResponse.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * StreamedResponse represents a streamed HTTP response. - * - * A StreamedResponse uses a callback for its content. - * - * The callback should use the standard PHP functions like echo - * to stream the response back to the client. The flush() method - * can also be used if needed. - * - * @see flush() - * - * @author Fabien Potencier - */ -class StreamedResponse extends Response -{ - protected $callback; - protected $streamed; - private $headersSent; - - /** - * @param callable|null $callback A valid PHP callback or null to set it later - * @param int $status The response status code - * @param array $headers An array of response headers - */ - public function __construct(callable $callback = null, $status = 200, $headers = array()) - { - parent::__construct(null, $status, $headers); - - if (null !== $callback) { - $this->setCallback($callback); - } - $this->streamed = false; - $this->headersSent = false; - } - - /** - * Factory method for chainability. - * - * @param callable|null $callback A valid PHP callback or null to set it later - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return static - */ - public static function create($callback = null, $status = 200, $headers = array()) - { - return new static($callback, $status, $headers); - } - - /** - * Sets the PHP callback associated with this Response. - * - * @param callable $callback A valid PHP callback - * - * @return $this - */ - public function setCallback(callable $callback) - { - $this->callback = $callback; - - return $this; - } - - /** - * {@inheritdoc} - * - * This method only sends the headers once. - * - * @return $this - */ - public function sendHeaders() - { - if ($this->headersSent) { - return $this; - } - - $this->headersSent = true; - - return parent::sendHeaders(); - } - - /** - * {@inheritdoc} - * - * This method only sends the content once. - * - * @return $this - */ - public function sendContent() - { - if ($this->streamed) { - return $this; - } - - $this->streamed = true; - - if (null === $this->callback) { - throw new \LogicException('The Response callback must not be null.'); - } - - call_user_func($this->callback); - - return $this; - } - - /** - * {@inheritdoc} - * - * @throws \LogicException when the content is not null - * - * @return $this - */ - public function setContent($content) - { - if (null !== $content) { - throw new \LogicException('The content cannot be set on a StreamedResponse instance.'); - } - - return $this; - } - - /** - * {@inheritdoc} - * - * @return false - */ - public function getContent() - { - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php deleted file mode 100644 index 226078763..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php +++ /dev/null @@ -1,172 +0,0 @@ - - * - * 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 - */ -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 bool - */ - 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/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php deleted file mode 100644 index 21a5d155f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php +++ /dev/null @@ -1,226 +0,0 @@ - - * - * 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 - */ -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 bool - */ - 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/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php deleted file mode 100644 index 84803ebae..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Request represents an HTTP request from an Apache server. - * - * @author Fabien Potencier - */ -class ApacheRequest extends Request -{ - /** - * {@inheritdoc} - */ - protected function prepareRequestUri() - { - return $this->server->get('REQUEST_URI'); - } - - /** - * {@inheritdoc} - */ - protected function prepareBaseUrl() - { - $baseUrl = $this->server->get('SCRIPT_NAME'); - - if (false === strpos($this->server->get('REQUEST_URI'), $baseUrl)) { - // assume mod_rewrite - return rtrim(dirname($baseUrl), '/\\'); - } - - return $baseUrl; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php deleted file mode 100644 index ac41c8fe9..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ /dev/null @@ -1,321 +0,0 @@ - - * - * 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 - * @author stealth35 - * @author Igor Wiedler - * @author Jordan Alliot - * @author Sergey Linnik - */ -class BinaryFileResponse extends Response -{ - protected static $trustXSendfileTypeHeader = false; - - protected $file; - protected $offset; - protected $maxlen; - protected $deleteFileAfterSend = false; - - /** - * Constructor. - * - * @param \SplFileInfo|string $file The file to stream - * @param int $status The response status code - * @param array $headers An array of response headers - * @param bool $public Files are public by default - * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename - * @param bool $autoEtag Whether the ETag header should be automatically set - * @param bool $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(); - } - } - - /** - * @param \SplFileInfo|string $file The file to stream - * @param int $status The response status code - * @param array $headers An array of response headers - * @param bool $public Files are public by default - * @param null|string $contentDisposition The type of Content-Disposition to set automatically with the filename - * @param bool $autoEtag Whether the ETag header should be automatically set - * @param bool $autoLastModified Whether the Last-Modified header should be automatically set - * - * @return BinaryFileResponse The created response - */ - 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 - * @param string $contentDisposition - * @param bool $autoEtag - * @param bool $autoLastModified - * - * @return BinaryFileResponse - * - * @throws FileException - */ - public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) - { - if (!$file instanceof File) { - if ($file instanceof \SplFileInfo) { - $file = new File($file->getPathname()); - } else { - $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 - * - * @return BinaryFileResponse - */ - 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()); - - if (!$this->headers->has('Accept-Ranges')) { - // Only accept ranges on safe HTTP methods - $this->headers->set('Accept-Ranges', $request->isMethodSafe() ? 'bytes' : 'none'); - } - - 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->ensureIEOverSSLCompatibility($request); - - $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. - // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect - foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { - $mapping = explode('=', $mapping, 2); - - if (2 == count($mapping)) { - $pathPrefix = trim($mapping[0]); - $location = 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'); - $fileSize = $this->file->getSize(); - - list($start, $end) = explode('-', substr($range, 6), 2) + array(0); - - $end = ('' === $end) ? $fileSize - 1 : (int) $end; - - if ('' === $start) { - $start = $fileSize - $end; - $end = $fileSize - 1; - } else { - $start = (int) $start; - } - - if ($start <= $end) { - if ($start < 0 || $end > $fileSize - 1) { - $this->setStatusCode(416); - } elseif ($start !== 0 || $end !== $fileSize - 1) { - $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; - $this->offset = $start; - - $this->setStatusCode(206); - $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); - $this->headers->set('Content-Length', $end - $start + 1); - } - } - } - } - - return $this; - } - - /** - * 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); - - if ($this->deleteFileAfterSend) { - unlink($this->file->getPathname()); - } - } - - /** - * {@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; - } - - /** - * If this is set to true, the file will be unlinked after the request is send - * Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used. - * @param bool $shouldDelete - * - * @return BinaryFileResponse - */ - public function deleteFileAfterSend($shouldDelete) - { - $this->deleteFileAfterSend = $shouldDelete; - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md deleted file mode 100644 index dcdeb4ebf..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md +++ /dev/null @@ -1,122 +0,0 @@ -CHANGELOG -========= - -2.6.0 ------ - - * PdoSessionHandler changes - - implemented different session locking strategies to prevent loss of data by concurrent access to the same session - - [BC BREAK] save session data in a binary column without base64_encode - - [BC BREAK] added lifetime column to the session table which allows to have different lifetimes for each session - - implemented lazy connections that are only opened when a session is used by either passing a dsn string - explicitly or falling back to session.save_path ini setting - - added a createTable method that initializes a correctly defined table depending on the database vendor - -2.5.0 ------ - - * added `JsonResponse::setEncodingOptions()` & `JsonResponse::getEncodingOptions()` for easier manipulation - of the options used while encoding data to JSON format. - -2.4.0 ------ - - * added RequestStack - * added Request::getEncodings() - * added accessors methods to session handlers - -2.3.0 ------ - - * added support for ranges of IPs in trusted proxies - * `UploadedFile::isValid` now returns false if the file was not uploaded via HTTP (in a non-test mode) - * Improved error-handling of `\Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler` - to ensure the supplied PDO handler throws Exceptions on error (as the class expects). Added related test cases - to verify that Exceptions are properly thrown when the PDO queries fail. - -2.2.0 ------ - - * fixed the Request::create() precedence (URI information always take precedence now) - * added Request::getTrustedProxies() - * deprecated Request::isProxyTrusted() - * [BC BREAK] JsonResponse does not turn a top level empty array to an object anymore, use an ArrayObject to enforce objects - * added a IpUtils class to check if an IP belongs to a CIDR - * 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, and Request::getHttpMethodParameterOverride() to check if it is supported) - * Request::splitHttpAcceptHeader() method is deprecated and will be removed in 2.3 - * Deprecated Flashbag::count() and \Countable interface, will be removed in 2.3 - -2.1.0 ------ - - * added Request::getSchemeAndHttpHost() and Request::getUserInfo() - * added a fluent interface to the Response class - * added Request::isProxyTrusted() - * added JsonResponse - * added a getTargetUrl method to RedirectResponse - * added support for streamed responses - * made Response::prepare() method the place to enforce HTTP specification - * [BC BREAK] moved management of the locale from the Session class to the Request class - * added a generic access to the PHP built-in filter mechanism: ParameterBag::filter() - * made FileBinaryMimeTypeGuesser command configurable - * added Request::getUser() and Request::getPassword() - * added support for the PATCH method in Request - * removed the ContentTypeMimeTypeGuesser class as it is deprecated and never used on PHP 5.3 - * added ResponseHeaderBag::makeDisposition() (implements RFC 6266) - * made mimetype to extension conversion configurable - * [BC BREAK] Moved all session related classes and interfaces into own namespace, as - `Symfony\Component\HttpFoundation\Session` and renamed classes accordingly. - Session handlers are located in the subnamespace `Symfony\Component\HttpFoundation\Session\Handler`. - * SessionHandlers must implement `\SessionHandlerInterface` or extend from the - `Symfony\Component\HttpFoundation\Storage\Handler\NativeSessionHandler` base class. - * Added internal storage driver proxy mechanism for forward compatibility with - PHP 5.4 `\SessionHandler` class. - * Added session handlers for custom Memcache, Memcached and Null session save handlers. - * [BC BREAK] Removed `NativeSessionStorage` and replaced with `NativeFileSessionHandler`. - * [BC BREAK] `SessionStorageInterface` methods removed: `write()`, `read()` and - `remove()`. Added `getBag()`, `registerBag()`. The `NativeSessionStorage` class - is a mediator for the session storage internals including the session handlers - which do the real work of participating in the internal PHP session workflow. - * [BC BREAK] Introduced mock implementations of `SessionStorage` to enable unit - and functional testing without starting real PHP sessions. Removed - `ArraySessionStorage`, and replaced with `MockArraySessionStorage` for unit - tests; removed `FilesystemSessionStorage`, and replaced with`MockFileSessionStorage` - for functional tests. These do not interact with global session ini - configuration values, session functions or `$_SESSION` superglobal. This means - they can be configured directly allowing multiple instances to work without - conflicting in the same PHP process. - * [BC BREAK] Removed the `close()` method from the `Session` class, as this is - now redundant. - * Deprecated the following methods from the Session class: `setFlash()`, `setFlashes()` - `getFlash()`, `hasFlash()`, and `removeFlash()`. Use `getFlashBag()` instead - which returns a `FlashBagInterface`. - * `Session->clear()` now only clears session attributes as before it cleared - flash messages and attributes. `Session->getFlashBag()->all()` clears flashes now. - * Session data is now managed by `SessionBagInterface` to better encapsulate - session data. - * Refactored session attribute and flash messages system to their own - `SessionBagInterface` implementations. - * Added `FlashBag`. Flashes expire when retrieved by `get()` or `all()`. This - implementation is ESI compatible. - * Added `AutoExpireFlashBag` (default) to replicate Symfony 2.0.x auto expire - behaviour of messages auto expiring after one page page load. Messages must - be retrieved by `get()` or `all()`. - * Added `Symfony\Component\HttpFoundation\Attribute\AttributeBag` to replicate - attributes storage behaviour from 2.0.x (default). - * Added `Symfony\Component\HttpFoundation\Attribute\NamespacedAttributeBag` for - namespace session attributes. - * Flash API can stores messages in an array so there may be multiple messages - per flash type. The old `Session` class API remains without BC break as it - will allow single messages as before. - * Added basic session meta-data to the session to record session create time, - last updated time, and the lifetime of the session cookie that was provided - to the client. - * Request::getClientIp() method doesn't take a parameter anymore but bases - itself on the trustProxy parameter. - * Added isMethod() to Request object. - * [BC BREAK] The methods `getPathInfo()`, `getBaseUrl()` and `getBasePath()` of - a `Request` now all return a raw value (vs a urldecoded value before). Any call - to one of these methods must be checked and wrapped in a `rawurldecode()` if - needed. diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php deleted file mode 100644 index 466d02043..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php +++ /dev/null @@ -1,210 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Represents a cookie. - * - * @author Johannes M. Schmitt - * - * @api - */ -class Cookie -{ - protected $name; - protected $value; - protected $domain; - protected $expire; - protected $path; - protected $secure; - protected $httpOnly; - - /** - * Constructor. - * - * @param string $name The name of the cookie - * @param string $value The value of the cookie - * @param int|string|\DateTime $expire The time the cookie expires - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available to - * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client - * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol - * - * @throws \InvalidArgumentException - * - * @api - */ - public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true) - { - // from PHP source code - if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { - throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name)); - } - - if (empty($name)) { - throw new \InvalidArgumentException('The cookie name cannot be empty.'); - } - - // convert expiration time to a Unix timestamp - if ($expire instanceof \DateTime) { - $expire = $expire->format('U'); - } elseif (!is_numeric($expire)) { - $expire = strtotime($expire); - - if (false === $expire || -1 === $expire) { - throw new \InvalidArgumentException('The cookie expiration time is not valid.'); - } - } - - $this->name = $name; - $this->value = $value; - $this->domain = $domain; - $this->expire = $expire; - $this->path = empty($path) ? '/' : $path; - $this->secure = (bool) $secure; - $this->httpOnly = (bool) $httpOnly; - } - - /** - * Returns the cookie as a string. - * - * @return string The cookie - */ - public function __toString() - { - $str = urlencode($this->getName()).'='; - - if ('' === (string) $this->getValue()) { - $str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001); - } else { - $str .= urlencode($this->getValue()); - - if ($this->getExpiresTime() !== 0) { - $str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()); - } - } - - if ($this->path) { - $str .= '; path='.$this->path; - } - - if ($this->getDomain()) { - $str .= '; domain='.$this->getDomain(); - } - - if (true === $this->isSecure()) { - $str .= '; secure'; - } - - if (true === $this->isHttpOnly()) { - $str .= '; httponly'; - } - - return $str; - } - - /** - * Gets the name of the cookie. - * - * @return string - * - * @api - */ - public function getName() - { - return $this->name; - } - - /** - * Gets the value of the cookie. - * - * @return string - * - * @api - */ - public function getValue() - { - return $this->value; - } - - /** - * Gets the domain that the cookie is available to. - * - * @return string - * - * @api - */ - public function getDomain() - { - return $this->domain; - } - - /** - * Gets the time the cookie expires. - * - * @return int - * - * @api - */ - public function getExpiresTime() - { - return $this->expire; - } - - /** - * Gets the path on the server in which the cookie will be available on. - * - * @return string - * - * @api - */ - public function getPath() - { - return $this->path; - } - - /** - * Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client. - * - * @return bool - * - * @api - */ - public function isSecure() - { - return $this->secure; - } - - /** - * Checks whether the cookie will be made accessible only through the HTTP protocol. - * - * @return bool - * - * @api - */ - public function isHttpOnly() - { - return $this->httpOnly; - } - - /** - * Whether this cookie is about to be cleared. - * - * @return bool - * - * @api - */ - public function isCleared() - { - return $this->expire < time(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php deleted file mode 100644 index e9c8441ce..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * 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\ExpressionLanguage\ExpressionLanguage; - -/** - * ExpressionRequestMatcher uses an expression to match a Request. - * - * @author Fabien Potencier - */ -class ExpressionRequestMatcher extends RequestMatcher -{ - private $language; - private $expression; - - public function setExpression(ExpressionLanguage $language, $expression) - { - $this->language = $language; - $this->expression = $expression; - } - - public function matches(Request $request) - { - if (!$this->language) { - throw new \LogicException('Unable to match the request as the expression language is not available.'); - } - - return $this->language->evaluate($this->expression, array( - 'request' => $request, - 'method' => $request->getMethod(), - 'path' => rawurldecode($request->getPathInfo()), - 'host' => $request->getHost(), - 'ip' => $request->getClientIp(), - 'attributes' => $request->attributes->all(), - )) && parent::matches($request); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php deleted file mode 100644 index 41f7a4625..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when the access on a file was denied. - * - * @author Bernhard Schussek - */ -class AccessDeniedException extends FileException -{ - /** - * Constructor. - * - * @param string $path The path to the accessed file - */ - public function __construct($path) - { - parent::__construct(sprintf('The file %s could not be accessed', $path)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileException.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileException.php deleted file mode 100644 index fad5133e1..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when an error occurred in the component File. - * - * @author Bernhard Schussek - */ -class FileException extends \RuntimeException -{ -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php deleted file mode 100644 index ac90d4035..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when a file was not found. - * - * @author Bernhard Schussek - */ -class FileNotFoundException extends FileException -{ - /** - * Constructor. - * - * @param string $path The path to the file that was not found - */ - public function __construct($path) - { - parent::__construct(sprintf('The file "%s" does not exist', $path)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php deleted file mode 100644 index 0444b8778..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -class UnexpectedTypeException extends FileException -{ - public function __construct($value, $expectedType) - { - parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UploadException.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UploadException.php deleted file mode 100644 index 7074e7653..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UploadException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\Exception; - -/** - * Thrown when an error occurred during file upload. - * - * @author Bernhard Schussek - */ -class UploadException extends FileException -{ -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php deleted file mode 100644 index 87c1606d4..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php +++ /dev/null @@ -1,160 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File; - -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; - -/** - * A file in the file system. - * - * @author Bernhard Schussek - * - * @api - */ -class File extends \SplFileInfo -{ - /** - * Constructs a new file from the given path. - * - * @param string $path The path to the file - * @param bool $checkPath Whether to check the path or not - * - * @throws FileNotFoundException If the given path is not a file - * - * @api - */ - public function __construct($path, $checkPath = true) - { - if ($checkPath && !is_file($path)) { - throw new FileNotFoundException($path); - } - - parent::__construct($path); - } - - /** - * Returns the extension based on the mime type. - * - * If the mime type is unknown, returns null. - * - * This method uses the mime type as guessed by getMimeType() - * to guess the file extension. - * - * @return string|null The guessed extension or null if it cannot be guessed - * - * @api - * - * @see ExtensionGuesser - * @see getMimeType() - */ - public function guessExtension() - { - $type = $this->getMimeType(); - $guesser = ExtensionGuesser::getInstance(); - - return $guesser->guess($type); - } - - /** - * Returns the mime type of the file. - * - * The mime type is guessed using a MimeTypeGuesser instance, which uses finfo(), - * mime_content_type() and the system binary "file" (in this order), depending on - * which of those are available. - * - * @return string|null The guessed mime type (i.e. "application/pdf") - * - * @see MimeTypeGuesser - * - * @api - */ - public function getMimeType() - { - $guesser = MimeTypeGuesser::getInstance(); - - return $guesser->guess($this->getPathname()); - } - - /** - * Returns the extension of the file. - * - * \SplFileInfo::getExtension() is not available before PHP 5.3.6 - * - * @return string The extension - * - * @api - */ - public function getExtension() - { - return pathinfo($this->getBasename(), PATHINFO_EXTENSION); - } - - /** - * Moves the file to a new location. - * - * @param string $directory The destination folder - * @param string $name The new file name - * - * @return File A File object representing the new file - * - * @throws FileException if the target file could not be created - * - * @api - */ - public function move($directory, $name = null) - { - $target = $this->getTargetFile($directory, $name); - - if (!@rename($this->getPathname(), $target)) { - $error = error_get_last(); - throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); - } - - @chmod($target, 0666 & ~umask()); - - return $target; - } - - protected function getTargetFile($directory, $name = null) - { - if (!is_dir($directory)) { - if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) { - throw new FileException(sprintf('Unable to create the "%s" directory', $directory)); - } - } elseif (!is_writable($directory)) { - throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); - } - - $target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); - - return new self($target, false); - } - - /** - * 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/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php deleted file mode 100644 index ec9b78ab2..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * A singleton mime type to file extension guesser. - * - * A default guesser is provided. - * You can register custom guessers by calling the register() - * method on the singleton instance: - * - * $guesser = ExtensionGuesser::getInstance(); - * $guesser->register(new MyCustomExtensionGuesser()); - * - * The last registered guesser is preferred over previously registered ones. - */ -class ExtensionGuesser implements ExtensionGuesserInterface -{ - /** - * The singleton instance. - * - * @var ExtensionGuesser - */ - private static $instance = null; - - /** - * All registered ExtensionGuesserInterface instances. - * - * @var array - */ - protected $guessers = array(); - - /** - * Returns the singleton instance. - * - * @return ExtensionGuesser - */ - public static function getInstance() - { - if (null === self::$instance) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Registers all natively provided extension guessers. - */ - private function __construct() - { - $this->register(new MimeTypeExtensionGuesser()); - } - - /** - * Registers a new extension guesser. - * - * When guessing, this guesser is preferred over previously registered ones. - * - * @param ExtensionGuesserInterface $guesser - */ - public function register(ExtensionGuesserInterface $guesser) - { - array_unshift($this->guessers, $guesser); - } - - /** - * Tries to guess the extension. - * - * The mime type is passed to each registered mime type guesser in reverse order - * of their registration (last registered is queried first). Once a guesser - * returns a value that is not NULL, this method terminates and returns the - * value. - * - * @param string $mimeType The mime type - * - * @return string The guessed extension or NULL, if none could be guessed - */ - public function guess($mimeType) - { - foreach ($this->guessers as $guesser) { - if (null !== $extension = $guesser->guess($mimeType)) { - return $extension; - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php deleted file mode 100644 index d19a0e537..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * Guesses the file extension corresponding to a given mime type. - */ -interface ExtensionGuesserInterface -{ - /** - * Makes a best guess for a file extension, given a mime type. - * - * @param string $mimeType The mime type - * - * @return string The guessed extension or NULL, if none could be guessed - */ - public function guess($mimeType); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php deleted file mode 100644 index f917a06d6..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type with the binary "file" (only available on *nix). - * - * @author Bernhard Schussek - */ -class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface -{ - private $cmd; - - /** - * Constructor. - * - * The $cmd pattern must contain a "%s" string that will be replaced - * with the file name to guess. - * - * The command output must start with the mime type of the file. - * - * @param string $cmd The command to run to get the mime type of a file - */ - public function __construct($cmd = 'file -b --mime %s 2>/dev/null') - { - $this->cmd = $cmd; - } - - /** - * Returns whether this guesser is supported on the current OS. - * - * @return bool - */ - public static function isSupported() - { - return '\\' !== DIRECTORY_SEPARATOR && function_exists('passthru') && function_exists('escapeshellarg'); - } - - /** - * {@inheritdoc} - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!self::isSupported()) { - return; - } - - ob_start(); - - // need to use --mime instead of -i. see #6641 - passthru(sprintf($this->cmd, escapeshellarg($path)), $return); - if ($return > 0) { - ob_end_clean(); - - return; - } - - $type = trim(ob_get_clean()); - - if (!preg_match('#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i', $type, $match)) { - // it's not a type, but an error message - return; - } - - return $match[1]; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php deleted file mode 100644 index a7e4ae2e5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type using the PECL extension FileInfo. - * - * @author Bernhard Schussek - */ -class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface -{ - private $magicFile; - - /** - * Constructor. - * - * @param string $magicFile A magic file to use with the finfo instance - * - * @link http://www.php.net/manual/en/function.finfo-open.php - */ - public function __construct($magicFile = null) - { - $this->magicFile = $magicFile; - } - - /** - * Returns whether this guesser is supported on the current OS/PHP setup. - * - * @return bool - */ - public static function isSupported() - { - return function_exists('finfo_open'); - } - - /** - * {@inheritdoc} - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!self::isSupported()) { - return; - } - - if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) { - return; - } - - return $finfo->file($path); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php deleted file mode 100644 index 75eeefbf5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php +++ /dev/null @@ -1,807 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -/** - * Provides a best-guess mapping of mime type to file extension. - */ -class MimeTypeExtensionGuesser implements ExtensionGuesserInterface -{ - /** - * A map of mime types and their default extensions. - * - * This list has been placed under the public domain by the Apache HTTPD project. - * This list has been updated from upstream on 2013-04-23. - * - * @see http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types - * - * @var array - */ - protected $defaultExtensions = array( - 'application/andrew-inset' => 'ez', - 'application/applixware' => 'aw', - 'application/atom+xml' => 'atom', - 'application/atomcat+xml' => 'atomcat', - 'application/atomsvc+xml' => 'atomsvc', - 'application/ccxml+xml' => 'ccxml', - 'application/cdmi-capability' => 'cdmia', - 'application/cdmi-container' => 'cdmic', - 'application/cdmi-domain' => 'cdmid', - 'application/cdmi-object' => 'cdmio', - 'application/cdmi-queue' => 'cdmiq', - 'application/cu-seeme' => 'cu', - 'application/davmount+xml' => 'davmount', - 'application/docbook+xml' => 'dbk', - 'application/dssc+der' => 'dssc', - 'application/dssc+xml' => 'xdssc', - 'application/ecmascript' => 'ecma', - 'application/emma+xml' => 'emma', - 'application/epub+zip' => 'epub', - 'application/exi' => 'exi', - 'application/font-tdpfr' => 'pfr', - 'application/gml+xml' => 'gml', - 'application/gpx+xml' => 'gpx', - 'application/gxf' => 'gxf', - 'application/hyperstudio' => 'stk', - 'application/inkml+xml' => 'ink', - 'application/ipfix' => 'ipfix', - 'application/java-archive' => 'jar', - 'application/java-serialized-object' => 'ser', - 'application/java-vm' => 'class', - 'application/javascript' => 'js', - 'application/json' => 'json', - 'application/jsonml+json' => 'jsonml', - 'application/lost+xml' => 'lostxml', - 'application/mac-binhex40' => 'hqx', - 'application/mac-compactpro' => 'cpt', - 'application/mads+xml' => 'mads', - 'application/marc' => 'mrc', - 'application/marcxml+xml' => 'mrcx', - 'application/mathematica' => 'ma', - 'application/mathml+xml' => 'mathml', - 'application/mbox' => 'mbox', - 'application/mediaservercontrol+xml' => 'mscml', - 'application/metalink+xml' => 'metalink', - 'application/metalink4+xml' => 'meta4', - 'application/mets+xml' => 'mets', - 'application/mods+xml' => 'mods', - 'application/mp21' => 'm21', - 'application/mp4' => 'mp4s', - 'application/msword' => 'doc', - 'application/mxf' => 'mxf', - 'application/octet-stream' => 'bin', - 'application/oda' => 'oda', - 'application/oebps-package+xml' => 'opf', - 'application/ogg' => 'ogx', - 'application/omdoc+xml' => 'omdoc', - 'application/onenote' => 'onetoc', - 'application/oxps' => 'oxps', - 'application/patch-ops-error+xml' => 'xer', - 'application/pdf' => 'pdf', - 'application/pgp-encrypted' => 'pgp', - 'application/pgp-signature' => 'asc', - 'application/pics-rules' => 'prf', - 'application/pkcs10' => 'p10', - 'application/pkcs7-mime' => 'p7m', - 'application/pkcs7-signature' => 'p7s', - 'application/pkcs8' => 'p8', - 'application/pkix-attr-cert' => 'ac', - 'application/pkix-cert' => 'cer', - 'application/pkix-crl' => 'crl', - 'application/pkix-pkipath' => 'pkipath', - 'application/pkixcmp' => 'pki', - 'application/pls+xml' => 'pls', - 'application/postscript' => 'ai', - 'application/prs.cww' => 'cww', - 'application/pskc+xml' => 'pskcxml', - 'application/rdf+xml' => 'rdf', - 'application/reginfo+xml' => 'rif', - 'application/relax-ng-compact-syntax' => 'rnc', - 'application/resource-lists+xml' => 'rl', - 'application/resource-lists-diff+xml' => 'rld', - 'application/rls-services+xml' => 'rs', - 'application/rpki-ghostbusters' => 'gbr', - 'application/rpki-manifest' => 'mft', - 'application/rpki-roa' => 'roa', - 'application/rsd+xml' => 'rsd', - 'application/rss+xml' => 'rss', - 'application/rtf' => 'rtf', - 'application/sbml+xml' => 'sbml', - 'application/scvp-cv-request' => 'scq', - 'application/scvp-cv-response' => 'scs', - 'application/scvp-vp-request' => 'spq', - 'application/scvp-vp-response' => 'spp', - 'application/sdp' => 'sdp', - 'application/set-payment-initiation' => 'setpay', - 'application/set-registration-initiation' => 'setreg', - 'application/shf+xml' => 'shf', - 'application/smil+xml' => 'smi', - 'application/sparql-query' => 'rq', - 'application/sparql-results+xml' => 'srx', - 'application/srgs' => 'gram', - 'application/srgs+xml' => 'grxml', - 'application/sru+xml' => 'sru', - 'application/ssdl+xml' => 'ssdl', - 'application/ssml+xml' => 'ssml', - 'application/tei+xml' => 'tei', - 'application/thraud+xml' => 'tfi', - 'application/timestamped-data' => 'tsd', - 'application/vnd.3gpp.pic-bw-large' => 'plb', - 'application/vnd.3gpp.pic-bw-small' => 'psb', - 'application/vnd.3gpp.pic-bw-var' => 'pvb', - 'application/vnd.3gpp2.tcap' => 'tcap', - 'application/vnd.3m.post-it-notes' => 'pwn', - 'application/vnd.accpac.simply.aso' => 'aso', - 'application/vnd.accpac.simply.imp' => 'imp', - 'application/vnd.acucobol' => 'acu', - 'application/vnd.acucorp' => 'atc', - 'application/vnd.adobe.air-application-installer-package+zip' => 'air', - 'application/vnd.adobe.formscentral.fcdt' => 'fcdt', - 'application/vnd.adobe.fxp' => 'fxp', - 'application/vnd.adobe.xdp+xml' => 'xdp', - 'application/vnd.adobe.xfdf' => 'xfdf', - 'application/vnd.ahead.space' => 'ahead', - 'application/vnd.airzip.filesecure.azf' => 'azf', - 'application/vnd.airzip.filesecure.azs' => 'azs', - 'application/vnd.amazon.ebook' => 'azw', - 'application/vnd.americandynamics.acc' => 'acc', - 'application/vnd.amiga.ami' => 'ami', - 'application/vnd.android.package-archive' => 'apk', - 'application/vnd.anser-web-certificate-issue-initiation' => 'cii', - 'application/vnd.anser-web-funds-transfer-initiation' => 'fti', - 'application/vnd.antix.game-component' => 'atx', - 'application/vnd.apple.installer+xml' => 'mpkg', - 'application/vnd.apple.mpegurl' => 'm3u8', - 'application/vnd.aristanetworks.swi' => 'swi', - 'application/vnd.astraea-software.iota' => 'iota', - 'application/vnd.audiograph' => 'aep', - 'application/vnd.blueice.multipass' => 'mpm', - 'application/vnd.bmi' => 'bmi', - 'application/vnd.businessobjects' => 'rep', - 'application/vnd.chemdraw+xml' => 'cdxml', - 'application/vnd.chipnuts.karaoke-mmd' => 'mmd', - 'application/vnd.cinderella' => 'cdy', - 'application/vnd.claymore' => 'cla', - 'application/vnd.cloanto.rp9' => 'rp9', - 'application/vnd.clonk.c4group' => 'c4g', - 'application/vnd.cluetrust.cartomobile-config' => 'c11amc', - 'application/vnd.cluetrust.cartomobile-config-pkg' => 'c11amz', - 'application/vnd.commonspace' => 'csp', - 'application/vnd.contact.cmsg' => 'cdbcmsg', - 'application/vnd.cosmocaller' => 'cmc', - 'application/vnd.crick.clicker' => 'clkx', - 'application/vnd.crick.clicker.keyboard' => 'clkk', - 'application/vnd.crick.clicker.palette' => 'clkp', - 'application/vnd.crick.clicker.template' => 'clkt', - 'application/vnd.crick.clicker.wordbank' => 'clkw', - 'application/vnd.criticaltools.wbs+xml' => 'wbs', - 'application/vnd.ctc-posml' => 'pml', - 'application/vnd.cups-ppd' => 'ppd', - 'application/vnd.curl.car' => 'car', - 'application/vnd.curl.pcurl' => 'pcurl', - 'application/vnd.dart' => 'dart', - 'application/vnd.data-vision.rdz' => 'rdz', - 'application/vnd.dece.data' => 'uvf', - 'application/vnd.dece.ttml+xml' => 'uvt', - 'application/vnd.dece.unspecified' => 'uvx', - 'application/vnd.dece.zip' => 'uvz', - 'application/vnd.denovo.fcselayout-link' => 'fe_launch', - 'application/vnd.dna' => 'dna', - 'application/vnd.dolby.mlp' => 'mlp', - 'application/vnd.dpgraph' => 'dpg', - 'application/vnd.dreamfactory' => 'dfac', - 'application/vnd.ds-keypoint' => 'kpxx', - 'application/vnd.dvb.ait' => 'ait', - 'application/vnd.dvb.service' => 'svc', - 'application/vnd.dynageo' => 'geo', - 'application/vnd.ecowin.chart' => 'mag', - 'application/vnd.enliven' => 'nml', - 'application/vnd.epson.esf' => 'esf', - 'application/vnd.epson.msf' => 'msf', - 'application/vnd.epson.quickanime' => 'qam', - 'application/vnd.epson.salt' => 'slt', - 'application/vnd.epson.ssf' => 'ssf', - 'application/vnd.eszigno3+xml' => 'es3', - 'application/vnd.ezpix-album' => 'ez2', - 'application/vnd.ezpix-package' => 'ez3', - 'application/vnd.fdf' => 'fdf', - 'application/vnd.fdsn.mseed' => 'mseed', - 'application/vnd.fdsn.seed' => 'seed', - 'application/vnd.flographit' => 'gph', - 'application/vnd.fluxtime.clip' => 'ftc', - 'application/vnd.framemaker' => 'fm', - 'application/vnd.frogans.fnc' => 'fnc', - 'application/vnd.frogans.ltf' => 'ltf', - 'application/vnd.fsc.weblaunch' => 'fsc', - 'application/vnd.fujitsu.oasys' => 'oas', - 'application/vnd.fujitsu.oasys2' => 'oa2', - 'application/vnd.fujitsu.oasys3' => 'oa3', - 'application/vnd.fujitsu.oasysgp' => 'fg5', - 'application/vnd.fujitsu.oasysprs' => 'bh2', - 'application/vnd.fujixerox.ddd' => 'ddd', - 'application/vnd.fujixerox.docuworks' => 'xdw', - 'application/vnd.fujixerox.docuworks.binder' => 'xbd', - 'application/vnd.fuzzysheet' => 'fzs', - 'application/vnd.genomatix.tuxedo' => 'txd', - 'application/vnd.geogebra.file' => 'ggb', - 'application/vnd.geogebra.tool' => 'ggt', - 'application/vnd.geometry-explorer' => 'gex', - 'application/vnd.geonext' => 'gxt', - 'application/vnd.geoplan' => 'g2w', - 'application/vnd.geospace' => 'g3w', - 'application/vnd.gmx' => 'gmx', - 'application/vnd.google-earth.kml+xml' => 'kml', - 'application/vnd.google-earth.kmz' => 'kmz', - 'application/vnd.grafeq' => 'gqf', - 'application/vnd.groove-account' => 'gac', - 'application/vnd.groove-help' => 'ghf', - 'application/vnd.groove-identity-message' => 'gim', - 'application/vnd.groove-injector' => 'grv', - 'application/vnd.groove-tool-message' => 'gtm', - 'application/vnd.groove-tool-template' => 'tpl', - 'application/vnd.groove-vcard' => 'vcg', - 'application/vnd.hal+xml' => 'hal', - 'application/vnd.handheld-entertainment+xml' => 'zmm', - 'application/vnd.hbci' => 'hbci', - 'application/vnd.hhe.lesson-player' => 'les', - 'application/vnd.hp-hpgl' => 'hpgl', - 'application/vnd.hp-hpid' => 'hpid', - 'application/vnd.hp-hps' => 'hps', - 'application/vnd.hp-jlyt' => 'jlt', - 'application/vnd.hp-pcl' => 'pcl', - 'application/vnd.hp-pclxl' => 'pclxl', - 'application/vnd.hydrostatix.sof-data' => 'sfd-hdstx', - 'application/vnd.ibm.minipay' => 'mpy', - 'application/vnd.ibm.modcap' => 'afp', - 'application/vnd.ibm.rights-management' => 'irm', - 'application/vnd.ibm.secure-container' => 'sc', - 'application/vnd.iccprofile' => 'icc', - 'application/vnd.igloader' => 'igl', - 'application/vnd.immervision-ivp' => 'ivp', - 'application/vnd.immervision-ivu' => 'ivu', - 'application/vnd.insors.igm' => 'igm', - 'application/vnd.intercon.formnet' => 'xpw', - 'application/vnd.intergeo' => 'i2g', - 'application/vnd.intu.qbo' => 'qbo', - 'application/vnd.intu.qfx' => 'qfx', - 'application/vnd.ipunplugged.rcprofile' => 'rcprofile', - 'application/vnd.irepository.package+xml' => 'irp', - 'application/vnd.is-xpr' => 'xpr', - 'application/vnd.isac.fcs' => 'fcs', - 'application/vnd.jam' => 'jam', - 'application/vnd.jcp.javame.midlet-rms' => 'rms', - 'application/vnd.jisp' => 'jisp', - 'application/vnd.joost.joda-archive' => 'joda', - 'application/vnd.kahootz' => 'ktz', - 'application/vnd.kde.karbon' => 'karbon', - 'application/vnd.kde.kchart' => 'chrt', - 'application/vnd.kde.kformula' => 'kfo', - 'application/vnd.kde.kivio' => 'flw', - 'application/vnd.kde.kontour' => 'kon', - 'application/vnd.kde.kpresenter' => 'kpr', - 'application/vnd.kde.kspread' => 'ksp', - 'application/vnd.kde.kword' => 'kwd', - 'application/vnd.kenameaapp' => 'htke', - 'application/vnd.kidspiration' => 'kia', - 'application/vnd.kinar' => 'kne', - 'application/vnd.koan' => 'skp', - 'application/vnd.kodak-descriptor' => 'sse', - 'application/vnd.las.las+xml' => 'lasxml', - 'application/vnd.llamagraphics.life-balance.desktop' => 'lbd', - 'application/vnd.llamagraphics.life-balance.exchange+xml' => 'lbe', - 'application/vnd.lotus-1-2-3' => '123', - 'application/vnd.lotus-approach' => 'apr', - 'application/vnd.lotus-freelance' => 'pre', - 'application/vnd.lotus-notes' => 'nsf', - 'application/vnd.lotus-organizer' => 'org', - 'application/vnd.lotus-screencam' => 'scm', - 'application/vnd.lotus-wordpro' => 'lwp', - 'application/vnd.macports.portpkg' => 'portpkg', - 'application/vnd.mcd' => 'mcd', - 'application/vnd.medcalcdata' => 'mc1', - 'application/vnd.mediastation.cdkey' => 'cdkey', - 'application/vnd.mfer' => 'mwf', - 'application/vnd.mfmp' => 'mfm', - 'application/vnd.micrografx.flo' => 'flo', - 'application/vnd.micrografx.igx' => 'igx', - 'application/vnd.mif' => 'mif', - 'application/vnd.mobius.daf' => 'daf', - 'application/vnd.mobius.dis' => 'dis', - 'application/vnd.mobius.mbk' => 'mbk', - 'application/vnd.mobius.mqy' => 'mqy', - 'application/vnd.mobius.msl' => 'msl', - 'application/vnd.mobius.plc' => 'plc', - 'application/vnd.mobius.txf' => 'txf', - 'application/vnd.mophun.application' => 'mpn', - 'application/vnd.mophun.certificate' => 'mpc', - 'application/vnd.mozilla.xul+xml' => 'xul', - 'application/vnd.ms-artgalry' => 'cil', - 'application/vnd.ms-cab-compressed' => 'cab', - 'application/vnd.ms-excel' => 'xls', - 'application/vnd.ms-excel.addin.macroenabled.12' => 'xlam', - 'application/vnd.ms-excel.sheet.binary.macroenabled.12' => 'xlsb', - 'application/vnd.ms-excel.sheet.macroenabled.12' => 'xlsm', - 'application/vnd.ms-excel.template.macroenabled.12' => 'xltm', - 'application/vnd.ms-fontobject' => 'eot', - 'application/vnd.ms-htmlhelp' => 'chm', - 'application/vnd.ms-ims' => 'ims', - 'application/vnd.ms-lrm' => 'lrm', - 'application/vnd.ms-officetheme' => 'thmx', - 'application/vnd.ms-pki.seccat' => 'cat', - 'application/vnd.ms-pki.stl' => 'stl', - 'application/vnd.ms-powerpoint' => 'ppt', - 'application/vnd.ms-powerpoint.addin.macroenabled.12' => 'ppam', - 'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 'pptm', - 'application/vnd.ms-powerpoint.slide.macroenabled.12' => 'sldm', - 'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 'ppsm', - 'application/vnd.ms-powerpoint.template.macroenabled.12' => 'potm', - 'application/vnd.ms-project' => 'mpp', - 'application/vnd.ms-word.document.macroenabled.12' => 'docm', - 'application/vnd.ms-word.template.macroenabled.12' => 'dotm', - 'application/vnd.ms-works' => 'wps', - 'application/vnd.ms-wpl' => 'wpl', - 'application/vnd.ms-xpsdocument' => 'xps', - 'application/vnd.mseq' => 'mseq', - 'application/vnd.musician' => 'mus', - 'application/vnd.muvee.style' => 'msty', - 'application/vnd.mynfc' => 'taglet', - 'application/vnd.neurolanguage.nlu' => 'nlu', - 'application/vnd.nitf' => 'ntf', - 'application/vnd.noblenet-directory' => 'nnd', - 'application/vnd.noblenet-sealer' => 'nns', - 'application/vnd.noblenet-web' => 'nnw', - 'application/vnd.nokia.n-gage.data' => 'ngdat', - 'application/vnd.nokia.n-gage.symbian.install' => 'n-gage', - 'application/vnd.nokia.radio-preset' => 'rpst', - 'application/vnd.nokia.radio-presets' => 'rpss', - 'application/vnd.novadigm.edm' => 'edm', - 'application/vnd.novadigm.edx' => 'edx', - 'application/vnd.novadigm.ext' => 'ext', - 'application/vnd.oasis.opendocument.chart' => 'odc', - 'application/vnd.oasis.opendocument.chart-template' => 'otc', - 'application/vnd.oasis.opendocument.database' => 'odb', - 'application/vnd.oasis.opendocument.formula' => 'odf', - 'application/vnd.oasis.opendocument.formula-template' => 'odft', - 'application/vnd.oasis.opendocument.graphics' => 'odg', - 'application/vnd.oasis.opendocument.graphics-template' => 'otg', - 'application/vnd.oasis.opendocument.image' => 'odi', - 'application/vnd.oasis.opendocument.image-template' => 'oti', - 'application/vnd.oasis.opendocument.presentation' => 'odp', - 'application/vnd.oasis.opendocument.presentation-template' => 'otp', - 'application/vnd.oasis.opendocument.spreadsheet' => 'ods', - 'application/vnd.oasis.opendocument.spreadsheet-template' => 'ots', - 'application/vnd.oasis.opendocument.text' => 'odt', - 'application/vnd.oasis.opendocument.text-master' => 'odm', - 'application/vnd.oasis.opendocument.text-template' => 'ott', - 'application/vnd.oasis.opendocument.text-web' => 'oth', - 'application/vnd.olpc-sugar' => 'xo', - 'application/vnd.oma.dd2+xml' => 'dd2', - 'application/vnd.openofficeorg.extension' => 'oxt', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', - 'application/vnd.openxmlformats-officedocument.presentationml.slide' => 'sldx', - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'ppsx', - 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'potx', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'xltx', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'dotx', - 'application/vnd.osgeo.mapguide.package' => 'mgp', - 'application/vnd.osgi.dp' => 'dp', - 'application/vnd.osgi.subsystem' => 'esa', - 'application/vnd.palm' => 'pdb', - 'application/vnd.pawaafile' => 'paw', - 'application/vnd.pg.format' => 'str', - 'application/vnd.pg.osasli' => 'ei6', - 'application/vnd.picsel' => 'efif', - 'application/vnd.pmi.widget' => 'wg', - 'application/vnd.pocketlearn' => 'plf', - 'application/vnd.powerbuilder6' => 'pbd', - 'application/vnd.previewsystems.box' => 'box', - 'application/vnd.proteus.magazine' => 'mgz', - 'application/vnd.publishare-delta-tree' => 'qps', - 'application/vnd.pvi.ptid1' => 'ptid', - 'application/vnd.quark.quarkxpress' => 'qxd', - 'application/vnd.realvnc.bed' => 'bed', - 'application/vnd.recordare.musicxml' => 'mxl', - 'application/vnd.recordare.musicxml+xml' => 'musicxml', - 'application/vnd.rig.cryptonote' => 'cryptonote', - 'application/vnd.rim.cod' => 'cod', - 'application/vnd.rn-realmedia' => 'rm', - 'application/vnd.rn-realmedia-vbr' => 'rmvb', - 'application/vnd.route66.link66+xml' => 'link66', - 'application/vnd.sailingtracker.track' => 'st', - 'application/vnd.seemail' => 'see', - 'application/vnd.sema' => 'sema', - 'application/vnd.semd' => 'semd', - 'application/vnd.semf' => 'semf', - 'application/vnd.shana.informed.formdata' => 'ifm', - 'application/vnd.shana.informed.formtemplate' => 'itp', - 'application/vnd.shana.informed.interchange' => 'iif', - 'application/vnd.shana.informed.package' => 'ipk', - 'application/vnd.simtech-mindmapper' => 'twd', - 'application/vnd.smaf' => 'mmf', - 'application/vnd.smart.teacher' => 'teacher', - 'application/vnd.solent.sdkm+xml' => 'sdkm', - 'application/vnd.spotfire.dxp' => 'dxp', - 'application/vnd.spotfire.sfs' => 'sfs', - 'application/vnd.stardivision.calc' => 'sdc', - 'application/vnd.stardivision.draw' => 'sda', - 'application/vnd.stardivision.impress' => 'sdd', - 'application/vnd.stardivision.math' => 'smf', - 'application/vnd.stardivision.writer' => 'sdw', - 'application/vnd.stardivision.writer-global' => 'sgl', - 'application/vnd.stepmania.package' => 'smzip', - 'application/vnd.stepmania.stepchart' => 'sm', - 'application/vnd.sun.xml.calc' => 'sxc', - 'application/vnd.sun.xml.calc.template' => 'stc', - 'application/vnd.sun.xml.draw' => 'sxd', - 'application/vnd.sun.xml.draw.template' => 'std', - 'application/vnd.sun.xml.impress' => 'sxi', - 'application/vnd.sun.xml.impress.template' => 'sti', - 'application/vnd.sun.xml.math' => 'sxm', - 'application/vnd.sun.xml.writer' => 'sxw', - 'application/vnd.sun.xml.writer.global' => 'sxg', - 'application/vnd.sun.xml.writer.template' => 'stw', - 'application/vnd.sus-calendar' => 'sus', - 'application/vnd.svd' => 'svd', - 'application/vnd.symbian.install' => 'sis', - 'application/vnd.syncml+xml' => 'xsm', - 'application/vnd.syncml.dm+wbxml' => 'bdm', - 'application/vnd.syncml.dm+xml' => 'xdm', - 'application/vnd.tao.intent-module-archive' => 'tao', - 'application/vnd.tcpdump.pcap' => 'pcap', - 'application/vnd.tmobile-livetv' => 'tmo', - 'application/vnd.trid.tpt' => 'tpt', - 'application/vnd.triscape.mxs' => 'mxs', - 'application/vnd.trueapp' => 'tra', - 'application/vnd.ufdl' => 'ufd', - 'application/vnd.uiq.theme' => 'utz', - 'application/vnd.umajin' => 'umj', - 'application/vnd.unity' => 'unityweb', - 'application/vnd.uoml+xml' => 'uoml', - 'application/vnd.vcx' => 'vcx', - 'application/vnd.visio' => 'vsd', - 'application/vnd.visionary' => 'vis', - 'application/vnd.vsf' => 'vsf', - 'application/vnd.wap.wbxml' => 'wbxml', - 'application/vnd.wap.wmlc' => 'wmlc', - 'application/vnd.wap.wmlscriptc' => 'wmlsc', - 'application/vnd.webturbo' => 'wtb', - 'application/vnd.wolfram.player' => 'nbp', - 'application/vnd.wordperfect' => 'wpd', - 'application/vnd.wqd' => 'wqd', - 'application/vnd.wt.stf' => 'stf', - 'application/vnd.xara' => 'xar', - 'application/vnd.xfdl' => 'xfdl', - 'application/vnd.yamaha.hv-dic' => 'hvd', - 'application/vnd.yamaha.hv-script' => 'hvs', - 'application/vnd.yamaha.hv-voice' => 'hvp', - 'application/vnd.yamaha.openscoreformat' => 'osf', - 'application/vnd.yamaha.openscoreformat.osfpvg+xml' => 'osfpvg', - 'application/vnd.yamaha.smaf-audio' => 'saf', - 'application/vnd.yamaha.smaf-phrase' => 'spf', - 'application/vnd.yellowriver-custom-menu' => 'cmp', - 'application/vnd.zul' => 'zir', - 'application/vnd.zzazz.deck+xml' => 'zaz', - 'application/voicexml+xml' => 'vxml', - 'application/widget' => 'wgt', - 'application/winhlp' => 'hlp', - 'application/wsdl+xml' => 'wsdl', - 'application/wspolicy+xml' => 'wspolicy', - 'application/x-7z-compressed' => '7z', - 'application/x-abiword' => 'abw', - 'application/x-ace-compressed' => 'ace', - 'application/x-apple-diskimage' => 'dmg', - 'application/x-authorware-bin' => 'aab', - 'application/x-authorware-map' => 'aam', - 'application/x-authorware-seg' => 'aas', - 'application/x-bcpio' => 'bcpio', - 'application/x-bittorrent' => 'torrent', - 'application/x-blorb' => 'blb', - 'application/x-bzip' => 'bz', - 'application/x-bzip2' => 'bz2', - 'application/x-cbr' => 'cbr', - 'application/x-cdlink' => 'vcd', - 'application/x-cfs-compressed' => 'cfs', - 'application/x-chat' => 'chat', - 'application/x-chess-pgn' => 'pgn', - 'application/x-conference' => 'nsc', - 'application/x-cpio' => 'cpio', - 'application/x-csh' => 'csh', - 'application/x-debian-package' => 'deb', - 'application/x-dgc-compressed' => 'dgc', - 'application/x-director' => 'dir', - 'application/x-doom' => 'wad', - 'application/x-dtbncx+xml' => 'ncx', - 'application/x-dtbook+xml' => 'dtb', - 'application/x-dtbresource+xml' => 'res', - 'application/x-dvi' => 'dvi', - 'application/x-envoy' => 'evy', - 'application/x-eva' => 'eva', - 'application/x-font-bdf' => 'bdf', - 'application/x-font-ghostscript' => 'gsf', - 'application/x-font-linux-psf' => 'psf', - 'application/x-font-otf' => 'otf', - 'application/x-font-pcf' => 'pcf', - 'application/x-font-snf' => 'snf', - 'application/x-font-ttf' => 'ttf', - 'application/x-font-type1' => 'pfa', - 'application/x-font-woff' => 'woff', - 'application/x-freearc' => 'arc', - 'application/x-futuresplash' => 'spl', - 'application/x-gca-compressed' => 'gca', - 'application/x-glulx' => 'ulx', - 'application/x-gnumeric' => 'gnumeric', - 'application/x-gramps-xml' => 'gramps', - 'application/x-gtar' => 'gtar', - 'application/x-hdf' => 'hdf', - 'application/x-install-instructions' => 'install', - 'application/x-iso9660-image' => 'iso', - 'application/x-java-jnlp-file' => 'jnlp', - 'application/x-latex' => 'latex', - 'application/x-lzh-compressed' => 'lzh', - 'application/x-mie' => 'mie', - 'application/x-mobipocket-ebook' => 'prc', - 'application/x-ms-application' => 'application', - 'application/x-ms-shortcut' => 'lnk', - 'application/x-ms-wmd' => 'wmd', - 'application/x-ms-wmz' => 'wmz', - 'application/x-ms-xbap' => 'xbap', - 'application/x-msaccess' => 'mdb', - 'application/x-msbinder' => 'obd', - 'application/x-mscardfile' => 'crd', - 'application/x-msclip' => 'clp', - 'application/x-msdownload' => 'exe', - 'application/x-msmediaview' => 'mvb', - 'application/x-msmetafile' => 'wmf', - 'application/x-msmoney' => 'mny', - 'application/x-mspublisher' => 'pub', - 'application/x-msschedule' => 'scd', - 'application/x-msterminal' => 'trm', - 'application/x-mswrite' => 'wri', - 'application/x-netcdf' => 'nc', - 'application/x-nzb' => 'nzb', - 'application/x-pkcs12' => 'p12', - 'application/x-pkcs7-certificates' => 'p7b', - 'application/x-pkcs7-certreqresp' => 'p7r', - 'application/x-rar-compressed' => 'rar', - 'application/x-rar' => 'rar', - 'application/x-research-info-systems' => 'ris', - 'application/x-sh' => 'sh', - 'application/x-shar' => 'shar', - 'application/x-shockwave-flash' => 'swf', - 'application/x-silverlight-app' => 'xap', - 'application/x-sql' => 'sql', - 'application/x-stuffit' => 'sit', - 'application/x-stuffitx' => 'sitx', - 'application/x-subrip' => 'srt', - 'application/x-sv4cpio' => 'sv4cpio', - 'application/x-sv4crc' => 'sv4crc', - 'application/x-t3vm-image' => 't3', - 'application/x-tads' => 'gam', - 'application/x-tar' => 'tar', - 'application/x-tcl' => 'tcl', - 'application/x-tex' => 'tex', - 'application/x-tex-tfm' => 'tfm', - 'application/x-texinfo' => 'texinfo', - 'application/x-tgif' => 'obj', - 'application/x-ustar' => 'ustar', - 'application/x-wais-source' => 'src', - 'application/x-x509-ca-cert' => 'der', - 'application/x-xfig' => 'fig', - 'application/x-xliff+xml' => 'xlf', - 'application/x-xpinstall' => 'xpi', - 'application/x-xz' => 'xz', - 'application/x-zmachine' => 'z1', - 'application/xaml+xml' => 'xaml', - 'application/xcap-diff+xml' => 'xdf', - 'application/xenc+xml' => 'xenc', - 'application/xhtml+xml' => 'xhtml', - 'application/xml' => 'xml', - 'application/xml-dtd' => 'dtd', - 'application/xop+xml' => 'xop', - 'application/xproc+xml' => 'xpl', - 'application/xslt+xml' => 'xslt', - 'application/xspf+xml' => 'xspf', - 'application/xv+xml' => 'mxml', - 'application/yang' => 'yang', - 'application/yin+xml' => 'yin', - 'application/zip' => 'zip', - 'audio/adpcm' => 'adp', - 'audio/basic' => 'au', - 'audio/midi' => 'mid', - 'audio/mp4' => 'mp4a', - 'audio/mpeg' => 'mpga', - 'audio/ogg' => 'oga', - 'audio/s3m' => 's3m', - 'audio/silk' => 'sil', - 'audio/vnd.dece.audio' => 'uva', - 'audio/vnd.digital-winds' => 'eol', - 'audio/vnd.dra' => 'dra', - 'audio/vnd.dts' => 'dts', - 'audio/vnd.dts.hd' => 'dtshd', - 'audio/vnd.lucent.voice' => 'lvp', - 'audio/vnd.ms-playready.media.pya' => 'pya', - 'audio/vnd.nuera.ecelp4800' => 'ecelp4800', - 'audio/vnd.nuera.ecelp7470' => 'ecelp7470', - 'audio/vnd.nuera.ecelp9600' => 'ecelp9600', - 'audio/vnd.rip' => 'rip', - 'audio/webm' => 'weba', - 'audio/x-aac' => 'aac', - 'audio/x-aiff' => 'aif', - 'audio/x-caf' => 'caf', - 'audio/x-flac' => 'flac', - 'audio/x-matroska' => 'mka', - 'audio/x-mpegurl' => 'm3u', - 'audio/x-ms-wax' => 'wax', - 'audio/x-ms-wma' => 'wma', - 'audio/x-pn-realaudio' => 'ram', - 'audio/x-pn-realaudio-plugin' => 'rmp', - 'audio/x-wav' => 'wav', - 'audio/xm' => 'xm', - 'chemical/x-cdx' => 'cdx', - 'chemical/x-cif' => 'cif', - 'chemical/x-cmdf' => 'cmdf', - 'chemical/x-cml' => 'cml', - 'chemical/x-csml' => 'csml', - 'chemical/x-xyz' => 'xyz', - 'image/bmp' => 'bmp', - 'image/x-ms-bmp' => 'bmp', - 'image/cgm' => 'cgm', - 'image/g3fax' => 'g3', - 'image/gif' => 'gif', - 'image/ief' => 'ief', - 'image/jpeg' => 'jpeg', - 'image/ktx' => 'ktx', - 'image/png' => 'png', - 'image/prs.btif' => 'btif', - 'image/sgi' => 'sgi', - 'image/svg+xml' => 'svg', - 'image/tiff' => 'tiff', - 'image/vnd.adobe.photoshop' => 'psd', - 'image/vnd.dece.graphic' => 'uvi', - 'image/vnd.dvb.subtitle' => 'sub', - 'image/vnd.djvu' => 'djvu', - 'image/vnd.dwg' => 'dwg', - 'image/vnd.dxf' => 'dxf', - 'image/vnd.fastbidsheet' => 'fbs', - 'image/vnd.fpx' => 'fpx', - 'image/vnd.fst' => 'fst', - 'image/vnd.fujixerox.edmics-mmr' => 'mmr', - 'image/vnd.fujixerox.edmics-rlc' => 'rlc', - 'image/vnd.ms-modi' => 'mdi', - 'image/vnd.ms-photo' => 'wdp', - 'image/vnd.net-fpx' => 'npx', - 'image/vnd.wap.wbmp' => 'wbmp', - 'image/vnd.xiff' => 'xif', - 'image/webp' => 'webp', - 'image/x-3ds' => '3ds', - 'image/x-cmu-raster' => 'ras', - 'image/x-cmx' => 'cmx', - 'image/x-freehand' => 'fh', - 'image/x-icon' => 'ico', - 'image/x-mrsid-image' => 'sid', - 'image/x-pcx' => 'pcx', - 'image/x-pict' => 'pic', - 'image/x-portable-anymap' => 'pnm', - 'image/x-portable-bitmap' => 'pbm', - 'image/x-portable-graymap' => 'pgm', - 'image/x-portable-pixmap' => 'ppm', - 'image/x-rgb' => 'rgb', - 'image/x-tga' => 'tga', - 'image/x-xbitmap' => 'xbm', - 'image/x-xpixmap' => 'xpm', - 'image/x-xwindowdump' => 'xwd', - 'message/rfc822' => 'eml', - 'model/iges' => 'igs', - 'model/mesh' => 'msh', - 'model/vnd.collada+xml' => 'dae', - 'model/vnd.dwf' => 'dwf', - 'model/vnd.gdl' => 'gdl', - 'model/vnd.gtw' => 'gtw', - 'model/vnd.mts' => 'mts', - 'model/vnd.vtu' => 'vtu', - 'model/vrml' => 'wrl', - 'model/x3d+binary' => 'x3db', - 'model/x3d+vrml' => 'x3dv', - 'model/x3d+xml' => 'x3d', - 'text/cache-manifest' => 'appcache', - 'text/calendar' => 'ics', - 'text/css' => 'css', - 'text/csv' => 'csv', - 'text/html' => 'html', - 'text/n3' => 'n3', - 'text/plain' => 'txt', - 'text/prs.lines.tag' => 'dsc', - 'text/richtext' => 'rtx', - 'text/rtf' => 'rtf', - 'text/sgml' => 'sgml', - 'text/tab-separated-values' => 'tsv', - 'text/troff' => 't', - 'text/turtle' => 'ttl', - 'text/uri-list' => 'uri', - 'text/vcard' => 'vcard', - 'text/vnd.curl' => 'curl', - 'text/vnd.curl.dcurl' => 'dcurl', - 'text/vnd.curl.scurl' => 'scurl', - 'text/vnd.curl.mcurl' => 'mcurl', - 'text/vnd.dvb.subtitle' => 'sub', - 'text/vnd.fly' => 'fly', - 'text/vnd.fmi.flexstor' => 'flx', - 'text/vnd.graphviz' => 'gv', - 'text/vnd.in3d.3dml' => '3dml', - 'text/vnd.in3d.spot' => 'spot', - 'text/vnd.sun.j2me.app-descriptor' => 'jad', - 'text/vnd.wap.wml' => 'wml', - 'text/vnd.wap.wmlscript' => 'wmls', - 'text/x-asm' => 's', - 'text/x-c' => 'c', - 'text/x-fortran' => 'f', - 'text/x-pascal' => 'p', - 'text/x-java-source' => 'java', - 'text/x-opml' => 'opml', - 'text/x-nfo' => 'nfo', - 'text/x-setext' => 'etx', - 'text/x-sfv' => 'sfv', - 'text/x-uuencode' => 'uu', - 'text/x-vcalendar' => 'vcs', - 'text/x-vcard' => 'vcf', - 'video/3gpp' => '3gp', - 'video/3gpp2' => '3g2', - 'video/h261' => 'h261', - 'video/h263' => 'h263', - 'video/h264' => 'h264', - 'video/jpeg' => 'jpgv', - 'video/jpm' => 'jpm', - 'video/mj2' => 'mj2', - 'video/mp4' => 'mp4', - 'video/mpeg' => 'mpeg', - 'video/ogg' => 'ogv', - 'video/quicktime' => 'qt', - 'video/vnd.dece.hd' => 'uvh', - 'video/vnd.dece.mobile' => 'uvm', - 'video/vnd.dece.pd' => 'uvp', - 'video/vnd.dece.sd' => 'uvs', - 'video/vnd.dece.video' => 'uvv', - 'video/vnd.dvb.file' => 'dvb', - 'video/vnd.fvt' => 'fvt', - 'video/vnd.mpegurl' => 'mxu', - 'video/vnd.ms-playready.media.pyv' => 'pyv', - 'video/vnd.uvvu.mp4' => 'uvu', - 'video/vnd.vivo' => 'viv', - 'video/webm' => 'webm', - 'video/x-f4v' => 'f4v', - 'video/x-fli' => 'fli', - 'video/x-flv' => 'flv', - 'video/x-m4v' => 'm4v', - 'video/x-matroska' => 'mkv', - 'video/x-mng' => 'mng', - 'video/x-ms-asf' => 'asf', - 'video/x-ms-vob' => 'vob', - 'video/x-ms-wm' => 'wm', - 'video/x-ms-wmv' => 'wmv', - 'video/x-ms-wmx' => 'wmx', - 'video/x-ms-wvx' => 'wvx', - 'video/x-msvideo' => 'avi', - 'video/x-sgi-movie' => 'movie', - 'video/x-smv' => 'smv', - 'x-conference/x-cooltalk' => 'ice', - ); - - /** - * {@inheritdoc} - */ - public function guess($mimeType) - { - return isset($this->defaultExtensions[$mimeType]) ? $this->defaultExtensions[$mimeType] : null; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php deleted file mode 100644 index ecc8a30ac..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * A singleton mime type guesser. - * - * By default, all mime type guessers provided by the framework are installed - * (if available on the current OS/PHP setup). - * - * You can register custom guessers by calling the register() method on the - * singleton instance. Custom guessers are always called before any default ones. - * - * $guesser = MimeTypeGuesser::getInstance(); - * $guesser->register(new MyCustomMimeTypeGuesser()); - * - * If you want to change the order of the default guessers, just re-register your - * preferred one as a custom one. The last registered guesser is preferred over - * previously registered ones. - * - * Re-registering a built-in guesser also allows you to configure it: - * - * $guesser = MimeTypeGuesser::getInstance(); - * $guesser->register(new FileinfoMimeTypeGuesser('/path/to/magic/file')); - * - * @author Bernhard Schussek - */ -class MimeTypeGuesser implements MimeTypeGuesserInterface -{ - /** - * The singleton instance. - * - * @var MimeTypeGuesser - */ - private static $instance = null; - - /** - * All registered MimeTypeGuesserInterface instances. - * - * @var array - */ - protected $guessers = array(); - - /** - * Returns the singleton instance. - * - * @return MimeTypeGuesser - */ - public static function getInstance() - { - if (null === self::$instance) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Resets the singleton instance. - */ - public static function reset() - { - self::$instance = null; - } - - /** - * Registers all natively provided mime type guessers. - */ - private function __construct() - { - if (FileBinaryMimeTypeGuesser::isSupported()) { - $this->register(new FileBinaryMimeTypeGuesser()); - } - - if (FileinfoMimeTypeGuesser::isSupported()) { - $this->register(new FileinfoMimeTypeGuesser()); - } - } - - /** - * Registers a new mime type guesser. - * - * When guessing, this guesser is preferred over previously registered ones. - * - * @param MimeTypeGuesserInterface $guesser - */ - public function register(MimeTypeGuesserInterface $guesser) - { - array_unshift($this->guessers, $guesser); - } - - /** - * Tries to guess the mime type of the given file. - * - * The file is passed to each registered mime type guesser in reverse order - * of their registration (last registered is queried first). Once a guesser - * returns a value that is not NULL, this method terminates and returns the - * value. - * - * @param string $path The path to the file - * - * @return string The mime type or NULL, if none could be guessed - * - * @throws \LogicException - * @throws FileNotFoundException - * @throws AccessDeniedException - */ - public function guess($path) - { - if (!is_file($path)) { - throw new FileNotFoundException($path); - } - - if (!is_readable($path)) { - throw new AccessDeniedException($path); - } - - if (!$this->guessers) { - $msg = 'Unable to guess the mime type as no guessers are available'; - if (!FileinfoMimeTypeGuesser::isSupported()) { - $msg .= ' (Did you enable the php_fileinfo extension?)'; - } - throw new \LogicException($msg); - } - - foreach ($this->guessers as $guesser) { - if (null !== $mimeType = $guesser->guess($path)) { - return $mimeType; - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php deleted file mode 100644 index f8c3ad228..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File\MimeType; - -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException; - -/** - * Guesses the mime type of a file. - * - * @author Bernhard Schussek - */ -interface MimeTypeGuesserInterface -{ - /** - * Guesses the mime type of the file with the given path. - * - * @param string $path The path to the file - * - * @return string The mime type or NULL, if none could be guessed - * - * @throws FileNotFoundException If the file does not exist - * @throws AccessDeniedException If the file could not be read - */ - public function guess($path); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php deleted file mode 100644 index 0f3f8022e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ /dev/null @@ -1,309 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\File; - -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; - -/** - * A file uploaded through a form. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - * @author Fabien Potencier - * - * @api - */ -class UploadedFile extends File -{ - /** - * Whether the test mode is activated. - * - * Local files are used in test mode hence the code should not enforce HTTP uploads. - * - * @var bool - */ - private $test = false; - - /** - * The original name of the uploaded file. - * - * @var string - */ - private $originalName; - - /** - * The mime type provided by the uploader. - * - * @var string - */ - private $mimeType; - - /** - * The file size provided by the uploader. - * - * @var string - */ - private $size; - - /** - * The UPLOAD_ERR_XXX constant provided by the uploader. - * - * @var int - */ - private $error; - - /** - * Accepts the information of the uploaded file as provided by the PHP global $_FILES. - * - * The file object is only created when the uploaded file is valid (i.e. when the - * isValid() method returns true). Otherwise the only methods that could be called - * on an UploadedFile instance are: - * - * * getClientOriginalName, - * * getClientMimeType, - * * isValid, - * * getError. - * - * Calling any other method on an non-valid instance will cause an unpredictable result. - * - * @param string $path The full temporary path to the file - * @param string $originalName The original file name - * @param string $mimeType The type of the file as provided by PHP - * @param int $size The file size - * @param int $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants) - * @param bool $test Whether the test mode is active - * - * @throws FileException If file_uploads is disabled - * @throws FileNotFoundException If the file does not exist - * - * @api - */ - public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false) - { - $this->originalName = $this->getName($originalName); - $this->mimeType = $mimeType ?: 'application/octet-stream'; - $this->size = $size; - $this->error = $error ?: UPLOAD_ERR_OK; - $this->test = (bool) $test; - - parent::__construct($path, UPLOAD_ERR_OK === $this->error); - } - - /** - * Returns the original file name. - * - * It is extracted from the request from which the file has been uploaded. - * Then it should not be considered as a safe value. - * - * @return string|null The original name - * - * @api - */ - public function getClientOriginalName() - { - return $this->originalName; - } - - /** - * Returns the original file extension. - * - * It is extracted from the original file name that was uploaded. - * Then it 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. - * - * The client mime type is extracted from the request from which the file - * was uploaded, so it should not be considered as a safe value. - * - * For a trusted mime type, use getMimeType() instead (which guesses the mime - * type based on the file content). - * - * @return string|null The mime type - * - * @see getMimeType() - * - * @api - */ - public function getClientMimeType() - { - return $this->mimeType; - } - - /** - * Returns the extension based on the client mime type. - * - * If the mime type is unknown, returns null. - * - * This method uses the mime type as guessed by getClientMimeType() - * to guess the file extension. As such, the extension returned - * by this method cannot be trusted. - * - * For a trusted extension, use guessExtension() instead (which guesses - * the extension based on the guessed mime type for the file). - * - * @return string|null The guessed extension or null if it cannot be guessed - * - * @see guessExtension() - * @see getClientMimeType() - */ - public function guessClientExtension() - { - $type = $this->getClientMimeType(); - $guesser = ExtensionGuesser::getInstance(); - - return $guesser->guess($type); - } - - /** - * Returns the file size. - * - * It is extracted from the request from which the file has been uploaded. - * Then it should not be considered as a safe value. - * - * @return int|null The file size - * - * @api - */ - public function getClientSize() - { - return $this->size; - } - - /** - * Returns the upload error. - * - * If the upload was successful, the constant UPLOAD_ERR_OK is returned. - * Otherwise one of the other UPLOAD_ERR_XXX constants is returned. - * - * @return int The upload error - * - * @api - */ - public function getError() - { - return $this->error; - } - - /** - * Returns whether the file was uploaded successfully. - * - * @return bool True if the file has been uploaded with HTTP and no error occurred. - * - * @api - */ - public function isValid() - { - $isOk = $this->error === UPLOAD_ERR_OK; - - return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname()); - } - - /** - * Moves the file to a new location. - * - * @param string $directory The destination folder - * @param string $name The new file name - * - * @return File A File object representing the new file - * - * @throws FileException if, for any reason, the file could not have been moved - * - * @api - */ - public function move($directory, $name = null) - { - if ($this->isValid()) { - if ($this->test) { - return parent::move($directory, $name); - } - - $target = $this->getTargetFile($directory, $name); - - if (!@move_uploaded_file($this->getPathname(), $target)) { - $error = error_get_last(); - throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message']))); - } - - @chmod($target, 0666 & ~umask()); - - return $target; - } - - throw new FileException($this->getErrorMessage()); - } - - /** - * Returns the maximum size of an uploaded file as configured in php.ini. - * - * @return int The maximum size of an uploaded file in bytes - */ - public static function getMaxFilesize() - { - $iniMax = strtolower(ini_get('upload_max_filesize')); - - if ('' === $iniMax) { - return PHP_INT_MAX; - } - - $max = ltrim($iniMax, '+'); - if (0 === strpos($max, '0x')) { - $max = intval($max, 16); - } elseif (0 === strpos($max, '0')) { - $max = intval($max, 8); - } else { - $max = (int) $max; - } - - switch (substr($iniMax, -1)) { - case 't': $max *= 1024; - case 'g': $max *= 1024; - case 'm': $max *= 1024; - case 'k': $max *= 1024; - } - - return $max; - } - - /** - * Returns an informative upload error message. - * - * @return string The error message regarding the specified error code - */ - public function getErrorMessage() - { - static $errors = array( - UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).', - UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.', - UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.', - UPLOAD_ERR_NO_FILE => 'No file was uploaded.', - UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.', - UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.', - UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.', - ); - - $errorCode = $this->error; - $maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0; - $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; - - return sprintf($message, $this->getClientOriginalName(), $maxFilesize); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php deleted file mode 100644 index 43b8af3c8..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php +++ /dev/null @@ -1,155 +0,0 @@ - - * - * 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\UploadedFile; - -/** - * FileBag is a container for uploaded files. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - * - * @api - */ -class FileBag extends ParameterBag -{ - private static $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type'); - - /** - * Constructor. - * - * @param array $parameters An array of HTTP files - * - * @api - */ - public function __construct(array $parameters = array()) - { - $this->replace($parameters); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function replace(array $files = array()) - { - $this->parameters = array(); - $this->add($files); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function set($key, $value) - { - if (!is_array($value) && !$value instanceof UploadedFile) { - throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.'); - } - - parent::set($key, $this->convertFileInformation($value)); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function add(array $files = array()) - { - foreach ($files as $key => $file) { - $this->set($key, $file); - } - } - - /** - * Converts uploaded files to UploadedFile instances. - * - * @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information - * - * @return array A (multi-dimensional) array of UploadedFile instances - */ - protected function convertFileInformation($file) - { - if ($file instanceof UploadedFile) { - return $file; - } - - $file = $this->fixPhpFilesArray($file); - if (is_array($file)) { - $keys = array_keys($file); - sort($keys); - - if ($keys == self::$fileKeys) { - if (UPLOAD_ERR_NO_FILE == $file['error']) { - $file = null; - } else { - $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']); - } - } else { - $file = array_map(array($this, 'convertFileInformation'), $file); - } - } - - return $file; - } - - /** - * Fixes a malformed PHP $_FILES array. - * - * PHP has a bug that the format of the $_FILES array differs, depending on - * whether the uploaded file fields had normal field names or array-like - * field names ("normal" vs. "parent[child]"). - * - * This method fixes the array to look like the "normal" $_FILES array. - * - * It's safe to pass an already converted array, in which case this method - * just returns the original array unmodified. - * - * @param array $data - * - * @return array - */ - protected function fixPhpFilesArray($data) - { - if (!is_array($data)) { - return $data; - } - - $keys = array_keys($data); - sort($keys); - - if (self::$fileKeys != $keys || !isset($data['name']) || !is_array($data['name'])) { - return $data; - } - - $files = $data; - foreach (self::$fileKeys as $k) { - unset($files[$k]); - } - - foreach ($data['name'] as $key => $name) { - $files[$key] = $this->fixPhpFilesArray(array( - 'error' => $data['error'][$key], - 'name' => $name, - 'type' => $data['type'][$key], - 'tmp_name' => $data['tmp_name'][$key], - 'size' => $data['size'][$key], - )); - } - - return $files; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php deleted file mode 100644 index d3adfface..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php +++ /dev/null @@ -1,348 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * HeaderBag is a container for HTTP headers. - * - * @author Fabien Potencier - * - * @api - */ -class HeaderBag implements \IteratorAggregate, \Countable -{ - protected $headers = array(); - protected $cacheControl = array(); - - /** - * Constructor. - * - * @param array $headers An array of HTTP headers - * - * @api - */ - public function __construct(array $headers = array()) - { - foreach ($headers as $key => $values) { - $this->set($key, $values); - } - } - - /** - * Returns the headers as a string. - * - * @return string The headers - */ - public function __toString() - { - if (!$this->headers) { - return ''; - } - - $max = max(array_map('strlen', array_keys($this->headers))) + 1; - $content = ''; - ksort($this->headers); - foreach ($this->headers as $name => $values) { - $name = implode('-', array_map('ucfirst', explode('-', $name))); - foreach ($values as $value) { - $content .= sprintf("%-{$max}s %s\r\n", $name.':', $value); - } - } - - return $content; - } - - /** - * Returns the headers. - * - * @return array An array of headers - * - * @api - */ - public function all() - { - return $this->headers; - } - - /** - * Returns the parameter keys. - * - * @return array An array of parameter keys - * - * @api - */ - public function keys() - { - return array_keys($this->headers); - } - - /** - * Replaces the current HTTP headers by a new set. - * - * @param array $headers An array of HTTP headers - * - * @api - */ - public function replace(array $headers = array()) - { - $this->headers = array(); - $this->add($headers); - } - - /** - * Adds new headers the current HTTP headers set. - * - * @param array $headers An array of HTTP headers - * - * @api - */ - public function add(array $headers) - { - foreach ($headers as $key => $values) { - $this->set($key, $values); - } - } - - /** - * Returns a header value by name. - * - * @param string $key The header name - * @param mixed $default The default value - * @param bool $first Whether to return the first value or all header values - * - * @return string|array The first header value if $first is true, an array of values otherwise - * - * @api - */ - public function get($key, $default = null, $first = true) - { - $key = strtr(strtolower($key), '_', '-'); - - if (!array_key_exists($key, $this->headers)) { - if (null === $default) { - return $first ? null : array(); - } - - return $first ? $default : array($default); - } - - if ($first) { - return count($this->headers[$key]) ? $this->headers[$key][0] : $default; - } - - return $this->headers[$key]; - } - - /** - * Sets a header by name. - * - * @param string $key The key - * @param string|array $values The value or an array of values - * @param bool $replace Whether to replace the actual value or not (true by default) - * - * @api - */ - public function set($key, $values, $replace = true) - { - $key = strtr(strtolower($key), '_', '-'); - - $values = array_values((array) $values); - - if (true === $replace || !isset($this->headers[$key])) { - $this->headers[$key] = $values; - } else { - $this->headers[$key] = array_merge($this->headers[$key], $values); - } - - if ('cache-control' === $key) { - $this->cacheControl = $this->parseCacheControl($values[0]); - } - } - - /** - * Returns true if the HTTP header is defined. - * - * @param string $key The HTTP header - * - * @return bool true if the parameter exists, false otherwise - * - * @api - */ - public function has($key) - { - return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers); - } - - /** - * Returns true if the given HTTP header contains the given value. - * - * @param string $key The HTTP header name - * @param string $value The HTTP value - * - * @return bool true if the value is contained in the header, false otherwise - * - * @api - */ - public function contains($key, $value) - { - return in_array($value, $this->get($key, null, false)); - } - - /** - * Removes a header. - * - * @param string $key The HTTP header name - * - * @api - */ - public function remove($key) - { - $key = strtr(strtolower($key), '_', '-'); - - unset($this->headers[$key]); - - if ('cache-control' === $key) { - $this->cacheControl = array(); - } - } - - /** - * Returns the HTTP header value converted to a date. - * - * @param string $key The parameter key - * @param \DateTime $default The default value - * - * @return null|\DateTime The parsed DateTime or the default value if the header does not exist - * - * @throws \RuntimeException When the HTTP header is not parseable - * - * @api - */ - public function getDate($key, \DateTime $default = null) - { - if (null === $value = $this->get($key)) { - return $default; - } - - if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { - throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value)); - } - - return $date; - } - - /** - * Adds a custom Cache-Control directive. - * - * @param string $key The Cache-Control directive name - * @param mixed $value The Cache-Control directive value - */ - public function addCacheControlDirective($key, $value = true) - { - $this->cacheControl[$key] = $value; - - $this->set('Cache-Control', $this->getCacheControlHeader()); - } - - /** - * Returns true if the Cache-Control directive is defined. - * - * @param string $key The Cache-Control directive - * - * @return bool true if the directive exists, false otherwise - */ - public function hasCacheControlDirective($key) - { - return array_key_exists($key, $this->cacheControl); - } - - /** - * Returns a Cache-Control directive value by name. - * - * @param string $key The directive name - * - * @return mixed|null The directive value if defined, null otherwise - */ - public function getCacheControlDirective($key) - { - return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; - } - - /** - * Removes a Cache-Control directive. - * - * @param string $key The Cache-Control directive - */ - public function removeCacheControlDirective($key) - { - unset($this->cacheControl[$key]); - - $this->set('Cache-Control', $this->getCacheControlHeader()); - } - - /** - * Returns an iterator for headers. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->headers); - } - - /** - * Returns the number of headers. - * - * @return int The number of headers - */ - public function count() - { - return count($this->headers); - } - - protected function getCacheControlHeader() - { - $parts = array(); - ksort($this->cacheControl); - foreach ($this->cacheControl as $key => $value) { - if (true === $value) { - $parts[] = $key; - } else { - if (preg_match('#[^a-zA-Z0-9._-]#', $value)) { - $value = '"'.$value.'"'; - } - - $parts[] = "$key=$value"; - } - } - - return implode(', ', $parts); - } - - /** - * Parses a Cache-Control HTTP header. - * - * @param string $header The value of the Cache-Control HTTP header - * - * @return array An array representing the attribute values - */ - protected function parseCacheControl($header) - { - $cacheControl = array(); - preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER); - foreach ($matches as $match) { - $cacheControl[strtolower($match[1])] = isset($match[3]) ? $match[3] : (isset($match[2]) ? $match[2] : true); - } - - return $cacheControl; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php deleted file mode 100644 index fb906b681..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Http utility functions. - * - * @author Fabien Potencier - */ -class IpUtils -{ - /** - * This class should not be instantiated. - */ - private function __construct() - { - } - - /** - * Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets. - * - * @param string $requestIp IP to check - * @param string|array $ips List of IPs or subnets (can be a string if only a single one) - * - * @return bool Whether the IP is valid - */ - public static function checkIp($requestIp, $ips) - { - if (!is_array($ips)) { - $ips = array($ips); - } - - $method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4'; - - foreach ($ips as $ip) { - if (self::$method($requestIp, $ip)) { - return true; - } - } - - return false; - } - - /** - * Compares two IPv4 addresses. - * In case a subnet is given, it checks if it contains the request IP. - * - * @param string $requestIp IPv4 address to check - * @param string $ip IPv4 address or subnet in CIDR notation - * - * @return bool Whether the IP is valid - */ - public static function checkIp4($requestIp, $ip) - { - if (false !== strpos($ip, '/')) { - if ('0.0.0.0/0' === $ip) { - return true; - } - - list($address, $netmask) = explode('/', $ip, 2); - - if ($netmask < 1 || $netmask > 32) { - return false; - } - } else { - $address = $ip; - $netmask = 32; - } - - return 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask); - } - - /** - * Compares two IPv6 addresses. - * In case a subnet is given, it checks if it contains the request IP. - * - * @author David Soria Parra - * - * @see https://github.com/dsp/v6tools - * - * @param string $requestIp IPv6 address to check - * @param string $ip IPv6 address or subnet in CIDR notation - * - * @return bool Whether the IP is valid - * - * @throws \RuntimeException When IPV6 support is not enabled - */ - public static function checkIp6($requestIp, $ip) - { - 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; - } - } else { - $address = $ip; - $netmask = 128; - } - - $bytesAddr = unpack('n*', inet_pton($address)); - $bytesTest = unpack('n*', inet_pton($requestIp)); - - for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) { - $left = $netmask - 16 * ($i - 1); - $left = ($left <= 16) ? $left : 16; - $mask = ~(0xffff >> $left) & 0xffff; - if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) { - return false; - } - } - - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php deleted file mode 100644 index 5399d1b1f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php +++ /dev/null @@ -1,226 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Response represents an HTTP response in JSON format. - * - * Note that this class does not force the returned JSON content to be an - * object. It is however recommended that you do return an object as it - * protects yourself against XSSI and JSON-JavaScript Hijacking. - * - * @see https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines#Always_return_JSON_with_an_Object_on_the_outside - * - * @author Igor Wiedler - */ -class JsonResponse extends Response -{ - protected $data; - protected $callback; - - // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML. - // 15 === JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT - protected $encodingOptions = 15; - - /** - * Constructor. - * - * @param mixed $data The response data - * @param int $status The response status code - * @param array $headers An array of response headers - */ - public function __construct($data = null, $status = 200, $headers = array()) - { - parent::__construct('', $status, $headers); - - if (null === $data) { - $data = new \ArrayObject(); - } - - $this->setData($data); - } - - /** - * {@inheritdoc} - */ - public static function create($data = null, $status = 200, $headers = array()) - { - return new static($data, $status, $headers); - } - - /** - * Sets the JSONP callback. - * - * @param string|null $callback The JSONP callback or null to use none - * - * @return JsonResponse - * - * @throws \InvalidArgumentException When the callback name is not valid - */ - public function setCallback($callback = null) - { - if (null !== $callback) { - // taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/ - $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u'; - $parts = explode('.', $callback); - foreach ($parts as $part) { - if (!preg_match($pattern, $part)) { - throw new \InvalidArgumentException('The callback name is not valid.'); - } - } - } - - $this->callback = $callback; - - return $this->update(); - } - - /** - * Sets the data to be sent as JSON. - * - * @param mixed $data - * - * @return JsonResponse - * - * @throws \InvalidArgumentException - */ - public function setData($data = array()) - { - if (defined('HHVM_VERSION')) { - // HHVM does not trigger any warnings and let exceptions - // thrown from a JsonSerializable object pass through. - // If only PHP did the same... - $data = json_encode($data, $this->encodingOptions); - } else { - try { - if (PHP_VERSION_ID < 50400) { - // PHP 5.3 triggers annoying warnings for some - // types that can't be serialized as JSON (INF, resources, etc.) - // but doesn't provide the JsonSerializable interface. - set_error_handler('var_dump', 0); - $data = @json_encode($data, $this->encodingOptions); - } else { - // PHP 5.4 and up wrap exceptions thrown by JsonSerializable - // objects in a new exception that needs to be removed. - // Fortunately, PHP 5.5 and up do not trigger any warning anymore. - if (PHP_VERSION_ID < 50500) { - // Clear json_last_error() - json_encode(null); - $errorHandler = set_error_handler('var_dump'); - restore_error_handler(); - set_error_handler(function () use ($errorHandler) { - if (JSON_ERROR_NONE === json_last_error()) { - return $errorHandler && false !== call_user_func_array($errorHandler, func_get_args()); - } - }); - } - - $data = json_encode($data, $this->encodingOptions); - } - - if (PHP_VERSION_ID < 50500) { - restore_error_handler(); - } - } catch (\Exception $e) { - if (PHP_VERSION_ID < 50500) { - restore_error_handler(); - } - if (PHP_VERSION_ID >= 50400 && 'Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) { - throw $e->getPrevious() ?: $e; - } - throw $e; - } - } - - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException($this->transformJsonError()); - } - - $this->data = $data; - - return $this->update(); - } - - /** - * Returns options used while encoding data to JSON. - * - * @return int - */ - public function getEncodingOptions() - { - return $this->encodingOptions; - } - - /** - * Sets options used while encoding data to JSON. - * - * @param int $encodingOptions - * - * @return JsonResponse - */ - public function setEncodingOptions($encodingOptions) - { - $this->encodingOptions = (int) $encodingOptions; - - return $this->setData(json_decode($this->data)); - } - - /** - * Updates the content and headers according to the JSON data and callback. - * - * @return JsonResponse - */ - protected function update() - { - if (null !== $this->callback) { - // Not using application/javascript for compatibility reasons with older browsers. - $this->headers->set('Content-Type', 'text/javascript'); - - return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data)); - } - - // Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback) - // in order to not overwrite a custom definition. - if (!$this->headers->has('Content-Type') || 'text/javascript' === $this->headers->get('Content-Type')) { - $this->headers->set('Content-Type', 'application/json'); - } - - return $this->setContent($this->data); - } - - private function transformJsonError() - { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - switch (json_last_error()) { - case JSON_ERROR_DEPTH: - return 'Maximum stack depth exceeded.'; - - case JSON_ERROR_STATE_MISMATCH: - return 'Underflow or the modes mismatch.'; - - case JSON_ERROR_CTRL_CHAR: - return 'Unexpected control character found.'; - - case JSON_ERROR_SYNTAX: - return 'Syntax error, malformed JSON.'; - - case JSON_ERROR_UTF8: - return 'Malformed UTF-8 characters, possibly incorrectly encoded.'; - - default: - return 'Unknown error.'; - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE deleted file mode 100644 index 43028bc60..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php deleted file mode 100644 index 6081f3f4a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php +++ /dev/null @@ -1,319 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ParameterBag is a container for key/value pairs. - * - * @author Fabien Potencier - * - * @api - */ -class ParameterBag implements \IteratorAggregate, \Countable -{ - /** - * Parameter storage. - * - * @var array - */ - protected $parameters; - - /** - * Constructor. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function __construct(array $parameters = array()) - { - $this->parameters = $parameters; - } - - /** - * Returns the parameters. - * - * @return array An array of parameters - * - * @api - */ - public function all() - { - return $this->parameters; - } - - /** - * Returns the parameter keys. - * - * @return array An array of parameter keys - * - * @api - */ - public function keys() - { - return array_keys($this->parameters); - } - - /** - * Replaces the current parameters by a new set. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function replace(array $parameters = array()) - { - $this->parameters = $parameters; - } - - /** - * Adds parameters. - * - * @param array $parameters An array of parameters - * - * @api - */ - public function add(array $parameters = array()) - { - $this->parameters = array_replace($this->parameters, $parameters); - } - - /** - * Returns a parameter by name. - * - * @param string $path The key - * @param mixed $default The default value if the parameter key does not exist - * @param bool $deep If true, a path like foo[bar] will find deeper items - * - * @return mixed - * - * @throws \InvalidArgumentException - * - * @api - */ - public function get($path, $default = null, $deep = false) - { - if (!$deep || false === $pos = strpos($path, '[')) { - return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default; - } - - $root = substr($path, 0, $pos); - if (!array_key_exists($root, $this->parameters)) { - return $default; - } - - $value = $this->parameters[$root]; - $currentKey = null; - for ($i = $pos, $c = strlen($path); $i < $c; ++$i) { - $char = $path[$i]; - - if ('[' === $char) { - if (null !== $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "[" at position %d.', $i)); - } - - $currentKey = ''; - } elseif (']' === $char) { - if (null === $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "]" at position %d.', $i)); - } - - if (!is_array($value) || !array_key_exists($currentKey, $value)) { - return $default; - } - - $value = $value[$currentKey]; - $currentKey = null; - } else { - if (null === $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "%s" at position %d.', $char, $i)); - } - - $currentKey .= $char; - } - } - - if (null !== $currentKey) { - throw new \InvalidArgumentException(sprintf('Malformed path. Path must end with "]".')); - } - - return $value; - } - - /** - * Sets a parameter by name. - * - * @param string $key The key - * @param mixed $value The value - * - * @api - */ - public function set($key, $value) - { - $this->parameters[$key] = $value; - } - - /** - * Returns true if the parameter is defined. - * - * @param string $key The key - * - * @return bool true if the parameter exists, false otherwise - * - * @api - */ - public function has($key) - { - return array_key_exists($key, $this->parameters); - } - - /** - * Removes a parameter. - * - * @param string $key The key - * - * @api - */ - public function remove($key) - { - unset($this->parameters[$key]); - } - - /** - * Returns the alphabetic characters of the parameter value. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param bool $deep If true, a path like foo[bar] will find deeper items - * - * @return string The filtered value - * - * @api - */ - public function getAlpha($key, $default = '', $deep = false) - { - return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default, $deep)); - } - - /** - * Returns the alphabetic characters and digits of the parameter value. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param bool $deep If true, a path like foo[bar] will find deeper items - * - * @return string The filtered value - * - * @api - */ - public function getAlnum($key, $default = '', $deep = false) - { - return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default, $deep)); - } - - /** - * Returns the digits of the parameter value. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param bool $deep If true, a path like foo[bar] will find deeper items - * - * @return string The filtered value - * - * @api - */ - public function getDigits($key, $default = '', $deep = false) - { - // we need to remove - and + because they're allowed in the filter - return str_replace(array('-', '+'), '', $this->filter($key, $default, $deep, FILTER_SANITIZE_NUMBER_INT)); - } - - /** - * Returns the parameter value converted to integer. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param bool $deep If true, a path like foo[bar] will find deeper items - * - * @return int The filtered value - * - * @api - */ - public function getInt($key, $default = 0, $deep = false) - { - return (int) $this->get($key, $default, $deep); - } - - /** - * Returns the parameter value converted to boolean. - * - * @param string $key The parameter key - * @param mixed $default The default value if the parameter key does not exist - * @param bool $deep If true, a path like foo[bar] will find deeper items - * - * @return bool The filtered value - */ - public function getBoolean($key, $default = false, $deep = false) - { - return $this->filter($key, $default, $deep, FILTER_VALIDATE_BOOLEAN); - } - - /** - * Filter key. - * - * @param string $key Key. - * @param mixed $default Default = null. - * @param bool $deep Default = false. - * @param int $filter FILTER_* constant. - * @param mixed $options Filter options. - * - * @see http://php.net/manual/en/function.filter-var.php - * - * @return mixed - */ - public function filter($key, $default = null, $deep = false, $filter = FILTER_DEFAULT, $options = array()) - { - $value = $this->get($key, $default, $deep); - - // Always turn $options into an array - this allows filter_var option shortcuts. - if (!is_array($options) && $options) { - $options = array('flags' => $options); - } - - // Add a convenience check for arrays. - if (is_array($value) && !isset($options['flags'])) { - $options['flags'] = FILTER_REQUIRE_ARRAY; - } - - return filter_var($value, $filter, $options); - } - - /** - * Returns an iterator for parameters. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->parameters); - } - - /** - * Returns the number of parameters. - * - * @return int The number of parameters - */ - public function count() - { - return count($this->parameters); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md deleted file mode 100644 index 11ad6eef5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md +++ /dev/null @@ -1,56 +0,0 @@ -HttpFoundation Component -======================== - -HttpFoundation defines an object-oriented layer for the HTTP specification. - -It provides an abstraction for requests, responses, uploaded files, cookies, -sessions, ... - -In this example, we get a Request object from the current PHP global -variables: - -```php -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -$request = Request::createFromGlobals(); -echo $request->getPathInfo(); -``` - -You can also create a Request directly -- that's interesting for unit testing: - -```php -$request = Request::create('/?foo=bar', 'GET'); -echo $request->getPathInfo(); -``` - -And here is how to create and send a Response: - -```php -$response = new Response('Not Found', 404, array('Content-Type' => 'text/plain')); -$response->send(); -``` - -The Request and the Response classes have many other methods that implement -the HTTP specification. - -Loading -------- - -If you are not using Composer but are using PHP 5.3.x, you must add the following to your autoloader: - -```php -// SessionHandlerInterface -if (!interface_exists('SessionHandlerInterface')) { - $loader->registerPrefixFallback(__DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs'); -} -``` - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/HttpFoundation/ - $ composer install - $ phpunit diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php deleted file mode 100644 index 5dc0b9edd..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * RedirectResponse represents an HTTP response doing a redirect. - * - * @author Fabien Potencier - * - * @api - */ -class RedirectResponse extends Response -{ - protected $targetUrl; - - /** - * Creates a redirect response so that it conforms to the rules defined for a redirect status code. - * - * @param string $url The URL to redirect to - * @param int $status The status code (302 by default) - * @param array $headers The headers (Location is always set to the given URL) - * - * @throws \InvalidArgumentException - * - * @see http://tools.ietf.org/html/rfc2616#section-10.3 - * - * @api - */ - public function __construct($url, $status = 302, $headers = array()) - { - if (empty($url)) { - throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); - } - - parent::__construct('', $status, $headers); - - $this->setTargetUrl($url); - - if (!$this->isRedirect()) { - throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); - } - } - - /** - * {@inheritdoc} - */ - public static function create($url = '', $status = 302, $headers = array()) - { - return new static($url, $status, $headers); - } - - /** - * Returns the target URL. - * - * @return string target URL - */ - public function getTargetUrl() - { - return $this->targetUrl; - } - - /** - * Sets the redirect target of this response. - * - * @param string $url The URL to redirect to - * - * @return RedirectResponse The current response. - * - * @throws \InvalidArgumentException - */ - public function setTargetUrl($url) - { - if (empty($url)) { - throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); - } - - $this->targetUrl = $url; - - $this->setContent( - sprintf(' - - - - - - Redirecting to %1$s - - - Redirecting to %1$s. - -', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'))); - - $this->headers->set('Location', $url); - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php deleted file mode 100644 index 15b05bb21..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php +++ /dev/null @@ -1,1954 +0,0 @@ - - * - * 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\Session\SessionInterface; - -/** - * Request represents an HTTP request. - * - * The methods dealing with URL accept / return a raw path (% encoded): - * * getBasePath - * * getBaseUrl - * * getPathInfo - * * getRequestUri - * * getUri - * * getUriForPath - * - * @author Fabien Potencier - * - * @api - */ -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'; - - const METHOD_HEAD = 'HEAD'; - const METHOD_GET = 'GET'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_PATCH = 'PATCH'; - const METHOD_DELETE = 'DELETE'; - const METHOD_PURGE = 'PURGE'; - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - - protected static $trustedProxies = array(); - - /** - * @var string[] - */ - protected static $trustedHostPatterns = array(); - - /** - * @var string[] - */ - protected static $trustedHosts = 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; - - /** - * Custom parameters. - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $attributes; - - /** - * Request body parameters ($_POST). - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $request; - - /** - * Query string parameters ($_GET). - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $query; - - /** - * Server and execution environment parameters ($_SERVER). - * - * @var \Symfony\Component\HttpFoundation\ServerBag - * - * @api - */ - public $server; - - /** - * Uploaded files ($_FILES). - * - * @var \Symfony\Component\HttpFoundation\FileBag - * - * @api - */ - public $files; - - /** - * Cookies ($_COOKIE). - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - * - * @api - */ - public $cookies; - - /** - * Headers (taken from the $_SERVER). - * - * @var \Symfony\Component\HttpFoundation\HeaderBag - * - * @api - */ - public $headers; - - /** - * @var string - */ - protected $content; - - /** - * @var array - */ - protected $languages; - - /** - * @var array - */ - protected $charsets; - - /** - * @var array - */ - protected $encodings; - - /** - * @var array - */ - protected $acceptableContentTypes; - - /** - * @var string - */ - protected $pathInfo; - - /** - * @var string - */ - protected $requestUri; - - /** - * @var string - */ - protected $baseUrl; - - /** - * @var string - */ - protected $basePath; - - /** - * @var string - */ - protected $method; - - /** - * @var string - */ - protected $format; - - /** - * @var \Symfony\Component\HttpFoundation\Session\SessionInterface - */ - protected $session; - - /** - * @var string - */ - protected $locale; - - /** - * @var string - */ - protected $defaultLocale = 'en'; - - /** - * @var array - */ - protected static $formats; - - protected static $requestFactory; - - /** - * Constructor. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * @param string|resource $content The raw body data - * - * @api - */ - public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - $this->initialize($query, $request, $attributes, $cookies, $files, $server, $content); - } - - /** - * Sets the parameters for this request. - * - * This method also re-initializes all properties. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * @param string|resource $content The raw body data - * - * @api - */ - public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - $this->request = new ParameterBag($request); - $this->query = new ParameterBag($query); - $this->attributes = new ParameterBag($attributes); - $this->cookies = new ParameterBag($cookies); - $this->files = new FileBag($files); - $this->server = new ServerBag($server); - $this->headers = new HeaderBag($this->server->getHeaders()); - - $this->content = $content; - $this->languages = null; - $this->charsets = null; - $this->encodings = null; - $this->acceptableContentTypes = null; - $this->pathInfo = null; - $this->requestUri = null; - $this->baseUrl = null; - $this->basePath = null; - $this->method = null; - $this->format = null; - } - - /** - * Creates a new request with values from PHP's super globals. - * - * @return Request A new request - * - * @api - */ - public static function createFromGlobals() - { - // With the php's bug #66606, the php's built-in web server - // stores the Content-Type and Content-Length header values in - // HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields. - $server = $_SERVER; - if ('cli-server' === php_sapi_name()) { - if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) { - $server['CONTENT_LENGTH'] = $_SERVER['HTTP_CONTENT_LENGTH']; - } - if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) { - $server['CONTENT_TYPE'] = $_SERVER['HTTP_CONTENT_TYPE']; - } - } - - $request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $server); - - 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); - $request->request = new ParameterBag($data); - } - - return $request; - } - - /** - * Creates a Request based on a given URI and configuration. - * - * The information contained in the URI always take precedence - * over the other information (server and parameters). - * - * @param string $uri The URI - * @param string $method The HTTP method - * @param array $parameters The query (GET) or request (POST) parameters - * @param array $cookies The request cookies ($_COOKIE) - * @param array $files The request files ($_FILES) - * @param array $server The server parameters ($_SERVER) - * @param string $content The raw body data - * - * @return Request A Request instance - * - * @api - */ - public static function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null) - { - $server = array_replace(array( - 'SERVER_NAME' => 'localhost', - 'SERVER_PORT' => 80, - 'HTTP_HOST' => 'localhost', - 'HTTP_USER_AGENT' => 'Symfony/2.X', - 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', - 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', - 'REMOTE_ADDR' => '127.0.0.1', - 'SCRIPT_NAME' => '', - 'SCRIPT_FILENAME' => '', - 'SERVER_PROTOCOL' => 'HTTP/1.1', - 'REQUEST_TIME' => time(), - ), $server); - - $server['PATH_INFO'] = ''; - $server['REQUEST_METHOD'] = strtoupper($method); - - $components = parse_url($uri); - if (isset($components['host'])) { - $server['SERVER_NAME'] = $components['host']; - $server['HTTP_HOST'] = $components['host']; - } - - if (isset($components['scheme'])) { - if ('https' === $components['scheme']) { - $server['HTTPS'] = 'on'; - $server['SERVER_PORT'] = 443; - } else { - unset($server['HTTPS']); - $server['SERVER_PORT'] = 80; - } - } - - if (isset($components['port'])) { - $server['SERVER_PORT'] = $components['port']; - $server['HTTP_HOST'] = $server['HTTP_HOST'].':'.$components['port']; - } - - if (isset($components['user'])) { - $server['PHP_AUTH_USER'] = $components['user']; - } - - if (isset($components['pass'])) { - $server['PHP_AUTH_PW'] = $components['pass']; - } - - if (!isset($components['path'])) { - $components['path'] = '/'; - } - - switch (strtoupper($method)) { - case 'POST': - case 'PUT': - case 'DELETE': - if (!isset($server['CONTENT_TYPE'])) { - $server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; - } - // no break - case 'PATCH': - $request = $parameters; - $query = array(); - break; - default: - $request = array(); - $query = $parameters; - break; - } - - $queryString = ''; - if (isset($components['query'])) { - parse_str(html_entity_decode($components['query']), $qs); - - if ($query) { - $query = array_replace($qs, $query); - $queryString = http_build_query($query, '', '&'); - } else { - $query = $qs; - $queryString = $components['query']; - } - } elseif ($query) { - $queryString = http_build_query($query, '', '&'); - } - - $server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : ''); - $server['QUERY_STRING'] = $queryString; - - return self::createRequestFromFactory($query, $request, array(), $cookies, $files, $server, $content); - } - - /** - * Sets a callable able to create a Request instance. - * - * This is mainly useful when you need to override the Request class - * to keep BC with an existing system. It should not be used for any - * other purpose. - * - * @param callable|null $callable A PHP callable - */ - public static function setFactory($callable) - { - self::$requestFactory = $callable; - } - - /** - * Clones a request and overrides some of its parameters. - * - * @param array $query The GET parameters - * @param array $request The POST parameters - * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...) - * @param array $cookies The COOKIE parameters - * @param array $files The FILES parameters - * @param array $server The SERVER parameters - * - * @return Request The duplicated request - * - * @api - */ - public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) - { - $dup = clone $this; - if ($query !== null) { - $dup->query = new ParameterBag($query); - } - if ($request !== null) { - $dup->request = new ParameterBag($request); - } - if ($attributes !== null) { - $dup->attributes = new ParameterBag($attributes); - } - if ($cookies !== null) { - $dup->cookies = new ParameterBag($cookies); - } - if ($files !== null) { - $dup->files = new FileBag($files); - } - if ($server !== null) { - $dup->server = new ServerBag($server); - $dup->headers = new HeaderBag($dup->server->getHeaders()); - } - $dup->languages = null; - $dup->charsets = null; - $dup->encodings = null; - $dup->acceptableContentTypes = null; - $dup->pathInfo = null; - $dup->requestUri = null; - $dup->baseUrl = null; - $dup->basePath = null; - $dup->method = null; - $dup->format = null; - - if (!$dup->get('_format') && $this->get('_format')) { - $dup->attributes->set('_format', $this->get('_format')); - } - - if (!$dup->getRequestFormat(null)) { - $dup->setRequestFormat($this->getRequestFormat(null)); - } - - return $dup; - } - - /** - * Clones the current request. - * - * Note that the session is not cloned as duplicated requests - * are most of the time sub-requests of the main one. - */ - public function __clone() - { - $this->query = clone $this->query; - $this->request = clone $this->request; - $this->attributes = clone $this->attributes; - $this->cookies = clone $this->cookies; - $this->files = clone $this->files; - $this->server = clone $this->server; - $this->headers = clone $this->headers; - } - - /** - * Returns the request as a string. - * - * @return string The request - */ - public function __toString() - { - try { - $content = $this->getContent(); - } catch (\LogicException $e) { - return trigger_error($e, E_USER_ERROR); - } - - return - sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n". - $this->headers."\r\n". - $content; - } - - /** - * Overrides the PHP global variables according to this request instance. - * - * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE. - * $_FILES is never overridden, see rfc1867 - * - * @api - */ - public function overrideGlobals() - { - $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), null, '&'))); - - $_GET = $this->query->all(); - $_POST = $this->request->all(); - $_SERVER = $this->server->all(); - $_COOKIE = $this->cookies->all(); - - foreach ($this->headers->all() as $key => $value) { - $key = strtoupper(str_replace('-', '_', $key)); - if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) { - $_SERVER[$key] = implode(', ', $value); - } else { - $_SERVER['HTTP_'.$key] = implode(', ', $value); - } - } - - $request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE); - - $requestOrder = ini_get('request_order') ?: ini_get('variables_order'); - $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp'; - - $_REQUEST = array(); - foreach (str_split($requestOrder) as $order) { - $_REQUEST = array_merge($_REQUEST, $request[$order]); - } - } - - /** - * 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; - } - - /** - * Gets the list of trusted proxies. - * - * @return array An array of trusted proxies. - */ - public static function getTrustedProxies() - { - return self::$trustedProxies; - } - - /** - * Sets a list of trusted host patterns. - * - * You should only list the hosts you manage using regexs. - * - * @param array $hostPatterns A list of trusted host patterns - */ - public static function setTrustedHosts(array $hostPatterns) - { - self::$trustedHostPatterns = array_map(function ($hostPattern) { - return sprintf('#%s#i', $hostPattern); - }, $hostPatterns); - // we need to reset trusted hosts on trusted host patterns change - self::$trustedHosts = array(); - } - - /** - * Gets the list of trusted host patterns. - * - * @return array An array of trusted host patterns. - */ - public static function getTrustedHosts() - { - return self::$trustedHostPatterns; - } - - /** - * 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 getHost()) - * * Request::HEADER_CLIENT_PORT: defaults to X-Forwarded-Port (see getPort()) - * * 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 - * - * @throws \InvalidArgumentException - */ - 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; - } - - /** - * Gets the trusted proxy header name. - * - * @param string $key The header key - * - * @return string The header name - * - * @throws \InvalidArgumentException - */ - public static function getTrustedHeaderName($key) - { - if (!array_key_exists($key, self::$trustedHeaders)) { - throw new \InvalidArgumentException(sprintf('Unable to get the trusted header name for key "%s".', $key)); - } - - return self::$trustedHeaders[$key]; - } - - /** - * Normalizes a query string. - * - * It builds a normalized query string, where keys/value pairs are alphabetized, - * have consistent escaping and unneeded delimiters are removed. - * - * @param string $qs Query string - * - * @return string A normalized query string for the Request - */ - public static function normalizeQueryString($qs) - { - if ('' == $qs) { - return ''; - } - - $parts = array(); - $order = array(); - - foreach (explode('&', $qs) as $param) { - if ('' === $param || '=' === $param[0]) { - // Ignore useless delimiters, e.g. "x=y&". - // Also ignore pairs with empty key, even if there was a value, e.g. "=value", as such nameless values cannot be retrieved anyway. - // PHP also does not include them when building _GET. - continue; - } - - $keyValuePair = explode('=', $param, 2); - - // GET parameters, that are submitted from a HTML form, encode spaces as "+" by default (as defined in enctype application/x-www-form-urlencoded). - // PHP also converts "+" to spaces when filling the global _GET or when using the function parse_str. This is why we use urldecode and then normalize to - // RFC 3986 with rawurlencode. - $parts[] = isset($keyValuePair[1]) ? - rawurlencode(urldecode($keyValuePair[0])).'='.rawurlencode(urldecode($keyValuePair[1])) : - rawurlencode(urldecode($keyValuePair[0])); - $order[] = urldecode($keyValuePair[0]); - } - - array_multisort($order, SORT_ASC, $parts); - - 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. - * If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered - * and used to send a "PUT" or "DELETE" request via the _method request parameter. - * If these methods are not protected against CSRF, this presents a possible vulnerability. - * - * The HTTP method can only be overridden when the real HTTP method is POST. - */ - public static function enableHttpMethodParameterOverride() - { - self::$httpMethodParameterOverride = true; - } - - /** - * Checks whether support for the _method request parameter is enabled. - * - * @return bool True when the _method request parameter is enabled, false otherwise - */ - public static function getHttpMethodParameterOverride() - { - return self::$httpMethodParameterOverride; - } - - /** - * Gets a "parameter" value. - * - * This method is mainly useful for libraries that want to provide some flexibility. - * - * Order of precedence: GET, PATH, POST - * - * Avoid using this method in controllers: - * - * * slow - * * prefer to get from a "named" source - * - * It is better to explicitly get request parameters from the appropriate - * public property instead (query, attributes, request). - * - * @param string $key the key - * @param mixed $default the default value - * @param bool $deep is parameter deep in multidimensional array - * - * @return mixed - */ - public function get($key, $default = null, $deep = false) - { - if ($this !== $result = $this->query->get($key, $this, $deep)) { - return $result; - } - - if ($this !== $result = $this->attributes->get($key, $this, $deep)) { - return $result; - } - - if ($this !== $result = $this->request->get($key, $this, $deep)) { - return $result; - } - - return $default; - } - - /** - * Gets the Session. - * - * @return SessionInterface|null The session - * - * @api - */ - public function getSession() - { - return $this->session; - } - - /** - * Whether the request contains a Session which was started in one of the - * previous requests. - * - * @return bool - * - * @api - */ - public function hasPreviousSession() - { - // the check for $this->session avoids malicious users trying to fake a session cookie with proper name - return $this->hasSession() && $this->cookies->has($this->session->getName()); - } - - /** - * Whether the request contains a Session object. - * - * 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 bool true when the Request contains a Session object, false otherwise - * - * @api - */ - public function hasSession() - { - return null !== $this->session; - } - - /** - * Sets the Session. - * - * @param SessionInterface $session The Session - * - * @api - */ - public function setSession(SessionInterface $session) - { - $this->session = $session; - } - - /** - * Returns the client IP addresses. - * - * In the returned array the most trusted IP address is first, and the - * least trusted one last. The "real" client IP address is the last one, - * but this is also the least trusted one. Trusted proxies are stripped. - * - * Use this method carefully; you should use getClientIp() instead. - * - * @return array The client IP addresses - * - * @see getClientIp() - */ - public function getClientIps() - { - $ip = $this->server->get('REMOTE_ADDR'); - - if (!$this->isFromTrustedProxy()) { - return array($ip); - } - - if (!self::$trustedHeaders[self::HEADER_CLIENT_IP] || !$this->headers->has(self::$trustedHeaders[self::HEADER_CLIENT_IP])) { - return array($ip); - } - - $clientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP]))); - $clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from - - $ip = $clientIps[0]; // Fallback to this when the client IP falls into the range of trusted proxies - - // Eliminate all IPs from the forwarded IP chain which are trusted proxies - foreach ($clientIps as $key => $clientIp) { - // Remove port on IPv4 address (unfortunately, it does happen) - if (preg_match('{((?:\d+\.){3}\d+)\:\d+}', $clientIp, $match)) { - $clientIps[$key] = $clientIp = $match[1]; - } - - if (IpUtils::checkIp($clientIp, self::$trustedProxies)) { - unset($clientIps[$key]); - } - } - - // Now the IP chain contains only untrusted proxies and the client IP - return $clientIps ? array_reverse($clientIps) : array($ip); - } - - /** - * 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 getClientIps() - * @see http://en.wikipedia.org/wiki/X-Forwarded-For - * - * @api - */ - public function getClientIp() - { - $ipAddresses = $this->getClientIps(); - - return $ipAddresses[0]; - } - - /** - * Returns current script name. - * - * @return string - * - * @api - */ - public function getScriptName() - { - return $this->server->get('SCRIPT_NAME', $this->server->get('ORIG_SCRIPT_NAME', '')); - } - - /** - * Returns the path being requested relative to the executed script. - * - * The path info always starts with a /. - * - * Suppose this request is instantiated from /mysite on localhost: - * - * * http://localhost/mysite returns an empty string - * * http://localhost/mysite/about returns '/about' - * * http://localhost/mysite/enco%20ded returns '/enco%20ded' - * * http://localhost/mysite/about?var=1 returns '/about' - * - * @return string The raw path (i.e. not urldecoded) - * - * @api - */ - public function getPathInfo() - { - if (null === $this->pathInfo) { - $this->pathInfo = $this->preparePathInfo(); - } - - return $this->pathInfo; - } - - /** - * Returns the root path from which this request is executed. - * - * Suppose that an index.php file instantiates this request object: - * - * * http://localhost/index.php returns an empty string - * * http://localhost/index.php/page returns an empty string - * * http://localhost/web/index.php returns '/web' - * * http://localhost/we%20b/index.php returns '/we%20b' - * - * @return string The raw path (i.e. not urldecoded) - * - * @api - */ - public function getBasePath() - { - if (null === $this->basePath) { - $this->basePath = $this->prepareBasePath(); - } - - return $this->basePath; - } - - /** - * Returns the root URL from which this request is executed. - * - * The base URL never ends with a /. - * - * This is similar to getBasePath(), except that it also includes the - * script filename (e.g. index.php) if one exists. - * - * @return string The raw URL (i.e. not urldecoded) - * - * @api - */ - public function getBaseUrl() - { - if (null === $this->baseUrl) { - $this->baseUrl = $this->prepareBaseUrl(); - } - - return $this->baseUrl; - } - - /** - * Gets the request's scheme. - * - * @return string - * - * @api - */ - public function getScheme() - { - return $this->isSecure() ? 'https' : 'http'; - } - - /** - * 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 ($this->isFromTrustedProxy()) { - if (self::$trustedHeaders[self::HEADER_CLIENT_PORT] && $port = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PORT])) { - return $port; - } - - if (self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && 'https' === $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO], 'http')) { - return 443; - } - } - - if ($host = $this->headers->get('HOST')) { - if ($host[0] === '[') { - $pos = strpos($host, ':', strrpos($host, ']')); - } else { - $pos = strrpos($host, ':'); - } - - if (false !== $pos) { - return (int) substr($host, $pos + 1); - } - - return 'https' === $this->getScheme() ? 443 : 80; - } - - return $this->server->get('SERVER_PORT'); - } - - /** - * Returns the user. - * - * @return string|null - */ - public function getUser() - { - return $this->headers->get('PHP_AUTH_USER'); - } - - /** - * Returns the password. - * - * @return string|null - */ - public function getPassword() - { - return $this->headers->get('PHP_AUTH_PW'); - } - - /** - * Gets the user info. - * - * @return string A user name and, optionally, scheme-specific information about how to gain authorization to access the server - */ - public function getUserInfo() - { - $userinfo = $this->getUser(); - - $pass = $this->getPassword(); - if ('' != $pass) { - $userinfo .= ":$pass"; - } - - return $userinfo; - } - - /** - * Returns the HTTP host being requested. - * - * The port name will be appended to the host if it's non-standard. - * - * @return string - * - * @api - */ - public function getHttpHost() - { - $scheme = $this->getScheme(); - $port = $this->getPort(); - - if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { - return $this->getHost(); - } - - return $this->getHost().':'.$port; - } - - /** - * Returns the requested URI (path and query string). - * - * @return string The raw URI (i.e. not URI decoded) - * - * @api - */ - public function getRequestUri() - { - if (null === $this->requestUri) { - $this->requestUri = $this->prepareRequestUri(); - } - - return $this->requestUri; - } - - /** - * 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().'://'.$this->getHttpHost(); - } - - /** - * Generates a normalized URI (URL) for the Request. - * - * @return string A normalized URI (URL) for the Request - * - * @see getQueryString() - * - * @api - */ - public function getUri() - { - if (null !== $qs = $this->getQueryString()) { - $qs = '?'.$qs; - } - - return $this->getSchemeAndHttpHost().$this->getBaseUrl().$this->getPathInfo().$qs; - } - - /** - * Generates a normalized URI for the given path. - * - * @param string $path A path to use instead of the current one - * - * @return string The normalized URI for the path - * - * @api - */ - public function getUriForPath($path) - { - return $this->getSchemeAndHttpHost().$this->getBaseUrl().$path; - } - - /** - * Generates the normalized query string for the Request. - * - * It builds a normalized query string, where keys/value pairs are alphabetized - * and have consistent escaping. - * - * @return string|null A normalized query string for the Request - * - * @api - */ - public function getQueryString() - { - $qs = static::normalizeQueryString($this->server->get('QUERY_STRING')); - - return '' === $qs ? null : $qs; - } - - /** - * 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 bool - * - * @api - */ - public function isSecure() - { - if ($this->isFromTrustedProxy() && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) { - return in_array(strtolower(current(explode(',', $proto))), array('https', 'on', 'ssl', '1')); - } - - $https = $this->server->get('HTTPS'); - - return !empty($https) && 'off' !== strtolower($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 - * - * @throws \UnexpectedValueException when the host name is invalid - * - * @api - */ - public function getHost() - { - if ($this->isFromTrustedProxy() && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) { - $elements = explode(',', $host); - - $host = $elements[count($elements) - 1]; - } elseif (!$host = $this->headers->get('HOST')) { - if (!$host = $this->server->get('SERVER_NAME')) { - $host = $this->server->get('SERVER_ADDR', ''); - } - } - - // trim and remove port number from host - // host is lowercase as per RFC 952/2181 - $host = strtolower(preg_replace('/:\d+$/', '', trim($host))); - - // as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user) - // check that it does not contain forbidden characters (see RFC 952 and RFC 2181) - // use preg_replace() instead of preg_match() to prevent DoS attacks with long host names - if ($host && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) { - throw new \UnexpectedValueException(sprintf('Invalid Host "%s"', $host)); - } - - if (count(self::$trustedHostPatterns) > 0) { - // to avoid host header injection attacks, you should provide a list of trusted host patterns - - if (in_array($host, self::$trustedHosts)) { - return $host; - } - - foreach (self::$trustedHostPatterns as $pattern) { - if (preg_match($pattern, $host)) { - self::$trustedHosts[] = $host; - - return $host; - } - } - - throw new \UnexpectedValueException(sprintf('Untrusted Host "%s"', $host)); - } - - return $host; - } - - /** - * Sets the request method. - * - * @param string $method - * - * @api - */ - public function setMethod($method) - { - $this->method = null; - $this->server->set('REQUEST_METHOD', $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) { - 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. - * - * @param string $format The format - * - * @return string The associated mime type (null if not found) - * - * @api - */ - public function getMimeType($format) - { - if (null === static::$formats) { - static::initializeFormats(); - } - - return isset(static::$formats[$format]) ? static::$formats[$format][0] : null; - } - - /** - * Gets the format associated with the mime type. - * - * @param string $mimeType The associated mime type - * - * @return string|null The format (null if not found) - * - * @api - */ - public function getFormat($mimeType) - { - if (false !== $pos = strpos($mimeType, ';')) { - $mimeType = substr($mimeType, 0, $pos); - } - - if (null === static::$formats) { - static::initializeFormats(); - } - - foreach (static::$formats as $format => $mimeTypes) { - if (in_array($mimeType, (array) $mimeTypes)) { - return $format; - } - } - } - - /** - * Associates a format with mime types. - * - * @param string $format The format - * @param string|array $mimeTypes The associated mime types (the preferred one must be the first as it will be used as the content type) - * - * @api - */ - public function setFormat($format, $mimeTypes) - { - if (null === static::$formats) { - static::initializeFormats(); - } - - static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes); - } - - /** - * Gets the request format. - * - * Here is the process to determine the format: - * - * * format defined by the user (with setRequestFormat()) - * * _format request parameter - * * $default - * - * @param string $default The default format - * - * @return string The request format - * - * @api - */ - public function getRequestFormat($default = 'html') - { - if (null === $this->format) { - $this->format = $this->get('_format', $default); - } - - return $this->format; - } - - /** - * Sets the request format. - * - * @param string $format The request format. - * - * @api - */ - public function setRequestFormat($format) - { - $this->format = $format; - } - - /** - * Gets the format associated with the request. - * - * @return string|null The format (null if no content type is present) - * - * @api - */ - public function getContentType() - { - return $this->getFormat($this->headers->get('CONTENT_TYPE')); - } - - /** - * Sets the default locale. - * - * @param string $locale - * - * @api - */ - public function setDefaultLocale($locale) - { - $this->defaultLocale = $locale; - - if (null === $this->locale) { - $this->setPhpDefaultLocale($locale); - } - } - - /** - * Get the default locale. - * - * @return string - */ - public function getDefaultLocale() - { - return $this->defaultLocale; - } - - /** - * Sets the locale. - * - * @param string $locale - * - * @api - */ - public function setLocale($locale) - { - $this->setPhpDefaultLocale($this->locale = $locale); - } - - /** - * Get the locale. - * - * @return string - */ - public function getLocale() - { - return null === $this->locale ? $this->defaultLocale : $this->locale; - } - - /** - * Checks if the request method is of specified type. - * - * @param string $method Uppercase request method (GET, POST etc). - * - * @return bool - */ - public function isMethod($method) - { - return $this->getMethod() === strtoupper($method); - } - - /** - * Checks whether the method is safe or not. - * - * @return bool - * - * @api - */ - public function isMethodSafe() - { - return in_array($this->getMethod(), array('GET', 'HEAD')); - } - - /** - * Returns the request body content. - * - * @param bool $asResource If true, a resource will be returned - * - * @return string|resource The request body content or a resource to read the body stream. - * - * @throws \LogicException - */ - public function getContent($asResource = false) - { - $currentContentIsResource = is_resource($this->content); - if (PHP_VERSION_ID < 50600 && false === $this->content) { - throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.'); - } - - if (true === $asResource) { - if ($currentContentIsResource) { - rewind($this->content); - - return $this->content; - } - - // Content passed in parameter (test) - if (is_string($this->content)) { - $resource = fopen('php://temp','r+'); - fwrite($resource, $this->content); - rewind($resource); - - return $resource; - } - - $this->content = false; - - return fopen('php://input', 'rb'); - } - - if ($currentContentIsResource) { - rewind($this->content); - - return stream_get_contents($this->content); - } - - if (null === $this->content) { - $this->content = file_get_contents('php://input'); - } - - return $this->content; - } - - /** - * Gets the Etags. - * - * @return array The entity tags - */ - public function getETags() - { - return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY); - } - - /** - * @return bool - */ - public function isNoCache() - { - return $this->headers->hasCacheControlDirective('no-cache') || 'no-cache' == $this->headers->get('Pragma'); - } - - /** - * Returns the preferred language. - * - * @param array $locales An array of ordered available locales - * - * @return string|null The preferred locale - * - * @api - */ - public function getPreferredLanguage(array $locales = null) - { - $preferredLanguages = $this->getLanguages(); - - if (empty($locales)) { - return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null; - } - - if (!$preferredLanguages) { - return $locales[0]; - } - - $extendedPreferredLanguages = array(); - foreach ($preferredLanguages as $language) { - $extendedPreferredLanguages[] = $language; - if (false !== $position = strpos($language, '_')) { - $superLanguage = substr($language, 0, $position); - if (!in_array($superLanguage, $preferredLanguages)) { - $extendedPreferredLanguages[] = $superLanguage; - } - } - } - - $preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales)); - - return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0]; - } - - /** - * Gets a list of languages acceptable by the client browser. - * - * @return array Languages ordered in the user browser preferences - * - * @api - */ - public function getLanguages() - { - if (null !== $this->languages) { - return $this->languages; - } - - $languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all(); - $this->languages = array(); - foreach ($languages as $lang => $acceptHeaderItem) { - if (false !== strpos($lang, '-')) { - $codes = explode('-', $lang); - if ('i' === $codes[0]) { - // Language not listed in ISO 639 that are not variants - // of any listed language, which can be registered with the - // i-prefix, such as i-cherokee - if (count($codes) > 1) { - $lang = $codes[1]; - } - } else { - for ($i = 0, $max = count($codes); $i < $max; ++$i) { - if ($i === 0) { - $lang = strtolower($codes[0]); - } else { - $lang .= '_'.strtoupper($codes[$i]); - } - } - } - } - - $this->languages[] = $lang; - } - - return $this->languages; - } - - /** - * Gets a list of charsets acceptable by the client browser. - * - * @return array List of charsets in preferable order - * - * @api - */ - public function getCharsets() - { - if (null !== $this->charsets) { - return $this->charsets; - } - - return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all()); - } - - /** - * Gets a list of encodings acceptable by the client browser. - * - * @return array List of encodings in preferable order - */ - public function getEncodings() - { - if (null !== $this->encodings) { - return $this->encodings; - } - - return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all()); - } - - /** - * Gets a list of content types acceptable by the client browser. - * - * @return array List of content types in preferable order - * - * @api - */ - public function getAcceptableContentTypes() - { - if (null !== $this->acceptableContentTypes) { - return $this->acceptableContentTypes; - } - - return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all()); - } - - /** - * Returns true if the request is a XMLHttpRequest. - * - * It works if your JavaScript library sets an X-Requested-With HTTP header. - * It is known to work with common JavaScript frameworks: - * - * @link http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript - * - * @return bool true if the request is an XMLHttpRequest, false otherwise - * - * @api - */ - public function isXmlHttpRequest() - { - return 'XMLHttpRequest' == $this->headers->get('X-Requested-With'); - } - - /* - * The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24) - * - * Code subject to the new BSD license (http://framework.zend.com/license/new-bsd). - * - * Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - */ - - protected function prepareRequestUri() - { - $requestUri = ''; - - if ($this->headers->has('X_ORIGINAL_URL')) { - // IIS with Microsoft Rewrite Module - $requestUri = $this->headers->get('X_ORIGINAL_URL'); - $this->headers->remove('X_ORIGINAL_URL'); - $this->server->remove('HTTP_X_ORIGINAL_URL'); - $this->server->remove('UNENCODED_URL'); - $this->server->remove('IIS_WasUrlRewritten'); - } elseif ($this->headers->has('X_REWRITE_URL')) { - // IIS with ISAPI_Rewrite - $requestUri = $this->headers->get('X_REWRITE_URL'); - $this->headers->remove('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) - $requestUri = $this->server->get('UNENCODED_URL'); - $this->server->remove('UNENCODED_URL'); - $this->server->remove('IIS_WasUrlRewritten'); - } elseif ($this->server->has('REQUEST_URI')) { - $requestUri = $this->server->get('REQUEST_URI'); - // HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path - $schemeAndHttpHost = $this->getSchemeAndHttpHost(); - if (strpos($requestUri, $schemeAndHttpHost) === 0) { - $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); - } - } elseif ($this->server->has('ORIG_PATH_INFO')) { - // IIS 5.0, PHP as CGI - $requestUri = $this->server->get('ORIG_PATH_INFO'); - if ('' != $this->server->get('QUERY_STRING')) { - $requestUri .= '?'.$this->server->get('QUERY_STRING'); - } - $this->server->remove('ORIG_PATH_INFO'); - } - - // normalize the request URI to ease creating sub-requests from this request - $this->server->set('REQUEST_URI', $requestUri); - - return $requestUri; - } - - /** - * Prepares the base URL. - * - * @return string - */ - protected function prepareBaseUrl() - { - $filename = basename($this->server->get('SCRIPT_FILENAME')); - - if (basename($this->server->get('SCRIPT_NAME')) === $filename) { - $baseUrl = $this->server->get('SCRIPT_NAME'); - } elseif (basename($this->server->get('PHP_SELF')) === $filename) { - $baseUrl = $this->server->get('PHP_SELF'); - } elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) { - $baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); // 1and1 shared hosting compatibility - } else { - // Backtrack up the script_filename to find the portion matching - // php_self - $path = $this->server->get('PHP_SELF', ''); - $file = $this->server->get('SCRIPT_FILENAME', ''); - $segs = explode('/', trim($file, '/')); - $segs = array_reverse($segs); - $index = 0; - $last = count($segs); - $baseUrl = ''; - do { - $seg = $segs[$index]; - $baseUrl = '/'.$seg.$baseUrl; - ++$index; - } while ($last > $index && (false !== $pos = strpos($path, $baseUrl)) && 0 != $pos); - } - - // Does the baseUrl have anything in common with the request_uri? - $requestUri = $this->getRequestUri(); - - if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) { - // full $baseUrl matches - return $prefix; - } - - if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/').'/')) { - // directory portion of $baseUrl matches - return rtrim($prefix, '/'); - } - - $truncatedRequestUri = $requestUri; - if (false !== $pos = strpos($requestUri, '?')) { - $truncatedRequestUri = substr($requestUri, 0, $pos); - } - - $basename = basename($baseUrl); - if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) { - // no match whatsoever; set it blank - return ''; - } - - // If using mod_rewrite or ISAPI_Rewrite strip the script filename - // out of baseUrl. $pos !== 0 makes sure it is not matching a value - // from PATH_INFO or QUERY_STRING - if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && $pos !== 0) { - $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); - } - - return rtrim($baseUrl, '/'); - } - - /** - * Prepares the base path. - * - * @return string base path - */ - protected function prepareBasePath() - { - $filename = basename($this->server->get('SCRIPT_FILENAME')); - $baseUrl = $this->getBaseUrl(); - if (empty($baseUrl)) { - return ''; - } - - if (basename($baseUrl) === $filename) { - $basePath = dirname($baseUrl); - } else { - $basePath = $baseUrl; - } - - if ('\\' === DIRECTORY_SEPARATOR) { - $basePath = str_replace('\\', '/', $basePath); - } - - return rtrim($basePath, '/'); - } - - /** - * Prepares the path info. - * - * @return string path info - */ - protected function preparePathInfo() - { - $baseUrl = $this->getBaseUrl(); - - if (null === ($requestUri = $this->getRequestUri())) { - return '/'; - } - - $pathInfo = '/'; - - // Remove the query string from REQUEST_URI - if ($pos = strpos($requestUri, '?')) { - $requestUri = substr($requestUri, 0, $pos); - } - - $pathInfo = substr($requestUri, strlen($baseUrl)); - if (null !== $baseUrl && (false === $pathInfo || '' === $pathInfo)) { - // If substr() returns false then PATH_INFO is set to an empty string - return '/'; - } elseif (null === $baseUrl) { - return $requestUri; - } - - return (string) $pathInfo; - } - - /** - * Initializes HTTP request formats. - */ - protected static function initializeFormats() - { - static::$formats = array( - 'html' => array('text/html', 'application/xhtml+xml'), - 'txt' => array('text/plain'), - 'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'), - 'css' => array('text/css'), - 'json' => array('application/json', 'application/x-json'), - 'xml' => array('text/xml', 'application/xml', 'application/x-xml'), - 'rdf' => array('application/rdf+xml'), - 'atom' => array('application/atom+xml'), - 'rss' => array('application/rss+xml'), - 'form' => array('application/x-www-form-urlencoded'), - ); - } - - /** - * Sets the default PHP locale. - * - * @param string $locale - */ - private function setPhpDefaultLocale($locale) - { - // if either the class Locale doesn't exist, or an exception is thrown when - // setting the default locale, the intl module is not installed, and - // the call can be ignored: - try { - if (class_exists('Locale', false)) { - \Locale::setDefault($locale); - } - } catch (\Exception $e) { - } - } - - /* - * Returns the prefix as encoded in the string when the string starts with - * the given prefix, false otherwise. - * - * @param string $string The urlencoded string - * @param string $prefix The prefix not encoded - * - * @return string|false The prefix as it is encoded in $string, or false - */ - private function getUrlencodedPrefix($string, $prefix) - { - if (0 !== strpos(rawurldecode($string), $prefix)) { - return false; - } - - $len = strlen($prefix); - - if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $len), $string, $match)) { - return $match[0]; - } - - return false; - } - - private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) - { - if (self::$requestFactory) { - $request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content); - - if (!$request instanceof Request) { - throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.'); - } - - return $request; - } - - return new static($query, $request, $attributes, $cookies, $files, $server, $content); - } - - private function isFromTrustedProxy() - { - return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php deleted file mode 100644 index c571c604b..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * RequestMatcher compares a pre-defined set of checks against a Request instance. - * - * @author Fabien Potencier - * - * @api - */ -class RequestMatcher implements RequestMatcherInterface -{ - /** - * @var string - */ - private $path; - - /** - * @var string - */ - private $host; - - /** - * @var array - */ - private $methods = array(); - - /** - * @var string - */ - private $ips = array(); - - /** - * @var array - */ - private $attributes = array(); - - /** - * @var string[] - */ - private $schemes = array(); - - /** - * @param string|null $path - * @param string|null $host - * @param string|string[]|null $methods - * @param string|string[]|null $ips - * @param array $attributes - * @param string|string[]|null $schemes - */ - public function __construct($path = null, $host = null, $methods = null, $ips = null, array $attributes = array(), $schemes = null) - { - $this->matchPath($path); - $this->matchHost($host); - $this->matchMethod($methods); - $this->matchIps($ips); - $this->matchScheme($schemes); - - foreach ($attributes as $k => $v) { - $this->matchAttribute($k, $v); - } - } - - /** - * Adds a check for the HTTP scheme. - * - * @param string|string[]|null $scheme An HTTP scheme or an array of HTTP schemes - */ - public function matchScheme($scheme) - { - $this->schemes = array_map('strtolower', (array) $scheme); - } - - /** - * Adds a check for the URL host name. - * - * @param string $regexp A Regexp - */ - public function matchHost($regexp) - { - $this->host = $regexp; - } - - /** - * Adds a check for the URL path info. - * - * @param string $regexp A Regexp - */ - public function matchPath($regexp) - { - $this->path = $regexp; - } - - /** - * Adds a check for the client IP. - * - * @param string $ip A specific IP address or a range specified using IP/netmask like 192.168.1.0/24 - */ - public function matchIp($ip) - { - $this->matchIps($ip); - } - - /** - * Adds a check for the client IP. - * - * @param string|string[] $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24 - */ - public function matchIps($ips) - { - $this->ips = (array) $ips; - } - - /** - * Adds a check for the HTTP method. - * - * @param string|string[] $method An HTTP method or an array of HTTP methods - */ - public function matchMethod($method) - { - $this->methods = array_map('strtoupper', (array) $method); - } - - /** - * Adds a check for request attribute. - * - * @param string $key The request attribute name - * @param string $regexp A Regexp - */ - public function matchAttribute($key, $regexp) - { - $this->attributes[$key] = $regexp; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function matches(Request $request) - { - if ($this->schemes && !in_array($request->getScheme(), $this->schemes)) { - return false; - } - - if ($this->methods && !in_array($request->getMethod(), $this->methods)) { - return false; - } - - foreach ($this->attributes as $key => $pattern) { - if (!preg_match('{'.$pattern.'}', $request->attributes->get($key))) { - return false; - } - } - - if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getPathInfo()))) { - return false; - } - - if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getHost())) { - return false; - } - - if (IpUtils::checkIp($request->getClientIp(), $this->ips)) { - return true; - } - - // Note to future implementors: add additional checks above the - // foreach above or else your check might not be run! - return count($this->ips) === 0; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php deleted file mode 100644 index b45f80ce8..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * RequestMatcherInterface is an interface for strategies to match a Request. - * - * @author Fabien Potencier - * - * @api - */ -interface RequestMatcherInterface -{ - /** - * Decides whether the rule(s) implemented by the strategy matches the supplied request. - * - * @param Request $request The request to check for a match - * - * @return bool true if the request matches, false otherwise - * - * @api - */ - public function matches(Request $request); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php deleted file mode 100644 index 3d9cfd0c6..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Request stack that controls the lifecycle of requests. - * - * @author Benjamin Eberlei - */ -class RequestStack -{ - /** - * @var Request[] - */ - private $requests = array(); - - /** - * Pushes a Request on the stack. - * - * This method should generally not be called directly as the stack - * management should be taken care of by the application itself. - */ - public function push(Request $request) - { - $this->requests[] = $request; - } - - /** - * Pops the current request from the stack. - * - * This operation lets the current request go out of scope. - * - * This method should generally not be called directly as the stack - * management should be taken care of by the application itself. - * - * @return Request|null - */ - public function pop() - { - if (!$this->requests) { - return; - } - - return array_pop($this->requests); - } - - /** - * @return Request|null - */ - public function getCurrentRequest() - { - return end($this->requests) ?: null; - } - - /** - * Gets the master Request. - * - * Be warned that making your code aware of the master request - * might make it un-compatible with other features of your framework - * like ESI support. - * - * @return Request|null - */ - public function getMasterRequest() - { - if (!$this->requests) { - return; - } - - return $this->requests[0]; - } - - /** - * Returns the parent request of the current. - * - * Be warned that making your code aware of the parent request - * might make it un-compatible with other features of your framework - * like ESI support. - * - * If current Request is the master request, it returns null. - * - * @return Request|null - */ - public function getParentRequest() - { - $pos = count($this->requests) - 2; - - if (!isset($this->requests[$pos])) { - return; - } - - return $this->requests[$pos]; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php deleted file mode 100644 index 9baa7bc0f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * SessionHandlerInterface for PHP < 5.4. - * - * The order in which these methods are invoked by PHP are: - * 1. open [session_start] - * 2. read - * 3. gc [optional depending on probability settings: gc_probability / gc_divisor] - * 4. destroy [optional when session_regenerate_id(true) is used] - * 5. write [session_write_close] or destroy [session_destroy] - * 6. close - * - * Extensive documentation can be found at php.net, see links: - * - * @see http://php.net/sessionhandlerinterface - * @see http://php.net/session.customhandler - * @see http://php.net/session-set-save-handler - * - * @author Drak - * @author Tobias Schultze - */ -interface SessionHandlerInterface -{ - /** - * Re-initializes existing session, or creates a new one. - * - * @see http://php.net/sessionhandlerinterface.open - * - * @param string $savePath Save path - * @param string $sessionName Session name, see http://php.net/function.session-name.php - * - * @return bool true on success, false on failure - */ - public function open($savePath, $sessionName); - - /** - * Closes the current session. - * - * @see http://php.net/sessionhandlerinterface.close - * - * @return bool true on success, false on failure - */ - public function close(); - - /** - * Reads the session data. - * - * @see http://php.net/sessionhandlerinterface.read - * - * @param string $sessionId Session ID, see http://php.net/function.session-id - * - * @return string Same session data as passed in write() or empty string when non-existent or on failure - */ - public function read($sessionId); - - /** - * Writes the session data to the storage. - * - * Care, the session ID passed to write() can be different from the one previously - * received in read() when the session ID changed due to session_regenerate_id(). - * - * @see http://php.net/sessionhandlerinterface.write - * - * @param string $sessionId Session ID , see http://php.net/function.session-id - * @param string $data Serialized session data to save - * - * @return bool true on success, false on failure - */ - public function write($sessionId, $data); - - /** - * Destroys a session. - * - * @see http://php.net/sessionhandlerinterface.destroy - * - * @param string $sessionId Session ID, see http://php.net/function.session-id - * - * @return bool true on success, false on failure - */ - public function destroy($sessionId); - - /** - * Cleans up expired sessions (garbage collection). - * - * @see http://php.net/sessionhandlerinterface.gc - * - * @param string|int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed - * - * @return bool true on success, false on failure - */ - public function gc($maxlifetime); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php deleted file mode 100644 index 17fb98102..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php +++ /dev/null @@ -1,1269 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * Response represents an HTTP response. - * - * @author Fabien Potencier - * - * @api - */ -class Response -{ - const HTTP_CONTINUE = 100; - const HTTP_SWITCHING_PROTOCOLS = 101; - const HTTP_PROCESSING = 102; // RFC2518 - const HTTP_OK = 200; - const HTTP_CREATED = 201; - const HTTP_ACCEPTED = 202; - const HTTP_NON_AUTHORITATIVE_INFORMATION = 203; - const HTTP_NO_CONTENT = 204; - const HTTP_RESET_CONTENT = 205; - const HTTP_PARTIAL_CONTENT = 206; - const HTTP_MULTI_STATUS = 207; // RFC4918 - const HTTP_ALREADY_REPORTED = 208; // RFC5842 - const HTTP_IM_USED = 226; // RFC3229 - const HTTP_MULTIPLE_CHOICES = 300; - const HTTP_MOVED_PERMANENTLY = 301; - const HTTP_FOUND = 302; - const HTTP_SEE_OTHER = 303; - const HTTP_NOT_MODIFIED = 304; - const HTTP_USE_PROXY = 305; - const HTTP_RESERVED = 306; - const HTTP_TEMPORARY_REDIRECT = 307; - const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238 - const HTTP_BAD_REQUEST = 400; - const HTTP_UNAUTHORIZED = 401; - const HTTP_PAYMENT_REQUIRED = 402; - const HTTP_FORBIDDEN = 403; - const HTTP_NOT_FOUND = 404; - const HTTP_METHOD_NOT_ALLOWED = 405; - const HTTP_NOT_ACCEPTABLE = 406; - const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; - const HTTP_REQUEST_TIMEOUT = 408; - const HTTP_CONFLICT = 409; - const HTTP_GONE = 410; - const HTTP_LENGTH_REQUIRED = 411; - const HTTP_PRECONDITION_FAILED = 412; - const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; - const HTTP_REQUEST_URI_TOO_LONG = 414; - const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; - const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; - const HTTP_EXPECTATION_FAILED = 417; - const HTTP_I_AM_A_TEAPOT = 418; // RFC2324 - const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918 - const HTTP_LOCKED = 423; // RFC4918 - const HTTP_FAILED_DEPENDENCY = 424; // RFC4918 - const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817 - const HTTP_UPGRADE_REQUIRED = 426; // RFC2817 - const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 - const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 - const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 - const HTTP_INTERNAL_SERVER_ERROR = 500; - const HTTP_NOT_IMPLEMENTED = 501; - const HTTP_BAD_GATEWAY = 502; - const HTTP_SERVICE_UNAVAILABLE = 503; - const HTTP_GATEWAY_TIMEOUT = 504; - const HTTP_VERSION_NOT_SUPPORTED = 505; - const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295 - const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918 - const HTTP_LOOP_DETECTED = 508; // RFC5842 - const HTTP_NOT_EXTENDED = 510; // RFC2774 - const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585 - - /** - * @var \Symfony\Component\HttpFoundation\ResponseHeaderBag - */ - public $headers; - - /** - * @var string - */ - protected $content; - - /** - * @var string - */ - protected $version; - - /** - * @var int - */ - protected $statusCode; - - /** - * @var string - */ - protected $statusText; - - /** - * @var string - */ - protected $charset; - - /** - * Status codes translation table. - * - * The list of codes is complete according to the - * {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry} - * (last updated 2012-02-13). - * - * Unless otherwise noted, the status code is defined in RFC2616. - * - * @var array - */ - public static $statusTexts = array( - 100 => 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', // RFC2518 - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', // RFC4918 - 208 => 'Already Reported', // RFC5842 - 226 => 'IM Used', // RFC3229 - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 306 => 'Reserved', - 307 => 'Temporary Redirect', - 308 => 'Permanent Redirect', // RFC7238 - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - 418 => 'I\'m a teapot', // RFC2324 - 422 => 'Unprocessable Entity', // RFC4918 - 423 => 'Locked', // RFC4918 - 424 => 'Failed Dependency', // RFC4918 - 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 - 426 => 'Upgrade Required', // RFC2817 - 428 => 'Precondition Required', // RFC6585 - 429 => 'Too Many Requests', // RFC6585 - 431 => 'Request Header Fields Too Large', // RFC6585 - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 - 507 => 'Insufficient Storage', // RFC4918 - 508 => 'Loop Detected', // RFC5842 - 510 => 'Not Extended', // RFC2774 - 511 => 'Network Authentication Required', // RFC6585 - ); - - /** - * Constructor. - * - * @param mixed $content The response content, see setContent() - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @throws \InvalidArgumentException When the HTTP status code is not valid - * - * @api - */ - public function __construct($content = '', $status = 200, $headers = array()) - { - $this->headers = new ResponseHeaderBag($headers); - $this->setContent($content); - $this->setStatusCode($status); - $this->setProtocolVersion('1.0'); - if (!$this->headers->has('Date')) { - $this->setDate(new \DateTime(null, new \DateTimeZone('UTC'))); - } - } - - /** - * Factory method for chainability. - * - * Example: - * - * return Response::create($body, 200) - * ->setSharedMaxAge(300); - * - * @param mixed $content The response content, see setContent() - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return Response - */ - public static function create($content = '', $status = 200, $headers = array()) - { - return new static($content, $status, $headers); - } - - /** - * Returns the Response as an HTTP string. - * - * The string representation of the Response is the same as the - * one that will be sent to the client only if the prepare() method - * has been called before. - * - * @return string The Response as an HTTP string - * - * @see prepare() - */ - public function __toString() - { - return - sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n". - $this->headers."\r\n". - $this->getContent(); - } - - /** - * Clones the current Response instance. - */ - public function __clone() - { - $this->headers = clone $this->headers; - } - - /** - * Prepares the Response before it is sent to the client. - * - * This method tweaks the Response to ensure that it is - * compliant with RFC 2616. Most of the changes are based on - * the Request that is "associated" with this Response. - * - * @param Request $request A Request instance - * - * @return Response The current response. - */ - public function prepare(Request $request) - { - $headers = $this->headers; - - if ($this->isInformational() || $this->isEmpty()) { - $this->setContent(null); - $headers->remove('Content-Type'); - $headers->remove('Content-Length'); - } else { - // Content-type based on the Request - if (!$headers->has('Content-Type')) { - $format = $request->getRequestFormat(); - if (null !== $format && $mimeType = $request->getMimeType($format)) { - $headers->set('Content-Type', $mimeType); - } - } - - // Fix Content-Type - $charset = $this->charset ?: 'UTF-8'; - if (!$headers->has('Content-Type')) { - $headers->set('Content-Type', 'text/html; charset='.$charset); - } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { - // add the charset - $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); - } - - // Fix Content-Length - if ($headers->has('Transfer-Encoding')) { - $headers->remove('Content-Length'); - } - - if ($request->isMethod('HEAD')) { - // cf. RFC2616 14.13 - $length = $headers->get('Content-Length'); - $this->setContent(null); - if ($length) { - $headers->set('Content-Length', $length); - } - } - } - - // Fix protocol - if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { - $this->setProtocolVersion('1.1'); - } - - // Check if we need to send extra expire info headers - if ('1.0' == $this->getProtocolVersion() && 'no-cache' == $this->headers->get('Cache-Control')) { - $this->headers->set('pragma', 'no-cache'); - $this->headers->set('expires', -1); - } - - $this->ensureIEOverSSLCompatibility($request); - - return $this; - } - - /** - * Sends HTTP headers. - * - * @return Response - */ - public function sendHeaders() - { - // headers have already been sent by the developer - if (headers_sent()) { - return $this; - } - - // status - header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode); - - // headers - foreach ($this->headers->allPreserveCase() as $name => $values) { - foreach ($values as $value) { - header($name.': '.$value, false, $this->statusCode); - } - } - - // cookies - foreach ($this->headers->getCookies() as $cookie) { - setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - - return $this; - } - - /** - * Sends content for the current web response. - * - * @return Response - */ - public function sendContent() - { - echo $this->content; - - return $this; - } - - /** - * Sends HTTP headers and content. - * - * @return Response - * - * @api - */ - public function send() - { - $this->sendHeaders(); - $this->sendContent(); - - if (function_exists('fastcgi_finish_request')) { - fastcgi_finish_request(); - } elseif ('cli' !== PHP_SAPI) { - static::closeOutputBuffers(0, true); - } - - return $this; - } - - /** - * Sets the response content. - * - * Valid types are strings, numbers, null, and objects that implement a __toString() method. - * - * @param mixed $content Content that can be cast to string - * - * @return Response - * - * @throws \UnexpectedValueException - * - * @api - */ - public function setContent($content) - { - if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) { - throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content))); - } - - $this->content = (string) $content; - - return $this; - } - - /** - * Gets the current response content. - * - * @return string Content - * - * @api - */ - public function getContent() - { - return $this->content; - } - - /** - * Sets the HTTP protocol version (1.0 or 1.1). - * - * @param string $version The HTTP protocol version - * - * @return Response - * - * @api - */ - public function setProtocolVersion($version) - { - $this->version = $version; - - return $this; - } - - /** - * Gets the HTTP protocol version. - * - * @return string The HTTP protocol version - * - * @api - */ - public function getProtocolVersion() - { - return $this->version; - } - - /** - * Sets the response status code. - * - * @param int $code HTTP status code - * @param mixed $text HTTP status text - * - * If the status text is null it will be automatically populated for the known - * status codes and left empty otherwise. - * - * @return Response - * - * @throws \InvalidArgumentException When the HTTP status code is not valid - * - * @api - */ - public function setStatusCode($code, $text = null) - { - $this->statusCode = $code = (int) $code; - if ($this->isInvalid()) { - throw new \InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code)); - } - - if (null === $text) { - $this->statusText = isset(self::$statusTexts[$code]) ? self::$statusTexts[$code] : ''; - - return $this; - } - - if (false === $text) { - $this->statusText = ''; - - return $this; - } - - $this->statusText = $text; - - return $this; - } - - /** - * Retrieves the status code for the current web response. - * - * @return int Status code - * - * @api - */ - public function getStatusCode() - { - return $this->statusCode; - } - - /** - * Sets the response charset. - * - * @param string $charset Character set - * - * @return Response - * - * @api - */ - public function setCharset($charset) - { - $this->charset = $charset; - - return $this; - } - - /** - * Retrieves the response charset. - * - * @return string Character set - * - * @api - */ - public function getCharset() - { - return $this->charset; - } - - /** - * Returns true if the response is worth caching under any circumstance. - * - * Responses marked "private" with an explicit Cache-Control directive are - * considered uncacheable. - * - * Responses with neither a freshness lifetime (Expires, max-age) nor cache - * validator (Last-Modified, ETag) are considered uncacheable. - * - * @return bool true if the response is worth caching, false otherwise - * - * @api - */ - public function isCacheable() - { - if (!in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) { - return false; - } - - if ($this->headers->hasCacheControlDirective('no-store') || $this->headers->getCacheControlDirective('private')) { - return false; - } - - return $this->isValidateable() || $this->isFresh(); - } - - /** - * Returns true if the response is "fresh". - * - * Fresh responses may be served from cache without any interaction with the - * origin. A response is considered fresh when it includes a Cache-Control/max-age - * indicator or Expires header and the calculated age is less than the freshness lifetime. - * - * @return bool true if the response is fresh, false otherwise - * - * @api - */ - public function isFresh() - { - return $this->getTtl() > 0; - } - - /** - * Returns true if the response includes headers that can be used to validate - * the response with the origin server using a conditional GET request. - * - * @return bool true if the response is validateable, false otherwise - * - * @api - */ - public function isValidateable() - { - return $this->headers->has('Last-Modified') || $this->headers->has('ETag'); - } - - /** - * Marks the response as "private". - * - * It makes the response ineligible for serving other clients. - * - * @return Response - * - * @api - */ - public function setPrivate() - { - $this->headers->removeCacheControlDirective('public'); - $this->headers->addCacheControlDirective('private'); - - return $this; - } - - /** - * Marks the response as "public". - * - * It makes the response eligible for serving other clients. - * - * @return Response - * - * @api - */ - public function setPublic() - { - $this->headers->addCacheControlDirective('public'); - $this->headers->removeCacheControlDirective('private'); - - return $this; - } - - /** - * Returns true if the response must be revalidated by caches. - * - * This method indicates that the response must not be served stale by a - * cache in any circumstance without first revalidating with the origin. - * When present, the TTL of the response should not be overridden to be - * greater than the value provided by the origin. - * - * @return bool true if the response must be revalidated by a cache, false otherwise - * - * @api - */ - public function mustRevalidate() - { - return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->has('proxy-revalidate'); - } - - /** - * Returns the Date header as a DateTime instance. - * - * @return \DateTime A \DateTime instance - * - * @throws \RuntimeException When the header is not parseable - * - * @api - */ - public function getDate() - { - return $this->headers->getDate('Date', new \DateTime()); - } - - /** - * Sets the Date header. - * - * @param \DateTime $date A \DateTime instance - * - * @return Response - * - * @api - */ - public function setDate(\DateTime $date) - { - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT'); - - return $this; - } - - /** - * Returns the age of the response. - * - * @return int The age of the response in seconds - */ - public function getAge() - { - if (null !== $age = $this->headers->get('Age')) { - return (int) $age; - } - - return max(time() - $this->getDate()->format('U'), 0); - } - - /** - * Marks the response stale by setting the Age header to be equal to the maximum age of the response. - * - * @return Response - * - * @api - */ - public function expire() - { - if ($this->isFresh()) { - $this->headers->set('Age', $this->getMaxAge()); - } - - return $this; - } - - /** - * Returns the value of the Expires header as a DateTime instance. - * - * @return \DateTime|null A DateTime instance or null if the header does not exist - * - * @api - */ - public function getExpires() - { - try { - return $this->headers->getDate('Expires'); - } catch (\RuntimeException $e) { - // according to RFC 2616 invalid date formats (e.g. "0" and "-1") must be treated as in the past - return \DateTime::createFromFormat(DATE_RFC2822, 'Sat, 01 Jan 00 00:00:00 +0000'); - } - } - - /** - * Sets the Expires HTTP header with a DateTime instance. - * - * Passing null as value will remove the header. - * - * @param \DateTime|null $date A \DateTime instance or null to remove the header - * - * @return Response - * - * @api - */ - public function setExpires(\DateTime $date = null) - { - if (null === $date) { - $this->headers->remove('Expires'); - } else { - $date = clone $date; - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Expires', $date->format('D, d M Y H:i:s').' GMT'); - } - - return $this; - } - - /** - * Returns the number of seconds after the time specified in the response's Date - * header when the response should no longer be considered fresh. - * - * First, it checks for a s-maxage directive, then a max-age directive, and then it falls - * back on an expires header. It returns null when no maximum age can be established. - * - * @return int|null Number of seconds - * - * @api - */ - public function getMaxAge() - { - if ($this->headers->hasCacheControlDirective('s-maxage')) { - return (int) $this->headers->getCacheControlDirective('s-maxage'); - } - - if ($this->headers->hasCacheControlDirective('max-age')) { - return (int) $this->headers->getCacheControlDirective('max-age'); - } - - if (null !== $this->getExpires()) { - return $this->getExpires()->format('U') - $this->getDate()->format('U'); - } - } - - /** - * Sets the number of seconds after which the response should no longer be considered fresh. - * - * This methods sets the Cache-Control max-age directive. - * - * @param int $value Number of seconds - * - * @return Response - * - * @api - */ - public function setMaxAge($value) - { - $this->headers->addCacheControlDirective('max-age', $value); - - return $this; - } - - /** - * Sets the number of seconds after which the response should no longer be considered fresh by shared caches. - * - * This methods sets the Cache-Control s-maxage directive. - * - * @param int $value Number of seconds - * - * @return Response - * - * @api - */ - public function setSharedMaxAge($value) - { - $this->setPublic(); - $this->headers->addCacheControlDirective('s-maxage', $value); - - return $this; - } - - /** - * Returns the response's time-to-live in seconds. - * - * It returns null when no freshness information is present in the response. - * - * When the responses TTL is <= 0, the response may not be served from cache without first - * revalidating with the origin. - * - * @return int|null The TTL in seconds - * - * @api - */ - public function getTtl() - { - if (null !== $maxAge = $this->getMaxAge()) { - return $maxAge - $this->getAge(); - } - } - - /** - * Sets the response's time-to-live for shared caches. - * - * This method adjusts the Cache-Control/s-maxage directive. - * - * @param int $seconds Number of seconds - * - * @return Response - * - * @api - */ - public function setTtl($seconds) - { - $this->setSharedMaxAge($this->getAge() + $seconds); - - return $this; - } - - /** - * Sets the response's time-to-live for private/client caches. - * - * This method adjusts the Cache-Control/max-age directive. - * - * @param int $seconds Number of seconds - * - * @return Response - * - * @api - */ - public function setClientTtl($seconds) - { - $this->setMaxAge($this->getAge() + $seconds); - - return $this; - } - - /** - * Returns the Last-Modified HTTP header as a DateTime instance. - * - * @return \DateTime|null A DateTime instance or null if the header does not exist - * - * @throws \RuntimeException When the HTTP header is not parseable - * - * @api - */ - public function getLastModified() - { - return $this->headers->getDate('Last-Modified'); - } - - /** - * Sets the Last-Modified HTTP header with a DateTime instance. - * - * Passing null as value will remove the header. - * - * @param \DateTime|null $date A \DateTime instance or null to remove the header - * - * @return Response - * - * @api - */ - public function setLastModified(\DateTime $date = null) - { - if (null === $date) { - $this->headers->remove('Last-Modified'); - } else { - $date = clone $date; - $date->setTimezone(new \DateTimeZone('UTC')); - $this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT'); - } - - return $this; - } - - /** - * Returns the literal value of the ETag HTTP header. - * - * @return string|null The ETag HTTP header or null if it does not exist - * - * @api - */ - public function getEtag() - { - return $this->headers->get('ETag'); - } - - /** - * Sets the ETag value. - * - * @param string|null $etag The ETag unique identifier or null to remove the header - * @param bool $weak Whether you want a weak ETag or not - * - * @return Response - * - * @api - */ - public function setEtag($etag = null, $weak = false) - { - if (null === $etag) { - $this->headers->remove('Etag'); - } else { - if (0 !== strpos($etag, '"')) { - $etag = '"'.$etag.'"'; - } - - $this->headers->set('ETag', (true === $weak ? 'W/' : '').$etag); - } - - return $this; - } - - /** - * Sets the response's cache headers (validation and/or expiration). - * - * Available options are: etag, last_modified, max_age, s_maxage, private, and public. - * - * @param array $options An array of cache options - * - * @return Response - * - * @throws \InvalidArgumentException - * - * @api - */ - public function setCache(array $options) - { - if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public'))) { - throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff)))); - } - - if (isset($options['etag'])) { - $this->setEtag($options['etag']); - } - - if (isset($options['last_modified'])) { - $this->setLastModified($options['last_modified']); - } - - if (isset($options['max_age'])) { - $this->setMaxAge($options['max_age']); - } - - if (isset($options['s_maxage'])) { - $this->setSharedMaxAge($options['s_maxage']); - } - - if (isset($options['public'])) { - if ($options['public']) { - $this->setPublic(); - } else { - $this->setPrivate(); - } - } - - if (isset($options['private'])) { - if ($options['private']) { - $this->setPrivate(); - } else { - $this->setPublic(); - } - } - - return $this; - } - - /** - * Modifies the response so that it conforms to the rules defined for a 304 status code. - * - * This sets the status, removes the body, and discards any headers - * that MUST NOT be included in 304 responses. - * - * @return Response - * - * @see http://tools.ietf.org/html/rfc2616#section-10.3.5 - * - * @api - */ - public function setNotModified() - { - $this->setStatusCode(304); - $this->setContent(null); - - // remove headers that MUST NOT be included with 304 Not Modified responses - foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) { - $this->headers->remove($header); - } - - return $this; - } - - /** - * Returns true if the response includes a Vary header. - * - * @return bool true if the response includes a Vary header, false otherwise - * - * @api - */ - public function hasVary() - { - return null !== $this->headers->get('Vary'); - } - - /** - * Returns an array of header names given in the Vary header. - * - * @return array An array of Vary names - * - * @api - */ - public function getVary() - { - if (!$vary = $this->headers->get('Vary', null, false)) { - return array(); - } - - $ret = array(); - foreach ($vary as $item) { - $ret = array_merge($ret, preg_split('/[\s,]+/', $item)); - } - - return $ret; - } - - /** - * Sets the Vary header. - * - * @param string|array $headers - * @param bool $replace Whether to replace the actual value of not (true by default) - * - * @return Response - * - * @api - */ - public function setVary($headers, $replace = true) - { - $this->headers->set('Vary', $headers, $replace); - - return $this; - } - - /** - * Determines if the Response validators (ETag, Last-Modified) match - * a conditional value specified in the Request. - * - * If the Response is not modified, it sets the status code to 304 and - * removes the actual content by calling the setNotModified() method. - * - * @param Request $request A Request instance - * - * @return bool true if the Response validators match the Request, false otherwise - * - * @api - */ - public function isNotModified(Request $request) - { - if (!$request->isMethodSafe()) { - return false; - } - - $notModified = false; - $lastModified = $this->headers->get('Last-Modified'); - $modifiedSince = $request->headers->get('If-Modified-Since'); - - if ($etags = $request->getETags()) { - $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags); - } - - if ($modifiedSince && $lastModified) { - $notModified = strtotime($modifiedSince) >= strtotime($lastModified) && (!$etags || $notModified); - } - - if ($notModified) { - $this->setNotModified(); - } - - return $notModified; - } - - // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - /** - * Is response invalid? - * - * @return bool - * - * @api - */ - public function isInvalid() - { - return $this->statusCode < 100 || $this->statusCode >= 600; - } - - /** - * Is response informative? - * - * @return bool - * - * @api - */ - public function isInformational() - { - return $this->statusCode >= 100 && $this->statusCode < 200; - } - - /** - * Is response successful? - * - * @return bool - * - * @api - */ - public function isSuccessful() - { - return $this->statusCode >= 200 && $this->statusCode < 300; - } - - /** - * Is the response a redirect? - * - * @return bool - * - * @api - */ - public function isRedirection() - { - return $this->statusCode >= 300 && $this->statusCode < 400; - } - - /** - * Is there a client error? - * - * @return bool - * - * @api - */ - public function isClientError() - { - return $this->statusCode >= 400 && $this->statusCode < 500; - } - - /** - * Was there a server side error? - * - * @return bool - * - * @api - */ - public function isServerError() - { - return $this->statusCode >= 500 && $this->statusCode < 600; - } - - /** - * Is the response OK? - * - * @return bool - * - * @api - */ - public function isOk() - { - return 200 === $this->statusCode; - } - - /** - * Is the response forbidden? - * - * @return bool - * - * @api - */ - public function isForbidden() - { - return 403 === $this->statusCode; - } - - /** - * Is the response a not found error? - * - * @return bool - * - * @api - */ - public function isNotFound() - { - return 404 === $this->statusCode; - } - - /** - * Is the response a redirect of some form? - * - * @param string $location - * - * @return bool - * - * @api - */ - public function isRedirect($location = null) - { - return in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location')); - } - - /** - * Is the response empty? - * - * @return bool - * - * @api - */ - public function isEmpty() - { - return in_array($this->statusCode, array(204, 304)); - } - - /** - * Cleans or flushes output buffers up to target level. - * - * Resulting level can be greater than target level if a non-removable buffer has been encountered. - * - * @param int $targetLevel The target output buffering level - * @param bool $flush Whether to flush or clean the buffers - */ - public static function closeOutputBuffers($targetLevel, $flush) - { - $status = ob_get_status(true); - $level = count($status); - $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; - - while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) { - if ($flush) { - ob_end_flush(); - } else { - ob_end_clean(); - } - } - } - - /** - * Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9. - * - * @link http://support.microsoft.com/kb/323308 - */ - protected function ensureIEOverSSLCompatibility(Request $request) - { - if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) { - if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) { - $this->headers->remove('Cache-Control'); - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php deleted file mode 100644 index 375d191db..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ /dev/null @@ -1,322 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ResponseHeaderBag is a container for Response HTTP headers. - * - * @author Fabien Potencier - * - * @api - */ -class ResponseHeaderBag extends HeaderBag -{ - const COOKIES_FLAT = 'flat'; - const COOKIES_ARRAY = 'array'; - - const DISPOSITION_ATTACHMENT = 'attachment'; - const DISPOSITION_INLINE = 'inline'; - - /** - * @var array - */ - protected $computedCacheControl = array(); - - /** - * @var array - */ - protected $cookies = array(); - - /** - * @var array - */ - protected $headerNames = array(); - - /** - * Constructor. - * - * @param array $headers An array of HTTP headers - * - * @api - */ - public function __construct(array $headers = array()) - { - parent::__construct($headers); - - if (!isset($this->headers['cache-control'])) { - $this->set('Cache-Control', ''); - } - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - $cookies = ''; - foreach ($this->getCookies() as $cookie) { - $cookies .= 'Set-Cookie: '.$cookie."\r\n"; - } - - ksort($this->headerNames); - - 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} - * - * @api - */ - public function replace(array $headers = array()) - { - $this->headerNames = array(); - - parent::replace($headers); - - if (!isset($this->headers['cache-control'])) { - $this->set('Cache-Control', ''); - } - } - - /** - * {@inheritdoc} - * - * @api - */ - 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($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); - } - } - - /** - * {@inheritdoc} - * - * @api - */ - public function remove($key) - { - parent::remove($key); - - $uniqueKey = strtr(strtolower($key), '_', '-'); - unset($this->headerNames[$uniqueKey]); - - if ('cache-control' === $uniqueKey) { - $this->computedCacheControl = array(); - } - } - - /** - * {@inheritdoc} - */ - public function hasCacheControlDirective($key) - { - return array_key_exists($key, $this->computedCacheControl); - } - - /** - * {@inheritdoc} - */ - public function getCacheControlDirective($key) - { - return array_key_exists($key, $this->computedCacheControl) ? $this->computedCacheControl[$key] : null; - } - - /** - * Sets a cookie. - * - * @param Cookie $cookie - * - * @api - */ - public function setCookie(Cookie $cookie) - { - $this->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; - } - - /** - * Removes a cookie from the array, but does not unset it in the browser. - * - * @param string $name - * @param string $path - * @param string $domain - * - * @api - */ - public function removeCookie($name, $path = '/', $domain = null) - { - if (null === $path) { - $path = '/'; - } - - unset($this->cookies[$domain][$path][$name]); - - if (empty($this->cookies[$domain][$path])) { - unset($this->cookies[$domain][$path]); - - if (empty($this->cookies[$domain])) { - unset($this->cookies[$domain]); - } - } - } - - /** - * Returns an array with all cookies. - * - * @param string $format - * - * @throws \InvalidArgumentException When the $format is invalid - * - * @return array - * - * @api - */ - public function getCookies($format = self::COOKIES_FLAT) - { - if (!in_array($format, array(self::COOKIES_FLAT, self::COOKIES_ARRAY))) { - throw new \InvalidArgumentException(sprintf('Format "%s" invalid (%s).', $format, implode(', ', array(self::COOKIES_FLAT, self::COOKIES_ARRAY)))); - } - - if (self::COOKIES_ARRAY === $format) { - return $this->cookies; - } - - $flattenedCookies = array(); - foreach ($this->cookies as $path) { - foreach ($path as $cookies) { - foreach ($cookies as $cookie) { - $flattenedCookies[] = $cookie; - } - } - } - - return $flattenedCookies; - } - - /** - * Clears a cookie in the browser. - * - * @param string $name - * @param string $path - * @param string $domain - * @param bool $secure - * @param bool $httpOnly - * - * @api - */ - public function clearCookie($name, $path = '/', $domain = null, $secure = false, $httpOnly = true) - { - $this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly)); - } - - /** - * Generates a HTTP Content-Disposition field-value. - * - * @param string $disposition One of "inline" or "attachment" - * @param string $filename A unicode string - * @param string $filenameFallback A string containing only ASCII characters that - * is semantically equivalent to $filename. If the filename is already ASCII, - * it can be omitted, or just copied from $filename - * - * @return string A string suitable for use as a Content-Disposition field-value. - * - * @throws \InvalidArgumentException - * - * @see RFC 6266 - */ - public function makeDisposition($disposition, $filename, $filenameFallback = '') - { - if (!in_array($disposition, array(self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE))) { - throw new \InvalidArgumentException(sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE)); - } - - if ('' == $filenameFallback) { - $filenameFallback = $filename; - } - - // filenameFallback is not ASCII. - if (!preg_match('/^[\x20-\x7e]*$/', $filenameFallback)) { - throw new \InvalidArgumentException('The filename fallback must only contain ASCII characters.'); - } - - // percent characters aren't safe in fallback. - if (false !== strpos($filenameFallback, '%')) { - throw new \InvalidArgumentException('The filename fallback cannot contain the "%" character.'); - } - - // path separators aren't allowed in either. - if (false !== strpos($filename, '/') || false !== strpos($filename, '\\') || false !== strpos($filenameFallback, '/') || false !== strpos($filenameFallback, '\\')) { - throw new \InvalidArgumentException('The filename and the fallback cannot contain the "/" and "\\" characters.'); - } - - $output = sprintf('%s; filename="%s"', $disposition, str_replace('"', '\\"', $filenameFallback)); - - if ($filename !== $filenameFallback) { - $output .= sprintf("; filename*=utf-8''%s", rawurlencode($filename)); - } - - return $output; - } - - /** - * Returns the calculated value of the cache-control header. - * - * This considers several other headers and calculates or modifies the - * cache-control header to a sensible, conservative value. - * - * @return string - */ - protected function computeCacheControlValue() - { - if (!$this->cacheControl && !$this->has('ETag') && !$this->has('Last-Modified') && !$this->has('Expires')) { - return 'no-cache'; - } - - if (!$this->cacheControl) { - // conservative by default - return 'private, must-revalidate'; - } - - $header = $this->getCacheControlHeader(); - if (isset($this->cacheControl['public']) || isset($this->cacheControl['private'])) { - return $header; - } - - // public if s-maxage is defined, private otherwise - if (!isset($this->cacheControl['s-maxage'])) { - return $header.', private'; - } - - return $header; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php deleted file mode 100644 index fa1cb2fc9..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * ServerBag is a container for HTTP headers from the $_SERVER variable. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - * @author Robert Kiss - */ -class ServerBag extends ParameterBag -{ - /** - * Gets the HTTP headers. - * - * @return array - */ - public function getHeaders() - { - $headers = array(); - $contentHeaders = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); - foreach ($this->parameters as $key => $value) { - if (0 === strpos($key, 'HTTP_')) { - $headers[substr($key, 5)] = $value; - } - // CONTENT_* are not prefixed with HTTP_ - elseif (isset($contentHeaders[$key])) { - $headers[$key] = $value; - } - } - - if (isset($this->parameters['PHP_AUTH_USER'])) { - $headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER']; - $headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : ''; - } else { - /* - * php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default - * For this workaround to work, add these lines to your .htaccess file: - * RewriteCond %{HTTP:Authorization} ^(.+)$ - * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - * - * A sample .htaccess file: - * RewriteEngine On - * RewriteCond %{HTTP:Authorization} ^(.+)$ - * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - * RewriteCond %{REQUEST_FILENAME} !-f - * RewriteRule ^(.*)$ app.php [QSA,L] - */ - - $authorizationHeader = null; - if (isset($this->parameters['HTTP_AUTHORIZATION'])) { - $authorizationHeader = $this->parameters['HTTP_AUTHORIZATION']; - } elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) { - $authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION']; - } - - if (null !== $authorizationHeader) { - if (0 === stripos($authorizationHeader, 'basic ')) { - // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic - $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2); - if (count($exploded) == 2) { - list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; - } - } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) { - // In some circumstances PHP_AUTH_DIGEST needs to be set - $headers['PHP_AUTH_DIGEST'] = $authorizationHeader; - $this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader; - } elseif (0 === stripos($authorizationHeader, 'bearer ')) { - /* - * XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables, - * I'll just set $headers['AUTHORIZATION'] here. - * http://php.net/manual/en/reserved.variables.server.php - */ - $headers['AUTHORIZATION'] = $authorizationHeader; - } - } - } - - // PHP_AUTH_USER/PHP_AUTH_PW - if (isset($headers['PHP_AUTH_USER'])) { - $headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']); - } elseif (isset($headers['PHP_AUTH_DIGEST'])) { - $headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST']; - } - - return $headers; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php deleted file mode 100644 index af292e37a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php +++ /dev/null @@ -1,157 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Attribute; - -/** - * This class relates to session attribute storage. - */ -class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Countable -{ - private $name = 'attributes'; - - /** - * @var string - */ - private $storageKey; - - /** - * @var array - */ - protected $attributes = array(); - - /** - * Constructor. - * - * @param string $storageKey The key used to store attributes in the session - */ - public function __construct($storageKey = '_sf2_attributes') - { - $this->storageKey = $storageKey; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$attributes) - { - $this->attributes = &$attributes; - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - return array_key_exists($name, $this->attributes); - } - - /** - * {@inheritdoc} - */ - public function get($name, $default = null) - { - return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default; - } - - /** - * {@inheritdoc} - */ - public function set($name, $value) - { - $this->attributes[$name] = $value; - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->attributes; - } - - /** - * {@inheritdoc} - */ - public function replace(array $attributes) - { - $this->attributes = array(); - foreach ($attributes as $key => $value) { - $this->set($key, $value); - } - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - $retval = null; - if (array_key_exists($name, $this->attributes)) { - $retval = $this->attributes[$name]; - unset($this->attributes[$name]); - } - - return $retval; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $return = $this->attributes; - $this->attributes = array(); - - return $return; - } - - /** - * Returns an iterator for attributes. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->attributes); - } - - /** - * Returns the number of attributes. - * - * @return int The number of attributes - */ - public function count() - { - return count($this->attributes); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php deleted file mode 100644 index 0d8d17991..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Attribute; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * Attributes store. - * - * @author Drak - */ -interface AttributeBagInterface extends SessionBagInterface -{ - /** - * Checks if an attribute is defined. - * - * @param string $name The attribute name - * - * @return bool true if the attribute is defined, false otherwise - */ - public function has($name); - - /** - * Returns an attribute. - * - * @param string $name The attribute name - * @param mixed $default The default value if not found - * - * @return mixed - */ - public function get($name, $default = null); - - /** - * Sets an attribute. - * - * @param string $name - * @param mixed $value - */ - public function set($name, $value); - - /** - * Returns attributes. - * - * @return array Attributes - */ - public function all(); - - /** - * Sets attributes. - * - * @param array $attributes Attributes - */ - public function replace(array $attributes); - - /** - * Removes an attribute. - * - * @param string $name - * - * @return mixed The removed value or null when it does not exist - */ - public function remove($name); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php deleted file mode 100644 index 68cecf63d..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php +++ /dev/null @@ -1,160 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Attribute; - -/** - * This class provides structured storage of session attributes using - * a name spacing character in the key. - * - * @author Drak - */ -class NamespacedAttributeBag extends AttributeBag -{ - /** - * Namespace character. - * - * @var string - */ - private $namespaceCharacter; - - /** - * Constructor. - * - * @param string $storageKey Session storage key. - * @param string $namespaceCharacter Namespace character to use in keys. - */ - public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter = '/') - { - $this->namespaceCharacter = $namespaceCharacter; - parent::__construct($storageKey); - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - // reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is - $attributes = $this->resolveAttributePath($name); - $name = $this->resolveKey($name); - - if (null === $attributes) { - return false; - } - - return array_key_exists($name, $attributes); - } - - /** - * {@inheritdoc} - */ - public function get($name, $default = null) - { - // reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is - $attributes = $this->resolveAttributePath($name); - $name = $this->resolveKey($name); - - if (null === $attributes) { - return $default; - } - - return array_key_exists($name, $attributes) ? $attributes[$name] : $default; - } - - /** - * {@inheritdoc} - */ - public function set($name, $value) - { - $attributes = &$this->resolveAttributePath($name, true); - $name = $this->resolveKey($name); - $attributes[$name] = $value; - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - $retval = null; - $attributes = &$this->resolveAttributePath($name); - $name = $this->resolveKey($name); - if (null !== $attributes && array_key_exists($name, $attributes)) { - $retval = $attributes[$name]; - unset($attributes[$name]); - } - - return $retval; - } - - /** - * Resolves a path in attributes property and returns it as a reference. - * - * This method allows structured namespacing of session attributes. - * - * @param string $name Key name - * @param bool $writeContext Write context, default false - * - * @return array - */ - protected function &resolveAttributePath($name, $writeContext = false) - { - $array = &$this->attributes; - $name = (strpos($name, $this->namespaceCharacter) === 0) ? substr($name, 1) : $name; - - // Check if there is anything to do, else return - if (!$name) { - return $array; - } - - $parts = explode($this->namespaceCharacter, $name); - if (count($parts) < 2) { - if (!$writeContext) { - return $array; - } - - $array[$parts[0]] = array(); - - return $array; - } - - unset($parts[count($parts) - 1]); - - foreach ($parts as $part) { - if (null !== $array && !array_key_exists($part, $array)) { - $array[$part] = $writeContext ? array() : null; - } - - $array = &$array[$part]; - } - - return $array; - } - - /** - * Resolves the key from the name. - * - * This is the last part in a dot separated string. - * - * @param string $name - * - * @return string - */ - protected function resolveKey($name) - { - if (false !== $pos = strrpos($name, $this->namespaceCharacter)) { - $name = substr($name, $pos + 1); - } - - return $name; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php deleted file mode 100644 index b9de5ceb3..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php +++ /dev/null @@ -1,175 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Flash; - -/** - * AutoExpireFlashBag flash message container. - * - * @author Drak - */ -class AutoExpireFlashBag implements FlashBagInterface -{ - private $name = 'flashes'; - - /** - * Flash messages. - * - * @var array - */ - private $flashes = array('display' => array(), 'new' => array()); - - /** - * The storage key for flashes in the session. - * - * @var string - */ - private $storageKey; - - /** - * Constructor. - * - * @param string $storageKey The key used to store flashes in the session. - */ - public function __construct($storageKey = '_sf2_flashes') - { - $this->storageKey = $storageKey; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$flashes) - { - $this->flashes = &$flashes; - - // The logic: messages from the last request will be stored in new, so we move them to previous - // This request we will show what is in 'display'. What is placed into 'new' this time round will - // be moved to display next time round. - $this->flashes['display'] = array_key_exists('new', $this->flashes) ? $this->flashes['new'] : array(); - $this->flashes['new'] = array(); - } - - /** - * {@inheritdoc} - */ - public function add($type, $message) - { - $this->flashes['new'][$type][] = $message; - } - - /** - * {@inheritdoc} - */ - public function peek($type, array $default = array()) - { - return $this->has($type) ? $this->flashes['display'][$type] : $default; - } - - /** - * {@inheritdoc} - */ - public function peekAll() - { - return array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : array(); - } - - /** - * {@inheritdoc} - */ - public function get($type, array $default = array()) - { - $return = $default; - - if (!$this->has($type)) { - return $return; - } - - if (isset($this->flashes['display'][$type])) { - $return = $this->flashes['display'][$type]; - unset($this->flashes['display'][$type]); - } - - return $return; - } - - /** - * {@inheritdoc} - */ - public function all() - { - $return = $this->flashes['display']; - $this->flashes = array('new' => array(), 'display' => array()); - - return $return; - } - - /** - * {@inheritdoc} - */ - public function setAll(array $messages) - { - $this->flashes['new'] = $messages; - } - - /** - * {@inheritdoc} - */ - public function set($type, $messages) - { - $this->flashes['new'][$type] = (array) $messages; - } - - /** - * {@inheritdoc} - */ - public function has($type) - { - return array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type]; - } - - /** - * {@inheritdoc} - */ - public function keys() - { - return array_keys($this->flashes['display']); - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - return $this->all(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php deleted file mode 100644 index ac412d7dc..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Flash; - -/** - * FlashBag flash message container. - * - * \IteratorAggregate implementation is deprecated and will be removed in 3.0. - * - * @author Drak - */ -class FlashBag implements FlashBagInterface, \IteratorAggregate -{ - private $name = 'flashes'; - - /** - * Flash messages. - * - * @var array - */ - private $flashes = array(); - - /** - * The storage key for flashes in the session. - * - * @var string - */ - private $storageKey; - - /** - * Constructor. - * - * @param string $storageKey The key used to store flashes in the session. - */ - public function __construct($storageKey = '_sf2_flashes') - { - $this->storageKey = $storageKey; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$flashes) - { - $this->flashes = &$flashes; - } - - /** - * {@inheritdoc} - */ - public function add($type, $message) - { - $this->flashes[$type][] = $message; - } - - /** - * {@inheritdoc} - */ - public function peek($type, array $default = array()) - { - return $this->has($type) ? $this->flashes[$type] : $default; - } - - /** - * {@inheritdoc} - */ - public function peekAll() - { - return $this->flashes; - } - - /** - * {@inheritdoc} - */ - public function get($type, array $default = array()) - { - if (!$this->has($type)) { - return $default; - } - - $return = $this->flashes[$type]; - - unset($this->flashes[$type]); - - return $return; - } - - /** - * {@inheritdoc} - */ - public function all() - { - $return = $this->peekAll(); - $this->flashes = array(); - - return $return; - } - - /** - * {@inheritdoc} - */ - public function set($type, $messages) - { - $this->flashes[$type] = (array) $messages; - } - - /** - * {@inheritdoc} - */ - public function setAll(array $messages) - { - $this->flashes = $messages; - } - - /** - * {@inheritdoc} - */ - public function has($type) - { - return array_key_exists($type, $this->flashes) && $this->flashes[$type]; - } - - /** - * {@inheritdoc} - */ - public function keys() - { - return array_keys($this->flashes); - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - return $this->all(); - } - - /** - * Returns an iterator for flashes. - * - * @deprecated Will be removed in 3.0. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->all()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php deleted file mode 100644 index be79d9d75..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Flash; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * FlashBagInterface. - * - * @author Drak - */ -interface FlashBagInterface extends SessionBagInterface -{ - /** - * Adds a flash message for type. - * - * @param string $type - * @param string $message - */ - public function add($type, $message); - - /** - * Registers a message for a given type. - * - * @param string $type - * @param string|array $message - */ - public function set($type, $message); - - /** - * Gets flash messages for a given type. - * - * @param string $type Message category type. - * @param array $default Default value if $type does not exist. - * - * @return array - */ - public function peek($type, array $default = array()); - - /** - * Gets all flash messages. - * - * @return array - */ - public function peekAll(); - - /** - * Gets and clears flash from the stack. - * - * @param string $type - * @param array $default Default value if $type does not exist. - * - * @return array - */ - public function get($type, array $default = array()); - - /** - * Gets and clears flashes from the stack. - * - * @return array - */ - public function all(); - - /** - * Sets all flash messages. - */ - public function setAll(array $messages); - - /** - * Has flash messages for a given type? - * - * @param string $type - * - * @return bool - */ - public function has($type); - - /** - * Returns a list of all defined types. - * - * @return array - */ - public function keys(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php deleted file mode 100644 index ac626fd58..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php +++ /dev/null @@ -1,251 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Session. - * - * @author Fabien Potencier - * @author Drak - * - * @api - */ -class Session implements SessionInterface, \IteratorAggregate, \Countable -{ - /** - * Storage driver. - * - * @var SessionStorageInterface - */ - protected $storage; - - /** - * @var string - */ - private $flashName; - - /** - * @var string - */ - private $attributeName; - - /** - * Constructor. - * - * @param SessionStorageInterface $storage A SessionStorageInterface instance. - * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) - * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) - */ - public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) - { - $this->storage = $storage ?: new NativeSessionStorage(); - - $attributes = $attributes ?: new AttributeBag(); - $this->attributeName = $attributes->getName(); - $this->registerBag($attributes); - - $flashes = $flashes ?: new FlashBag(); - $this->flashName = $flashes->getName(); - $this->registerBag($flashes); - } - - /** - * {@inheritdoc} - */ - public function start() - { - return $this->storage->start(); - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - return $this->storage->getBag($this->attributeName)->has($name); - } - - /** - * {@inheritdoc} - */ - public function get($name, $default = null) - { - return $this->storage->getBag($this->attributeName)->get($name, $default); - } - - /** - * {@inheritdoc} - */ - public function set($name, $value) - { - $this->storage->getBag($this->attributeName)->set($name, $value); - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->storage->getBag($this->attributeName)->all(); - } - - /** - * {@inheritdoc} - */ - public function replace(array $attributes) - { - $this->storage->getBag($this->attributeName)->replace($attributes); - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - return $this->storage->getBag($this->attributeName)->remove($name); - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $this->storage->getBag($this->attributeName)->clear(); - } - - /** - * {@inheritdoc} - */ - public function isStarted() - { - return $this->storage->isStarted(); - } - - /** - * Returns an iterator for attributes. - * - * @return \ArrayIterator An \ArrayIterator instance - */ - public function getIterator() - { - return new \ArrayIterator($this->storage->getBag($this->attributeName)->all()); - } - - /** - * Returns the number of attributes. - * - * @return int The number of attributes - */ - public function count() - { - return count($this->storage->getBag($this->attributeName)->all()); - } - - /** - * {@inheritdoc} - */ - public function invalidate($lifetime = null) - { - $this->storage->clear(); - - return $this->migrate(true, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function migrate($destroy = false, $lifetime = null) - { - return $this->storage->regenerate($destroy, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function save() - { - $this->storage->save(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->storage->getId(); - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - $this->storage->setId($id); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->storage->getName(); - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->storage->setName($name); - } - - /** - * {@inheritdoc} - */ - public function getMetadataBag() - { - return $this->storage->getMetadataBag(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->storage->registerBag($bag); - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - return $this->storage->getBag($name); - } - - /** - * Gets the flashbag interface. - * - * @return FlashBagInterface - */ - public function getFlashBag() - { - return $this->getBag($this->flashName); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php deleted file mode 100644 index 182a47d96..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -/** - * Session Bag store. - * - * @author Drak - */ -interface SessionBagInterface -{ - /** - * Gets this bag's name. - * - * @return string - */ - public function getName(); - - /** - * Initializes the Bag. - * - * @param array $array - */ - public function initialize(array &$array); - - /** - * Gets the storage key for this bag. - * - * @return string - */ - public function getStorageKey(); - - /** - * Clears out data from bag. - * - * @return mixed Whatever data was contained. - */ - public function clear(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php deleted file mode 100644 index 773dc7a00..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php +++ /dev/null @@ -1,208 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session; - -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; - -/** - * Interface for the session. - * - * @author Drak - */ -interface SessionInterface -{ - /** - * Starts the session storage. - * - * @return bool True if session started. - * - * @throws \RuntimeException If session fails to start. - * - * @api - */ - public function start(); - - /** - * Returns the session ID. - * - * @return string The session ID. - * - * @api - */ - public function getId(); - - /** - * Sets the session ID. - * - * @param string $id - * - * @api - */ - public function setId($id); - - /** - * Returns the session name. - * - * @return mixed The session name. - * - * @api - */ - public function getName(); - - /** - * Sets the session name. - * - * @param string $name - * - * @api - */ - public function setName($name); - - /** - * Invalidates the current session. - * - * Clears all session attributes and flashes and regenerates the - * session and deletes the old session from persistence. - * - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return bool True if session invalidated, false if error. - * - * @api - */ - public function invalidate($lifetime = null); - - /** - * Migrates the current session to a new session id while maintaining all - * session attributes. - * - * @param bool $destroy Whether to delete the old session or leave it to garbage collection. - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return bool True if session migrated, false if error. - * - * @api - */ - public function migrate($destroy = false, $lifetime = null); - - /** - * Force the session to be saved and closed. - * - * This method is generally not required for real sessions as - * the session will be automatically saved at the end of - * code execution. - */ - public function save(); - - /** - * Checks if an attribute is defined. - * - * @param string $name The attribute name - * - * @return bool true if the attribute is defined, false otherwise - * - * @api - */ - public function has($name); - - /** - * Returns an attribute. - * - * @param string $name The attribute name - * @param mixed $default The default value if not found. - * - * @return mixed - * - * @api - */ - public function get($name, $default = null); - - /** - * Sets an attribute. - * - * @param string $name - * @param mixed $value - * - * @api - */ - public function set($name, $value); - - /** - * Returns attributes. - * - * @return array Attributes - * - * @api - */ - public function all(); - - /** - * Sets attributes. - * - * @param array $attributes Attributes - */ - public function replace(array $attributes); - - /** - * Removes an attribute. - * - * @param string $name - * - * @return mixed The removed value or null when it does not exist - * - * @api - */ - public function remove($name); - - /** - * Clears all attributes. - * - * @api - */ - public function clear(); - - /** - * Checks if the session was started. - * - * @return bool - */ - public function isStarted(); - - /** - * Registers a SessionBagInterface with the session. - * - * @param SessionBagInterface $bag - */ - public function registerBag(SessionBagInterface $bag); - - /** - * Gets a bag instance by name. - * - * @param string $name - * - * @return SessionBagInterface - */ - public function getBag($name); - - /** - * Gets session meta. - * - * @return MetadataBag - */ - public function getMetadataBag(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php deleted file mode 100644 index fff83315a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/LegacyPdoSessionHandler.php +++ /dev/null @@ -1,268 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Session handler using a PDO connection to read and write data. - * - * Session data is a binary string that can contain non-printable characters like the null byte. - * For this reason this handler base64 encodes the data to be able to save it in a character column. - * - * This version of the PdoSessionHandler does NOT implement locking. So concurrent requests to the - * same session can result in data loss due to race conditions. - * - * @author Fabien Potencier - * @author Michael Williams - * @author Tobias Schultze - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use - * {@link PdoSessionHandler} instead. - */ -class LegacyPdoSessionHandler implements \SessionHandlerInterface -{ - /** - * @var \PDO PDO instance - */ - private $pdo; - - /** - * @var string Table name - */ - private $table; - - /** - * @var string Column for session id - */ - private $idCol; - - /** - * @var string Column for session data - */ - private $dataCol; - - /** - * @var string Column for timestamp - */ - private $timeCol; - - /** - * Constructor. - * - * List of available options: - * * db_table: The name of the table [required] - * * db_id_col: The column where to store the session id [default: sess_id] - * * db_data_col: The column where to store the session data [default: sess_data] - * * db_time_col: The column where to store the timestamp [default: sess_time] - * - * @param \PDO $pdo A \PDO instance - * @param array $dbOptions An associative array of DB options - * - * @throws \InvalidArgumentException When "db_table" option is not provided - */ - public function __construct(\PDO $pdo, array $dbOptions = array()) - { - if (!array_key_exists('db_table', $dbOptions)) { - throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.'); - } - if (\PDO::ERRMODE_EXCEPTION !== $pdo->getAttribute(\PDO::ATTR_ERRMODE)) { - throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); - } - $this->pdo = $pdo; - $dbOptions = array_merge(array( - 'db_id_col' => 'sess_id', - 'db_data_col' => 'sess_data', - 'db_time_col' => 'sess_time', - ), $dbOptions); - - $this->table = $dbOptions['db_table']; - $this->idCol = $dbOptions['db_id_col']; - $this->dataCol = $dbOptions['db_data_col']; - $this->timeCol = $dbOptions['db_time_col']; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - // delete the record associated with this id - $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // delete the session records that have expired - $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); - $stmt->execute(); - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - - // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed - $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); - - if ($sessionRows) { - return base64_decode($sessionRows[0][0]); - } - - return ''; - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); - } - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - $encoded = base64_encode($data); - - try { - // We use a single MERGE SQL query when supported by the database. - $mergeSql = $this->getMergeSql(); - - if (null !== $mergeSql) { - $mergeStmt = $this->pdo->prepare($mergeSql); - $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $mergeStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $mergeStmt->execute(); - - return true; - } - - $updateStmt = $this->pdo->prepare( - "UPDATE $this->table SET $this->dataCol = :data, $this->timeCol = :time WHERE $this->idCol = :id" - ); - $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $updateStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $updateStmt->execute(); - - // When MERGE is not supported, like in Postgres, we have to use this approach that can result in - // duplicate key errors when the same session is written simultaneously. We can just catch such an - // error and re-execute the update. This is similar to a serializable transaction with retry logic - // on serialization failures but without the overhead and without possible false positives due to - // longer gap locking. - if (!$updateStmt->rowCount()) { - try { - $insertStmt = $this->pdo->prepare( - "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)" - ); - $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $insertStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); - $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $insertStmt->execute(); - } catch (\PDOException $e) { - // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys - if (0 === strpos($e->getCode(), '23')) { - $updateStmt->execute(); - } else { - throw $e; - } - } - } - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); - } - - return true; - } - - /** - * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database. - * - * @return string|null The SQL string or null when not supported - */ - private function getMergeSql() - { - $driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - - switch ($driver) { - case 'mysql': - return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". - "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; - case 'oci': - // DUAL is Oracle specific dummy table - return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time"; - case 'sqlsrv' === $driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): - // MERGE is only available since SQL Server 2008 and must be terminated by semicolon - // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx - return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; - case 'sqlite': - return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; - } - } - - /** - * Return a PDO instance - * - * @return \PDO - */ - protected function getConnection() - { - return $this->pdo; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php deleted file mode 100644 index 183093f87..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * MemcacheSessionHandler. - * - * @author Drak - */ -class MemcacheSessionHandler implements \SessionHandlerInterface -{ - /** - * @var \Memcache Memcache driver. - */ - private $memcache; - - /** - * @var int Time to live in seconds - */ - private $ttl; - - /** - * @var string Key prefix for shared environments. - */ - private $prefix; - - /** - * Constructor. - * - * List of available options: - * * prefix: The prefix to use for the memcache keys in order to avoid collision - * * expiretime: The time to live in seconds - * - * @param \Memcache $memcache A \Memcache instance - * @param array $options An associative array of Memcache options - * - * @throws \InvalidArgumentException When unsupported options are passed - */ - public function __construct(\Memcache $memcache, array $options = array()) - { - if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime'))) { - throw new \InvalidArgumentException(sprintf( - 'The following options are not supported "%s"', implode(', ', $diff) - )); - } - - $this->memcache = $memcache; - $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400; - $this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s'; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return $this->memcache->close(); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return $this->memcache->get($this->prefix.$sessionId) ?: ''; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return $this->memcache->set($this->prefix.$sessionId, $data, 0, time() + $this->ttl); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return $this->memcache->delete($this->prefix.$sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // not required here because memcache will auto expire the records anyhow. - return true; - } - - /** - * Return a Memcache instance - * - * @return \Memcache - */ - protected function getMemcache() - { - return $this->memcache; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php deleted file mode 100644 index 1f9d97e45..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * MemcachedSessionHandler. - * - * Memcached based session storage handler based on the Memcached class - * provided by the PHP memcached extension. - * - * @see http://php.net/memcached - * - * @author Drak - */ -class MemcachedSessionHandler implements \SessionHandlerInterface -{ - /** - * @var \Memcached Memcached driver. - */ - private $memcached; - - /** - * @var int Time to live in seconds - */ - private $ttl; - - /** - * @var string Key prefix for shared environments. - */ - private $prefix; - - /** - * Constructor. - * - * List of available options: - * * prefix: The prefix to use for the memcached keys in order to avoid collision - * * expiretime: The time to live in seconds - * - * @param \Memcached $memcached A \Memcached instance - * @param array $options An associative array of Memcached options - * - * @throws \InvalidArgumentException When unsupported options are passed - */ - public function __construct(\Memcached $memcached, array $options = array()) - { - $this->memcached = $memcached; - - if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime'))) { - throw new \InvalidArgumentException(sprintf( - 'The following options are not supported "%s"', implode(', ', $diff) - )); - } - - $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400; - $this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s'; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return $this->memcached->get($this->prefix.$sessionId) ?: ''; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return $this->memcached->delete($this->prefix.$sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // not required here because memcached will auto expire the records anyhow. - return true; - } - - /** - * Return a Memcached instance - * - * @return \Memcached - */ - protected function getMemcached() - { - return $this->memcached; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php deleted file mode 100644 index fa4ecfb0a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ /dev/null @@ -1,188 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * MongoDB session handler. - * - * @author Markus Bachmann - */ -class MongoDbSessionHandler implements \SessionHandlerInterface -{ - /** - * @var \Mongo - */ - private $mongo; - - /** - * @var \MongoCollection - */ - private $collection; - - /** - * @var array - */ - private $options; - - /** - * 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] - * * expiry_field: The field name for storing the expiry-timestamp [default: expires_at] - * - * It is strongly recommended to put an index on the `expiry_field` for - * garbage-collection. Alternatively it's possible to automatically expire - * the sessions in the database as described below: - * - * A TTL collections can be used on MongoDB 2.2+ to cleanup expired sessions - * automatically. Such an index can for example look like this: - * - * db..ensureIndex( - * { "": 1 }, - * { "expireAfterSeconds": 0 } - * ) - * - * More details on: http://docs.mongodb.org/manual/tutorial/expire-data/ - * - * If you use such an index, you can drop `gc_probability` to 0 since - * no garbage-collection is required. - * - * @param \Mongo|\MongoClient $mongo A MongoClient or Mongo instance - * @param array $options An associative array of field options - * - * @throws \InvalidArgumentException When MongoClient or Mongo instance not provided - * @throws \InvalidArgumentException When "database" or "collection" not provided - */ - public function __construct($mongo, array $options) - { - if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) { - throw new \InvalidArgumentException('MongoClient or Mongo instance required'); - } - - if (!isset($options['database']) || !isset($options['collection'])) { - throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler'); - } - - $this->mongo = $mongo; - - $this->options = array_merge(array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'expiry_field' => 'expires_at', - ), $options); - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - $this->getCollection()->remove(array( - $this->options['id_field'] => $sessionId, - )); - - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - $this->getCollection()->remove(array( - $this->options['expiry_field'] => array('$lt' => new \MongoDate()), - )); - - return true; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - $expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime')); - - $fields = array( - $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), - $this->options['time_field'] => new \MongoDate(), - $this->options['expiry_field'] => $expiry, - ); - - $this->getCollection()->update( - array($this->options['id_field'] => $sessionId), - array('$set' => $fields), - array('upsert' => true, 'multiple' => false) - ); - - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - $dbData = $this->getCollection()->findOne(array( - $this->options['id_field'] => $sessionId, - $this->options['expiry_field'] => array('$gte' => new \MongoDate()), - )); - - return null === $dbData ? '' : $dbData[$this->options['data_field']]->bin; - } - - /** - * Return a "MongoCollection" instance. - * - * @return \MongoCollection - */ - private function getCollection() - { - if (null === $this->collection) { - $this->collection = $this->mongo->selectCollection($this->options['database'], $this->options['collection']); - } - - return $this->collection; - } - - /** - * Return a Mongo instance - * - * @return \Mongo - */ - protected function getMongo() - { - return $this->mongo; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php deleted file mode 100644 index f39235cbf..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeFileSessionHandler. - * - * Native session handler using PHP's built in file storage. - * - * @author Drak - */ -class NativeFileSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path of directory to save session files. - * Default null will leave setting as defined by PHP. - * '/path', 'N;/path', or 'N;octal-mode;/path - * - * @see http://php.net/session.configuration.php#ini.session.save-path for further details. - * - * @throws \InvalidArgumentException On invalid $savePath - */ - public function __construct($savePath = null) - { - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - $baseDir = $savePath; - - if ($count = substr_count($savePath, ';')) { - if ($count > 2) { - throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'', $savePath)); - } - - // characters after last ';' are the path - $baseDir = ltrim(strrchr($savePath, ';'), ';'); - } - - if ($baseDir && !is_dir($baseDir)) { - mkdir($baseDir, 0777, true); - } - - ini_set('session.save_path', $savePath); - ini_set('session.save_handler', 'files'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php deleted file mode 100644 index 95d5cdbf5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -// Adds SessionHandler functionality if available. -// @see http://php.net/sessionhandler -if (PHP_VERSION_ID >= 50400) { - class NativeSessionHandler extends \SessionHandler - { - } -} else { - class NativeSessionHandler - { - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php deleted file mode 100644 index d88ce895b..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NullSessionHandler. - * - * Can be used in unit testing or in a situations where persisted sessions are not desired. - * - * @author Drak - * - * @api - */ -class NullSessionHandler implements \SessionHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return ''; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php deleted file mode 100644 index 48e81ee0f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ /dev/null @@ -1,695 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Session handler using a PDO connection to read and write data. - * - * It works with MySQL, PostgreSQL, Oracle, SQL Server and SQLite and implements - * different locking strategies to handle concurrent access to the same session. - * Locking is necessary to prevent loss of data due to race conditions and to keep - * the session data consistent between read() and write(). With locking, requests - * for the same session will wait until the other one finished writing. For this - * reason it's best practice to close a session as early as possible to improve - * concurrency. PHPs internal files session handler also implements locking. - * - * Attention: Since SQLite does not support row level locks but locks the whole database, - * it means only one session can be accessed at a time. Even different sessions would wait - * for another to finish. So saving session in SQLite should only be considered for - * development or prototypes. - * - * Session data is a binary string that can contain non-printable characters like the null byte. - * For this reason it must be saved in a binary column in the database like BLOB in MySQL. - * Saving it in a character column could corrupt the data. You can use createTable() - * to initialize a correctly defined table. - * - * @see http://php.net/sessionhandlerinterface - * - * @author Fabien Potencier - * @author Michael Williams - * @author Tobias Schultze - */ -class PdoSessionHandler implements \SessionHandlerInterface -{ - /** - * No locking is done. This means sessions are prone to loss of data due to - * race conditions of concurrent requests to the same session. The last session - * write will win in this case. It might be useful when you implement your own - * logic to deal with this like an optimistic approach. - */ - const LOCK_NONE = 0; - - /** - * Creates an application-level lock on a session. The disadvantage is that the - * lock is not enforced by the database and thus other, unaware parts of the - * application could still concurrently modify the session. The advantage is it - * does not require a transaction. - * This mode is not available for SQLite and not yet implemented for oci and sqlsrv. - */ - const LOCK_ADVISORY = 1; - - /** - * Issues a real row lock. Since it uses a transaction between opening and - * closing a session, you have to be careful when you use same database connection - * that you also use for your application logic. This mode is the default because - * it's the only reliable solution across DBMSs. - */ - const LOCK_TRANSACTIONAL = 2; - - /** - * @var \PDO|null PDO instance or null when not connected yet - */ - private $pdo; - - /** - * @var string|null|false DSN string or null for session.save_path or false when lazy connection disabled - */ - private $dsn = false; - - /** - * @var string Database driver - */ - private $driver; - - /** - * @var string Table name - */ - private $table = 'sessions'; - - /** - * @var string Column for session id - */ - private $idCol = 'sess_id'; - - /** - * @var string Column for session data - */ - private $dataCol = 'sess_data'; - - /** - * @var string Column for lifetime - */ - private $lifetimeCol = 'sess_lifetime'; - - /** - * @var string Column for timestamp - */ - private $timeCol = 'sess_time'; - - /** - * @var string Username when lazy-connect - */ - private $username = ''; - - /** - * @var string Password when lazy-connect - */ - private $password = ''; - - /** - * @var array Connection options when lazy-connect - */ - private $connectionOptions = array(); - - /** - * @var int The strategy for locking, see constants - */ - private $lockMode = self::LOCK_TRANSACTIONAL; - - /** - * It's an array to support multiple reads before closing which is manual, non-standard usage. - * - * @var \PDOStatement[] An array of statements to release advisory locks - */ - private $unlockStatements = array(); - - /** - * @var bool True when the current session exists but expired according to session.gc_maxlifetime - */ - private $sessionExpired = false; - - /** - * @var bool Whether a transaction is active - */ - private $inTransaction = false; - - /** - * @var bool Whether gc() has been called - */ - private $gcCalled = false; - - /** - * Constructor. - * - * You can either pass an existing database connection as PDO instance or - * pass a DSN string that will be used to lazy-connect to the database - * when the session is actually used. Furthermore it's possible to pass null - * which will then use the session.save_path ini setting as PDO DSN parameter. - * - * List of available options: - * * db_table: The name of the table [default: sessions] - * * db_id_col: The column where to store the session id [default: sess_id] - * * db_data_col: The column where to store the session data [default: sess_data] - * * db_lifetime_col: The column where to store the lifetime [default: sess_lifetime] - * * db_time_col: The column where to store the timestamp [default: sess_time] - * * db_username: The username when lazy-connect [default: ''] - * * db_password: The password when lazy-connect [default: ''] - * * db_connection_options: An array of driver-specific connection options [default: array()] - * * lock_mode: The strategy for locking, see constants [default: LOCK_TRANSACTIONAL] - * - * @param \PDO|string|null $pdoOrDsn A \PDO instance or DSN string or null - * @param array $options An associative array of options - * - * @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION - */ - public function __construct($pdoOrDsn = null, array $options = array()) - { - if ($pdoOrDsn instanceof \PDO) { - if (\PDO::ERRMODE_EXCEPTION !== $pdoOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) { - throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); - } - - $this->pdo = $pdoOrDsn; - $this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - } else { - $this->dsn = $pdoOrDsn; - } - - $this->table = isset($options['db_table']) ? $options['db_table'] : $this->table; - $this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol; - $this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol; - $this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol; - $this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol; - $this->username = isset($options['db_username']) ? $options['db_username'] : $this->username; - $this->password = isset($options['db_password']) ? $options['db_password'] : $this->password; - $this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions; - $this->lockMode = isset($options['lock_mode']) ? $options['lock_mode'] : $this->lockMode; - } - - /** - * Creates the table to store sessions which can be called once for setup. - * - * Session ID is saved in a column of maximum length 128 because that is enough even - * for a 512 bit configured session.hash_function like Whirlpool. Session data is - * saved in a BLOB. One could also use a shorter inlined varbinary column - * if one was sure the data fits into it. - * - * @throws \PDOException When the table already exists - * @throws \DomainException When an unsupported PDO driver is used - */ - public function createTable() - { - // connect if we are not yet - $this->getConnection(); - - switch ($this->driver) { - case 'mysql': - // We use varbinary for the ID column because it prevents unwanted conversions: - // - character set conversions between server and client - // - trailing space removal - // - case-insensitivity - // - language processing like é == e - $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol MEDIUMINT NOT NULL, $this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8_bin, ENGINE = InnoDB"; - break; - case 'sqlite': - $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - case 'pgsql': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->dataCol BYTEA NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - case 'oci': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - case 'sqlsrv': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->dataCol VARBINARY(MAX) NOT NULL, $this->lifetimeCol INTEGER NOT NULL, $this->timeCol INTEGER NOT NULL)"; - break; - default: - throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver)); - } - - try { - $this->pdo->exec($sql); - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - } - - /** - * Returns true when the current session exists but expired according to session.gc_maxlifetime. - * - * Can be used to distinguish between a new session and one that expired due to inactivity. - * - * @return bool Whether current session expired - */ - public function isSessionExpired() - { - return $this->sessionExpired; - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - if (null === $this->pdo) { - $this->connect($this->dsn ?: $savePath); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - try { - return $this->doRead($sessionId); - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // We delay gc() to close() so that it is executed outside the transactional and blocking read-write process. - // This way, pruning expired sessions does not block them from being started while the current session is used. - $this->gcCalled = true; - - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - // delete the record associated with this id - $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - $maxlifetime = (int) ini_get('session.gc_maxlifetime'); - - try { - // We use a single MERGE SQL query when supported by the database. - $mergeSql = $this->getMergeSql(); - - if (null !== $mergeSql) { - $mergeStmt = $this->pdo->prepare($mergeSql); - $mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $mergeStmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $mergeStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); - $mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $mergeStmt->execute(); - - return true; - } - - $updateStmt = $this->pdo->prepare( - "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id" - ); - $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $updateStmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); - $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $updateStmt->execute(); - - // When MERGE is not supported, like in Postgres, we have to use this approach that can result in - // duplicate key errors when the same session is written simultaneously (given the LOCK_NONE behavior). - // We can just catch such an error and re-execute the update. This is similar to a serializable - // transaction with retry logic on serialization failures but without the overhead and without possible - // false positives due to longer gap locking. - if (!$updateStmt->rowCount()) { - try { - $insertStmt = $this->pdo->prepare( - "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)" - ); - $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $insertStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT); - $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $insertStmt->execute(); - } catch (\PDOException $e) { - // Handle integrity violation SQLSTATE 23000 (or a subclass like 23505 in Postgres) for duplicate keys - if (0 === strpos($e->getCode(), '23')) { - $updateStmt->execute(); - } else { - throw $e; - } - } - } - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - $this->commit(); - - while ($unlockStmt = array_shift($this->unlockStatements)) { - $unlockStmt->execute(); - } - - if ($this->gcCalled) { - $this->gcCalled = false; - - // delete the session records that have expired - $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol < :time"; - - $stmt = $this->pdo->prepare($sql); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - } - - if (false !== $this->dsn) { - $this->pdo = null; // only close lazy-connection - } - - return true; - } - - /** - * Lazy-connects to the database. - * - * @param string $dsn DSN string - */ - private function connect($dsn) - { - $this->pdo = new \PDO($dsn, $this->username, $this->password, $this->connectionOptions); - $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - } - - /** - * Helper method to begin a transaction. - * - * Since SQLite does not support row level locks, we have to acquire a reserved lock - * on the database immediately. Because of https://bugs.php.net/42766 we have to create - * such a transaction manually which also means we cannot use PDO::commit or - * PDO::rollback or PDO::inTransaction for SQLite. - * - * Also MySQLs default isolation, REPEATABLE READ, causes deadlock for different sessions - * due to http://www.mysqlperformanceblog.com/2013/12/12/one-more-innodb-gap-lock-to-avoid/ . - * So we change it to READ COMMITTED. - */ - private function beginTransaction() - { - if (!$this->inTransaction) { - if ('sqlite' === $this->driver) { - $this->pdo->exec('BEGIN IMMEDIATE TRANSACTION'); - } else { - if ('mysql' === $this->driver) { - $this->pdo->exec('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); - } - $this->pdo->beginTransaction(); - } - $this->inTransaction = true; - } - } - - /** - * Helper method to commit a transaction. - */ - private function commit() - { - if ($this->inTransaction) { - try { - // commit read-write transaction which also releases the lock - if ('sqlite' === $this->driver) { - $this->pdo->exec('COMMIT'); - } else { - $this->pdo->commit(); - } - $this->inTransaction = false; - } catch (\PDOException $e) { - $this->rollback(); - - throw $e; - } - } - } - - /** - * Helper method to rollback a transaction. - */ - private function rollback() - { - // We only need to rollback if we are in a transaction. Otherwise the resulting - // error would hide the real problem why rollback was called. We might not be - // in a transaction when not using the transactional locking behavior or when - // two callbacks (e.g. destroy and write) are invoked that both fail. - if ($this->inTransaction) { - if ('sqlite' === $this->driver) { - $this->pdo->exec('ROLLBACK'); - } else { - $this->pdo->rollBack(); - } - $this->inTransaction = false; - } - } - - /** - * Reads the session data in respect to the different locking strategies. - * - * We need to make sure we do not return session data that is already considered garbage according - * to the session.gc_maxlifetime setting because gc() is called after read() and only sometimes. - * - * @param string $sessionId Session ID - * - * @return string The session data - */ - private function doRead($sessionId) - { - $this->sessionExpired = false; - - if (self::LOCK_ADVISORY === $this->lockMode) { - $this->unlockStatements[] = $this->doAdvisoryLock($sessionId); - } - - $selectSql = $this->getSelectSql(); - $selectStmt = $this->pdo->prepare($selectSql); - $selectStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $selectStmt->execute(); - - $sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM); - - if ($sessionRows) { - if ($sessionRows[0][1] + $sessionRows[0][2] < time()) { - $this->sessionExpired = true; - - return ''; - } - - return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0]; - } - - if (self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) { - // Exclusive-reading of non-existent rows does not block, so we need to do an insert to block - // until other connections to the session are committed. - try { - $insertStmt = $this->pdo->prepare( - "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)" - ); - $insertStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $insertStmt->bindValue(':data', '', \PDO::PARAM_LOB); - $insertStmt->bindValue(':lifetime', 0, \PDO::PARAM_INT); - $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); - $insertStmt->execute(); - } catch (\PDOException $e) { - // Catch duplicate key error because other connection created the session already. - // It would only not be the case when the other connection destroyed the session. - if (0 === strpos($e->getCode(), '23')) { - // Retrieve finished session data written by concurrent connection. SELECT - // FOR UPDATE is necessary to avoid deadlock of connection that starts reading - // before we write (transform intention to real lock). - $selectStmt->execute(); - $sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM); - - if ($sessionRows) { - return is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0]; - } - - return ''; - } - - throw $e; - } - } - - return ''; - } - - /** - * Executes an application-level lock on the database. - * - * @param string $sessionId Session ID - * - * @return \PDOStatement The statement that needs to be executed later to release the lock - * - * @throws \DomainException When an unsupported PDO driver is used - * - * @todo implement missing advisory locks - * - for oci using DBMS_LOCK.REQUEST - * - for sqlsrv using sp_getapplock with LockOwner = Session - */ - private function doAdvisoryLock($sessionId) - { - switch ($this->driver) { - case 'mysql': - // should we handle the return value? 0 on timeout, null on error - // we use a timeout of 50 seconds which is also the default for innodb_lock_wait_timeout - $stmt = $this->pdo->prepare('SELECT GET_LOCK(:key, 50)'); - $stmt->bindValue(':key', $sessionId, \PDO::PARAM_STR); - $stmt->execute(); - - $releaseStmt = $this->pdo->prepare('DO RELEASE_LOCK(:key)'); - $releaseStmt->bindValue(':key', $sessionId, \PDO::PARAM_STR); - - return $releaseStmt; - case 'pgsql': - // Obtaining an exclusive session level advisory lock requires an integer key. - // So we convert the HEX representation of the session id to an integer. - // Since integers are signed, we have to skip one hex char to fit in the range. - if (4 === PHP_INT_SIZE) { - $sessionInt1 = hexdec(substr($sessionId, 0, 7)); - $sessionInt2 = hexdec(substr($sessionId, 7, 7)); - - $stmt = $this->pdo->prepare('SELECT pg_advisory_lock(:key1, :key2)'); - $stmt->bindValue(':key1', $sessionInt1, \PDO::PARAM_INT); - $stmt->bindValue(':key2', $sessionInt2, \PDO::PARAM_INT); - $stmt->execute(); - - $releaseStmt = $this->pdo->prepare('SELECT pg_advisory_unlock(:key1, :key2)'); - $releaseStmt->bindValue(':key1', $sessionInt1, \PDO::PARAM_INT); - $releaseStmt->bindValue(':key2', $sessionInt2, \PDO::PARAM_INT); - } else { - $sessionBigInt = hexdec(substr($sessionId, 0, 15)); - - $stmt = $this->pdo->prepare('SELECT pg_advisory_lock(:key)'); - $stmt->bindValue(':key', $sessionBigInt, \PDO::PARAM_INT); - $stmt->execute(); - - $releaseStmt = $this->pdo->prepare('SELECT pg_advisory_unlock(:key)'); - $releaseStmt->bindValue(':key', $sessionBigInt, \PDO::PARAM_INT); - } - - return $releaseStmt; - case 'sqlite': - throw new \DomainException('SQLite does not support advisory locks.'); - default: - throw new \DomainException(sprintf('Advisory locks are currently not implemented for PDO driver "%s".', $this->driver)); - } - } - - /** - * Return a locking or nonlocking SQL query to read session information. - * - * @return string The SQL string - * - * @throws \DomainException When an unsupported PDO driver is used - */ - private function getSelectSql() - { - if (self::LOCK_TRANSACTIONAL === $this->lockMode) { - $this->beginTransaction(); - - switch ($this->driver) { - case 'mysql': - case 'oci': - case 'pgsql': - return "SELECT $this->dataCol, $this->lifetimeCol, $this->timeCol FROM $this->table WHERE $this->idCol = :id FOR UPDATE"; - case 'sqlsrv': - return "SELECT $this->dataCol, $this->lifetimeCol, $this->timeCol FROM $this->table WITH (UPDLOCK, ROWLOCK) WHERE $this->idCol = :id"; - case 'sqlite': - // we already locked when starting transaction - break; - default: - throw new \DomainException(sprintf('Transactional locks are currently not implemented for PDO driver "%s".', $this->driver)); - } - } - - return "SELECT $this->dataCol, $this->lifetimeCol, $this->timeCol FROM $this->table WHERE $this->idCol = :id"; - } - - /** - * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database for writing session data. - * - * @return string|null The SQL string or null when not supported - */ - private function getMergeSql() - { - switch ($this->driver) { - case 'mysql': - return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". - "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)"; - case 'oci': - // DUAL is Oracle specific dummy table - return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time"; - case 'sqlsrv' === $this->driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): - // MERGE is only available since SQL Server 2008 and must be terminated by semicolon - // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx - return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time;"; - case 'sqlite': - return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; - } - } - - /** - * Return a PDO instance. - * - * @return \PDO - */ - protected function getConnection() - { - if (null === $this->pdo) { - $this->connect($this->dsn ?: ini_get('session.save_path')); - } - - return $this->pdo; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php deleted file mode 100644 index d49c36cae..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Wraps another SessionHandlerInterface to only write the session when it has been modified. - * - * @author Adrien Brault - */ -class WriteCheckSessionHandler implements \SessionHandlerInterface -{ - /** - * @var \SessionHandlerInterface - */ - private $wrappedSessionHandler; - - /** - * @var array sessionId => session - */ - private $readSessions; - - public function __construct(\SessionHandlerInterface $wrappedSessionHandler) - { - $this->wrappedSessionHandler = $wrappedSessionHandler; - } - - /** - * {@inheritdoc} - */ - public function close() - { - return $this->wrappedSessionHandler->close(); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return $this->wrappedSessionHandler->destroy($sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - return $this->wrappedSessionHandler->gc($maxlifetime); - } - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - return $this->wrappedSessionHandler->open($savePath, $sessionName); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - $session = $this->wrappedSessionHandler->read($sessionId); - - $this->readSessions[$sessionId] = $session; - - return $session; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) { - return true; - } - - return $this->wrappedSessionHandler->write($sessionId, $data); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php deleted file mode 100644 index ec7b26799..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * Metadata container. - * - * Adds metadata to the session. - * - * @author Drak - */ -class MetadataBag implements SessionBagInterface -{ - const CREATED = 'c'; - const UPDATED = 'u'; - const LIFETIME = 'l'; - - /** - * @var string - */ - private $name = '__metadata'; - - /** - * @var string - */ - private $storageKey; - - /** - * @var array - */ - protected $meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0); - - /** - * Unix timestamp. - * - * @var int - */ - private $lastUsed; - - /** - * @var int - */ - private $updateThreshold; - - /** - * Constructor. - * - * @param string $storageKey The key used to store bag in the session. - * @param int $updateThreshold The time to wait between two UPDATED updates - */ - public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0) - { - $this->storageKey = $storageKey; - $this->updateThreshold = $updateThreshold; - } - - /** - * {@inheritdoc} - */ - public function initialize(array &$array) - { - $this->meta = &$array; - - if (isset($array[self::CREATED])) { - $this->lastUsed = $this->meta[self::UPDATED]; - - $timeStamp = time(); - if ($timeStamp - $array[self::UPDATED] >= $this->updateThreshold) { - $this->meta[self::UPDATED] = $timeStamp; - } - } else { - $this->stampCreated(); - } - } - - /** - * Gets the lifetime that the session cookie was set with. - * - * @return int - */ - public function getLifetime() - { - return $this->meta[self::LIFETIME]; - } - - /** - * Stamps a new session's metadata. - * - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - */ - public function stampNew($lifetime = null) - { - $this->stampCreated($lifetime); - } - - /** - * {@inheritdoc} - */ - public function getStorageKey() - { - return $this->storageKey; - } - - /** - * Gets the created timestamp metadata. - * - * @return int Unix timestamp - */ - public function getCreated() - { - return $this->meta[self::CREATED]; - } - - /** - * Gets the last used metadata. - * - * @return int Unix timestamp - */ - public function getLastUsed() - { - return $this->lastUsed; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // nothing to do - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * Sets name. - * - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - private function stampCreated($lifetime = null) - { - $timeStamp = time(); - $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp; - $this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php deleted file mode 100644 index bc1373755..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php +++ /dev/null @@ -1,268 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * MockArraySessionStorage mocks the session for unit tests. - * - * No PHP session is actually started since a session can be initialized - * and shutdown only once per PHP execution cycle. - * - * When doing functional testing, you should use MockFileSessionStorage instead. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - * @author Drak - */ -class MockArraySessionStorage implements SessionStorageInterface -{ - /** - * @var string - */ - protected $id = ''; - - /** - * @var string - */ - protected $name; - - /** - * @var bool - */ - protected $started = false; - - /** - * @var bool - */ - protected $closed = false; - - /** - * @var array - */ - protected $data = array(); - - /** - * @var MetadataBag - */ - protected $metadataBag; - - /** - * @var array - */ - protected $bags; - - /** - * Constructor. - * - * @param string $name Session name - * @param MetadataBag $metaBag MetadataBag instance. - */ - public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null) - { - $this->name = $name; - $this->setMetadataBag($metaBag); - } - - /** - * Sets the session data. - * - * @param array $array - */ - public function setSessionData(array $array) - { - $this->data = $array; - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - if (empty($this->id)) { - $this->id = $this->generateId(); - } - - $this->loadSession(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (!$this->started) { - $this->start(); - } - - $this->metadataBag->stampNew($lifetime); - $this->id = $this->generateId(); - - return true; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - if ($this->started) { - throw new \LogicException('Cannot set session ID after the session has started.'); - } - - $this->id = $id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function save() - { - if (!$this->started || $this->closed) { - throw new \RuntimeException('Trying to save a session that was not started yet or was already closed'); - } - // nothing to do since we don't persist the session data - $this->closed = false; - $this->started = false; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // clear out the session - $this->data = array(); - - // reconnect the bags to the session - $this->loadSession(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->bags[$bag->getName()] = $bag; - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); - } - - if (!$this->started) { - $this->start(); - } - - return $this->bags[$name]; - } - - /** - * {@inheritdoc} - */ - public function isStarted() - { - return $this->started; - } - - /** - * Sets the MetadataBag. - * - * @param MetadataBag $bag - */ - public function setMetadataBag(MetadataBag $bag = null) - { - if (null === $bag) { - $bag = new MetadataBag(); - } - - $this->metadataBag = $bag; - } - - /** - * Gets the MetadataBag. - * - * @return MetadataBag - */ - public function getMetadataBag() - { - return $this->metadataBag; - } - - /** - * Generates a session ID. - * - * This doesn't need to be particularly cryptographically secure since this is just - * a mock. - * - * @return string - */ - protected function generateId() - { - return hash('sha256', uniqid('ss_mock_', true)); - } - - protected function loadSession() - { - $bags = array_merge($this->bags, array($this->metadataBag)); - - foreach ($bags as $bag) { - $key = $bag->getStorageKey(); - $this->data[$key] = isset($this->data[$key]) ? $this->data[$key] : array(); - $bag->initialize($this->data[$key]); - } - - $this->started = true; - $this->closed = false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php deleted file mode 100644 index 1f4117b74..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -/** - * MockFileSessionStorage is used to mock sessions for - * functional testing when done in a single PHP process. - * - * No PHP session is actually started since a session can be initialized - * and shutdown only once per PHP execution cycle and this class does - * not pollute any session related globals, including session_*() functions - * or session.* PHP ini directives. - * - * @author Drak - */ -class MockFileSessionStorage extends MockArraySessionStorage -{ - /** - * @var string - */ - private $savePath; - - /** - * Constructor. - * - * @param string $savePath Path of directory to save session files. - * @param string $name Session name. - * @param MetadataBag $metaBag MetadataBag instance. - */ - public function __construct($savePath = null, $name = 'MOCKSESSID', MetadataBag $metaBag = null) - { - if (null === $savePath) { - $savePath = sys_get_temp_dir(); - } - - if (!is_dir($savePath)) { - mkdir($savePath, 0777, true); - } - - $this->savePath = $savePath; - - parent::__construct($name, $metaBag); - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - if (!$this->id) { - $this->id = $this->generateId(); - } - - $this->read(); - - $this->started = true; - - return true; - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (!$this->started) { - $this->start(); - } - - if ($destroy) { - $this->destroy(); - } - - return parent::regenerate($destroy, $lifetime); - } - - /** - * {@inheritdoc} - */ - public function save() - { - if (!$this->started) { - throw new \RuntimeException('Trying to save a session that was not started yet or was already closed'); - } - - file_put_contents($this->getFilePath(), serialize($this->data)); - - // this is needed for Silex, where the session object is re-used across requests - // in functional tests. In Symfony, the container is rebooted, so we don't have - // this issue - $this->started = false; - } - - /** - * Deletes a session from persistent storage. - * Deliberately leaves session data in memory intact. - */ - private function destroy() - { - if (is_file($this->getFilePath())) { - unlink($this->getFilePath()); - } - } - - /** - * Calculate path to file. - * - * @return string File path - */ - private function getFilePath() - { - return $this->savePath.'/'.$this->id.'.mocksess'; - } - - /** - * Reads session from storage and loads session. - */ - private function read() - { - $filePath = $this->getFilePath(); - $this->data = is_readable($filePath) && is_file($filePath) ? unserialize(file_get_contents($filePath)) : array(); - - $this->loadSession(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php deleted file mode 100644 index db705db87..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ /dev/null @@ -1,420 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * This provides a base class for session attribute storage. - * - * @author Drak - */ -class NativeSessionStorage implements SessionStorageInterface -{ - /** - * Array of SessionBagInterface. - * - * @var SessionBagInterface[] - */ - protected $bags; - - /** - * @var bool - */ - protected $started = false; - - /** - * @var bool - */ - protected $closed = false; - - /** - * @var AbstractProxy - */ - protected $saveHandler; - - /** - * @var MetadataBag - */ - protected $metadataBag; - - /** - * Constructor. - * - * Depending on how you want the storage driver to behave you probably - * want to override this constructor entirely. - * - * List of options for $options array with their defaults. - * - * @see http://php.net/session.configuration for options - * but we omit 'session.' from the beginning of the keys for convenience. - * - * ("auto_start", is not supported as it tells PHP to start a session before - * PHP starts to execute user-land code. Setting during runtime has no effect). - * - * cache_limiter, "nocache" (use "0" to prevent headers from being sent entirely). - * cookie_domain, "" - * cookie_httponly, "" - * cookie_lifetime, "0" - * cookie_path, "/" - * cookie_secure, "" - * entropy_file, "" - * entropy_length, "0" - * gc_divisor, "100" - * gc_maxlifetime, "1440" - * gc_probability, "1" - * hash_bits_per_character, "4" - * hash_function, "0" - * name, "PHPSESSID" - * referer_check, "" - * serialize_handler, "php" - * use_cookies, "1" - * use_only_cookies, "1" - * use_trans_sid, "0" - * upload_progress.enabled, "1" - * upload_progress.cleanup, "1" - * upload_progress.prefix, "upload_progress_" - * upload_progress.name, "PHP_SESSION_UPLOAD_PROGRESS" - * upload_progress.freq, "1%" - * upload_progress.min-freq, "1" - * url_rewriter.tags, "a=href,area=href,frame=src,form=,fieldset=" - * - * @param array $options Session configuration options. - * @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler - * @param MetadataBag $metaBag MetadataBag. - */ - public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null) - { - session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used) - ini_set('session.use_cookies', 1); - - if (PHP_VERSION_ID >= 50400) { - session_register_shutdown(); - } else { - register_shutdown_function('session_write_close'); - } - - $this->setMetadataBag($metaBag); - $this->setOptions($options); - $this->setSaveHandler($handler); - } - - /** - * Gets the save handler instance. - * - * @return AbstractProxy - */ - public function getSaveHandler() - { - return $this->saveHandler; - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) { - throw new \RuntimeException('Failed to start the session: already started by PHP.'); - } - - if (PHP_VERSION_ID < 50400 && !$this->closed && isset($_SESSION) && session_id()) { - // not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3 - throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).'); - } - - if (ini_get('session.use_cookies') && headers_sent($file, $line)) { - throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line)); - } - - // ok to try and start the session - if (!session_start()) { - throw new \RuntimeException('Failed to start the session'); - } - - $this->loadSession(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 with internal save handlers - $this->saveHandler->setActive(true); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->saveHandler->getId(); - } - - /** - * {@inheritdoc} - */ - public function setId($id) - { - $this->saveHandler->setId($id); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->saveHandler->getName(); - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->saveHandler->setName($name); - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) - { - if (null !== $lifetime) { - ini_set('session.cookie_lifetime', $lifetime); - } - - if ($destroy) { - $this->metadataBag->stampNew(); - } - - $isRegenerated = session_regenerate_id($destroy); - - // The reference to $_SESSION in session bags is lost in PHP7 and we need to re-create it. - // @see https://bugs.php.net/bug.php?id=70013 - $this->loadSession(); - - return $isRegenerated; - } - - /** - * {@inheritdoc} - */ - public function save() - { - session_write_close(); - - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 with internal save handlers - $this->saveHandler->setActive(false); - } - - $this->closed = true; - $this->started = false; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // clear out the session - $_SESSION = array(); - - // reconnect the bags to the session - $this->loadSession(); - } - - /** - * {@inheritdoc} - */ - public function registerBag(SessionBagInterface $bag) - { - $this->bags[$bag->getName()] = $bag; - } - - /** - * {@inheritdoc} - */ - public function getBag($name) - { - if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); - } - - if ($this->saveHandler->isActive() && !$this->started) { - $this->loadSession(); - } elseif (!$this->started) { - $this->start(); - } - - return $this->bags[$name]; - } - - /** - * Sets the MetadataBag. - * - * @param MetadataBag $metaBag - */ - public function setMetadataBag(MetadataBag $metaBag = null) - { - if (null === $metaBag) { - $metaBag = new MetadataBag(); - } - - $this->metadataBag = $metaBag; - } - - /** - * Gets the MetadataBag. - * - * @return MetadataBag - */ - public function getMetadataBag() - { - return $this->metadataBag; - } - - /** - * {@inheritdoc} - */ - public function isStarted() - { - return $this->started; - } - - /** - * Sets session.* ini variables. - * - * For convenience we omit 'session.' from the beginning of the keys. - * Explicitly ignores other ini keys. - * - * @param array $options Session ini directives array(key => value). - * - * @see http://php.net/session.configuration - */ - public function setOptions(array $options) - { - $validOptions = array_flip(array( - 'cache_limiter', 'cookie_domain', 'cookie_httponly', - 'cookie_lifetime', 'cookie_path', 'cookie_secure', - 'entropy_file', 'entropy_length', 'gc_divisor', - 'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character', - 'hash_function', 'name', 'referer_check', - 'serialize_handler', 'use_cookies', - 'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled', - 'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name', - 'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags', - )); - - foreach ($options as $key => $value) { - if (isset($validOptions[$key])) { - ini_set('session.'.$key, $value); - } - } - } - - /** - * Registers session save handler as a PHP session handler. - * - * To use internal PHP session save handlers, override this method using ini_set with - * session.save_handler and session.save_path e.g. - * - * ini_set('session.save_handler', 'files'); - * ini_set('session.save_path', /tmp'); - * - * or pass in a NativeSessionHandler instance which configures session.save_handler in the - * constructor, for a template see NativeFileSessionHandler or use handlers in - * composer package drak/native-session - * - * @see http://php.net/session-set-save-handler - * @see http://php.net/sessionhandlerinterface - * @see http://php.net/sessionhandler - * @see http://github.com/drak/NativeSession - * - * @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $saveHandler - * - * @throws \InvalidArgumentException - */ - public function setSaveHandler($saveHandler = null) - { - if (!$saveHandler instanceof AbstractProxy && - !$saveHandler instanceof NativeSessionHandler && - !$saveHandler instanceof \SessionHandlerInterface && - null !== $saveHandler) { - throw new \InvalidArgumentException('Must be instance of AbstractProxy or NativeSessionHandler; implement \SessionHandlerInterface; or be null.'); - } - - // Wrap $saveHandler in proxy and prevent double wrapping of proxy - if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { - $saveHandler = new SessionHandlerProxy($saveHandler); - } elseif (!$saveHandler instanceof AbstractProxy) { - $saveHandler = PHP_VERSION_ID >= 50400 ? - new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy(); - } - $this->saveHandler = $saveHandler; - - if ($this->saveHandler instanceof \SessionHandlerInterface) { - if (PHP_VERSION_ID >= 50400) { - session_set_save_handler($this->saveHandler, false); - } else { - session_set_save_handler( - array($this->saveHandler, 'open'), - array($this->saveHandler, 'close'), - array($this->saveHandler, 'read'), - array($this->saveHandler, 'write'), - array($this->saveHandler, 'destroy'), - array($this->saveHandler, 'gc') - ); - } - } - } - - /** - * Load the session with attributes. - * - * After starting the session, PHP retrieves the session from whatever handlers - * are set to (either PHP's internal, or a custom save handler set with session_set_save_handler()). - * PHP takes the return value from the read() handler, unserializes it - * and populates $_SESSION with the result automatically. - * - * @param array|null $session - */ - protected function loadSession(array &$session = null) - { - if (null === $session) { - $session = &$_SESSION; - } - - $bags = array_merge($this->bags, array($this->metadataBag)); - - foreach ($bags as $bag) { - $key = $bag->getStorageKey(); - $session[$key] = isset($session[$key]) ? $session[$key] : array(); - $bag->initialize($session[$key]); - } - - $this->started = true; - $this->closed = false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php deleted file mode 100644 index ced706f72..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; - -/** - * Allows session to be started by PHP and managed by Symfony. - * - * @author Drak - */ -class PhpBridgeSessionStorage extends NativeSessionStorage -{ - /** - * Constructor. - * - * @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler - * @param MetadataBag $metaBag MetadataBag - */ - public function __construct($handler = null, MetadataBag $metaBag = null) - { - $this->setMetadataBag($metaBag); - $this->setSaveHandler($handler); - } - - /** - * {@inheritdoc} - */ - public function start() - { - if ($this->started) { - return true; - } - - $this->loadSession(); - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - // This condition matches only PHP 5.3 + internal save handlers - $this->saveHandler->setActive(true); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // clear out the bags and nothing else that may be set - // since the purpose of this driver is to share a handler - foreach ($this->bags as $bag) { - $bag->clear(); - } - - // reconnect the bags to the session - $this->loadSession(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php deleted file mode 100644 index 103681827..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; - -/** - * AbstractProxy. - * - * @author Drak - */ -abstract class AbstractProxy -{ - /** - * Flag if handler wraps an internal PHP session handler (using \SessionHandler). - * - * @var bool - */ - protected $wrapper = false; - - /** - * @var bool - */ - protected $active = false; - - /** - * @var string - */ - protected $saveHandlerName; - - /** - * Gets the session.save_handler name. - * - * @return string - */ - public function getSaveHandlerName() - { - return $this->saveHandlerName; - } - - /** - * Is this proxy handler and instance of \SessionHandlerInterface. - * - * @return bool - */ - public function isSessionHandlerInterface() - { - return ($this instanceof \SessionHandlerInterface); - } - - /** - * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. - * - * @return bool - */ - public function isWrapper() - { - return $this->wrapper; - } - - /** - * Has a session started? - * - * @return bool - */ - public function isActive() - { - if (PHP_VERSION_ID >= 50400) { - return $this->active = \PHP_SESSION_ACTIVE === session_status(); - } - - return $this->active; - } - - /** - * Sets the active flag. - * - * Has no effect under PHP 5.4+ as status is detected - * automatically in isActive() - * - * @internal - * - * @param bool $flag - * - * @throws \LogicException - */ - public function setActive($flag) - { - if (PHP_VERSION_ID >= 50400) { - throw new \LogicException('This method is disabled in PHP 5.4.0+'); - } - - $this->active = (bool) $flag; - } - - /** - * Gets the session ID. - * - * @return string - */ - public function getId() - { - return session_id(); - } - - /** - * Sets the session ID. - * - * @param string $id - * - * @throws \LogicException - */ - public function setId($id) - { - if ($this->isActive()) { - throw new \LogicException('Cannot change the ID of an active session'); - } - - session_id($id); - } - - /** - * Gets the session name. - * - * @return string - */ - public function getName() - { - return session_name(); - } - - /** - * Sets the session name. - * - * @param string $name - * - * @throws \LogicException - */ - public function setName($name) - { - if ($this->isActive()) { - throw new \LogicException('Cannot change the name of an active session'); - } - - session_name($name); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php deleted file mode 100644 index 5bb2c712e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; - -/** - * NativeProxy. - * - * This proxy is built-in session handlers in PHP 5.3.x - * - * @author Drak - */ -class NativeProxy extends AbstractProxy -{ - /** - * Constructor. - */ - public function __construct() - { - // this makes an educated guess as to what the handler is since it should already be set. - $this->saveHandlerName = ini_get('session.save_handler'); - } - - /** - * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler. - * - * @return bool False. - */ - public function isWrapper() - { - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php deleted file mode 100644 index 81643c74b..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy; - -/** - * SessionHandler proxy. - * - * @author Drak - */ -class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterface -{ - /** - * @var \SessionHandlerInterface - */ - protected $handler; - - /** - * Constructor. - * - * @param \SessionHandlerInterface $handler - */ - public function __construct(\SessionHandlerInterface $handler) - { - $this->handler = $handler; - $this->wrapper = ($handler instanceof \SessionHandler); - $this->saveHandlerName = $this->wrapper ? ini_get('session.save_handler') : 'user'; - } - - // \SessionHandlerInterface - - /** - * {@inheritdoc} - */ - public function open($savePath, $sessionName) - { - $return = (bool) $this->handler->open($savePath, $sessionName); - - if (true === $return) { - $this->active = true; - } - - return $return; - } - - /** - * {@inheritdoc} - */ - public function close() - { - $this->active = false; - - return (bool) $this->handler->close(); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - return (string) $this->handler->read($sessionId); - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - return (bool) $this->handler->write($sessionId, $data); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - return (bool) $this->handler->destroy($sessionId); - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - return (bool) $this->handler->gc($maxlifetime); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php deleted file mode 100644 index 5dd309cad..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; - -/** - * StorageInterface. - * - * @author Fabien Potencier - * @author Drak - * - * @api - */ -interface SessionStorageInterface -{ - /** - * Starts the session. - * - * @throws \RuntimeException If something goes wrong starting the session. - * - * @return bool True if started. - * - * @api - */ - public function start(); - - /** - * Checks if the session is started. - * - * @return bool True if started, false otherwise. - */ - public function isStarted(); - - /** - * Returns the session ID. - * - * @return string The session ID or empty. - * - * @api - */ - public function getId(); - - /** - * Sets the session ID. - * - * @param string $id - * - * @api - */ - public function setId($id); - - /** - * Returns the session name. - * - * @return mixed The session name. - * - * @api - */ - public function getName(); - - /** - * Sets the session name. - * - * @param string $name - * - * @api - */ - public function setName($name); - - /** - * Regenerates id that represents this storage. - * - * This method must invoke session_regenerate_id($destroy) unless - * this interface is used for a storage object designed for unit - * or functional testing where a real PHP session would interfere - * with testing. - * - * Note regenerate+destroy should not clear the session data in memory - * only delete the session data from persistent storage. - * - * Care: When regenerating the session ID no locking is involved in PHPs - * session design. See https://bugs.php.net/bug.php?id=61470 for a discussion. - * So you must make sure the regenerated session is saved BEFORE sending the - * headers with the new ID. Symfonys HttpKernel offers a listener for this. - * See Symfony\Component\HttpKernel\EventListener\SaveSessionListener. - * Otherwise session data could get lost again for concurrent requests with the - * new ID. One result could be that you get logged out after just logging in. - * - * @param bool $destroy Destroy session when regenerating? - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value - * will leave the system settings unchanged, 0 sets the cookie - * to expire with browser session. Time is in seconds, and is - * not a Unix timestamp. - * - * @return bool True if session regenerated, false if error - * - * @throws \RuntimeException If an error occurs while regenerating this storage - * - * @api - */ - public function regenerate($destroy = false, $lifetime = null); - - /** - * Force the session to be saved and closed. - * - * This method must invoke session_write_close() unless this interface is - * used for a storage object design for unit or functional testing where - * a real PHP session would interfere with testing, in which case it - * it should actually persist the session data if required. - * - * @throws \RuntimeException If the session is saved without being started, or if the session - * is already closed. - */ - public function save(); - - /** - * Clear all session data in memory. - */ - public function clear(); - - /** - * Gets a SessionBagInterface by name. - * - * @param string $name - * - * @return SessionBagInterface - * - * @throws \InvalidArgumentException If the bag does not exist - */ - public function getBag($name); - - /** - * Registers a SessionBagInterface for use. - * - * @param SessionBagInterface $bag - */ - public function registerBag(SessionBagInterface $bag); - - /** - * @return MetadataBag - */ - public function getMetadataBag(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php deleted file mode 100644 index 38986e8aa..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -/** - * StreamedResponse represents a streamed HTTP response. - * - * A StreamedResponse uses a callback for its content. - * - * The callback should use the standard PHP functions like echo - * to stream the response back to the client. The flush() method - * can also be used if needed. - * - * @see flush() - * - * @author Fabien Potencier - * - * @api - */ -class StreamedResponse extends Response -{ - protected $callback; - protected $streamed; - - /** - * Constructor. - * - * @param callable|null $callback A valid PHP callback or null to set it later - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @api - */ - public function __construct($callback = null, $status = 200, $headers = array()) - { - parent::__construct(null, $status, $headers); - - if (null !== $callback) { - $this->setCallback($callback); - } - $this->streamed = false; - } - - /** - * Factory method for chainability - * - * @param callable|null $callback A valid PHP callback or null to set it later - * @param int $status The response status code - * @param array $headers An array of response headers - * - * @return StreamedResponse - */ - public static function create($callback = null, $status = 200, $headers = array()) - { - return new static($callback, $status, $headers); - } - - /** - * Sets the PHP callback associated with this Response. - * - * @param callable $callback A valid PHP callback - * - * @throws \LogicException - */ - public function setCallback($callback) - { - if (!is_callable($callback)) { - throw new \LogicException('The Response callback must be a valid PHP callable.'); - } - $this->callback = $callback; - } - - /** - * {@inheritdoc} - * - * This method only sends the content once. - */ - public function sendContent() - { - if ($this->streamed) { - return; - } - - $this->streamed = true; - - if (null === $this->callback) { - throw new \LogicException('The Response callback must not be null.'); - } - - call_user_func($this->callback); - } - - /** - * {@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 StreamedResponse instance.'); - } - } - - /** - * {@inheritdoc} - * - * @return false - */ - public function getContent() - { - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php deleted file mode 100644 index e4f354fc1..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * 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/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php deleted file mode 100644 index 9b3b58e21..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/AcceptHeaderTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * 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/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php deleted file mode 100644 index 6845118cc..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * 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\ApacheRequest; - -class ApacheRequestTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider provideServerVars - */ - public function testUriMethods($server, $expectedRequestUri, $expectedBaseUrl, $expectedPathInfo) - { - $request = new ApacheRequest(); - $request->server->replace($server); - - $this->assertEquals($expectedRequestUri, $request->getRequestUri(), '->getRequestUri() is correct'); - $this->assertEquals($expectedBaseUrl, $request->getBaseUrl(), '->getBaseUrl() is correct'); - $this->assertEquals($expectedPathInfo, $request->getPathInfo(), '->getPathInfo() is correct'); - } - - public function provideServerVars() - { - return array( - array( - array( - 'REQUEST_URI' => '/foo/app_dev.php/bar', - 'SCRIPT_NAME' => '/foo/app_dev.php', - 'PATH_INFO' => '/bar', - ), - '/foo/app_dev.php/bar', - '/foo/app_dev.php', - '/bar', - ), - array( - array( - 'REQUEST_URI' => '/foo/bar', - 'SCRIPT_NAME' => '/foo/app_dev.php', - ), - '/foo/bar', - '/foo', - '/bar', - ), - array( - array( - 'REQUEST_URI' => '/app_dev.php/foo/bar', - 'SCRIPT_NAME' => '/app_dev.php', - 'PATH_INFO' => '/foo/bar', - ), - '/app_dev.php/foo/bar', - '/app_dev.php', - '/foo/bar', - ), - array( - array( - 'REQUEST_URI' => '/foo/bar', - 'SCRIPT_NAME' => '/app_dev.php', - ), - '/foo/bar', - '', - '/foo/bar', - ), - array( - array( - 'REQUEST_URI' => '/app_dev.php', - 'SCRIPT_NAME' => '/app_dev.php', - ), - '/app_dev.php', - '/app_dev.php', - '/', - ), - array( - array( - 'REQUEST_URI' => '/', - 'SCRIPT_NAME' => '/app_dev.php', - ), - '/', - '', - '/', - ), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php deleted file mode 100644 index 47e4d4fed..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ /dev/null @@ -1,250 +0,0 @@ - - * - * 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; -use Symfony\Component\HttpFoundation\Tests\File\FakeFile; - -class BinaryFileResponseTest extends ResponseTestCase -{ - public function testConstruction() - { - $file = __DIR__.'/../README.md'; - $response = new BinaryFileResponse($file, 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($file, 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(__FILE__); - $response->setContent('foo'); - } - - public function testGetContent() - { - $response = new BinaryFileResponse(__FILE__); - $this->assertFalse($response->getContent()); - } - - /** - * @dataProvider provideRanges - */ - public function testRequests($requestRange, $offset, $length, $responseRange) - { - $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', $requestRange); - - $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); - fseek($file, $offset); - $data = fread($file, $length); - fclose($file); - - $this->expectOutputString($data); - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(206, $response->getStatusCode()); - $this->assertEquals($responseRange, $response->headers->get('Content-Range')); - } - - public function provideRanges() - { - return array( - array('bytes=1-4', 1, 4, 'bytes 1-4/35'), - array('bytes=-5', 30, 5, 'bytes 30-34/35'), - array('bytes=30-', 30, 5, 'bytes 30-34/35'), - array('bytes=30-30', 30, 1, 'bytes 30-30/35'), - array('bytes=30-34', 30, 5, 'bytes 30-34/35'), - ); - } - - /** - * @dataProvider provideFullFileRanges - */ - public function testFullFileRequests($requestRange) - { - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag(); - - // prepare a request for a range of the testing file - $request = Request::create('/'); - $request->headers->set('Range', $requestRange); - - $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); - $data = fread($file, 35); - fclose($file); - - $this->expectOutputString($data); - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(200, $response->getStatusCode()); - } - - public function provideFullFileRanges() - { - return array( - array('bytes=0-'), - array('bytes=0-34'), - array('bytes=-35'), - // Syntactical invalid range-request should also return the full resource - array('bytes=20-10'), - array('bytes=50-40'), - ); - } - - /** - * @dataProvider provideInvalidRanges - */ - public function testInvalidRequests($requestRange) - { - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag(); - - // prepare a request for a range of the testing file - $request = Request::create('/'); - $request->headers->set('Range', $requestRange); - - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(416, $response->getStatusCode()); - #$this->assertEquals('', $response->headers->get('Content-Range')); - } - - public function provideInvalidRanges() - { - return array( - array('bytes=-40'), - array('bytes=30-40'), - ); - } - - public function testXSendfile() - { - $request = Request::create('/'); - $request->headers->set('X-Sendfile-Type', 'X-Sendfile'); - - BinaryFileResponse::trustXSendfileTypeHeader(); - $response = BinaryFileResponse::create(__DIR__.'/../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 = new FakeFile($realpath, __DIR__.'/File/Fixtures/test'); - - BinaryFileResponse::trustXSendfileTypeHeader(); - $response = new BinaryFileResponse($file); - $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 testDeleteFileAfterSend() - { - $request = Request::create('/'); - - $path = __DIR__.'/File/Fixtures/to_delete'; - touch($path); - $realPath = realpath($path); - $this->assertFileExists($realPath); - - $response = new BinaryFileResponse($realPath); - $response->deleteFileAfterSend(true); - - $response->prepare($request); - $response->sendContent(); - - $this->assertFileNotExists($path); - } - - public function testAcceptRangeOnUnsafeMethods() - { - $request = Request::create('/', 'POST'); - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif'); - $response->prepare($request); - - $this->assertEquals('none', $response->headers->get('Accept-Ranges')); - } - - public function testAcceptRangeNotOverriden() - { - $request = Request::create('/', 'POST'); - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif'); - $response->headers->set('Accept-Ranges', 'foo'); - $response->prepare($request); - - $this->assertEquals('foo', $response->headers->get('Accept-Ranges')); - } - - public function getSampleXAccelMappings() - { - return array( - array('/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'), - array('/home/foo/bar.txt', '/var/www/=/files/,/home/foo/=/baz/', '/baz/bar.txt'), - ); - } - - protected function provideResponse() - { - return new BinaryFileResponse(__DIR__.'/../README.md'); - } - - public static function tearDownAfterClass() - { - $path = __DIR__.'/../Fixtures/to_delete'; - if (file_exists($path)) { - @unlink($path); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ClockMock.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ClockMock.php deleted file mode 100644 index 04a842d9b..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ClockMock.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation; - -function time($asFloat = false) -{ - return Tests\time(); -} - -namespace Symfony\Component\HttpFoundation\Tests; - -function time() -{ - return $_SERVER['REQUEST_TIME']; -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php deleted file mode 100644 index b8474db15..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ /dev/null @@ -1,147 +0,0 @@ - - * - * 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\Cookie; - -require_once __DIR__.'/ClockMock.php'; - -/** - * CookieTest. - * - * @author John Kary - * @author Hugo Hamon - */ -class CookieTest extends \PHPUnit_Framework_TestCase -{ - public function invalidNames() - { - return array( - array(''), - array(',MyName'), - array(';MyName'), - array(' MyName'), - array("\tMyName"), - array("\rMyName"), - array("\nMyName"), - array("\013MyName"), - array("\014MyName"), - ); - } - - /** - * @dataProvider invalidNames - * @expectedException \InvalidArgumentException - * @covers Symfony\Component\HttpFoundation\Cookie::__construct - */ - public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidCharacters($name) - { - new Cookie($name); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidExpiration() - { - $cookie = new Cookie('MyCookie', 'foo', 'bar'); - } - - /** - * @covers Symfony\Component\HttpFoundation\Cookie::getValue - */ - public function testGetValue() - { - $value = 'MyValue'; - $cookie = new Cookie('MyCookie', $value); - - $this->assertSame($value, $cookie->getValue(), '->getValue() returns the proper value'); - } - - public function testGetPath() - { - $cookie = new Cookie('foo', 'bar'); - - $this->assertSame('/', $cookie->getPath(), '->getPath() returns / as the default path'); - } - - public function testGetExpiresTime() - { - $cookie = new Cookie('foo', 'bar', 3600); - - $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'); - - $this->assertEquals('.myfoodomain.com', $cookie->getDomain(), '->getDomain() returns the domain name on which the cookie is valid'); - } - - public function testIsSecure() - { - $cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', true); - - $this->assertTrue($cookie->isSecure(), '->isSecure() returns whether the cookie is transmitted over HTTPS'); - } - - public function testIsHttpOnly() - { - $cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', false, true); - - $this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns whether the cookie is only transmitted over HTTP'); - } - - public function testCookieIsNotCleared() - { - $cookie = new Cookie('foo', 'bar', time() + 3600 * 24); - - $this->assertFalse($cookie->isCleared(), '->isCleared() returns false if the cookie did not expire yet'); - } - - public function testCookieIsCleared() - { - $cookie = new Cookie('foo', 'bar', time() - 20); - - $this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired'); - } - - public function testToString() - { - $cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true); - $this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly', $cookie->__toString(), '->__toString() returns string representation of the cookie'); - - $cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com'); - $this->assertEquals('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/admin/; domain=.myfoodomain.com; httponly', $cookie->__toString(), '->__toString() returns string representation of a cleared cookie if value is NULL'); - - $cookie = new Cookie('foo', 'bar', 0, '/', ''); - $this->assertEquals('foo=bar; path=/; httponly', $cookie->__toString()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php deleted file mode 100644 index fda372f3f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * 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\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\HttpFoundation\ExpressionRequestMatcher; -use Symfony\Component\HttpFoundation\Request; - -class ExpressionRequestMatcherTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \LogicException - */ - public function testWhenNoExpressionIsSet() - { - $expressionRequestMatcher = new ExpressionRequestMatcher(); - $expressionRequestMatcher->matches(new Request()); - } - - /** - * @dataProvider provideExpressions - */ - public function testMatchesWhenParentMatchesIsTrue($expression, $expected) - { - $request = Request::create('/foo'); - $expressionRequestMatcher = new ExpressionRequestMatcher(); - - $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); - $this->assertSame($expected, $expressionRequestMatcher->matches($request)); - } - - /** - * @dataProvider provideExpressions - */ - public function testMatchesWhenParentMatchesIsFalse($expression) - { - $request = Request::create('/foo'); - $request->attributes->set('foo', 'foo'); - $expressionRequestMatcher = new ExpressionRequestMatcher(); - $expressionRequestMatcher->matchAttribute('foo', 'bar'); - - $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); - $this->assertFalse($expressionRequestMatcher->matches($request)); - } - - public function provideExpressions() - { - return array( - array('request.getMethod() == method', true), - array('request.getPathInfo() == path', true), - array('request.getHost() == host', true), - array('request.getClientIp() == ip', true), - array('request.attributes.all() == attributes', true), - array('request.getMethod() == method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', true), - array('request.getMethod() != method', false), - array('request.getMethod() != method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', false), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php deleted file mode 100644 index c415989f2..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FakeFile.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File; - -use Symfony\Component\HttpFoundation\File\File as OrigFile; - -class FakeFile extends OrigFile -{ - private $realpath; - - public function __construct($realpath, $path) - { - $this->realpath = $realpath; - parent::__construct($path, false); - } - - public function isReadable() - { - return true; - } - - public function getRealpath() - { - return $this->realpath; - } - - public function getSize() - { - return 42; - } - - public function getMTime() - { - return time(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php deleted file mode 100644 index 08b7cccb5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File; - -use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; - -class FileTest extends \PHPUnit_Framework_TestCase -{ - protected $file; - - public function testGetMimeTypeUsesMimeTypeGuessers() - { - $file = new File(__DIR__.'/Fixtures/test.gif'); - $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif'); - - MimeTypeGuesser::getInstance()->register($guesser); - - $this->assertEquals('image/gif', $file->getMimeType()); - } - - public function testGuessExtensionWithoutGuesser() - { - $file = new File(__DIR__.'/Fixtures/directory/.empty'); - - $this->assertNull($file->guessExtension()); - } - - public function testGuessExtensionIsBasedOnMimeType() - { - $file = new File(__DIR__.'/Fixtures/test'); - $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif'); - - MimeTypeGuesser::getInstance()->register($guesser); - - $this->assertEquals('gif', $file->guessExtension()); - } - - public function testGuessExtensionWithReset() - { - $file = new File(__DIR__.'/Fixtures/other-file.example'); - $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif'); - MimeTypeGuesser::getInstance()->register($guesser); - - $this->assertEquals('gif', $file->guessExtension()); - - MimeTypeGuesser::reset(); - - $this->assertNull($file->guessExtension()); - } - - public function testConstructWhenFileNotExists() - { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - - new File(__DIR__.'/Fixtures/not_here'); - } - - public function testMove() - { - $path = __DIR__.'/Fixtures/test.copy.gif'; - $targetDir = __DIR__.'/Fixtures/directory'; - $targetPath = $targetDir.'/test.copy.gif'; - @unlink($path); - @unlink($targetPath); - copy(__DIR__.'/Fixtures/test.gif', $path); - - $file = new File($path); - $movedFile = $file->move($targetDir); - $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 testMoveWithNewName() - { - $path = __DIR__.'/Fixtures/test.copy.gif'; - $targetDir = __DIR__.'/Fixtures/directory'; - $targetPath = $targetDir.'/test.newname.gif'; - @unlink($path); - @unlink($targetPath); - copy(__DIR__.'/Fixtures/test.gif', $path); - - $file = new File($path); - $movedFile = $file->move($targetDir, 'test.newname.gif'); - - $this->assertTrue(file_exists($targetPath)); - $this->assertFalse(file_exists($path)); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @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'; - $targetDir = __DIR__.'/Fixtures/directory/sub'; - $targetPath = $targetDir.'/test.copy.gif'; - @unlink($sourcePath); - @unlink($targetPath); - @rmdir($targetDir); - copy(__DIR__.'/Fixtures/test.gif', $sourcePath); - - $file = new File($sourcePath); - $movedFile = $file->move($targetDir); - - $this->assertFileExists($targetPath); - $this->assertFileNotExists($sourcePath); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @unlink($sourcePath); - @unlink($targetPath); - @rmdir($targetDir); - } - - public function testGetExtension() - { - $file = new File(__DIR__.'/Fixtures/test.gif'); - $this->assertEquals('gif', $file->getExtension()); - } - - protected function createMockGuesser($path, $mimeType) - { - $guesser = $this->getMock('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface'); - $guesser - ->expects($this->once()) - ->method('guess') - ->with($this->equalTo($path)) - ->will($this->returnValue($mimeType)) - ; - - return $guesser; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/directory/.empty b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/directory/.empty deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/other-file.example b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/other-file.example deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/test b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/test deleted file mode 100644 index b636f4b8df536b0a85e7cea1a6cf3f0bd3179b96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35 jcmZ?wbh9u|WMp7uXkcLY4+c66KmZb9U}AD%WUvMRyAlZ1 diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/test.gif b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/Fixtures/test.gif deleted file mode 100644 index b636f4b8df536b0a85e7cea1a6cf3f0bd3179b96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35 jcmZ?wbh9u|WMp7uXkcLY4+c66KmZb9U}AD%WUvMRyAlZ1 diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php deleted file mode 100644 index b2a573e27..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File\MimeType; - -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser; - -class MimeTypeTest extends \PHPUnit_Framework_TestCase -{ - protected $path; - - public function testGuessImageWithoutExtension() - { - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } - } - - public function testGuessImageWithDirectory() - { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - - MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory'); - } - - public function testGuessImageWithFileBinaryMimeTypeGuesser() - { - $guesser = MimeTypeGuesser::getInstance(); - $guesser->register(new FileBinaryMimeTypeGuesser()); - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } - } - - public function testGuessImageWithKnownExtension() - { - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif')); - } - } - - public function testGuessFileWithUnknownExtension() - { - if (extension_loaded('fileinfo')) { - $this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension')); - } else { - $this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension')); - } - } - - public function testGuessWithIncorrectPath() - { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here'); - } - - public function testGuessWithNonReadablePath() - { - if ('\\' === DIRECTORY_SEPARATOR) { - $this->markTestSkipped('Can not verify chmod operations on Windows'); - } - - if ('root' === get_current_user()) { - $this->markTestSkipped('This test will fail if run under superuser'); - } - - $path = __DIR__.'/../Fixtures/to_delete'; - touch($path); - @chmod($path, 0333); - - if (get_current_user() != 'root' && substr(sprintf('%o', fileperms($path)), -4) == '0333') { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException'); - MimeTypeGuesser::getInstance()->guess($path); - } else { - $this->markTestSkipped('Can not verify chmod operations, change of file permissions failed'); - } - } - - public static function tearDownAfterClass() - { - $path = __DIR__.'/../Fixtures/to_delete'; - if (file_exists($path)) { - @chmod($path, 0666); - @unlink($path); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php deleted file mode 100644 index 5b48970d5..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ /dev/null @@ -1,272 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File; - -use Symfony\Component\HttpFoundation\File\UploadedFile; - -class UploadedFileTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - if (!ini_get('file_uploads')) { - $this->markTestSkipped('file_uploads is disabled in php.ini'); - } - } - - public function testConstructWhenFileNotExists() - { - $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - - new UploadedFile( - __DIR__.'/Fixtures/not_here', - 'original.gif', - null - ); - } - - public function testFileUploadsWithNoMimeType() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK - ); - - $this->assertEquals('application/octet-stream', $file->getClientMimeType()); - - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', $file->getMimeType()); - } - } - - public function testFileUploadsWithUnknownMimeType() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/.unknownextension', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/.unknownextension'), - UPLOAD_ERR_OK - ); - - $this->assertEquals('application/octet-stream', $file->getClientMimeType()); - } - - public function testGuessClientExtension() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals('gif', $file->guessClientExtension()); - } - - public function testGuessClientExtensionWithIncorrectMimeType() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/jpeg', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals('jpeg', $file->guessClientExtension()); - } - - public function testErrorIsOkByDefault() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals(UPLOAD_ERR_OK, $file->getError()); - } - - public function testGetClientOriginalName() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $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 - */ - public function testMoveLocalFileIsNotAllowed() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK - ); - - $movedFile = $file->move(__DIR__.'/Fixtures/directory'); - } - - public function testMoveLocalFileIsAllowedInTestMode() - { - $path = __DIR__.'/Fixtures/test.copy.gif'; - $targetDir = __DIR__.'/Fixtures/directory'; - $targetPath = $targetDir.'/test.copy.gif'; - @unlink($path); - @unlink($targetPath); - copy(__DIR__.'/Fixtures/test.gif', $path); - - $file = new UploadedFile( - $path, - 'original.gif', - 'image/gif', - filesize($path), - UPLOAD_ERR_OK, - true - ); - - $movedFile = $file->move(__DIR__.'/Fixtures/directory'); - - $this->assertTrue(file_exists($targetPath)); - $this->assertFalse(file_exists($path)); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @unlink($targetPath); - } - - public function testGetClientOriginalNameSanitizeFilename() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - '../../original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals('original.gif', $file->getClientOriginalName()); - } - - public function testGetSize() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals(filesize(__DIR__.'/Fixtures/test.gif'), $file->getSize()); - - $file = new UploadedFile( - __DIR__.'/Fixtures/test', - 'original.gif', - 'image/gif' - ); - - $this->assertEquals(filesize(__DIR__.'/Fixtures/test'), $file->getSize()); - } - - public function testGetExtension() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null - ); - - $this->assertEquals('gif', $file->getExtension()); - } - - public function testIsValid() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK, - true - ); - - $this->assertTrue($file->isValid()); - } - - /** - * @dataProvider uploadedFileErrorProvider - */ - public function testIsInvalidOnUploadError($error) - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - $error - ); - - $this->assertFalse($file->isValid()); - } - - public function uploadedFileErrorProvider() - { - return array( - array(UPLOAD_ERR_INI_SIZE), - array(UPLOAD_ERR_FORM_SIZE), - array(UPLOAD_ERR_PARTIAL), - array(UPLOAD_ERR_NO_TMP_DIR), - array(UPLOAD_ERR_EXTENSION), - ); - } - - public function testIsInvalidIfNotHttpUpload() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK - ); - - $this->assertFalse($file->isValid()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php deleted file mode 100644 index 738604bcc..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * 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\File\UploadedFile; -use Symfony\Component\HttpFoundation\FileBag; - -/** - * FileBagTest. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - */ -class FileBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \InvalidArgumentException - */ - public function testFileMustBeAnArrayOrUploadedFile() - { - new FileBag(array('file' => 'foo')); - } - - public function testShouldConvertsUploadedFiles() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array('file' => array( - 'name' => basename($tmpFile), - 'type' => 'text/plain', - 'tmp_name' => $tmpFile, - 'error' => 0, - 'size' => 100, - ))); - - $this->assertEquals($file, $bag->get('file')); - } - - public function testShouldSetEmptyUploadedFilesToNull() - { - $bag = new FileBag(array('file' => array( - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => UPLOAD_ERR_NO_FILE, - 'size' => 0, - ))); - - $this->assertNull($bag->get('file')); - } - - public function testShouldConvertUploadedFilesWithPhpBug() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array( - 'child' => array( - 'name' => array( - 'file' => basename($tmpFile), - ), - 'type' => array( - 'file' => 'text/plain', - ), - 'tmp_name' => array( - 'file' => $tmpFile, - ), - 'error' => array( - 'file' => 0, - ), - 'size' => array( - 'file' => 100, - ), - ), - )); - - $files = $bag->all(); - $this->assertEquals($file, $files['child']['file']); - } - - public function testShouldConvertNestedUploadedFilesWithPhpBug() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array( - 'child' => array( - 'name' => array( - 'sub' => array('file' => basename($tmpFile)), - ), - 'type' => array( - 'sub' => array('file' => 'text/plain'), - ), - 'tmp_name' => array( - 'sub' => array('file' => $tmpFile), - ), - 'error' => array( - 'sub' => array('file' => 0), - ), - 'size' => array( - 'sub' => array('file' => 100), - ), - ), - )); - - $files = $bag->all(); - $this->assertEquals($file, $files['child']['sub']['file']); - } - - public function testShouldNotConvertNestedUploadedFiles() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - $bag = new FileBag(array('image' => array('file' => $file))); - - $files = $bag->all(); - $this->assertEquals($file, $files['image']['file']); - } - - protected function createTempFile() - { - return tempnam(sys_get_temp_dir().'/form_test', 'FormTest'); - } - - protected function setUp() - { - mkdir(sys_get_temp_dir().'/form_test', 0777, true); - } - - protected function tearDown() - { - foreach (glob(sys_get_temp_dir().'/form_test/*') as $file) { - unlink($file); - } - - rmdir(sys_get_temp_dir().'/form_test'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php deleted file mode 100644 index ada9ac0d1..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php +++ /dev/null @@ -1,216 +0,0 @@ - - * - * 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\HeaderBag; - -class HeaderBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Symfony\Component\HttpFoundation\HeaderBag::__construct - */ - public function testConstructor() - { - $bag = new HeaderBag(array('foo' => 'bar')); - $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 - */ - public function testAll() - { - $bag = new HeaderBag(array('foo' => 'bar')); - $this->assertEquals(array('foo' => array('bar')), $bag->all(), '->all() gets all the input'); - - $bag = new HeaderBag(array('FOO' => 'BAR')); - $this->assertEquals(array('foo' => array('BAR')), $bag->all(), '->all() gets all the input key are lower case'); - } - - /** - * @covers Symfony\Component\HttpFoundation\HeaderBag::replace - */ - public function testReplace() - { - $bag = new HeaderBag(array('foo' => 'bar')); - - $bag->replace(array('NOPE' => 'BAR')); - $this->assertEquals(array('nope' => array('BAR')), $bag->all(), '->replace() replaces the input with the argument'); - $this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input'); - } - - /** - * @covers Symfony\Component\HttpFoundation\HeaderBag::get - */ - public function testGet() - { - $bag = new HeaderBag(array('foo' => 'bar', 'fuzz' => 'bizz')); - $this->assertEquals('bar', $bag->get('foo'), '->get return current value'); - $this->assertEquals('bar', $bag->get('FoO'), '->get key in case insensitive'); - $this->assertEquals(array('bar'), $bag->get('foo', 'nope', false), '->get return the value as array'); - - // defaults - $this->assertNull($bag->get('none'), '->get unknown values returns null'); - $this->assertEquals('default', $bag->get('none', 'default'), '->get unknown values returns default'); - $this->assertEquals(array('default'), $bag->get('none', 'default', false), '->get unknown values returns default as array'); - - $bag->set('foo', 'bor', false); - $this->assertEquals('bar', $bag->get('foo'), '->get return first value'); - $this->assertEquals(array('bar', 'bor'), $bag->get('foo', 'nope', false), '->get return all values as array'); - } - - public function testSetAssociativeArray() - { - $bag = new HeaderBag(); - $bag->set('foo', array('bad-assoc-index' => 'value')); - $this->assertSame('value', $bag->get('foo')); - $this->assertEquals(array('value'), $bag->get('foo', 'nope', false), 'assoc indices of multi-valued headers are ignored'); - } - - /** - * @covers Symfony\Component\HttpFoundation\HeaderBag::contains - */ - public function testContains() - { - $bag = new HeaderBag(array('foo' => 'bar', 'fuzz' => 'bizz')); - $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value'); - $this->assertTrue($bag->contains('fuzz', 'bizz'), '->contains second value'); - $this->assertFalse($bag->contains('nope', 'nope'), '->contains unknown value'); - $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value'); - - // Multiple values - $bag->set('foo', 'bor', false); - $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value'); - $this->assertTrue($bag->contains('foo', 'bor'), '->contains second value'); - $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value'); - } - - public function testCacheControlDirectiveAccessors() - { - $bag = new HeaderBag(); - $bag->addCacheControlDirective('public'); - - $this->assertTrue($bag->hasCacheControlDirective('public')); - $this->assertTrue($bag->getCacheControlDirective('public')); - $this->assertEquals('public', $bag->get('cache-control')); - - $bag->addCacheControlDirective('max-age', 10); - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); - $this->assertEquals('max-age=10, public', $bag->get('cache-control')); - - $bag->removeCacheControlDirective('max-age'); - $this->assertFalse($bag->hasCacheControlDirective('max-age')); - } - - public function testCacheControlDirectiveParsing() - { - $bag = new HeaderBag(array('cache-control' => 'public, max-age=10')); - $this->assertTrue($bag->hasCacheControlDirective('public')); - $this->assertTrue($bag->getCacheControlDirective('public')); - - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); - - $bag->addCacheControlDirective('s-maxage', 100); - $this->assertEquals('max-age=10, public, s-maxage=100', $bag->get('cache-control')); - } - - public function testCacheControlDirectiveParsingQuotedZero() - { - $bag = new HeaderBag(array('cache-control' => 'max-age="0"')); - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(0, $bag->getCacheControlDirective('max-age')); - } - - public function testCacheControlDirectiveOverrideWithReplace() - { - $bag = new HeaderBag(array('cache-control' => 'private, max-age=100')); - $bag->replace(array('cache-control' => 'public, max-age=10')); - $this->assertTrue($bag->hasCacheControlDirective('public')); - $this->assertTrue($bag->getCacheControlDirective('public')); - - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); - } - - /** - * @covers Symfony\Component\HttpFoundation\HeaderBag::getIterator - */ - public function testGetIterator() - { - $headers = array('foo' => 'bar', 'hello' => 'world', 'third' => 'charm'); - $headerBag = new HeaderBag($headers); - - $i = 0; - foreach ($headerBag as $key => $val) { - ++$i; - $this->assertEquals(array($headers[$key]), $val); - } - - $this->assertEquals(count($headers), $i); - } - - /** - * @covers Symfony\Component\HttpFoundation\HeaderBag::count - */ - public function testCount() - { - $headers = array('foo' => 'bar', 'HELLO' => 'WORLD'); - $headerBag = new HeaderBag($headers); - - $this->assertEquals(count($headers), count($headerBag)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php deleted file mode 100644 index 000247824..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * 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\IpUtils; - -class IpUtilsTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider testIpv4Provider - */ - public function testIpv4($matches, $remoteAddr, $cidr) - { - $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr)); - } - - public function testIpv4Provider() - { - return array( - array(true, '192.168.1.1', '192.168.1.1'), - array(true, '192.168.1.1', '192.168.1.1/1'), - array(true, '192.168.1.1', '192.168.1.0/24'), - array(false, '192.168.1.1', '1.2.3.4/1'), - array(false, '192.168.1.1', '192.168.1/33'), - array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')), - array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')), - array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')), - array(true, '1.2.3.4', '0.0.0.0/0'), - array(false, '1.2.3.4', '256.256.256/0'), - array(false, '1.2.3.4', '192.168.1.0/0'), - ); - } - - /** - * @dataProvider testIpv6Provider - */ - public function testIpv6($matches, $remoteAddr, $cidr) - { - if (!defined('AF_INET6')) { - $this->markTestSkipped('Only works when PHP is compiled without the option "disable-ipv6".'); - } - - $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr)); - } - - public function testIpv6Provider() - { - return array( - array(true, '2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'), - array(false, '2a00:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'), - array(false, '2a01:198:603:0:396e:4789:8e99:890f', '::1'), - array(true, '0:0:0:0:0:0:0:1', '::1'), - array(false, '0:0:603:0:396e:4789:8e99:0001', '::1'), - array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '2a01:198:603:0::/65')), - array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('2a01:198:603:0::/65', '::1')), - array(false, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '1a01:198:603:0::/65')), - ); - } - - /** - * @expectedException \RuntimeException - */ - public function testAnIpv6WithOptionDisabledIpv6() - { - if (!extension_loaded('sockets')) { - $this->markTestSkipped('Only works when the socket extension is enabled'); - } - - if (defined('AF_INET6')) { - $this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".'); - } - - IpUtils::checkIp('2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php deleted file mode 100644 index f1ea56570..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ /dev/null @@ -1,229 +0,0 @@ - - * - * 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\JsonResponse; - -class JsonResponseTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructorEmptyCreatesJsonObject() - { - $response = new JsonResponse(); - $this->assertSame('{}', $response->getContent()); - } - - public function testConstructorWithArrayCreatesJsonArray() - { - $response = new JsonResponse(array(0, 1, 2, 3)); - $this->assertSame('[0,1,2,3]', $response->getContent()); - } - - public function testConstructorWithAssocArrayCreatesJsonObject() - { - $response = new JsonResponse(array('foo' => 'bar')); - $this->assertSame('{"foo":"bar"}', $response->getContent()); - } - - public function testConstructorWithSimpleTypes() - { - $response = new JsonResponse('foo'); - $this->assertSame('"foo"', $response->getContent()); - - $response = new JsonResponse(0); - $this->assertSame('0', $response->getContent()); - - $response = new JsonResponse(0.1); - $this->assertSame('0.1', $response->getContent()); - - $response = new JsonResponse(true); - $this->assertSame('true', $response->getContent()); - } - - public function testConstructorWithCustomStatus() - { - $response = new JsonResponse(array(), 202); - $this->assertSame(202, $response->getStatusCode()); - } - - public function testConstructorAddsContentTypeHeader() - { - $response = new JsonResponse(); - $this->assertSame('application/json', $response->headers->get('Content-Type')); - } - - public function testConstructorWithCustomHeaders() - { - $response = new JsonResponse(array(), 200, array('ETag' => 'foo')); - $this->assertSame('application/json', $response->headers->get('Content-Type')); - $this->assertSame('foo', $response->headers->get('ETag')); - } - - public function testConstructorWithCustomContentType() - { - $headers = array('Content-Type' => 'application/vnd.acme.blog-v1+json'); - - $response = new JsonResponse(array(), 200, $headers); - $this->assertSame('application/vnd.acme.blog-v1+json', $response->headers->get('Content-Type')); - } - - public function testCreate() - { - $response = JsonResponse::create(array('foo' => 'bar'), 204); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); - $this->assertEquals('{"foo":"bar"}', $response->getContent()); - $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'); - - $this->assertEquals('/**/callback({"foo":"bar"});', $response->getContent()); - $this->assertEquals('text/javascript', $response->headers->get('Content-Type')); - } - - public function testJsonEncodeFlags() - { - $response = new JsonResponse('<>\'&"'); - - $this->assertEquals('"\u003C\u003E\u0027\u0026\u0022"', $response->getContent()); - } - - public function testGetEncodingOptions() - { - $response = new JsonResponse(); - - $this->assertEquals(JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT, $response->getEncodingOptions()); - } - - public function testSetEncodingOptions() - { - $response = new JsonResponse(); - $response->setData(array(array(1, 2, 3))); - - $this->assertEquals('[[1,2,3]]', $response->getContent()); - - $response->setEncodingOptions(JSON_FORCE_OBJECT); - - $this->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response->getContent()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSetCallbackInvalidIdentifier() - { - $response = new JsonResponse('foo'); - $response->setCallback('+invalid'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSetContent() - { - JsonResponse::create("\xB1\x31"); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage This error is expected - */ - public function testSetContentJsonSerializeError() - { - if (!interface_exists('JsonSerializable')) { - $this->markTestSkipped('Interface JsonSerializable is available in PHP 5.4+'); - } - - $serializable = new JsonSerializableObject(); - - JsonResponse::create($serializable); - } -} - -if (interface_exists('JsonSerializable')) { - class JsonSerializableObject implements \JsonSerializable - { - public function jsonSerialize() - { - throw new \Exception('This error is expected'); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php deleted file mode 100644 index 16fedbf83..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php +++ /dev/null @@ -1,266 +0,0 @@ - - * - * 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\ParameterBag; - -class ParameterBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::__construct - */ - public function testConstructor() - { - $this->testAll(); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::all - */ - public function testAll() - { - $bag = new ParameterBag(array('foo' => 'bar')); - $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 - */ - public function testReplace() - { - $bag = new ParameterBag(array('foo' => 'bar')); - - $bag->replace(array('FOO' => 'BAR')); - $this->assertEquals(array('FOO' => 'BAR'), $bag->all(), '->replace() replaces the input with the argument'); - $this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::get - */ - public function testGet() - { - $bag = new ParameterBag(array('foo' => 'bar', 'null' => null)); - - $this->assertEquals('bar', $bag->get('foo'), '->get() gets the value of a parameter'); - $this->assertEquals('default', $bag->get('unknown', 'default'), '->get() returns second argument as default if a parameter is not defined'); - $this->assertNull($bag->get('null', 'default'), '->get() returns null if null is set'); - } - - public function testGetDoesNotUseDeepByDefault() - { - $bag = new ParameterBag(array('foo' => array('bar' => 'moo'))); - - $this->assertNull($bag->get('foo[bar]')); - } - - /** - * @dataProvider getInvalidPaths - * @expectedException \InvalidArgumentException - */ - public function testGetDeepWithInvalidPaths($path) - { - $bag = new ParameterBag(array('foo' => array('bar' => 'moo'))); - - $bag->get($path, null, true); - } - - public function getInvalidPaths() - { - return array( - array('foo[['), - array('foo[d'), - array('foo[bar]]'), - array('foo[bar]d'), - ); - } - - public function testGetDeep() - { - $bag = new ParameterBag(array('foo' => array('bar' => array('moo' => 'boo')))); - - $this->assertEquals(array('moo' => 'boo'), $bag->get('foo[bar]', null, true)); - $this->assertEquals('boo', $bag->get('foo[bar][moo]', null, true)); - $this->assertEquals('default', $bag->get('foo[bar][foo]', 'default', true)); - $this->assertEquals('default', $bag->get('bar[moo][foo]', 'default', true)); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::set - */ - public function testSet() - { - $bag = new ParameterBag(array()); - - $bag->set('foo', 'bar'); - $this->assertEquals('bar', $bag->get('foo'), '->set() sets the value of parameter'); - - $bag->set('foo', 'baz'); - $this->assertEquals('baz', $bag->get('foo'), '->set() overrides previously set parameter'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::has - */ - public function testHas() - { - $bag = new ParameterBag(array('foo' => 'bar')); - - $this->assertTrue($bag->has('foo'), '->has() returns true if a parameter is defined'); - $this->assertFalse($bag->has('unknown'), '->has() return false if a parameter is not defined'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::getAlpha - */ - public function testGetAlpha() - { - $bag = new ParameterBag(array('word' => 'foo_BAR_012')); - - $this->assertEquals('fooBAR', $bag->getAlpha('word'), '->getAlpha() gets only alphabetic characters'); - $this->assertEquals('', $bag->getAlpha('unknown'), '->getAlpha() returns empty string if a parameter is not defined'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::getAlnum - */ - public function testGetAlnum() - { - $bag = new ParameterBag(array('word' => 'foo_BAR_012')); - - $this->assertEquals('fooBAR012', $bag->getAlnum('word'), '->getAlnum() gets only alphanumeric characters'); - $this->assertEquals('', $bag->getAlnum('unknown'), '->getAlnum() returns empty string if a parameter is not defined'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::getDigits - */ - public function testGetDigits() - { - $bag = new ParameterBag(array('word' => 'foo_BAR_012')); - - $this->assertEquals('012', $bag->getDigits('word'), '->getDigits() gets only digits as string'); - $this->assertEquals('', $bag->getDigits('unknown'), '->getDigits() returns empty string if a parameter is not defined'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::getInt - */ - public function testGetInt() - { - $bag = new ParameterBag(array('digits' => '0123')); - - $this->assertEquals(123, $bag->getInt('digits'), '->getInt() gets a value of parameter as integer'); - $this->assertEquals(0, $bag->getInt('unknown'), '->getInt() returns zero if a parameter is not defined'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::filter - */ - public function testFilter() - { - $bag = new ParameterBag(array( - 'digits' => '0123ab', - 'email' => 'example@example.com', - 'url' => 'http://example.com/foo', - 'dec' => '256', - 'hex' => '0x100', - 'array' => array('bang'), - )); - - $this->assertEmpty($bag->filter('nokey'), '->filter() should return empty by default if no key is found'); - - $this->assertEquals('0123', $bag->filter('digits', '', false, FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters'); - - $this->assertEquals('example@example.com', $bag->filter('email', '', false, FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email'); - - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, array('flags' => FILTER_FLAG_PATH_REQUIRED)), '->filter() gets a value of parameter as URL with a path'); - - // This test is repeated for code-coverage - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', false, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path'); - - $this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array( - 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff), - )), '->filter() gets a value of parameter as integer between boundaries'); - - $this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array( - 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff), - )), '->filter() gets a value of parameter as integer between boundaries'); - - $this->assertEquals(array('bang'), $bag->filter('array', '', false), '->filter() gets a value of parameter as an array'); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::getIterator - */ - public function testGetIterator() - { - $parameters = array('foo' => 'bar', 'hello' => 'world'); - $bag = new ParameterBag($parameters); - - $i = 0; - foreach ($bag as $key => $val) { - ++$i; - $this->assertEquals($parameters[$key], $val); - } - - $this->assertEquals(count($parameters), $i); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::count - */ - public function testCount() - { - $parameters = array('foo' => 'bar', 'hello' => 'world'); - $bag = new ParameterBag($parameters); - - $this->assertEquals(count($parameters), count($bag)); - } - - /** - * @covers Symfony\Component\HttpFoundation\ParameterBag::getBoolean - */ - public function testGetBoolean() - { - $parameters = array('string_true' => 'true', 'string_false' => 'false'); - $bag = new ParameterBag($parameters); - - $this->assertTrue($bag->getBoolean('string_true'), '->getBoolean() gets the string true as boolean true'); - $this->assertFalse($bag->getBoolean('string_false'), '->getBoolean() gets the string false as boolean false'); - $this->assertFalse($bag->getBoolean('unknown'), '->getBoolean() returns false if a parameter is not defined'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php deleted file mode 100644 index 2a097d6fd..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * 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\RedirectResponse; - -class RedirectResponseTest extends \PHPUnit_Framework_TestCase -{ - public function testGenerateMetaRedirect() - { - $response = new RedirectResponse('foo.bar'); - - $this->assertEquals(1, preg_match( - '##', - preg_replace(array('/\s+/', '/\'/'), array(' ', '"'), $response->getContent()) - )); - } - - /** - * @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'); - - $this->assertTrue($response->headers->has('Location')); - $this->assertEquals('foo.bar', $response->headers->get('Location')); - } - - public function testGetTargetUrl() - { - $response = new RedirectResponse('foo.bar'); - - $this->assertEquals('foo.bar', $response->getTargetUrl()); - } - - public function testSetTargetUrl() - { - $response = new RedirectResponse('foo.bar'); - $response->setTargetUrl('baz.beep'); - - $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); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); - $this->assertEquals(301, $response->getStatusCode()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php deleted file mode 100644 index cee9bcc26..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php +++ /dev/null @@ -1,150 +0,0 @@ - - * - * 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\RequestMatcher; -use Symfony\Component\HttpFoundation\Request; - -class RequestMatcherTest extends \PHPUnit_Framework_TestCase -{ - /** - * @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 = new RequestMatcher(null, null, $matcherMethod); - $request = Request::create('', $requestMethod); - $this->assertSame($isMatch, $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 testScheme() - { - $httpRequest = $request = $request = Request::create(''); - $httpsRequest = $request = $request = Request::create('', 'get', array(), array(), array(), array('HTTPS' => 'on')); - - $matcher = new RequestMatcher(); - $matcher->matchScheme('https'); - $this->assertFalse($matcher->matches($httpRequest)); - $this->assertTrue($matcher->matches($httpsRequest)); - - $matcher->matchScheme('http'); - $this->assertFalse($matcher->matches($httpsRequest)); - $this->assertTrue($matcher->matches($httpRequest)); - - $matcher = new RequestMatcher(); - $this->assertTrue($matcher->matches($httpsRequest)); - $this->assertTrue($matcher->matches($httpRequest)); - } - - /** - * @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($pattern); - $this->assertSame($isMatch, $matcher->matches($request)); - - $matcher = new RequestMatcher(null, $pattern); - $this->assertSame($isMatch, $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() - { - $matcher = new RequestMatcher(); - - $request = Request::create('/admin/foo'); - - $matcher->matchPath('/admin/.*'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchPath('/admin'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchPath('^/admin/.*$'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchMethod('/blog/.*'); - $this->assertFalse($matcher->matches($request)); - } - - public function testPathWithLocaleIsNotSupported() - { - $matcher = new RequestMatcher(); - $request = Request::create('/en/login'); - $request->setLocale('en'); - - $matcher->matchPath('^/{_locale}/login$'); - $this->assertFalse($matcher->matches($request)); - } - - public function testPathWithEncodedCharacters() - { - $matcher = new RequestMatcher(); - $request = Request::create('/admin/fo%20o'); - $matcher->matchPath('^/admin/fo o*$'); - $this->assertTrue($matcher->matches($request)); - } - - public function testAttributes() - { - $matcher = new RequestMatcher(); - - $request = Request::create('/admin/foo'); - $request->attributes->set('foo', 'foo_bar'); - - $matcher->matchAttribute('foo', 'foo_.*'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchAttribute('foo', 'foo'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchAttribute('foo', '^foo_bar$'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchAttribute('foo', 'babar'); - $this->assertFalse($matcher->matches($request)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php deleted file mode 100644 index e26b806fd..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestStackTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * 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\Request; -use Symfony\Component\HttpFoundation\RequestStack; - -class RequestStackTest extends \PHPUnit_Framework_TestCase -{ - public function testGetCurrentRequest() - { - $requestStack = new RequestStack(); - $this->assertNull($requestStack->getCurrentRequest()); - - $request = Request::create('/foo'); - - $requestStack->push($request); - $this->assertSame($request, $requestStack->getCurrentRequest()); - - $this->assertSame($request, $requestStack->pop()); - $this->assertNull($requestStack->getCurrentRequest()); - - $this->assertNull($requestStack->pop()); - } - - public function testGetMasterRequest() - { - $requestStack = new RequestStack(); - $this->assertNull($requestStack->getMasterRequest()); - - $masterRequest = Request::create('/foo'); - $subRequest = Request::create('/bar'); - - $requestStack->push($masterRequest); - $requestStack->push($subRequest); - - $this->assertSame($masterRequest, $requestStack->getMasterRequest()); - } - - public function testGetParentRequest() - { - $requestStack = new RequestStack(); - $this->assertNull($requestStack->getParentRequest()); - - $masterRequest = Request::create('/foo'); - - $requestStack->push($masterRequest); - $this->assertNull($requestStack->getParentRequest()); - - $firstSubRequest = Request::create('/bar'); - - $requestStack->push($firstSubRequest); - $this->assertSame($masterRequest, $requestStack->getParentRequest()); - - $secondSubRequest = Request::create('/baz'); - - $requestStack->push($secondSubRequest); - $this->assertSame($firstSubRequest, $requestStack->getParentRequest()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php deleted file mode 100644 index 28d1b4e24..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ /dev/null @@ -1,1826 +0,0 @@ - - * - * 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\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Request; - -class RequestTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Symfony\Component\HttpFoundation\Request::__construct - */ - public function testConstructor() - { - $this->testInitialize(); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::initialize - */ - public function testInitialize() - { - $request = new Request(); - - $request->initialize(array('foo' => 'bar')); - $this->assertEquals('bar', $request->query->get('foo'), '->initialize() takes an array of query parameters as its first argument'); - - $request->initialize(array(), array('foo' => 'bar')); - $this->assertEquals('bar', $request->request->get('foo'), '->initialize() takes an array of request parameters as its second argument'); - - $request->initialize(array(), array(), array('foo' => 'bar')); - $this->assertEquals('bar', $request->attributes->get('foo'), '->initialize() takes an array of attributes as its third argument'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_FOO' => 'bar')); - $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its sixth 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 - */ - public function testCreate() - { - $request = Request::create('http://test.com/foo?bar=baz'); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/foo', 'GET', array('bar' => 'baz')); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/foo?bar=foo', 'GET', array('bar' => 'baz')); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('https://test.com/foo?bar=baz'); - $this->assertEquals('https://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(443, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('test.com:90/foo'); - $this->assertEquals('http://test.com:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('test.com', $request->getHost()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('https://test.com:90/foo'); - $this->assertEquals('https://test.com:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('test.com', $request->getHost()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://127.0.0.1:90/foo'); - $this->assertEquals('https://127.0.0.1:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('127.0.0.1', $request->getHost()); - $this->assertEquals('127.0.0.1:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://[::1]:90/foo'); - $this->assertEquals('https://[::1]:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('[::1]', $request->getHost()); - $this->assertEquals('[::1]:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://[::1]/foo'); - $this->assertEquals('https://[::1]/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('[::1]', $request->getHost()); - $this->assertEquals('[::1]', $request->getHttpHost()); - $this->assertEquals(443, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; - $request = Request::create('http://example.com/jsonrpc', 'POST', array(), array(), array(), array(), $json); - $this->assertEquals($json, $request->getContent()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com'); - $this->assertEquals('http://test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $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()); - $this->assertEquals('test=1', $request->getQueryString()); - $this->assertEquals(90, $request->getPort()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://username:password@test.com'); - $this->assertEquals('http://test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('username', $request->getUser()); - $this->assertEquals('password', $request->getPassword()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://username@test.com'); - $this->assertEquals('http://test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('username', $request->getUser()); - $this->assertSame('', $request->getPassword()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/?foo'); - $this->assertEquals('/?foo', $request->getRequestUri()); - $this->assertEquals(array('foo' => ''), $request->query->all()); - - ## assume rewrite rule: (.*) --> app/app.php ; app/ is a symlink to a symfony web/ directory - $request = Request::create('http://test.com/apparthotel-1234', 'GET', array(), array(), array(), - array( - 'DOCUMENT_ROOT' => '/var/www/www.test.com', - 'SCRIPT_FILENAME' => '/var/www/www.test.com/app/app.php', - 'SCRIPT_NAME' => '/app/app.php', - 'PHP_SELF' => '/app/app.php/apparthotel-1234', - )); - $this->assertEquals('http://test.com/apparthotel-1234', $request->getUri()); - $this->assertEquals('/apparthotel-1234', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::create - */ - public function testCreateCheckPrecedence() - { - // server is used by default - $request = Request::create('/', 'DELETE', array(), array(), array(), array( - 'HTTP_HOST' => 'example.com', - 'HTTPS' => 'on', - 'SERVER_PORT' => 443, - 'PHP_AUTH_USER' => 'fabien', - 'PHP_AUTH_PW' => 'pa$$', - 'QUERY_STRING' => 'foo=bar', - 'CONTENT_TYPE' => 'application/json', - )); - $this->assertEquals('example.com', $request->getHost()); - $this->assertEquals(443, $request->getPort()); - $this->assertTrue($request->isSecure()); - $this->assertEquals('fabien', $request->getUser()); - $this->assertEquals('pa$$', $request->getPassword()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals('application/json', $request->headers->get('CONTENT_TYPE')); - - // URI has precedence over server - $request = Request::create('http://thomas:pokemon@example.net:8080/?foo=bar', 'GET', array(), array(), array(), array( - 'HTTP_HOST' => 'example.com', - 'HTTPS' => 'on', - 'SERVER_PORT' => 443, - )); - $this->assertEquals('example.net', $request->getHost()); - $this->assertEquals(8080, $request->getPort()); - $this->assertFalse($request->isSecure()); - $this->assertEquals('thomas', $request->getUser()); - $this->assertEquals('pokemon', $request->getPassword()); - $this->assertEquals('foo=bar', $request->getQueryString()); - } - - public function testDuplicate() - { - $request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array(), array(), array('HTTP_FOO' => 'bar')); - $dup = $request->duplicate(); - - $this->assertEquals($request->query->all(), $dup->query->all(), '->duplicate() duplicates a request an copy the current query parameters'); - $this->assertEquals($request->request->all(), $dup->request->all(), '->duplicate() duplicates a request an copy the current request parameters'); - $this->assertEquals($request->attributes->all(), $dup->attributes->all(), '->duplicate() duplicates a request an copy the current attributes'); - $this->assertEquals($request->headers->all(), $dup->headers->all(), '->duplicate() duplicates a request an copy the current HTTP headers'); - - $dup = $request->duplicate(array('foo' => 'foobar'), array('foo' => 'foobar'), array('foo' => 'foobar'), array(), array(), array('HTTP_FOO' => 'foobar')); - - $this->assertEquals(array('foo' => 'foobar'), $dup->query->all(), '->duplicate() overrides the query parameters if provided'); - $this->assertEquals(array('foo' => 'foobar'), $dup->request->all(), '->duplicate() overrides the request parameters if provided'); - $this->assertEquals(array('foo' => 'foobar'), $dup->attributes->all(), '->duplicate() overrides the attributes if provided'); - $this->assertEquals(array('foo' => array('foobar')), $dup->headers->all(), '->duplicate() overrides the HTTP header if provided'); - } - - public function testDuplicateWithFormat() - { - $request = new Request(array(), array(), array('_format' => 'json')); - $dup = $request->duplicate(); - - $this->assertEquals('json', $dup->getRequestFormat()); - $this->assertEquals('json', $dup->attributes->get('_format')); - - $request = new Request(); - $request->setRequestFormat('xml'); - $dup = $request->duplicate(); - - $this->assertEquals('xml', $dup->getRequestFormat()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getFormat - * @covers Symfony\Component\HttpFoundation\Request::setFormat - * @dataProvider getFormatToMimeTypeMapProvider - */ - public function testGetFormatFromMimeType($format, $mimeTypes) - { - $request = new Request(); - foreach ($mimeTypes as $mime) { - $this->assertEquals($format, $request->getFormat($mime)); - } - $request->setFormat($format, $mimeTypes); - foreach ($mimeTypes as $mime) { - $this->assertEquals($format, $request->getFormat($mime)); - } - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getFormat - */ - public function testGetFormatFromMimeTypeWithParameters() - { - $request = new Request(); - $this->assertEquals('json', $request->getFormat('application/json; charset=utf-8')); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getMimeType - * @dataProvider getFormatToMimeTypeMapProvider - */ - public function testGetMimeTypeFromFormat($format, $mimeTypes) - { - if (null !== $format) { - $request = new Request(); - $this->assertEquals($mimeTypes[0], $request->getMimeType($format)); - } - } - - public function getFormatToMimeTypeMapProvider() - { - return array( - array(null, array(null, 'unexistent-mime-type')), - array('txt', array('text/plain')), - array('js', array('application/javascript', 'application/x-javascript', 'text/javascript')), - array('css', array('text/css')), - array('json', array('application/json', 'application/x-json')), - array('xml', array('text/xml', 'application/xml', 'application/x-xml')), - array('rdf', array('application/rdf+xml')), - array('atom',array('application/atom+xml')), - ); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getUri - */ - public function testGetUri() - { - $server = array(); - - // Standard Request on non default PORT - // http://host:8080/index.php/path/info?query=string - - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/index.php/path/info?query=string'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PATH_INFO'] = '/path/info'; - $server['PATH_TRANSLATED'] = 'redirect:/index.php/path/info'; - $server['PHP_SELF'] = '/index_dev.php/path/info'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request = new Request(); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host:8080/index.php/path/info?query=string', $request->getUri(), '->getUri() with non default port'); - - // Use std port number - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port without HOST_HEADER'); - - // Request with URL REWRITING (hide index.php) - // RewriteCond %{REQUEST_FILENAME} !-f - // RewriteRule ^(.*)$ index.php [QSA,L] - // http://host:8080/path/info?query=string - $server = array(); - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['REDIRECT_QUERY_STRING'] = 'query=string'; - $server['REDIRECT_URL'] = '/path/info'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/path/info?toto=test&1=1'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PHP_SELF'] = '/index.php'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://host:8080/path/info?query=string', $request->getUri(), '->getUri() with rewrite'); - - // Use std port number - // http://host/path/info?query=string - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/path/info?query=string', $request->getUri(), '->getUri() with rewrite and default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/path/info?query=string', $request->getUri(), '->getUri() with rewrite, default port without HOST_HEADER'); - - // With encoded characters - - $server = array( - 'HTTP_HOST' => 'host:8080', - 'SERVER_NAME' => 'servername', - 'SERVER_PORT' => '8080', - 'QUERY_STRING' => 'query=string', - 'REQUEST_URI' => '/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', - 'SCRIPT_NAME' => '/ba se/index_dev.php', - 'PATH_TRANSLATED' => 'redirect:/index.php/foo bar/in+fo', - 'PHP_SELF' => '/ba se/index_dev.php/path/info', - 'SCRIPT_FILENAME' => '/some/where/ba se/index_dev.php', - ); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals( - 'http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', - $request->getUri() - ); - - // with user info - - $server['PHP_AUTH_USER'] = 'fabien'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://host: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://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getUriForPath - */ - public function testGetUriForPath() - { - $request = Request::create('http://test.com/foo?bar=baz'); - $this->assertEquals('http://test.com/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('http://test.com:90/foo?bar=baz'); - $this->assertEquals('http://test.com:90/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('https://test.com/foo?bar=baz'); - $this->assertEquals('https://test.com/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('https://test.com:90/foo?bar=baz'); - $this->assertEquals('https://test.com:90/some/path', $request->getUriForPath('/some/path')); - - $server = array(); - - // Standard Request on non default PORT - // http://host:8080/index.php/path/info?query=string - - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/index.php/path/info?query=string'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PATH_INFO'] = '/path/info'; - $server['PATH_TRANSLATED'] = 'redirect:/index.php/path/info'; - $server['PHP_SELF'] = '/index_dev.php/path/info'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request = new Request(); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host:8080/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with non default port'); - - // Use std port number - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port without HOST_HEADER'); - - // Request with URL REWRITING (hide index.php) - // RewriteCond %{REQUEST_FILENAME} !-f - // RewriteRule ^(.*)$ index.php [QSA,L] - // http://host:8080/path/info?query=string - $server = array(); - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['REDIRECT_QUERY_STRING'] = 'query=string'; - $server['REDIRECT_URL'] = '/path/info'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/path/info?toto=test&1=1'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PHP_SELF'] = '/index.php'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://host:8080/some/path', $request->getUriForPath('/some/path'), '->getUri() with rewrite'); - - // Use std port number - // http://host/path/info?query=string - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite and default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite, default port without HOST_HEADER'); - $this->assertEquals('servername', $request->getHttpHost()); - - // with user info - - $server['PHP_AUTH_USER'] = 'fabien'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $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://servername/some/path', $request->getUriForPath('/some/path')); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getUserInfo - */ - public function testGetUserInfo() - { - $request = new Request(); - - $server['PHP_AUTH_USER'] = 'fabien'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('fabien', $request->getUserInfo()); - - $server['PHP_AUTH_USER'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('0', $request->getUserInfo()); - - $server['PHP_AUTH_PW'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('0:0', $request->getUserInfo()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getSchemeAndHttpHost - */ - public function testGetSchemeAndHttpHost() - { - $request = new Request(); - - $server = array(); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '90'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - - $server['PHP_AUTH_USER'] = 'fabien'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - - $server['PHP_AUTH_USER'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - - $server['PHP_AUTH_PW'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::getQueryString - * @covers Symfony\Component\HttpFoundation\Request::normalizeQueryString - * @dataProvider getQueryStringNormalizationData - */ - public function testGetQueryString($query, $expectedQuery, $msg) - { - $request = new Request(); - - $request->server->set('QUERY_STRING', $query); - $this->assertSame($expectedQuery, $request->getQueryString(), $msg); - } - - public function getQueryStringNormalizationData() - { - return array( - array('foo', 'foo', 'works with valueless parameters'), - array('foo=', 'foo=', 'includes a dangling equal sign'), - array('bar=&foo=bar', 'bar=&foo=bar', '->works with empty parameters'), - array('foo=bar&bar=', 'bar=&foo=bar', 'sorts keys alphabetically'), - - // GET parameters, that are submitted from a HTML form, encode spaces as "+" by default (as defined in enctype application/x-www-form-urlencoded). - // PHP also converts "+" to spaces when filling the global _GET or when using the function parse_str. - array('him=John%20Doe&her=Jane+Doe', 'her=Jane%20Doe&him=John%20Doe', 'normalizes spaces in both encodings "%20" and "+"'), - - array('foo[]=1&foo[]=2', 'foo%5B%5D=1&foo%5B%5D=2', 'allows array notation'), - array('foo=1&foo=2', 'foo=1&foo=2', 'allows repeated parameters'), - array('pa%3Dram=foo%26bar%3Dbaz&test=test', 'pa%3Dram=foo%26bar%3Dbaz&test=test', 'works with encoded delimiters'), - array('0', '0', 'allows "0"'), - array('Jane Doe&John%20Doe', 'Jane%20Doe&John%20Doe', 'normalizes encoding in keys'), - array('her=Jane Doe&him=John%20Doe', 'her=Jane%20Doe&him=John%20Doe', 'normalizes encoding in values'), - array('foo=bar&&&test&&', 'foo=bar&test', 'removes unneeded delimiters'), - array('formula=e=m*c^2', 'formula=e%3Dm%2Ac%5E2', 'correctly treats only the first "=" as delimiter and the next as value'), - - // Ignore pairs with empty key, even if there was a value, e.g. "=value", as such nameless values cannot be retrieved anyway. - // PHP also does not include them when building _GET. - array('foo=bar&=a=b&=x=y', 'foo=bar', 'removes params with empty key'), - ); - } - - public function testGetQueryStringReturnsNull() - { - $request = new Request(); - - $this->assertNull($request->getQueryString(), '->getQueryString() returns null for non-existent query string'); - - $request->server->set('QUERY_STRING', ''); - $this->assertNull($request->getQueryString(), '->getQueryString() returns null for empty query string'); - } - - public function testGetHost() - { - $request = new Request(); - - $request->initialize(array('foo' => 'bar')); - $this->assertEquals('', $request->getHost(), '->getHost() return empty string if not initialized'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.example.com')); - $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from Host Header'); - - // Host header with port number - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.example.com:8080')); - $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from Host Header with port number'); - - // Server values - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.example.com')); - $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from server name'); - - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.example.com', 'HTTP_HOST' => 'www.host.com')); - $this->assertEquals('www.host.com', $request->getHost(), '->getHost() value from Host header has priority over SERVER_NAME '); - } - - public function testGetPort() - { - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '443', - )); - $port = $request->getPort(); - - $this->assertEquals(80, $port, 'Without trusted proxies FORWARDED_PROTO and FORWARDED_PORT are ignored.'); - - Request::setTrustedProxies(array('1.1.1.1')); - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '8443', - )); - $this->assertEquals(80, $request->getPort(), 'With PROTO and PORT on untrusted connection server value takes precedence.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(8443, $request->getPort(), 'With PROTO and PORT set PORT takes precedence.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https', - )); - $this->assertEquals(80, $request->getPort(), 'With only PROTO set getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(443, $request->getPort(), 'With only PROTO set getPort() defaults to 443.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'http', - )); - $this->assertEquals(80, $request->getPort(), 'If X_FORWARDED_PROTO is set to HTTP getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(80, $request->getPort(), 'If X_FORWARDED_PROTO is set to HTTP getPort() returns port of the original request.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'On', - )); - $this->assertEquals(80, $request->getPort(), 'With only PROTO set and value is On, getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(443, $request->getPort(), 'With only PROTO set and value is On, getPort() defaults to 443.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => '1', - )); - $this->assertEquals(80, $request->getPort(), 'With only PROTO set and value is 1, getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(443, $request->getPort(), 'With only PROTO set and value is 1, getPort() defaults to 443.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'something-else', - )); - $port = $request->getPort(); - $this->assertEquals(80, $port, 'With only PROTO set and value is not recognized, getPort() defaults to 80.'); - - Request::setTrustedProxies(array()); - } - - /** - * @expectedException \RuntimeException - */ - public function testGetHostWithFakeHttpHostValue() - { - $request = new Request(); - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.host.com?query=string')); - $request->getHost(); - } - - /** - * @covers Symfony\Component\HttpFoundation\Request::setMethod - * @covers Symfony\Component\HttpFoundation\Request::getMethod - */ - public function testGetSetMethod() - { - $request = new Request(); - - $this->assertEquals('GET', $request->getMethod(), '->getMethod() returns GET if no method is defined'); - - $request->setMethod('get'); - $this->assertEquals('GET', $request->getMethod(), '->getMethod() returns an uppercased string'); - - $request->setMethod('PURGE'); - $this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method even if it is not a standard one'); - - $request->setMethod('POST'); - $this->assertEquals('POST', $request->getMethod(), '->getMethod() returns the method POST if no _method is defined'); - - $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'); - - $this->assertFalse(Request::getHttpMethodParameterOverride(), 'httpMethodParameterOverride should be disabled by default'); - - Request::enableHttpMethodParameterOverride(); - - $this->assertTrue(Request::getHttpMethodParameterOverride(), 'httpMethodParameterOverride should be enabled now but it is not'); - - $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->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'); - - $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 if defined and POST'); - } - - /** - * @dataProvider testGetClientIpsProvider - */ - public function testGetClientIp($expected, $remoteAddr, $httpForwardedFor, $trustedProxies) - { - $request = $this->getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies); - - $this->assertEquals($expected[0], $request->getClientIp()); - - Request::setTrustedProxies(array()); - } - - /** - * @dataProvider testGetClientIpsProvider - */ - public function testGetClientIps($expected, $remoteAddr, $httpForwardedFor, $trustedProxies) - { - $request = $this->getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies); - - $this->assertEquals($expected, $request->getClientIps()); - - Request::setTrustedProxies(array()); - } - - public function testGetClientIpsProvider() - { - // $expected $remoteAddr $httpForwardedFor $trustedProxies - return array( - // simple IPv4 - array(array('88.88.88.88'), '88.88.88.88', null, null), - // trust the IPv4 remote addr - array(array('88.88.88.88'), '88.88.88.88', null, array('88.88.88.88')), - - // simple IPv6 - array(array('::1'), '::1', null, null), - // trust the IPv6 remote addr - array(array('::1'), '::1', null, array('::1')), - - // forwarded for with remote IPv4 addr not trusted - array(array('127.0.0.1'), '127.0.0.1', '88.88.88.88', null), - // forwarded for with remote IPv4 addr trusted - array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88', array('127.0.0.1')), - // forwarded for with remote IPv4 and all FF addrs trusted - array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88', array('127.0.0.1', '88.88.88.88')), - // forwarded for with remote IPv4 range trusted - array(array('88.88.88.88'), '123.45.67.89', '88.88.88.88', array('123.45.67.0/24')), - - // forwarded for with remote IPv6 addr not trusted - array(array('1620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '2620:0:1cfe:face:b00c::3', null), - // forwarded for with remote IPv6 addr trusted - array(array('2620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3')), - // forwarded for with remote IPv6 range trusted - array(array('88.88.88.88'), '2a01:198:603:0:396e:4789:8e99:890f', '88.88.88.88', array('2a01:198:603:0::/65')), - - // multiple forwarded for with remote IPv4 addr trusted - array(array('88.88.88.88', '87.65.43.21', '127.0.0.1'), '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89')), - // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted - array(array('87.65.43.21', '127.0.0.1'), '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')), - // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted but in the middle - array(array('88.88.88.88', '127.0.0.1'), '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '87.65.43.21')), - // multiple forwarded for with remote IPv4 addr and all reverse proxies trusted - array(array('127.0.0.1'), '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '87.65.43.21', '88.88.88.88', '127.0.0.1')), - - // multiple forwarded for with remote IPv6 addr trusted - array(array('2620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3')), - // multiple forwarded for with remote IPv6 addr and some reverse proxies trusted - array(array('3620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3', '2620:0:1cfe:face:b00c::3')), - // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted but in the middle - array(array('2620:0:1cfe:face:b00c::3', '4620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '4620:0:1cfe:face:b00c::3,3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3')), - - // client IP with port - array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88:12345, 127.0.0.1', array('127.0.0.1')), - ); - } - - public function testGetContentWorksTwiceInDefaultMode() - { - $req = new Request(); - $this->assertEquals('', $req->getContent()); - $this->assertEquals('', $req->getContent()); - } - - public function testGetContentReturnsResource() - { - $req = new Request(); - $retval = $req->getContent(true); - $this->assertInternalType('resource', $retval); - $this->assertEquals('', fread($retval, 1)); - $this->assertTrue(feof($retval)); - } - - public function testGetContentReturnsResourceWhenContentSetInConstructor() - { - $req = new Request(array(), array(), array(), array(), array(), array(), 'MyContent'); - $resource = $req->getContent(true); - - $this->assertTrue(is_resource($resource)); - $this->assertEquals('MyContent', stream_get_contents($resource)); - } - - public function testContentAsResource() - { - $resource = fopen('php://memory','r+'); - fwrite($resource, 'My other content'); - rewind($resource); - - $req = new Request(array(), array(), array(), array(), array(), array(), $resource); - $this->assertEquals('My other content', stream_get_contents($req->getContent(true))); - $this->assertEquals('My other content', $req->getContent()); - } - - /** - * @expectedException \LogicException - * @dataProvider getContentCantBeCalledTwiceWithResourcesProvider - */ - public function testGetContentCantBeCalledTwiceWithResources($first, $second) - { - if (PHP_VERSION_ID >= 50600) { - $this->markTestSkipped('PHP >= 5.6 allows to open php://input several times.'); - } - - $req = new Request(); - $req->getContent($first); - $req->getContent($second); - } - - /** - * @dataProvider getContentCantBeCalledTwiceWithResourcesProvider - */ - public function testGetContentCanBeCalledTwiceWithResources($first, $second) - { - if (PHP_VERSION_ID < 50600) { - $this->markTestSkipped('PHP < 5.6 does not allow to open php://input several times.'); - } - - $req = new Request(); - $a = $req->getContent($first); - $b = $req->getContent($second); - - if ($first) { - $a = stream_get_contents($a); - } - - if ($second) { - $b = stream_get_contents($b); - } - - $this->assertEquals($a, $b); - } - - public function getContentCantBeCalledTwiceWithResourcesProvider() - { - return array( - 'Resource then fetch' => array(true, false), - 'Resource then resource' => array(true, true), - ); - } - - public function provideOverloadedMethods() - { - return array( - array('PUT'), - array('DELETE'), - array('PATCH'), - array('put'), - array('delete'), - array('patch'), - - ); - } - - /** - * @dataProvider provideOverloadedMethods - */ - public function testCreateFromGlobals($method) - { - $normalizedMethod = strtoupper($method); - - $_GET['foo1'] = 'bar1'; - $_POST['foo2'] = 'bar2'; - $_COOKIE['foo3'] = 'bar3'; - $_FILES['foo4'] = array('bar4'); - $_SERVER['foo5'] = 'bar5'; - - $request = Request::createFromGlobals(); - $this->assertEquals('bar1', $request->query->get('foo1'), '::fromGlobals() uses values from $_GET'); - $this->assertEquals('bar2', $request->request->get('foo2'), '::fromGlobals() uses values from $_POST'); - $this->assertEquals('bar3', $request->cookies->get('foo3'), '::fromGlobals() uses values from $_COOKIE'); - $this->assertEquals(array('bar4'), $request->files->get('foo4'), '::fromGlobals() uses values from $_FILES'); - $this->assertEquals('bar5', $request->server->get('foo5'), '::fromGlobals() uses values from $_SERVER'); - - unset($_GET['foo1'], $_POST['foo2'], $_COOKIE['foo3'], $_FILES['foo4'], $_SERVER['foo5']); - - $_SERVER['REQUEST_METHOD'] = $method; - $_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; - $request = RequestContentProxy::createFromGlobals(); - $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'; - $request = Request::createFromGlobals(); - $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() - { - $request = new Request(); - $request->initialize(array('foo' => 'bar')); - - // as the Request::overrideGlobals really work, it erase $_SERVER, so we must backup it - $server = $_SERVER; - - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_GET); - - $request->initialize(array(), array('foo' => 'bar')); - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_POST); - - $this->assertArrayNotHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); - - $request->headers->set('X_FORWARDED_PROTO', 'https'); - - Request::setTrustedProxies(array('1.1.1.1')); - $this->assertFalse($request->isSecure()); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertTrue($request->isSecure()); - Request::setTrustedProxies(array()); - - $request->overrideGlobals(); - - $this->assertArrayHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); - - $request->headers->set('CONTENT_TYPE', 'multipart/form-data'); - $request->headers->set('CONTENT_LENGTH', 12345); - - $request->overrideGlobals(); - - $this->assertArrayHasKey('CONTENT_TYPE', $_SERVER); - $this->assertArrayHasKey('CONTENT_LENGTH', $_SERVER); - - $request->initialize(array('foo' => 'bar', 'baz' => 'foo')); - $request->query->remove('baz'); - - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_GET); - $this->assertEquals('foo=bar', $_SERVER['QUERY_STRING']); - $this->assertEquals('foo=bar', $request->server->get('QUERY_STRING')); - - // restore initial $_SERVER array - $_SERVER = $server; - } - - public function testGetScriptName() - { - $request = new Request(); - $this->assertEquals('', $request->getScriptName()); - - $server = array(); - $server['SCRIPT_NAME'] = '/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/index.php', $request->getScriptName()); - - $server = array(); - $server['ORIG_SCRIPT_NAME'] = '/frontend.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/frontend.php', $request->getScriptName()); - - $server = array(); - $server['SCRIPT_NAME'] = '/index.php'; - $server['ORIG_SCRIPT_NAME'] = '/frontend.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/index.php', $request->getScriptName()); - } - - public function testGetBasePath() - { - $request = new Request(); - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['SCRIPT_NAME'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['PHP_SELF'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['ORIG_SCRIPT_NAME'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - } - - public function testGetPathInfo() - { - $request = new Request(); - $this->assertEquals('/', $request->getPathInfo()); - - $server = array(); - $server['REQUEST_URI'] = '/path/info'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/path/info', $request->getPathInfo()); - - $server = array(); - $server['REQUEST_URI'] = '/path%20test/info'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/path%20test/info', $request->getPathInfo()); - } - - public function testGetPreferredLanguage() - { - $request = new Request(); - $this->assertNull($request->getPreferredLanguage()); - $this->assertNull($request->getPreferredLanguage(array())); - $this->assertEquals('fr', $request->getPreferredLanguage(array('fr'))); - $this->assertEquals('fr', $request->getPreferredLanguage(array('fr', 'en'))); - $this->assertEquals('en', $request->getPreferredLanguage(array('en', 'fr'))); - $this->assertEquals('fr-ch', $request->getPreferredLanguage(array('fr-ch', 'fr-fr'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $this->assertEquals('en', $request->getPreferredLanguage(array('en', 'en-us'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8'); - $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, fr-fr; q=0.6, fr; q=0.5'); - $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en'))); - } - - public function testIsXmlHttpRequest() - { - $request = new Request(); - $this->assertFalse($request->isXmlHttpRequest()); - - $request->headers->set('X-Requested-With', 'XMLHttpRequest'); - $this->assertTrue($request->isXmlHttpRequest()); - - $request->headers->remove('X-Requested-With'); - $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(); - $this->assertEquals(array(), $request->getCharsets()); - $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6'); - $this->assertEquals(array(), $request->getCharsets()); // testing caching - - $request = new Request(); - $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6'); - $this->assertEquals(array('ISO-8859-1', 'US-ASCII', 'UTF-8', 'ISO-10646-UCS-2'), $request->getCharsets()); - - $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()); - } - - public function testGetEncodings() - { - $request = new Request(); - $this->assertEquals(array(), $request->getEncodings()); - $request->headers->set('Accept-Encoding', 'gzip,deflate,sdch'); - $this->assertEquals(array(), $request->getEncodings()); // testing caching - - $request = new Request(); - $request->headers->set('Accept-Encoding', 'gzip,deflate,sdch'); - $this->assertEquals(array('gzip', 'deflate', 'sdch'), $request->getEncodings()); - - $request = new Request(); - $request->headers->set('Accept-Encoding', 'gzip;q=0.4,deflate;q=0.9,compress;q=0.7'); - $this->assertEquals(array('deflate', 'compress', 'gzip'), $request->getEncodings()); - } - - public function testGetAcceptableContentTypes() - { - $request = new Request(); - $this->assertEquals(array(), $request->getAcceptableContentTypes()); - $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(), $request->getAcceptableContentTypes()); // testing caching - - $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('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() - { - $request = new Request(); - $this->assertEquals(array(), $request->getLanguages()); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $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()); - } - - public function testGetRequestFormat() - { - $request = new Request(); - $this->assertEquals('html', $request->getRequestFormat()); - - $request = new Request(); - $this->assertNull($request->getRequestFormat(null)); - - $request = new Request(); - $this->assertNull($request->setRequestFormat('foo')); - $this->assertEquals('foo', $request->getRequestFormat(null)); - } - - public function testHasSession() - { - $request = new Request(); - - $this->assertFalse($request->hasSession()); - $request->setSession(new Session(new MockArraySessionStorage())); - $this->assertTrue($request->hasSession()); - } - - public function testGetSession() - { - $request = new Request(); - - $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() - { - $request = new Request(); - - $this->assertFalse($request->hasPreviousSession()); - $request->cookies->set('MOCKSESSID', 'foo'); - $this->assertFalse($request->hasPreviousSession()); - $request->setSession(new Session(new MockArraySessionStorage())); - $this->assertTrue($request->hasPreviousSession()); - } - - public function testToString() - { - $request = new Request(); - - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - - $this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $request->__toString()); - } - - public function testIsMethod() - { - $request = new Request(); - $request->setMethod('POST'); - $this->assertTrue($request->isMethod('POST')); - $this->assertTrue($request->isMethod('post')); - $this->assertFalse($request->isMethod('GET')); - $this->assertFalse($request->isMethod('get')); - - $request->setMethod('GET'); - $this->assertTrue($request->isMethod('GET')); - $this->assertTrue($request->isMethod('get')); - $this->assertFalse($request->isMethod('POST')); - $this->assertFalse($request->isMethod('post')); - } - - /** - * @dataProvider getBaseUrlData - */ - public function testGetBaseUrl($uri, $server, $expectedBaseUrl, $expectedPathInfo) - { - $request = Request::create($uri, 'GET', array(), array(), array(), $server); - - $this->assertSame($expectedBaseUrl, $request->getBaseUrl(), 'baseUrl'); - $this->assertSame($expectedPathInfo, $request->getPathInfo(), 'pathInfo'); - } - - public function getBaseUrlData() - { - return array( - array( - '/fruit/strawberry/1234index.php/blah', - array( - 'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/fruit/index.php', - 'SCRIPT_NAME' => '/fruit/index.php', - 'PHP_SELF' => '/fruit/index.php', - ), - '/fruit', - '/strawberry/1234index.php/blah', - ), - array( - '/fruit/strawberry/1234index.php/blah', - array( - 'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/index.php', - 'SCRIPT_NAME' => '/index.php', - 'PHP_SELF' => '/index.php', - ), - '', - '/fruit/strawberry/1234index.php/blah', - ), - array( - '/foo%20bar/', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar', - '/', - ), - array( - '/foo%20bar/home', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar', - '/home', - ), - array( - '/foo%20bar/app.php/home', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar/app.php', - '/home', - ), - array( - '/foo%20bar/app.php/home%3Dbaz', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar/app.php', - '/home%3Dbaz', - ), - array( - '/foo/bar+baz', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app.php', - 'SCRIPT_NAME' => '/foo/app.php', - 'PHP_SELF' => '/foo/app.php', - ), - '/foo', - '/bar+baz', - ), - ); - } - - /** - * @dataProvider urlencodedStringPrefixData - */ - public function testUrlencodedStringPrefix($string, $prefix, $expect) - { - $request = new Request(); - - $me = new \ReflectionMethod($request, 'getUrlencodedPrefix'); - $me->setAccessible(true); - - $this->assertSame($expect, $me->invoke($request, $string, $prefix)); - } - - public function urlencodedStringPrefixData() - { - return array( - array('foo', 'foo', 'foo'), - array('fo%6f', 'foo', 'fo%6f'), - array('foo/bar', 'foo', 'foo'), - array('fo%6f/bar', 'foo', 'fo%6f'), - array('f%6f%6f/bar', 'foo', 'f%6f%6f'), - array('%66%6F%6F/bar', 'foo', '%66%6F%6F'), - array('fo+o/bar', 'fo+o', 'fo+o'), - array('fo%2Bo/bar', 'fo+o', 'fo%2Bo'), - ); - } - - private function disableHttpMethodParameterOverride() - { - $class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request'); - $property = $class->getProperty('httpMethodParameterOverride'); - $property->setAccessible(true); - $property->setValue(false); - } - - private function getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies) - { - $request = new Request(); - - $server = array('REMOTE_ADDR' => $remoteAddr); - if (null !== $httpForwardedFor) { - $server['HTTP_X_FORWARDED_FOR'] = $httpForwardedFor; - } - - if ($trustedProxies) { - Request::setTrustedProxies($trustedProxies); - } - - $request->initialize(array(), array(), array(), array(), array(), $server); - - return $request; - } - - 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()); - - // 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()); - - // trusted proxy via setTrustedProxies() - Request::setTrustedProxies(array('3.3.3.4', '2.2.2.2')); - $this->assertEquals('3.3.3.3', $request->getClientIp()); - $this->assertEquals('example.com', $request->getHost()); - $this->assertEquals(80, $request->getPort()); - $this->assertFalse($request->isSecure()); - - // check various X_FORWARDED_PROTO header values - Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2')); - $request->headers->set('X_FORWARDED_PROTO', 'ssl'); - $this->assertTrue($request->isSecure()); - - $request->headers->set('X_FORWARDED_PROTO', 'https, http'); - $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()); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_FORWARDED_FOR'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X_FORWARDED_HOST'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'X_FORWARDED_PORT'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X_FORWARDED_PROTO'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSetTrustedProxiesInvalidHeaderName() - { - Request::create('http://example.com/'); - Request::setTrustedHeaderName('bogus name', 'X_MY_FOR'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetTrustedProxiesInvalidHeaderName() - { - Request::create('http://example.com/'); - Request::getTrustedHeaderName('bogus name'); - } - - /** - * @dataProvider iisRequestUriProvider - */ - public function testIISRequestUri($headers, $server, $expectedRequestUri) - { - $request = new Request(); - $request->headers->replace($headers); - $request->server->replace($server); - - $this->assertEquals($expectedRequestUri, $request->getRequestUri(), '->getRequestUri() is correct'); - - $subRequestUri = '/bar/foo'; - $subRequest = Request::create($subRequestUri, 'get', array(), array(), array(), $request->server->all()); - $this->assertEquals($subRequestUri, $subRequest->getRequestUri(), '->getRequestUri() is correct in sub request'); - } - - public function iisRequestUriProvider() - { - return array( - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array(), - '/foo/bar', - ), - array( - array( - 'X_REWRITE_URL' => '/foo/bar', - ), - array(), - '/foo/bar', - ), - array( - array(), - array( - 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array( - 'HTTP_X_ORIGINAL_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array( - 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array( - 'HTTP_X_ORIGINAL_URL' => '/foo/bar', - 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array(), - array( - 'ORIG_PATH_INFO' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array(), - array( - 'ORIG_PATH_INFO' => '/foo/bar', - 'QUERY_STRING' => 'foo=bar', - ), - '/foo/bar?foo=bar', - ), - ); - } - - public function testTrustedHosts() - { - // create a request - $request = Request::create('/'); - - // no trusted host set -> no host check - $request->headers->set('host', 'evil.com'); - $this->assertEquals('evil.com', $request->getHost()); - - // add a trusted domain and all its subdomains - Request::setTrustedHosts(array('^([a-z]{9}\.)?trusted\.com$')); - - // untrusted host - $request->headers->set('host', 'evil.com'); - try { - $request->getHost(); - $this->fail('Request::getHost() should throw an exception when host is not trusted.'); - } catch (\UnexpectedValueException $e) { - $this->assertEquals('Untrusted Host "evil.com"', $e->getMessage()); - } - - // trusted hosts - $request->headers->set('host', 'trusted.com'); - $this->assertEquals('trusted.com', $request->getHost()); - $this->assertEquals(80, $request->getPort()); - - $request->server->set('HTTPS', true); - $request->headers->set('host', 'trusted.com'); - $this->assertEquals('trusted.com', $request->getHost()); - $this->assertEquals(443, $request->getPort()); - $request->server->set('HTTPS', false); - - $request->headers->set('host', 'trusted.com:8000'); - $this->assertEquals('trusted.com', $request->getHost()); - $this->assertEquals(8000, $request->getPort()); - - $request->headers->set('host', 'subdomain.trusted.com'); - $this->assertEquals('subdomain.trusted.com', $request->getHost()); - - // reset request for following tests - Request::setTrustedHosts(array()); - } - - public function testFactory() - { - Request::setFactory(function (array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) { - return new NewRequest(); - }); - - $this->assertEquals('foo', Request::create('/')->getFoo()); - - Request::setFactory(null); - } - - /** - * @dataProvider getLongHostNames - */ - public function testVeryLongHosts($host) - { - $start = microtime(true); - - $request = Request::create('/'); - $request->headers->set('host', $host); - $this->assertEquals($host, $request->getHost()); - $this->assertLessThan(1, microtime(true) - $start); - } - - /** - * @dataProvider getHostValidities - */ - public function testHostValidity($host, $isValid, $expectedHost = null, $expectedPort = null) - { - $request = Request::create('/'); - $request->headers->set('host', $host); - - if ($isValid) { - $this->assertSame($expectedHost ?: $host, $request->getHost()); - if ($expectedPort) { - $this->assertSame($expectedPort, $request->getPort()); - } - } else { - $this->setExpectedException('UnexpectedValueException', 'Invalid Host'); - $request->getHost(); - } - } - - public function getHostValidities() - { - return array( - array('.a', false), - array('a..', false), - array('a.', true), - array("\xE9", false), - array('[::1]', true), - array('[::1]:80', true, '[::1]', 80), - array(str_repeat('.', 101), false), - ); - } - - public function getLongHostNames() - { - return array( - array('a'.str_repeat('.a', 40000)), - array(str_repeat(':', 101)), - ); - } -} - -class RequestContentProxy extends Request -{ - public function getContent($asResource = false) - { - return http_build_query(array('_method' => 'PUT', 'content' => 'mycontent')); - } -} - -class NewRequest extends Request -{ - public function getFoo() - { - return 'foo'; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php deleted file mode 100644 index 0fa198e09..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ /dev/null @@ -1,297 +0,0 @@ - - * - * 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\ResponseHeaderBag; -use Symfony\Component\HttpFoundation\Cookie; - -require_once __DIR__.'/ClockMock.php'; - -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()); - $this->assertEquals('no-cache', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('no-cache')); - - $bag = new ResponseHeaderBag(array('Cache-Control' => 'public')); - $this->assertEquals('public', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('public')); - - $bag = new ResponseHeaderBag(array('ETag' => 'abcde')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('private')); - $this->assertTrue($bag->hasCacheControlDirective('must-revalidate')); - $this->assertFalse($bag->hasCacheControlDirective('max-age')); - - $bag = new ResponseHeaderBag(array('Expires' => 'Wed, 16 Feb 2011 14:17:43 GMT')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array( - 'Expires' => 'Wed, 16 Feb 2011 14:17:43 GMT', - 'Cache-Control' => 'max-age=3600', - )); - $this->assertEquals('max-age=3600, private', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('Last-Modified' => 'abcde')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('Etag' => 'abcde', 'Last-Modified' => 'abcde')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 'max-age=100')); - $this->assertEquals('max-age=100, private', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 's-maxage=100')); - $this->assertEquals('s-maxage=100', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 'private, max-age=100')); - $this->assertEquals('max-age=100, private', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 'public, max-age=100')); - $this->assertEquals('max-age=100, public', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(); - $bag->set('Last-Modified', 'abcde'); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - } - - public function testToStringIncludesCookieHeaders() - { - $bag = new ResponseHeaderBag(array()); - $bag->setCookie(new Cookie('foo', 'bar')); - - $this->assertContains('Set-Cookie: foo=bar; path=/; httponly', explode("\r\n", $bag->__toString())); - - $bag->clearCookie('foo'); - - $this->assertRegExp('#^Set-Cookie: foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; httponly#m', $bag->__toString()); - } - - public function testClearCookieSecureNotHttpOnly() - { - $bag = new ResponseHeaderBag(array()); - - $bag->clearCookie('foo', '/', null, true, false); - - $this->assertRegExp('#^Set-Cookie: foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; path=/; secure#m', $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(); - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/foo', 'foo.bar')); - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'foo.bar')); - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'bar.foo')); - $bag->setCookie(new Cookie('foo', 'bar')); - - $this->assertCount(4, $bag->getCookies()); - - $headers = explode("\r\n", $bag->__toString()); - $this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers); - $this->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers); - $this->assertContains('Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly', $headers); - $this->assertContains('Set-Cookie: foo=bar; path=/; httponly', $headers); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo'])); - $this->assertTrue(isset($cookies['foo.bar']['/path/bar']['foo'])); - $this->assertTrue(isset($cookies['bar.foo']['/path/bar']['foo'])); - $this->assertTrue(isset($cookies['']['/']['foo'])); - } - - public function testRemoveCookie() - { - $bag = new ResponseHeaderBag(); - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/foo', 'foo.bar')); - $bag->setCookie(new Cookie('bar', 'foo', 0, '/path/bar', 'foo.bar')); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertTrue(isset($cookies['foo.bar']['/path/foo'])); - - $bag->removeCookie('foo', '/path/foo', 'foo.bar'); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertFalse(isset($cookies['foo.bar']['/path/foo'])); - - $bag->removeCookie('bar', '/path/bar', 'foo.bar'); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $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 - */ - public function testMakeDispositionInvalidDisposition() - { - $headers = new ResponseHeaderBag(); - - $headers->makeDisposition('invalid', 'foo.html'); - } - - /** - * @dataProvider provideMakeDisposition - */ - public function testMakeDisposition($disposition, $filename, $filenameFallback, $expected) - { - $headers = new ResponseHeaderBag(); - - $this->assertEquals($expected, $headers->makeDisposition($disposition, $filename, $filenameFallback)); - } - - public function testToStringDoesntMessUpHeaders() - { - $headers = new ResponseHeaderBag(); - - $headers->set('Location', 'http://www.symfony.com'); - $headers->set('Content-type', 'text/html'); - - (string) $headers; - - $allHeaders = $headers->allPreserveCase(); - $this->assertEquals(array('http://www.symfony.com'), $allHeaders['Location']); - $this->assertEquals(array('text/html'), $allHeaders['Content-type']); - } - - public function provideMakeDisposition() - { - return array( - array('attachment', 'foo.html', 'foo.html', 'attachment; filename="foo.html"'), - array('attachment', 'foo.html', '', 'attachment; filename="foo.html"'), - array('attachment', 'foo bar.html', '', 'attachment; filename="foo bar.html"'), - array('attachment', 'foo "bar".html', '', 'attachment; filename="foo \\"bar\\".html"'), - array('attachment', 'foo%20bar.html', 'foo bar.html', 'attachment; filename="foo bar.html"; filename*=utf-8\'\'foo%2520bar.html'), - array('attachment', 'föö.html', 'foo.html', 'attachment; filename="foo.html"; filename*=utf-8\'\'f%C3%B6%C3%B6.html'), - ); - } - - /** - * @dataProvider provideMakeDispositionFail - * @expectedException \InvalidArgumentException - */ - public function testMakeDispositionFail($disposition, $filename) - { - $headers = new ResponseHeaderBag(); - - $headers->makeDisposition($disposition, $filename); - } - - public function provideMakeDispositionFail() - { - return array( - array('attachment', 'foo%20bar.html'), - array('attachment', 'foo/bar.html'), - array('attachment', '/foo.html'), - array('attachment', 'foo\bar.html'), - array('attachment', '\foo.html'), - array('attachment', 'föö.html'), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php deleted file mode 100644 index 4319a39c2..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ /dev/null @@ -1,874 +0,0 @@ - - * - * 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\Request; -use Symfony\Component\HttpFoundation\Response; - -class ResponseTest extends ResponseTestCase -{ - public function testCreate() - { - $response = Response::create('foo', 301, array('Foo' => 'bar')); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - $this->assertEquals(301, $response->getStatusCode()); - $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 testIsCacheableWithErrorCode() - { - $response = new Response('', 500); - $this->assertFalse($response->isCacheable()); - } - - public function testIsCacheableWithNoStoreDirective() - { - $response = new Response(); - $response->headers->set('cache-control', 'private'); - $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 testIsNotModifiedNotSafe() - { - $request = Request::create('/homepage', 'POST'); - - $response = new Response(); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsNotModifiedLastModified() - { - $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; - $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; - $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; - - $request = new Request(); - $request->headers->set('If-Modified-Since', $modified); - - $response = new Response(); - - $response->headers->set('Last-Modified', $modified); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('Last-Modified', $before); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('Last-Modified', $after); - $this->assertFalse($response->isNotModified($request)); - - $response->headers->set('Last-Modified', ''); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsNotModifiedEtag() - { - $etagOne = 'randomly_generated_etag'; - $etagTwo = 'randomly_generated_etag_2'; - - $request = new Request(); - $request->headers->set('if_none_match', sprintf('%s, %s, %s', $etagOne, $etagTwo, 'etagThree')); - - $response = new Response(); - - $response->headers->set('ETag', $etagOne); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('ETag', $etagTwo); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('ETag', ''); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsNotModifiedLastModifiedAndEtag() - { - $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; - $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; - $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; - $etag = 'randomly_generated_etag'; - - $request = new Request(); - $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); - $request->headers->set('If-Modified-Since', $modified); - - $response = new Response(); - - $response->headers->set('ETag', $etag); - $response->headers->set('Last-Modified', $after); - $this->assertFalse($response->isNotModified($request)); - - $response->headers->set('ETag', 'non-existent-etag'); - $response->headers->set('Last-Modified', $before); - $this->assertFalse($response->isNotModified($request)); - - $response->headers->set('ETag', $etag); - $response->headers->set('Last-Modified', $modified); - $this->assertTrue($response->isNotModified($request)); - } - - public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified() - { - $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; - $etag = 'randomly_generated_etag'; - - $request = new Request(); - $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); - $request->headers->set('If-Modified-Since', $modified); - - $response = new Response(); - - $response->headers->set('ETag', $etag); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('ETag', 'non-existent-etag'); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsValidateable() - { - $response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $this->assertTrue($response->isValidateable(), '->isValidateable() returns true if Last-Modified is present'); - - $response = new Response('', 200, array('ETag' => '"12345"')); - $this->assertTrue($response->isValidateable(), '->isValidateable() returns true if ETag is present'); - - $response = new Response(); - $this->assertFalse($response->isValidateable(), '->isValidateable() returns false when no validator is present'); - } - - public function testGetDate() - { - $oneHourAgo = $this->createDateTimeOneHourAgo(); - $response = new Response('', 200, array('Date' => $oneHourAgo->format(DATE_RFC2822))); - $this->assertEquals(0, $oneHourAgo->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present'); - - $response = new Response(); - $date = $response->getDate(); - $this->assertLessThan(1, $date->diff(new \DateTime(), true)->format('%s'), '->getDate() returns the current Date if no Date header present'); - - $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $now = $this->createDateTimeNow(); - $response->headers->set('Date', $now->format(DATE_RFC2822)); - $this->assertLessThanOrEqual(1, $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() - { - $response = new Response(); - $response->headers->set('Cache-Control', 's-maxage=600, max-age=0'); - $this->assertEquals(600, $response->getMaxAge(), '->getMaxAge() uses s-maxage cache control directive when present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=600'); - $this->assertEquals(600, $response->getMaxAge(), '->getMaxAge() falls back to max-age when no s-maxage directive present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'must-revalidate'); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertLessThanOrEqual(1, $response->getMaxAge() - 3600, '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'must-revalidate'); - $response->headers->set('Expires', -1); - $this->assertEquals('Sat, 01 Jan 00 00:00:00 +0000', $response->getExpires()->format(DATE_RFC822)); - - $response = new Response(); - $this->assertNull($response->getMaxAge(), '->getMaxAge() returns null if no freshness information available'); - } - - public function testSetSharedMaxAge() - { - $response = new Response(); - $response->setSharedMaxAge(20); - - $cacheControl = $response->headers->get('Cache-Control'); - $this->assertEquals('public, s-maxage=20', $cacheControl); - } - - public function testIsPrivate() - { - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100'); - $response->setPrivate(); - $this->assertEquals(100, $response->headers->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertTrue($response->headers->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'public, max-age=100'); - $response->setPrivate(); - $this->assertEquals(100, $response->headers->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertTrue($response->headers->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertFalse($response->headers->hasCacheControlDirective('public'), '->isPrivate() removes the public Cache-Control directive'); - } - - public function testExpire() - { - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100'); - $response->expire(); - $this->assertEquals(100, $response->headers->get('Age'), '->expire() sets the Age to max-age when present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100, s-maxage=500'); - $response->expire(); - $this->assertEquals(500, $response->headers->get('Age'), '->expire() sets the Age to s-maxage when both max-age and s-maxage are present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=5, s-maxage=500'); - $response->headers->set('Age', '1000'); - $response->expire(); - $this->assertEquals(1000, $response->headers->get('Age'), '->expire() does nothing when the response is already stale/expired'); - - $response = new Response(); - $response->expire(); - $this->assertFalse($response->headers->has('Age'), '->expire() does nothing when the response does not include freshness information'); - - $response = new Response(); - $response->headers->set('Expires', -1); - $response->expire(); - $this->assertNull($response->headers->get('Age'), '->expire() does not set the Age when the response is expired'); - } - - public function testGetTtl() - { - $response = new Response(); - $this->assertNull($response->getTtl(), '->getTtl() returns null when no Expires or Cache-Control headers are present'); - - $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertLessThanOrEqual(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); - - $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)); - $this->assertLessThan(0, $response->getTtl(), '->getTtl() returns negative values when Expires is in past'); - - $response = new Response(); - $response->headers->set('Expires', $response->getDate()->format(DATE_RFC2822)); - $response->headers->set('Age', 0); - $this->assertSame(0, $response->getTtl(), '->getTtl() correctly handles zero'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=60'); - $this->assertLessThan(1, 60 - $response->getTtl(), '->getTtl() uses Cache-Control max-age when present'); - } - - public function testSetClientTtl() - { - $response = new Response(); - $response->setClientTtl(10); - - $this->assertEquals($response->getMaxAge(), $response->getAge() + 10); - } - - public function testGetSetProtocolVersion() - { - $response = new Response(); - - $this->assertEquals('1.0', $response->getProtocolVersion()); - - $response->setProtocolVersion('1.1'); - - $this->assertEquals('1.1', $response->getProtocolVersion()); - } - - public function testGetVary() - { - $response = new Response(); - $this->assertEquals(array(), $response->getVary(), '->getVary() returns an empty array if no Vary header is present'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language'); - $this->assertEquals(array('Accept-Language'), $response->getVary(), '->getVary() parses a single header name value'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language User-Agent X-Foo'); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by spaces'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language,User-Agent, X-Foo'); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by commas'); - - $vary = array('Accept-Language', 'User-Agent', 'X-foo'); - - $response = new Response(); - $response->headers->set('Vary', $vary); - $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language, User-Agent, X-foo'); - $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); - } - - public function testSetVary() - { - $response = new Response(); - $response->setVary('Accept-Language'); - $this->assertEquals(array('Accept-Language'), $response->getVary()); - - $response->setVary('Accept-Language, User-Agent'); - $this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() replace the vary header by default'); - - $response->setVary('X-Foo', false); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false'); - } - - public function testDefaultContentType() - { - $headerMock = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag', array('set')); - $headerMock->expects($this->at(0)) - ->method('set') - ->with('Content-Type', 'text/html'); - $headerMock->expects($this->at(1)) - ->method('set') - ->with('Content-Type', 'text/html; charset=UTF-8'); - - $response = new Response('foo'); - $response->headers = $headerMock; - - $response->prepare(new Request()); - } - - public function testContentTypeCharset() - { - $response = new Response(); - $response->headers->set('Content-Type', 'text/css'); - - // force fixContentType() to be called - $response->prepare(new Request()); - - $this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type')); - } - - public function testPrepareDoesNothingIfContentTypeIsSet() - { - $response = new Response('foo'); - $response->headers->set('Content-Type', 'text/plain'); - - $response->prepare(new Request()); - - $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('content-type')); - } - - public function testPrepareDoesNothingIfRequestFormatIsNotDefined() - { - $response = new Response('foo'); - - $response->prepare(new Request()); - - $this->assertEquals('text/html; charset=UTF-8', $response->headers->get('content-type')); - } - - public function testPrepareSetContentType() - { - $response = new Response('foo'); - $request = Request::create('/'); - $request->setRequestFormat('json'); - - $response->prepare($request); - - $this->assertEquals('application/json', $response->headers->get('content-type')); - } - - public function testPrepareRemovesContentForHeadRequests() - { - $response = new Response('foo'); - $request = Request::create('/', 'HEAD'); - - $length = 12345; - $response->headers->set('Content-Length', $length); - $response->prepare($request); - - $this->assertEquals('', $response->getContent()); - $this->assertEquals($length, $response->headers->get('Content-Length'), 'Content-Length should be as if it was GET; see RFC2616 14.13'); - } - - public function testPrepareRemovesContentForInformationalResponse() - { - $response = new Response('foo'); - $request = Request::create('/'); - - $response->setContent('content'); - $response->setStatusCode(101); - $response->prepare($request); - $this->assertEquals('', $response->getContent()); - $this->assertFalse($response->headers->has('Content-Type')); - $this->assertFalse($response->headers->has('Content-Type')); - - $response->setContent('content'); - $response->setStatusCode(304); - $response->prepare($request); - $this->assertEquals('', $response->getContent()); - $this->assertFalse($response->headers->has('Content-Type')); - $this->assertFalse($response->headers->has('Content-Length')); - } - - public function testPrepareRemovesContentLength() - { - $response = new Response('foo'); - $request = Request::create('/'); - - $response->headers->set('Content-Length', 12345); - $response->prepare($request); - $this->assertEquals(12345, $response->headers->get('Content-Length')); - - $response->headers->set('Transfer-Encoding', 'chunked'); - $response->prepare($request); - $this->assertFalse($response->headers->has('Content-Length')); - } - - public function testPrepareSetsPragmaOnHttp10Only() - { - $request = Request::create('/', 'GET'); - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0'); - - $response = new Response('foo'); - $response->prepare($request); - $this->assertEquals('no-cache', $response->headers->get('pragma')); - $this->assertEquals('-1', $response->headers->get('expires')); - - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1'); - $response = new Response('foo'); - $response->prepare($request); - $this->assertFalse($response->headers->has('pragma')); - $this->assertFalse($response->headers->has('expires')); - } - - public function testSetCache() - { - $response = new Response(); - //array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public') - try { - $response->setCache(array('wrong option' => 'value')); - $this->fail('->setCache() throws an InvalidArgumentException if an option is not supported'); - } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported'); - $this->assertContains('"wrong option"', $e->getMessage()); - } - - $options = array('etag' => '"whatever"'); - $response->setCache($options); - $this->assertEquals($response->getEtag(), '"whatever"'); - - $now = new \DateTime(); - $options = array('last_modified' => $now); - $response->setCache($options); - $this->assertEquals($response->getLastModified()->getTimestamp(), $now->getTimestamp()); - - $options = array('max_age' => 100); - $response->setCache($options); - $this->assertEquals($response->getMaxAge(), 100); - - $options = array('s_maxage' => 200); - $response->setCache($options); - $this->assertEquals($response->getMaxAge(), 200); - - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('public' => true)); - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('public' => false)); - $this->assertFalse($response->headers->hasCacheControlDirective('public')); - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('private' => true)); - $this->assertFalse($response->headers->hasCacheControlDirective('public')); - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('private' => false)); - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - } - - public function testSendContent() - { - $response = new Response('test response rendering', 200); - - ob_start(); - $response->sendContent(); - $string = ob_get_clean(); - $this->assertContains('test response rendering', $string); - } - - public function testSetPublic() - { - $response = new Response(); - $response->setPublic(); - - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - } - - public function testSetExpires() - { - $response = new Response(); - $response->setExpires(null); - - $this->assertNull($response->getExpires(), '->setExpires() remove the header when passed null'); - - $now = new \DateTime(); - $response->setExpires($now); - - $this->assertEquals($response->getExpires()->getTimestamp(), $now->getTimestamp()); - } - - public function testSetLastModified() - { - $response = new Response(); - $response->setLastModified(new \DateTime()); - $this->assertNotNull($response->getLastModified()); - - $response->setLastModified(null); - $this->assertNull($response->getLastModified()); - } - - public function testIsInvalid() - { - $response = new Response(); - - try { - $response->setStatusCode(99); - $this->fail(); - } catch (\InvalidArgumentException $e) { - $this->assertTrue($response->isInvalid()); - } - - try { - $response->setStatusCode(650); - $this->fail(); - } catch (\InvalidArgumentException $e) { - $this->assertTrue($response->isInvalid()); - } - - $response = new Response('', 200); - $this->assertFalse($response->isInvalid()); - } - - /** - * @dataProvider getStatusCodeFixtures - */ - public function testSetStatusCode($code, $text, $expectedText) - { - $response = new Response(); - - $response->setStatusCode($code, $text); - - $statusText = new \ReflectionProperty($response, 'statusText'); - $statusText->setAccessible(true); - - $this->assertEquals($expectedText, $statusText->getValue($response)); - } - - public function getStatusCodeFixtures() - { - return array( - array('200', null, 'OK'), - array('200', false, ''), - array('200', 'foo', 'foo'), - array('199', null, ''), - array('199', false, ''), - array('199', 'foo', 'foo'), - ); - } - - public function testIsInformational() - { - $response = new Response('', 100); - $this->assertTrue($response->isInformational()); - - $response = new Response('', 200); - $this->assertFalse($response->isInformational()); - } - - public function testIsRedirectRedirection() - { - foreach (array(301, 302, 303, 307) as $code) { - $response = new Response('', $code); - $this->assertTrue($response->isRedirection()); - $this->assertTrue($response->isRedirect()); - } - - $response = new Response('', 304); - $this->assertTrue($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 200); - $this->assertFalse($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 404); - $this->assertFalse($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 301, array('Location' => '/good-uri')); - $this->assertFalse($response->isRedirect('/bad-uri')); - $this->assertTrue($response->isRedirect('/good-uri')); - } - - public function testIsNotFound() - { - $response = new Response('', 404); - $this->assertTrue($response->isNotFound()); - - $response = new Response('', 200); - $this->assertFalse($response->isNotFound()); - } - - public function testIsEmpty() - { - foreach (array(204, 304) as $code) { - $response = new Response('', $code); - $this->assertTrue($response->isEmpty()); - } - - $response = new Response('', 200); - $this->assertFalse($response->isEmpty()); - } - - public function testIsForbidden() - { - $response = new Response('', 403); - $this->assertTrue($response->isForbidden()); - - $response = new Response('', 200); - $this->assertFalse($response->isForbidden()); - } - - public function testIsOk() - { - $response = new Response('', 200); - $this->assertTrue($response->isOk()); - - $response = new Response('', 404); - $this->assertFalse($response->isOk()); - } - - public function testIsServerOrClientError() - { - $response = new Response('', 404); - $this->assertTrue($response->isClientError()); - $this->assertFalse($response->isServerError()); - - $response = new Response('', 500); - $this->assertFalse($response->isClientError()); - $this->assertTrue($response->isServerError()); - } - - public function testHasVary() - { - $response = new Response(); - $this->assertFalse($response->hasVary()); - - $response->setVary('User-Agent'); - $this->assertTrue($response->hasVary()); - } - - public function testSetEtag() - { - $response = new Response('', 200, array('ETag' => '"12345"')); - $response->setEtag(); - - $this->assertNull($response->headers->get('Etag'), '->setEtag() removes Etags when call with null'); - } - - /** - * @dataProvider validContentProvider - */ - public function testSetContent($content) - { - $response = new Response(); - $response->setContent($content); - $this->assertEquals((string) $content, $response->getContent()); - } - - /** - * @expectedException \UnexpectedValueException - * @dataProvider invalidContentProvider - */ - public function testSetContentInvalid($content) - { - $response = new Response(); - $response->setContent($content); - } - - public function testSettersAreChainable() - { - $response = new Response(); - - $setters = array( - 'setProtocolVersion' => '1.0', - 'setCharset' => 'UTF-8', - 'setPublic' => null, - 'setPrivate' => null, - 'setDate' => new \DateTime(), - 'expire' => null, - 'setMaxAge' => 1, - 'setSharedMaxAge' => 1, - 'setTtl' => 1, - 'setClientTtl' => 1, - ); - - foreach ($setters as $setter => $arg) { - $this->assertEquals($response, $response->{$setter}($arg)); - } - } - - public function validContentProvider() - { - return array( - 'obj' => array(new StringableObject()), - 'string' => array('Foo'), - 'int' => array(2), - ); - } - - public function invalidContentProvider() - { - return array( - 'obj' => array(new \stdClass()), - 'array' => array(array()), - 'bool' => array(true, '1'), - ); - } - - protected function createDateTimeOneHourAgo() - { - $date = new \DateTime(); - - return $date->sub(new \DateInterval('PT1H')); - } - - protected function createDateTimeOneHourLater() - { - $date = new \DateTime(); - - return $date->add(new \DateInterval('PT1H')); - } - - protected function createDateTimeNow() - { - return new \DateTime(); - } - - protected function provideResponse() - { - return new Response(); - } -} - -class StringableObject -{ - public function __toString() - { - return 'Foo'; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php deleted file mode 100644 index 94c770a89..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * 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\Request; - -abstract class ResponseTestCase extends \PHPUnit_Framework_TestCase -{ - public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE() - { - // Check for HTTPS and IE 8 - $request = new Request(); - $request->server->set('HTTPS', true); - $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertFalse($response->headers->has('Cache-Control')); - - // Check for IE 10 and HTTPS - $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for IE 9 and HTTPS - $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for IE 9 and HTTP - $request->server->set('HTTPS', false); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for IE 8 and HTTP - $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for non-IE and HTTPS - $request->server->set('HTTPS', true); - $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for non-IE and HTTP - $request->server->set('HTTPS', false); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - } - - abstract protected function provideResponse(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php deleted file mode 100644 index 20773c4d7..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * 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\ServerBag; - -/** - * ServerBagTest. - * - * @author Bulat Shakirzyanov - */ -class ServerBagTest extends \PHPUnit_Framework_TestCase -{ - public function testShouldExtractHeadersFromServerArray() - { - $server = array( - 'SOME_SERVER_VARIABLE' => 'value', - 'SOME_SERVER_VARIABLE2' => 'value', - 'ROOT' => 'value', - 'HTTP_CONTENT_TYPE' => 'text/html', - 'HTTP_CONTENT_LENGTH' => '0', - 'HTTP_ETAG' => 'asdf', - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar', - ); - - $bag = new ServerBag($server); - - $this->assertEquals(array( - 'CONTENT_TYPE' => 'text/html', - 'CONTENT_LENGTH' => '0', - 'ETAG' => 'asdf', - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar', - ), $bag->getHeaders()); - } - - public function testHttpPasswordIsOptional() - { - $bag = new ServerBag(array('PHP_AUTH_USER' => 'foo')); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '', - ), $bag->getHeaders()); - } - - public function testHttpBasicAuthWithPhpCgi() - { - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'))); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar', - ), $bag->getHeaders()); - } - - public function testHttpBasicAuthWithPhpCgiBogus() - { - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'))); - - // Username and passwords should not be set as the header is bogus - $headers = $bag->getHeaders(); - $this->assertFalse(isset($headers['PHP_AUTH_USER'])); - $this->assertFalse(isset($headers['PHP_AUTH_PW'])); - } - - public function testHttpBasicAuthWithPhpCgiRedirect() - { - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'))); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'), - 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'pass:word', - ), $bag->getHeaders()); - } - - public function testHttpBasicAuthWithPhpCgiEmptyPassword() - { - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:'))); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '', - ), $bag->getHeaders()); - } - - public function testHttpDigestAuthWithPhpCgi() - { - $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $digest, - 'PHP_AUTH_DIGEST' => $digest, - ), $bag->getHeaders()); - } - - public function testHttpDigestAuthWithPhpCgiBogus() - { - $digest = 'Digest_username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); - - // Username and passwords should not be set as the header is bogus - $headers = $bag->getHeaders(); - $this->assertFalse(isset($headers['PHP_AUTH_USER'])); - $this->assertFalse(isset($headers['PHP_AUTH_PW'])); - } - - public function testHttpDigestAuthWithPhpCgiRedirect() - { - $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => $digest)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $digest, - 'PHP_AUTH_DIGEST' => $digest, - ), $bag->getHeaders()); - } - - public function testOAuthBearerAuth() - { - $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo'; - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $headerContent)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $headerContent, - ), $bag->getHeaders()); - } - - public function testOAuthBearerAuthWithRedirect() - { - $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo'; - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => $headerContent)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $headerContent, - ), $bag->getHeaders()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php deleted file mode 100644 index 5515003b4..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php +++ /dev/null @@ -1,193 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Attribute; - -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Tests AttributeBag. - * - * @author Drak - */ -class AttributeBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var array - */ - private $array; - - /** - * @var AttributeBag - */ - private $bag; - - protected function setUp() - { - $this->array = array( - 'hello' => 'world', - 'always' => 'be happy', - 'user.login' => 'drak', - 'csrf.token' => array( - 'a' => '1234', - 'b' => '4321', - ), - 'category' => array( - 'fishing' => array( - 'first' => 'cod', - 'second' => 'sole',), - ), - ); - $this->bag = new AttributeBag('_sf2'); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - $this->array = array(); - } - - public function testInitialize() - { - $bag = new AttributeBag(); - $bag->initialize($this->array); - $this->assertEquals($this->array, $bag->all()); - $array = array('should' => 'change'); - $bag->initialize($array); - $this->assertEquals($array, $bag->all()); - } - - public function testGetStorageKey() - { - $this->assertEquals('_sf2', $this->bag->getStorageKey()); - $attributeBag = new AttributeBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - public function testGetSetName() - { - $this->assertEquals('attributes', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - /** - * @dataProvider attributesProvider - */ - public function testHas($key, $value, $exists) - { - $this->assertEquals($exists, $this->bag->has($key)); - } - - /** - * @dataProvider attributesProvider - */ - public function testGet($key, $value, $expected) - { - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testGetDefaults() - { - $this->assertNull($this->bag->get('user2.login')); - $this->assertEquals('default', $this->bag->get('user2.login', 'default')); - } - - /** - * @dataProvider attributesProvider - */ - public function testSet($key, $value, $expected) - { - $this->bag->set($key, $value); - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testAll() - { - $this->assertEquals($this->array, $this->bag->all()); - - $this->bag->set('hello', 'fabien'); - $array = $this->array; - $array['hello'] = 'fabien'; - $this->assertEquals($array, $this->bag->all()); - } - - public function testReplace() - { - $array = array(); - $array['name'] = 'jack'; - $array['foo.bar'] = 'beep'; - $this->bag->replace($array); - $this->assertEquals($array, $this->bag->all()); - $this->assertNull($this->bag->get('hello')); - $this->assertNull($this->bag->get('always')); - $this->assertNull($this->bag->get('user.login')); - } - - public function testRemove() - { - $this->assertEquals('world', $this->bag->get('hello')); - $this->bag->remove('hello'); - $this->assertNull($this->bag->get('hello')); - - $this->assertEquals('be happy', $this->bag->get('always')); - $this->bag->remove('always'); - $this->assertNull($this->bag->get('always')); - - $this->assertEquals('drak', $this->bag->get('user.login')); - $this->bag->remove('user.login'); - $this->assertNull($this->bag->get('user.login')); - } - - public function testClear() - { - $this->bag->clear(); - $this->assertEquals(array(), $this->bag->all()); - } - - public function attributesProvider() - { - return array( - array('hello', 'world', true), - array('always', 'be happy', true), - array('user.login', 'drak', true), - array('csrf.token', array('a' => '1234', 'b' => '4321'), true), - array('category', array('fishing' => array('first' => 'cod', 'second' => 'sole')), true), - array('user2.login', null, false), - array('never', null, false), - array('bye', null, false), - array('bye/for/now', null, false), - ); - } - - /** - * @covers Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::getIterator - */ - public function testGetIterator() - { - $i = 0; - foreach ($this->bag as $key => $val) { - $this->assertEquals($this->array[$key], $val); - ++$i; - } - - $this->assertEquals(count($this->array), $i); - } - - /** - * @covers Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag::count - */ - public function testCount() - { - $this->assertEquals(count($this->array), count($this->bag)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php deleted file mode 100644 index b8261da5d..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ /dev/null @@ -1,183 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Attribute; - -use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag; - -/** - * Tests NamespacedAttributeBag. - * - * @author Drak - */ -class NamespacedAttributeBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var array - */ - private $array; - - /** - * @var NamespacedAttributeBag - */ - private $bag; - - protected function setUp() - { - $this->array = array( - 'hello' => 'world', - 'always' => 'be happy', - 'user.login' => 'drak', - 'csrf.token' => array( - 'a' => '1234', - 'b' => '4321', - ), - 'category' => array( - 'fishing' => array( - 'first' => 'cod', - 'second' => 'sole',), - ), - ); - $this->bag = new NamespacedAttributeBag('_sf2', '/'); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - $this->array = array(); - } - - public function testInitialize() - { - $bag = new NamespacedAttributeBag(); - $bag->initialize($this->array); - $this->assertEquals($this->array, $this->bag->all()); - $array = array('should' => 'not stick'); - $bag->initialize($array); - - // should have remained the same - $this->assertEquals($this->array, $this->bag->all()); - } - - public function testGetStorageKey() - { - $this->assertEquals('_sf2', $this->bag->getStorageKey()); - $attributeBag = new NamespacedAttributeBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - /** - * @dataProvider attributesProvider - */ - public function testHas($key, $value, $exists) - { - $this->assertEquals($exists, $this->bag->has($key)); - } - - /** - * @dataProvider attributesProvider - */ - public function testGet($key, $value, $expected) - { - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testGetDefaults() - { - $this->assertNull($this->bag->get('user2.login')); - $this->assertEquals('default', $this->bag->get('user2.login', 'default')); - } - - /** - * @dataProvider attributesProvider - */ - public function testSet($key, $value, $expected) - { - $this->bag->set($key, $value); - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testAll() - { - $this->assertEquals($this->array, $this->bag->all()); - - $this->bag->set('hello', 'fabien'); - $array = $this->array; - $array['hello'] = 'fabien'; - $this->assertEquals($array, $this->bag->all()); - } - - public function testReplace() - { - $array = array(); - $array['name'] = 'jack'; - $array['foo.bar'] = 'beep'; - $this->bag->replace($array); - $this->assertEquals($array, $this->bag->all()); - $this->assertNull($this->bag->get('hello')); - $this->assertNull($this->bag->get('always')); - $this->assertNull($this->bag->get('user.login')); - } - - public function testRemove() - { - $this->assertEquals('world', $this->bag->get('hello')); - $this->bag->remove('hello'); - $this->assertNull($this->bag->get('hello')); - - $this->assertEquals('be happy', $this->bag->get('always')); - $this->bag->remove('always'); - $this->assertNull($this->bag->get('always')); - - $this->assertEquals('drak', $this->bag->get('user.login')); - $this->bag->remove('user.login'); - $this->assertNull($this->bag->get('user.login')); - } - - public function testRemoveExistingNamespacedAttribute() - { - $this->assertSame('cod', $this->bag->remove('category/fishing/first')); - } - - public function testRemoveNonexistingNamespacedAttribute() - { - $this->assertNull($this->bag->remove('foo/bar/baz')); - } - - public function testClear() - { - $this->bag->clear(); - $this->assertEquals(array(), $this->bag->all()); - } - - public function attributesProvider() - { - return array( - array('hello', 'world', true), - array('always', 'be happy', true), - array('user.login', 'drak', true), - array('csrf.token', array('a' => '1234', 'b' => '4321'), true), - array('csrf.token/a', '1234', true), - array('csrf.token/b', '4321', true), - array('category', array('fishing' => array('first' => 'cod', 'second' => 'sole')), true), - array('category/fishing', array('first' => 'cod', 'second' => 'sole'), true), - array('category/fishing/missing/first', null, false), - array('category/fishing/first', 'cod', true), - array('category/fishing/second', 'sole', true), - array('category/fishing/missing/second', null, false), - array('user2.login', null, false), - array('never', null, false), - array('bye', null, false), - array('bye/for/now', null, false), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/AutoExpireFlashBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/AutoExpireFlashBagTest.php deleted file mode 100644 index 852158f18..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/AutoExpireFlashBagTest.php +++ /dev/null @@ -1,155 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Flash; - -use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag as FlashBag; - -/** - * AutoExpireFlashBagTest. - * - * @author Drak - */ -class AutoExpireFlashBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag - */ - private $bag; - - /** - * @var array - */ - protected $array = array(); - - protected function setUp() - { - parent::setUp(); - $this->bag = new FlashBag(); - $this->array = array('new' => array('notice' => array('A previous flash message'))); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - parent::tearDown(); - } - - public function testInitialize() - { - $bag = new FlashBag(); - $array = array('new' => array('notice' => array('A previous flash message'))); - $bag->initialize($array); - $this->assertEquals(array('A previous flash message'), $bag->peek('notice')); - $array = array('new' => array( - 'notice' => array('Something else'), - 'error' => array('a'), - )); - $bag->initialize($array); - $this->assertEquals(array('Something else'), $bag->peek('notice')); - $this->assertEquals(array('a'), $bag->peek('error')); - } - - public function testGetStorageKey() - { - $this->assertEquals('_sf2_flashes', $this->bag->getStorageKey()); - $attributeBag = new FlashBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - public function testGetSetName() - { - $this->assertEquals('flashes', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - public function testPeek() - { - $this->assertEquals(array(), $this->bag->peek('non_existing')); - $this->assertEquals(array('default'), $this->bag->peek('non_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - } - - public function testSet() - { - $this->bag->set('notice', 'Foo'); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - } - - public function testHas() - { - $this->assertFalse($this->bag->has('nothing')); - $this->assertTrue($this->bag->has('notice')); - } - - public function testKeys() - { - $this->assertEquals(array('notice'), $this->bag->keys()); - } - - public function testPeekAll() - { - $array = array( - 'new' => array( - 'notice' => 'Foo', - 'error' => 'Bar', - ), - ); - - $this->bag->initialize($array); - $this->assertEquals(array( - 'notice' => 'Foo', - 'error' => 'Bar', - ), $this->bag->peekAll() - ); - - $this->assertEquals(array( - 'notice' => 'Foo', - 'error' => 'Bar', - ), $this->bag->peekAll() - ); - } - - public function testGet() - { - $this->assertEquals(array(), $this->bag->get('non_existing')); - $this->assertEquals(array('default'), $this->bag->get('non_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->get('notice')); - $this->assertEquals(array(), $this->bag->get('notice')); - } - - public function testSetAll() - { - $this->bag->setAll(array('a' => 'first', 'b' => 'second')); - $this->assertFalse($this->bag->has('a')); - $this->assertFalse($this->bag->has('b')); - } - - public function testAll() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('error', 'Bar'); - $this->assertEquals(array( - 'notice' => array('A previous flash message'), - ), $this->bag->all() - ); - - $this->assertEquals(array(), $this->bag->all()); - } - - public function testClear() - { - $this->assertEquals(array('notice' => array('A previous flash message')), $this->bag->clear()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php deleted file mode 100644 index c42459175..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Flash; - -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; - -/** - * FlashBagTest. - * - * @author Drak - */ -class FlashBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface - */ - private $bag; - - /** - * @var array - */ - protected $array = array(); - - protected function setUp() - { - parent::setUp(); - $this->bag = new FlashBag(); - $this->array = array('notice' => array('A previous flash message')); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - parent::tearDown(); - } - - public function testInitialize() - { - $bag = new FlashBag(); - $bag->initialize($this->array); - $this->assertEquals($this->array, $bag->peekAll()); - $array = array('should' => array('change')); - $bag->initialize($array); - $this->assertEquals($array, $bag->peekAll()); - } - - public function testGetStorageKey() - { - $this->assertEquals('_sf2_flashes', $this->bag->getStorageKey()); - $attributeBag = new FlashBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - public function testGetSetName() - { - $this->assertEquals('flashes', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - public function testPeek() - { - $this->assertEquals(array(), $this->bag->peek('non_existing')); - $this->assertEquals(array('default'), $this->bag->peek('not_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - } - - public function testGet() - { - $this->assertEquals(array(), $this->bag->get('non_existing')); - $this->assertEquals(array('default'), $this->bag->get('not_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->get('notice')); - $this->assertEquals(array(), $this->bag->get('notice')); - } - - public function testAll() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('error', 'Bar'); - $this->assertEquals(array( - 'notice' => array('Foo'), - 'error' => array('Bar'), ), $this->bag->all() - ); - - $this->assertEquals(array(), $this->bag->all()); - } - - public function testSet() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('notice', 'Bar'); - $this->assertEquals(array('Bar'), $this->bag->peek('notice')); - } - - public function testHas() - { - $this->assertFalse($this->bag->has('nothing')); - $this->assertTrue($this->bag->has('notice')); - } - - public function testKeys() - { - $this->assertEquals(array('notice'), $this->bag->keys()); - } - - public function testPeekAll() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('error', 'Bar'); - $this->assertEquals(array( - 'notice' => array('Foo'), - 'error' => array('Bar'), - ), $this->bag->peekAll() - ); - $this->assertTrue($this->bag->has('notice')); - $this->assertTrue($this->bag->has('error')); - $this->assertEquals(array( - 'notice' => array('Foo'), - 'error' => array('Bar'), - ), $this->bag->peekAll() - ); - } - - /** - * @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::getIterator - */ - public function testGetIterator() - { - $flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope'); - foreach ($flashes as $key => $val) { - $this->bag->set($key, $val); - } - - $i = 0; - foreach ($this->bag as $key => $val) { - $this->assertEquals(array($flashes[$key]), $val); - ++$i; - } - - $this->assertEquals(count($flashes), $i); - $this->assertCount(0, $this->bag->all()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php deleted file mode 100644 index 385df1e46..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ /dev/null @@ -1,227 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session; - -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; - -/** - * SessionTest. - * - * @author Fabien Potencier - * @author Robert Schönthal - * @author Drak - */ -class SessionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface - */ - protected $storage; - - /** - * @var \Symfony\Component\HttpFoundation\Session\SessionInterface - */ - protected $session; - - protected function setUp() - { - $this->storage = new MockArraySessionStorage(); - $this->session = new Session($this->storage, new AttributeBag(), new FlashBag()); - } - - protected function tearDown() - { - $this->storage = null; - $this->session = null; - } - - public function testStart() - { - $this->assertEquals('', $this->session->getId()); - $this->assertTrue($this->session->start()); - $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 - $this->assertNull($this->session->get('foo')); - $this->assertEquals(1, $this->session->get('foo', 1)); - } - - /** - * @dataProvider setProvider - */ - public function testSet($key, $value) - { - $this->session->set($key, $value); - $this->assertEquals($value, $this->session->get($key)); - } - - /** - * @dataProvider setProvider - */ - public function testHas($key, $value) - { - $this->session->set($key, $value); - $this->assertTrue($this->session->has($key)); - $this->assertFalse($this->session->has($key.'non_value')); - } - - public function testReplace() - { - $this->session->replace(array('happiness' => 'be good', 'symfony' => 'awesome')); - $this->assertEquals(array('happiness' => 'be good', 'symfony' => 'awesome'), $this->session->all()); - $this->session->replace(array()); - $this->assertEquals(array(), $this->session->all()); - } - - /** - * @dataProvider setProvider - */ - public function testAll($key, $value, $result) - { - $this->session->set($key, $value); - $this->assertEquals($result, $this->session->all()); - } - - /** - * @dataProvider setProvider - */ - public function testClear($key, $value) - { - $this->session->set('hi', 'fabien'); - $this->session->set($key, $value); - $this->session->clear(); - $this->assertEquals(array(), $this->session->all()); - } - - public function setProvider() - { - return array( - array('foo', 'bar', array('foo' => 'bar')), - array('foo.bar', 'too much beer', array('foo.bar' => 'too much beer')), - array('great', 'symfony is great', array('great' => 'symfony is great')), - ); - } - - /** - * @dataProvider setProvider - */ - public function testRemove($key, $value) - { - $this->session->set('hi.world', 'have a nice day'); - $this->session->set($key, $value); - $this->session->remove($key); - $this->assertEquals(array('hi.world' => 'have a nice day'), $this->session->all()); - } - - public function testInvalidate() - { - $this->session->set('invalidate', 123); - $this->session->invalidate(); - $this->assertEquals(array(), $this->session->all()); - } - - public function testMigrate() - { - $this->session->set('migrate', 321); - $this->session->migrate(); - $this->assertEquals(321, $this->session->get('migrate')); - } - - public function testMigrateDestroy() - { - $this->session->set('migrate', 333); - $this->session->migrate(true); - $this->assertEquals(333, $this->session->get('migrate')); - } - - public function testSave() - { - $this->session->start(); - $this->session->save(); - } - - public function testGetId() - { - $this->assertEquals('', $this->session->getId()); - $this->session->start(); - $this->assertNotEquals('', $this->session->getId()); - } - - public function testGetFlashBag() - { - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag()); - } - - /** - * @covers Symfony\Component\HttpFoundation\Session\Session::getIterator - */ - public function testGetIterator() - { - $attributes = array('hello' => 'world', 'symfony' => 'rocks'); - foreach ($attributes as $key => $val) { - $this->session->set($key, $val); - } - - $i = 0; - foreach ($this->session as $key => $val) { - $this->assertEquals($attributes[$key], $val); - ++$i; - } - - $this->assertEquals(count($attributes), $i); - } - - /** - * @covers \Symfony\Component\HttpFoundation\Session\Session::count - */ - public function testGetCount() - { - $this->session->set('hello', 'world'); - $this->session->set('symfony', 'rocks'); - - $this->assertCount(2, $this->session); - } - - public function testGetMeta() - { - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\MetadataBag', $this->session->getMetadataBag()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php deleted file mode 100644 index 92f890152..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\LegacyPdoSessionHandler; - -/** - * @group legacy - */ -class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - private $pdo; - - protected function setUp() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - $this->markTestSkipped('This test requires SQLite support in your environment'); - } - - $this->pdo = new \PDO('sqlite::memory:'); - $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $sql = 'CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)'; - $this->pdo->exec($sql); - } - - public function testIncompleteOptions() - { - $this->setExpectedException('InvalidArgumentException'); - $storage = new LegacyPdoSessionHandler($this->pdo, array()); - } - - public function testWrongPdoErrMode() - { - $pdo = new \PDO('sqlite::memory:'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); - $pdo->exec('CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)'); - - $this->setExpectedException('InvalidArgumentException'); - $storage = new LegacyPdoSessionHandler($pdo, array('db_table' => 'sessions')); - } - - public function testWrongTableOptionsWrite() - { - $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); - $this->setExpectedException('RuntimeException'); - $storage->write('foo', 'bar'); - } - - public function testWrongTableOptionsRead() - { - $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); - $this->setExpectedException('RuntimeException'); - $storage->read('foo', 'bar'); - } - - public function testWriteRead() - { - $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $storage->write('foo', 'bar'); - $this->assertEquals('bar', $storage->read('foo'), 'written value can be read back correctly'); - } - - public function testMultipleInstances() - { - $storage1 = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $storage1->write('foo', 'bar'); - - $storage2 = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $this->assertEquals('bar', $storage2->read('foo'), 'values persist between instances'); - } - - public function testSessionDestroy() - { - $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $storage->write('foo', 'bar'); - $this->assertCount(1, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); - - $storage->destroy('foo'); - - $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); - } - - public function testSessionGC() - { - $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - - $storage->write('foo', 'bar'); - $storage->write('baz', 'bar'); - - $this->assertCount(2, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); - - $storage->gc(-1); - $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); - } - - public function testGetConnection() - { - $storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); - - $method = new \ReflectionMethod($storage, 'getConnection'); - $method->setAccessible(true); - - $this->assertInstanceOf('\PDO', $method->invoke($storage)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php deleted file mode 100644 index 8d38ab3de..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler; - -class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - const PREFIX = 'prefix_'; - const TTL = 1000; - /** - * @var MemcacheSessionHandler - */ - protected $storage; - - protected $memcache; - - protected function setUp() - { - if (!class_exists('Memcache')) { - $this->markTestSkipped('Skipped tests Memcache class is not present'); - } - - $this->memcache = $this->getMock('Memcache'); - $this->storage = new MemcacheSessionHandler( - $this->memcache, - array('prefix' => self::PREFIX, 'expiretime' => self::TTL) - ); - } - - protected function tearDown() - { - $this->memcache = null; - $this->storage = null; - } - - public function testOpenSession() - { - $this->assertTrue($this->storage->open('', '')); - } - - public function testCloseSession() - { - $this->memcache - ->expects($this->once()) - ->method('close') - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->close()); - } - - public function testReadSession() - { - $this->memcache - ->expects($this->once()) - ->method('get') - ->with(self::PREFIX.'id') - ; - - $this->assertEquals('', $this->storage->read('id')); - } - - public function testWriteSession() - { - $this->memcache - ->expects($this->once()) - ->method('set') - ->with(self::PREFIX.'id', 'data', 0, $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->write('id', 'data')); - } - - public function testDestroySession() - { - $this->memcache - ->expects($this->once()) - ->method('delete') - ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->destroy('id')); - } - - public function testGcSession() - { - $this->assertTrue($this->storage->gc(123)); - } - - /** - * @dataProvider getOptionFixtures - */ - public function testSupportedOptions($options, $supported) - { - try { - new MemcacheSessionHandler($this->memcache, $options); - $this->assertTrue($supported); - } catch (\InvalidArgumentException $e) { - $this->assertFalse($supported); - } - } - - public function getOptionFixtures() - { - return array( - array(array('prefix' => 'session'), true), - array(array('expiretime' => 100), true), - array(array('prefix' => 'session', 'expiretime' => 200), true), - array(array('expiretime' => 100, 'foo' => 'bar'), false), - ); - } - - public function testGetConnection() - { - $method = new \ReflectionMethod($this->storage, 'getMemcache'); - $method->setAccessible(true); - - $this->assertInstanceOf('\Memcache', $method->invoke($this->storage)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php deleted file mode 100644 index a7e590871..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler; - -class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - const PREFIX = 'prefix_'; - const TTL = 1000; - - /** - * @var MemcachedSessionHandler - */ - protected $storage; - - protected $memcached; - - protected function setUp() - { - if (!class_exists('Memcached')) { - $this->markTestSkipped('Skipped tests Memcached class is not present'); - } - - if (version_compare(phpversion('memcached'), '2.2.0', '>=')) { - $this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower'); - } - - $this->memcached = $this->getMock('Memcached'); - $this->storage = new MemcachedSessionHandler( - $this->memcached, - array('prefix' => self::PREFIX, 'expiretime' => self::TTL) - ); - } - - protected function tearDown() - { - $this->memcached = null; - $this->storage = null; - } - - public function testOpenSession() - { - $this->assertTrue($this->storage->open('', '')); - } - - public function testCloseSession() - { - $this->assertTrue($this->storage->close()); - } - - public function testReadSession() - { - $this->memcached - ->expects($this->once()) - ->method('get') - ->with(self::PREFIX.'id') - ; - - $this->assertEquals('', $this->storage->read('id')); - } - - public function testWriteSession() - { - $this->memcached - ->expects($this->once()) - ->method('set') - ->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->write('id', 'data')); - } - - public function testDestroySession() - { - $this->memcached - ->expects($this->once()) - ->method('delete') - ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->destroy('id')); - } - - public function testGcSession() - { - $this->assertTrue($this->storage->gc(123)); - } - - /** - * @dataProvider getOptionFixtures - */ - public function testSupportedOptions($options, $supported) - { - try { - new MemcachedSessionHandler($this->memcached, $options); - $this->assertTrue($supported); - } catch (\InvalidArgumentException $e) { - $this->assertFalse($supported); - } - } - - public function getOptionFixtures() - { - return array( - array(array('prefix' => 'session'), true), - array(array('expiretime' => 100), true), - array(array('prefix' => 'session', 'expiretime' => 200), true), - array(array('expiretime' => 100, 'foo' => 'bar'), false), - ); - } - - public function testGetConnection() - { - $method = new \ReflectionMethod($this->storage, 'getMemcached'); - $method->setAccessible(true); - - $this->assertInstanceOf('\Memcached', $method->invoke($this->storage)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php deleted file mode 100644 index 0bc012ac3..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ /dev/null @@ -1,255 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; - -/** - * @author Markus Bachmann - */ -class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $mongo; - private $storage; - public $options; - - protected function setUp() - { - if (!extension_loaded('mongo')) { - $this->markTestSkipped('MongoDbSessionHandler requires the PHP "mongo" extension.'); - } - - $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient'; - - $this->mongo = $this->getMockBuilder($mongoClass) - ->getMock(); - - $this->options = array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'expiry_field' => 'expires_at', - 'database' => 'sf2-test', - 'collection' => 'session-test', - ); - - $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testConstructorShouldThrowExceptionForInvalidMongo() - { - new MongoDbSessionHandler(new \stdClass(), $this->options); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testConstructorShouldThrowExceptionForMissingOptions() - { - new MongoDbSessionHandler($this->mongo, array()); - } - - public function testOpenMethodAlwaysReturnTrue() - { - $this->assertTrue($this->storage->open('test', 'test'), 'The "open" method should always return true'); - } - - public function testCloseMethodAlwaysReturnTrue() - { - $this->assertTrue($this->storage->close(), 'The "close" method should always return true'); - } - - public function testRead() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $that = $this; - - // defining the timeout before the actual method call - // allows to test for "greater than" values in the $criteria - $testTimeout = time() + 1; - - $collection->expects($this->once()) - ->method('findOne') - ->will($this->returnCallback(function ($criteria) use ($that, $testTimeout) { - $that->assertArrayHasKey($that->options['id_field'], $criteria); - $that->assertEquals($criteria[$that->options['id_field']], 'foo'); - - $that->assertArrayHasKey($that->options['expiry_field'], $criteria); - $that->assertArrayHasKey('$gte', $criteria[$that->options['expiry_field']]); - $that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$gte']); - $that->assertGreaterThanOrEqual($criteria[$that->options['expiry_field']]['$gte']->sec, $testTimeout); - - return array( - $that->options['id_field'] => 'foo', - $that->options['data_field'] => new \MongoBinData('bar', \MongoBinData::BYTE_ARRAY), - $that->options['id_field'] => new \MongoDate(), - ); - })); - - $this->assertEquals('bar', $this->storage->read('foo')); - } - - public function testWrite() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $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']; - })); - - $expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime'); - $this->assertTrue($this->storage->write('foo', 'bar')); - - $this->assertEquals('bar', $data[$this->options['data_field']]->bin); - $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); - $this->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); - $this->assertGreaterThanOrEqual($expectedExpiry, $data[$this->options['expiry_field']]->sec); - } - - public function testWriteWhenUsingExpiresField() - { - $this->options = array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'database' => 'sf2-test', - 'collection' => 'session-test', - 'expiry_field' => 'expiresAt', - ); - - $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); - - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $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', $data[$this->options['data_field']]->bin); - $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); - $that->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); - } - - public function testReplaceSessionData() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $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'); - - $this->assertEquals('foobar', $data['$set'][$this->options['data_field']]->bin); - } - - public function testDestroy() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $collection->expects($this->once()) - ->method('remove') - ->with(array($this->options['id_field'] => 'foo')); - - $this->assertTrue($this->storage->destroy('foo')); - } - - public function testGc() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $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['expiry_field']]['$lt']); - $that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['expiry_field']]['$lt']->sec); - })); - - $this->assertTrue($this->storage->gc(1)); - } - - private function createMongoCollectionMock() - { - $mongoClient = $this->getMockBuilder('MongoClient') - ->getMock(); - $mongoDb = $this->getMockBuilder('MongoDB') - ->setConstructorArgs(array($mongoClient, 'database-name')) - ->getMock(); - $collection = $this->getMockBuilder('MongoCollection') - ->setConstructorArgs(array($mongoDb, 'collection-name')) - ->getMock(); - - return $collection; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php deleted file mode 100644 index ab848b6b9..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeFileSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testConstruct() - { - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); - - if (PHP_VERSION_ID < 50400) { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('files', ini_get('session.save_handler')); - } else { - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } - - /** - * @dataProvider savePathDataProvider - */ - public function testConstructSavePath($savePath, $expectedSavePath, $path) - { - $handler = new NativeFileSessionHandler($savePath); - $this->assertEquals($expectedSavePath, ini_get('session.save_path')); - $this->assertTrue(is_dir(realpath($path))); - - rmdir($path); - } - - public function savePathDataProvider() - { - $base = sys_get_temp_dir(); - - return array( - array("$base/foo", "$base/foo", "$base/foo"), - array("5;$base/foo", "5;$base/foo", "$base/foo"), - array("5;0600;$base/foo", "5;0600;$base/foo", "$base/foo"), - ); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testConstructException() - { - $handler = new NativeFileSessionHandler('something;invalid;with;too-many-args'); - } - - public function testConstructDefault() - { - $path = ini_get('session.save_path'); - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler()); - - $this->assertEquals($path, ini_get('session.save_path')); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php deleted file mode 100644 index 3437cf08f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; - -/** - * Test class for NativeSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class NativeSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testConstruct() - { - $handler = new NativeSessionHandler(); - - // note for PHPUnit optimisers - the use of assertTrue/False - // here is deliberate since the tests do not require the classes to exist - drak - if (PHP_VERSION_ID < 50400) { - $this->assertFalse($handler instanceof \SessionHandler); - $this->assertTrue($handler instanceof NativeSessionHandler); - } else { - $this->assertTrue($handler instanceof \SessionHandler); - $this->assertTrue($handler instanceof NativeSessionHandler); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php deleted file mode 100644 index 35823d685..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Session; - -/** - * Test class for NullSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class NullSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - $storage = $this->getStorage(); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - public function testSession() - { - session_id('nullsessionstorage'); - $storage = $this->getStorage(); - $session = new Session($storage); - $this->assertNull($session->get('something')); - $session->set('something', 'unique'); - $this->assertEquals('unique', $session->get('something')); - } - - public function testNothingIsPersisted() - { - session_id('nullsessionstorage'); - $storage = $this->getStorage(); - $session = new Session($storage); - $session->start(); - $this->assertEquals('nullsessionstorage', $session->getId()); - $this->assertNull($session->get('something')); - } - - public function getStorage() - { - return new NativeSessionStorage(array(), new NullSessionHandler()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php deleted file mode 100644 index ba06fccff..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ /dev/null @@ -1,359 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - -class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - private $dbFile; - - protected function setUp() - { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) { - $this->markTestSkipped('This test requires SQLite support in your environment'); - } - } - - protected function tearDown() - { - // make sure the temporary database file is deleted when it has been created (even when a test fails) - if ($this->dbFile) { - @unlink($this->dbFile); - } - } - - protected function getPersistentSqliteDsn() - { - $this->dbFile = tempnam(sys_get_temp_dir(), 'sf2_sqlite_sessions'); - - return 'sqlite:'.$this->dbFile; - } - - protected function getMemorySqlitePdo() - { - $pdo = new \PDO('sqlite::memory:'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $storage = new PdoSessionHandler($pdo); - $storage->createTable(); - - return $pdo; - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testWrongPdoErrMode() - { - $pdo = $this->getMemorySqlitePdo(); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); - - $storage = new PdoSessionHandler($pdo); - } - - /** - * @expectedException \RuntimeException - */ - public function testInexistentTable() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo(), array('db_table' => 'inexistent_table')); - $storage->open('', 'sid'); - $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - } - - /** - * @expectedException \RuntimeException - */ - public function testCreateTableTwice() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->createTable(); - } - - public function testWithLazyDsnConnection() - { - $dsn = $this->getPersistentSqliteDsn(); - - $storage = new PdoSessionHandler($dsn); - $storage->createTable(); - $storage->open('', 'sid'); - $data = $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - $this->assertSame('', $data, 'New session returns empty string data'); - - $storage->open('', 'sid'); - $data = $storage->read('id'); - $storage->close(); - $this->assertSame('data', $data, 'Written value can be read back correctly'); - } - - public function testWithLazySavePathConnection() - { - $dsn = $this->getPersistentSqliteDsn(); - - // Open is called with what ini_set('session.save_path', $dsn) would mean - $storage = new PdoSessionHandler(null); - $storage->open($dsn, 'sid'); - $storage->createTable(); - $data = $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - $this->assertSame('', $data, 'New session returns empty string data'); - - $storage->open($dsn, 'sid'); - $data = $storage->read('id'); - $storage->close(); - $this->assertSame('data', $data, 'Written value can be read back correctly'); - } - - public function testReadWriteReadWithNullByte() - { - $sessionData = 'da'."\0".'ta'; - - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->open('', 'sid'); - $readData = $storage->read('id'); - $storage->write('id', $sessionData); - $storage->close(); - $this->assertSame('', $readData, 'New session returns empty string data'); - - $storage->open('', 'sid'); - $readData = $storage->read('id'); - $storage->close(); - $this->assertSame($sessionData, $readData, 'Written value can be read back correctly'); - } - - public function testReadConvertsStreamToString() - { - $pdo = new MockPdo('pgsql'); - $pdo->prepareResult = $this->getMock('PDOStatement'); - - $content = 'foobar'; - $stream = $this->createStream($content); - - $pdo->prepareResult->expects($this->once())->method('fetchAll') - ->will($this->returnValue(array(array($stream, 42, time())))); - - $storage = new PdoSessionHandler($pdo); - $result = $storage->read('foo'); - - $this->assertSame($content, $result); - } - - public function testReadLockedConvertsStreamToString() - { - $pdo = new MockPdo('pgsql'); - $selectStmt = $this->getMock('PDOStatement'); - $insertStmt = $this->getMock('PDOStatement'); - - $pdo->prepareResult = function ($statement) use ($selectStmt, $insertStmt) { - return 0 === strpos($statement, 'INSERT') ? $insertStmt : $selectStmt; - }; - - $content = 'foobar'; - $stream = $this->createStream($content); - $exception = null; - - $selectStmt->expects($this->atLeast(2))->method('fetchAll') - ->will($this->returnCallback(function () use (&$exception, $stream) { - return $exception ? array(array($stream, 42, time())) : array(); - })); - - $insertStmt->expects($this->once())->method('execute') - ->will($this->returnCallback(function () use (&$exception) { - throw $exception = new \PDOException('', '23'); - })); - - $storage = new PdoSessionHandler($pdo); - $result = $storage->read('foo'); - - $this->assertSame($content, $result); - } - - public function testReadingRequiresExactlySameId() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->open('', 'sid'); - $storage->write('id', 'data'); - $storage->write('test', 'data'); - $storage->write('space ', 'data'); - $storage->close(); - - $storage->open('', 'sid'); - $readDataCaseSensitive = $storage->read('ID'); - $readDataNoCharFolding = $storage->read('tést'); - $readDataKeepSpace = $storage->read('space '); - $readDataExtraSpace = $storage->read('space '); - $storage->close(); - - $this->assertSame('', $readDataCaseSensitive, 'Retrieval by ID should be case-sensitive (collation setting)'); - $this->assertSame('', $readDataNoCharFolding, 'Retrieval by ID should not do character folding (collation setting)'); - $this->assertSame('data', $readDataKeepSpace, 'Retrieval by ID requires spaces as-is'); - $this->assertSame('', $readDataExtraSpace, 'Retrieval by ID requires spaces as-is'); - } - - /** - * Simulates session_regenerate_id(true) which will require an INSERT or UPDATE (replace) - */ - public function testWriteDifferentSessionIdThanRead() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->open('', 'sid'); - $storage->read('id'); - $storage->destroy('id'); - $storage->write('new_id', 'data_of_new_session_id'); - $storage->close(); - - $storage->open('', 'sid'); - $data = $storage->read('new_id'); - $storage->close(); - - $this->assertSame('data_of_new_session_id', $data, 'Data of regenerated session id is available'); - } - - public function testWrongUsageStillWorks() - { - // wrong method sequence that should no happen, but still works - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->write('id', 'data'); - $storage->write('other_id', 'other_data'); - $storage->destroy('inexistent'); - $storage->open('', 'sid'); - $data = $storage->read('id'); - $otherData = $storage->read('other_id'); - $storage->close(); - - $this->assertSame('data', $data); - $this->assertSame('other_data', $otherData); - } - - public function testSessionDestroy() - { - $pdo = $this->getMemorySqlitePdo(); - $storage = new PdoSessionHandler($pdo); - - $storage->open('', 'sid'); - $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - $this->assertEquals(1, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); - - $storage->open('', 'sid'); - $storage->read('id'); - $storage->destroy('id'); - $storage->close(); - $this->assertEquals(0, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); - - $storage->open('', 'sid'); - $data = $storage->read('id'); - $storage->close(); - $this->assertSame('', $data, 'Destroyed session returns empty string'); - } - - public function testSessionGC() - { - $previousLifeTime = ini_set('session.gc_maxlifetime', 1000); - $pdo = $this->getMemorySqlitePdo(); - $storage = new PdoSessionHandler($pdo); - - $storage->open('', 'sid'); - $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - - $storage->open('', 'sid'); - $storage->read('gc_id'); - ini_set('session.gc_maxlifetime', -1); // test that you can set lifetime of a session after it has been read - $storage->write('gc_id', 'data'); - $storage->close(); - $this->assertEquals(2, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn(), 'No session pruned because gc not called'); - - $storage->open('', 'sid'); - $data = $storage->read('gc_id'); - $storage->gc(-1); - $storage->close(); - - ini_set('session.gc_maxlifetime', $previousLifeTime); - - $this->assertSame('', $data, 'Session already considered garbage, so not returning data even if it is not pruned yet'); - $this->assertEquals(1, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn(), 'Expired session is pruned'); - } - - public function testGetConnection() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - - $method = new \ReflectionMethod($storage, 'getConnection'); - $method->setAccessible(true); - - $this->assertInstanceOf('\PDO', $method->invoke($storage)); - } - - public function testGetConnectionConnectsIfNeeded() - { - $storage = new PdoSessionHandler('sqlite::memory:'); - - $method = new \ReflectionMethod($storage, 'getConnection'); - $method->setAccessible(true); - - $this->assertInstanceOf('\PDO', $method->invoke($storage)); - } - - private function createStream($content) - { - $stream = tmpfile(); - fwrite($stream, $content); - fseek($stream, 0); - - return $stream; - } -} - -class MockPdo extends \PDO -{ - public $prepareResult; - private $driverName; - private $errorMode; - - public function __construct($driverName = null, $errorMode = null) - { - $this->driverName = $driverName; - $this->errorMode = null !== $errorMode ?: \PDO::ERRMODE_EXCEPTION; - } - - public function getAttribute($attribute) - { - if (\PDO::ATTR_ERRMODE === $attribute) { - return $this->errorMode; - } - - if (\PDO::ATTR_DRIVER_NAME === $attribute) { - return $this->driverName; - } - - return parent::getAttribute($attribute); - } - - public function prepare($statement, $driverOptions = array()) - { - return is_callable($this->prepareResult) - ? call_user_func($this->prepareResult, $statement, $driverOptions) - : $this->prepareResult; - } - - public function beginTransaction() - { - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php deleted file mode 100644 index 069c88703..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler; - -/** - * @author Adrien Brault - */ -class WriteCheckSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function test() - { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('close') - ->with() - ->will($this->returnValue(true)) - ; - - $this->assertTrue($writeCheckSessionHandler->close()); - } - - public function testWrite() - { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('write') - ->with('foo', 'bar') - ->will($this->returnValue(true)) - ; - - $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); - } - - public function testSkippedWrite() - { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('read') - ->with('foo') - ->will($this->returnValue('bar')) - ; - - $wrappedSessionHandlerMock - ->expects($this->never()) - ->method('write') - ; - - $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); - $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); - } - - public function testNonSkippedWrite() - { - $wrappedSessionHandlerMock = $this->getMock('SessionHandlerInterface'); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('read') - ->with('foo') - ->will($this->returnValue('bar')) - ; - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('write') - ->with('foo', 'baZZZ') - ->will($this->returnValue(true)) - ; - - $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); - $this->assertTrue($writeCheckSessionHandler->write('foo', 'baZZZ')); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php deleted file mode 100644 index fb632a84f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; - -/** - * Test class for MetadataBag. - */ -class MetadataBagTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var MetadataBag - */ - protected $bag; - - /** - * @var array - */ - protected $array = array(); - - protected function setUp() - { - $this->bag = new MetadataBag(); - $this->array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 0); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->array = array(); - $this->bag = null; - } - - public function testInitialize() - { - $sessionMetadata = array(); - - $bag1 = new MetadataBag(); - $bag1->initialize($sessionMetadata); - $this->assertGreaterThanOrEqual(time(), $bag1->getCreated()); - $this->assertEquals($bag1->getCreated(), $bag1->getLastUsed()); - - sleep(1); - $bag2 = new MetadataBag(); - $bag2->initialize($sessionMetadata); - $this->assertEquals($bag1->getCreated(), $bag2->getCreated()); - $this->assertEquals($bag1->getLastUsed(), $bag2->getLastUsed()); - $this->assertEquals($bag2->getCreated(), $bag2->getLastUsed()); - - sleep(1); - $bag3 = new MetadataBag(); - $bag3->initialize($sessionMetadata); - $this->assertEquals($bag1->getCreated(), $bag3->getCreated()); - $this->assertGreaterThan($bag2->getLastUsed(), $bag3->getLastUsed()); - $this->assertNotEquals($bag3->getCreated(), $bag3->getLastUsed()); - } - - public function testGetSetName() - { - $this->assertEquals('__metadata', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - 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()); - } - - public function testGetLastUsed() - { - $this->assertLessThanOrEqual(time(), $this->bag->getLastUsed()); - } - - public function testClear() - { - $this->bag->clear(); - } - - public function testSkipLastUsedUpdate() - { - $bag = new MetadataBag('', 30); - $timeStamp = time(); - - $created = $timeStamp - 15; - $sessionMetadata = array( - MetadataBag::CREATED => $created, - MetadataBag::UPDATED => $created, - MetadataBag::LIFETIME => 1000, - ); - $bag->initialize($sessionMetadata); - - $this->assertEquals($created, $sessionMetadata[MetadataBag::UPDATED]); - } - - public function testDoesNotSkipLastUsedUpdate() - { - $bag = new MetadataBag('', 30); - $timeStamp = time(); - - $created = $timeStamp - 45; - $sessionMetadata = array( - MetadataBag::CREATED => $created, - MetadataBag::UPDATED => $created, - MetadataBag::LIFETIME => 1000, - ); - $bag->initialize($sessionMetadata); - - $this->assertEquals($timeStamp, $sessionMetadata[MetadataBag::UPDATED]); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php deleted file mode 100644 index c56ea4a60..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; - -/** - * Test class for MockArraySessionStorage. - * - * @author Drak - */ -class MockArraySessionStorageTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var MockArraySessionStorage - */ - private $storage; - - /** - * @var AttributeBag - */ - private $attributes; - - /** - * @var FlashBag - */ - private $flashes; - - private $data; - - protected function setUp() - { - $this->attributes = new AttributeBag(); - $this->flashes = new FlashBag(); - - $this->data = array( - $this->attributes->getStorageKey() => array('foo' => 'bar'), - $this->flashes->getStorageKey() => array('notice' => 'hello'), - ); - - $this->storage = new MockArraySessionStorage(); - $this->storage->registerBag($this->flashes); - $this->storage->registerBag($this->attributes); - $this->storage->setSessionData($this->data); - } - - protected function tearDown() - { - $this->data = null; - $this->flashes = null; - $this->attributes = null; - $this->storage = null; - } - - public function testStart() - { - $this->assertEquals('', $this->storage->getId()); - $this->storage->start(); - $id = $this->storage->getId(); - $this->assertNotEquals('', $id); - $this->storage->start(); - $this->assertEquals($id, $this->storage->getId()); - } - - public function testRegenerate() - { - $this->storage->start(); - $id = $this->storage->getId(); - $this->storage->regenerate(); - $this->assertNotEquals($id, $this->storage->getId()); - $this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all()); - $this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll()); - - $id = $this->storage->getId(); - $this->storage->regenerate(true); - $this->assertNotEquals($id, $this->storage->getId()); - $this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all()); - $this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll()); - } - - public function testGetId() - { - $this->assertEquals('', $this->storage->getId()); - $this->storage->start(); - $this->assertNotEquals('', $this->storage->getId()); - } - - /** - * @expectedException \RuntimeException - */ - public function testUnstartedSave() - { - $this->storage->save(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php deleted file mode 100644 index 54321ea4f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Test class for MockFileSessionStorage. - * - * @author Drak - */ -class MockFileSessionStorageTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - private $sessionDir; - - /** - * @var MockFileSessionStorage - */ - protected $storage; - - protected function setUp() - { - $this->sessionDir = sys_get_temp_dir().'/sf2test'; - $this->storage = $this->getStorage(); - } - - protected function tearDown() - { - $this->sessionDir = null; - $this->storage = null; - array_map('unlink', glob($this->sessionDir.'/*.session')); - if (is_dir($this->sessionDir)) { - rmdir($this->sessionDir); - } - } - - public function testStart() - { - $this->assertEquals('', $this->storage->getId()); - $this->assertTrue($this->storage->start()); - $id = $this->storage->getId(); - $this->assertNotEquals('', $this->storage->getId()); - $this->assertTrue($this->storage->start()); - $this->assertEquals($id, $this->storage->getId()); - } - - public function testRegenerate() - { - $this->storage->start(); - $this->storage->getBag('attributes')->set('regenerate', 1234); - $this->storage->regenerate(); - $this->assertEquals(1234, $this->storage->getBag('attributes')->get('regenerate')); - $this->storage->regenerate(true); - $this->assertEquals(1234, $this->storage->getBag('attributes')->get('regenerate')); - } - - public function testGetId() - { - $this->assertEquals('', $this->storage->getId()); - $this->storage->start(); - $this->assertNotEquals('', $this->storage->getId()); - } - - public function testSave() - { - $this->storage->start(); - $id = $this->storage->getId(); - $this->assertNotEquals('108', $this->storage->getBag('attributes')->get('new')); - $this->assertFalse($this->storage->getBag('flashes')->has('newkey')); - $this->storage->getBag('attributes')->set('new', '108'); - $this->storage->getBag('flashes')->set('newkey', 'test'); - $this->storage->save(); - - $storage = $this->getStorage(); - $storage->setId($id); - $storage->start(); - $this->assertEquals('108', $storage->getBag('attributes')->get('new')); - $this->assertTrue($storage->getBag('flashes')->has('newkey')); - $this->assertEquals(array('test'), $storage->getBag('flashes')->peek('newkey')); - } - - public function testMultipleInstances() - { - $storage1 = $this->getStorage(); - $storage1->start(); - $storage1->getBag('attributes')->set('foo', 'bar'); - $storage1->save(); - - $storage2 = $this->getStorage(); - $storage2->setId($storage1->getId()); - $storage2->start(); - $this->assertEquals('bar', $storage2->getBag('attributes')->get('foo'), 'values persist between instances'); - } - - /** - * @expectedException \RuntimeException - */ - public function testSaveWithoutStart() - { - $storage1 = $this->getStorage(); - $storage1->save(); - } - - private function getStorage() - { - $storage = new MockFileSessionStorage($this->sessionDir); - $storage->registerBag(new FlashBag()); - $storage->registerBag(new AttributeBag()); - - return $storage; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php deleted file mode 100644 index c8743aba9..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ /dev/null @@ -1,258 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * Test class for NativeSessionStorage. - * - * @author Drak - * - * These tests require separate processes. - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase -{ - private $savePath; - - protected function setUp() - { - $this->iniSet('session.save_handler', 'files'); - $this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test'); - if (!is_dir($this->savePath)) { - mkdir($this->savePath); - } - } - - protected function tearDown() - { - session_write_close(); - array_map('unlink', glob($this->savePath.'/*')); - if (is_dir($this->savePath)) { - rmdir($this->savePath); - } - - $this->savePath = null; - } - - /** - * @param array $options - * - * @return NativeSessionStorage - */ - protected function getStorage(array $options = array()) - { - $storage = new NativeSessionStorage($options); - $storage->registerBag(new AttributeBag()); - - return $storage; - } - - public function testBag() - { - $storage = $this->getStorage(); - $bag = new FlashBag(); - $storage->registerBag($bag); - $this->assertSame($bag, $storage->getBag($bag->getName())); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRegisterBagException() - { - $storage = $this->getStorage(); - $storage->getBag('non_existing'); - } - - public function testGetId() - { - $storage = $this->getStorage(); - $this->assertSame('', $storage->getId(), 'Empty ID before starting session'); - - $storage->start(); - $id = $storage->getId(); - $this->assertInternalType('string', $id); - $this->assertNotSame('', $id); - - $storage->save(); - $this->assertSame($id, $storage->getId(), 'ID stays after saving session'); - } - - public function testRegenerate() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('lucky', 7); - $storage->regenerate(); - $this->assertNotEquals($id, $storage->getId()); - $this->assertEquals(7, $storage->getBag('attributes')->get('lucky')); - } - - public function testRegenerateDestroy() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('legs', 11); - $storage->regenerate(true); - $this->assertNotEquals($id, $storage->getId()); - $this->assertEquals(11, $storage->getBag('attributes')->get('legs')); - } - - public function testSessionGlobalIsUpToDateAfterIdRegeneration() - { - $storage = $this->getStorage(); - $storage->start(); - $storage->getBag('attributes')->set('lucky', 7); - $storage->regenerate(); - $storage->getBag('attributes')->set('lucky', 42); - - $this->assertEquals(42, $_SESSION['_sf2_attributes']['lucky']); - } - - public function testDefaultSessionCacheLimiter() - { - $this->iniSet('session.cache_limiter', 'nocache'); - - $storage = new NativeSessionStorage(); - $this->assertEquals('', ini_get('session.cache_limiter')); - } - - public function testExplicitSessionCacheLimiter() - { - $this->iniSet('session.cache_limiter', 'nocache'); - - $storage = new NativeSessionStorage(array('cache_limiter' => 'public')); - $this->assertEquals('public', ini_get('session.cache_limiter')); - } - - public function testCookieOptions() - { - $options = array( - 'cookie_lifetime' => 123456, - 'cookie_path' => '/my/cookie/path', - 'cookie_domain' => 'symfony.example.com', - 'cookie_secure' => true, - 'cookie_httponly' => false, - ); - - $this->getStorage($options); - $temp = session_get_cookie_params(); - $gco = array(); - - foreach ($temp as $key => $value) { - $gco['cookie_'.$key] = $value; - } - - $this->assertEquals($options, $gco); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSetSaveHandlerException() - { - $storage = $this->getStorage(); - $storage->setSaveHandler(new \stdClass()); - } - - public function testSetSaveHandler53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->iniSet('session.save_handler', 'files'); - $storage = $this->getStorage(); - $storage->setSaveHandler(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(null); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NullSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeProxy()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler()); - } - - public function testSetSaveHandler54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - $this->iniSet('session.save_handler', 'files'); - $storage = $this->getStorage(); - $storage->setSaveHandler(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(null); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new NativeSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NullSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - } - - /** - * @expectedException \RuntimeException - */ - public function testStartedOutside() - { - $storage = $this->getStorage(); - - $this->assertFalse($storage->getSaveHandler()->isActive()); - $this->assertFalse($storage->isStarted()); - - session_start(); - $this->assertTrue(isset($_SESSION)); - if (PHP_VERSION_ID >= 50400) { - // this only works in PHP >= 5.4 where session_status is available - $this->assertTrue($storage->getSaveHandler()->isActive()); - } - // PHP session might have started, but the storage driver has not, so false is correct here - $this->assertFalse($storage->isStarted()); - - $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); - $storage->start(); - } - - public function testRestart() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('lucky', 7); - $storage->save(); - $storage->start(); - $this->assertSame($id, $storage->getId(), 'Same session ID after restarting'); - $this->assertSame(7, $storage->getBag('attributes')->get('lucky'), 'Data still available'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php deleted file mode 100644 index 07d560f71..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Test class for PhpSessionStorage. - * - * @author Drak - * - * These tests require separate processes. - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase -{ - private $savePath; - - protected function setUp() - { - $this->iniSet('session.save_handler', 'files'); - $this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test'); - if (!is_dir($this->savePath)) { - mkdir($this->savePath); - } - } - - protected function tearDown() - { - session_write_close(); - array_map('unlink', glob($this->savePath.'/*')); - if (is_dir($this->savePath)) { - rmdir($this->savePath); - } - - $this->savePath = null; - } - - /** - * @return PhpBridgeSessionStorage - */ - protected function getStorage() - { - $storage = new PhpBridgeSessionStorage(); - $storage->registerBag(new AttributeBag()); - - return $storage; - } - - public function testPhpSession53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $storage = $this->getStorage(); - - $this->assertFalse(isset($_SESSION)); - $this->assertFalse($storage->getSaveHandler()->isActive()); - - session_start(); - $this->assertTrue(isset($_SESSION)); - // in PHP 5.3 we cannot reliably tell if a session has started - $this->assertFalse($storage->getSaveHandler()->isActive()); - // PHP session might have started, but the storage driver has not, so false is correct here - $this->assertFalse($storage->isStarted()); - - $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); - $storage->start(); - $this->assertTrue(isset($_SESSION[$key])); - } - - public function testPhpSession54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - $storage = $this->getStorage(); - - $this->assertFalse($storage->getSaveHandler()->isActive()); - $this->assertFalse($storage->isStarted()); - - session_start(); - $this->assertTrue(isset($_SESSION)); - // in PHP 5.4 we can reliably detect a session started - $this->assertTrue($storage->getSaveHandler()->isActive()); - // PHP session might have started, but the storage driver has not, so false is correct here - $this->assertFalse($storage->isStarted()); - - $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertFalse(isset($_SESSION[$key])); - $storage->start(); - $this->assertTrue(isset($_SESSION[$key])); - } - - public function testClear() - { - $storage = $this->getStorage(); - session_start(); - $_SESSION['drak'] = 'loves symfony'; - $storage->getBag('attributes')->set('symfony', 'greatness'); - $key = $storage->getBag('attributes')->getStorageKey(); - $this->assertEquals($_SESSION[$key], array('symfony' => 'greatness')); - $this->assertEquals($_SESSION['drak'], 'loves symfony'); - $storage->clear(); - $this->assertEquals($_SESSION[$key], array()); - $this->assertEquals($_SESSION['drak'], 'loves symfony'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php deleted file mode 100644 index ee476a879..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ /dev/null @@ -1,217 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy; - -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; - -// Note until PHPUnit_Mock_Objects 1.2 is released you cannot mock abstracts due to -// https://github.com/sebastianbergmann/phpunit-mock-objects/issues/73 -class ConcreteProxy extends AbstractProxy -{ -} - -class ConcreteSessionHandlerInterfaceProxy extends AbstractProxy implements \SessionHandlerInterface -{ - public function open($savePath, $sessionName) - { - } - - public function close() - { - } - - public function read($id) - { - } - - public function write($id, $data) - { - } - - public function destroy($id) - { - } - - public function gc($maxlifetime) - { - } -} - -/** - * Test class for AbstractProxy. - * - * @author Drak - */ -class AbstractProxyTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var AbstractProxy - */ - protected $proxy; - - protected function setUp() - { - $this->proxy = new ConcreteProxy(); - } - - protected function tearDown() - { - $this->proxy = null; - } - - public function testGetSaveHandlerName() - { - $this->assertNull($this->proxy->getSaveHandlerName()); - } - - public function testIsSessionHandlerInterface() - { - $this->assertFalse($this->proxy->isSessionHandlerInterface()); - $sh = new ConcreteSessionHandlerInterfaceProxy(); - $this->assertTrue($sh->isSessionHandlerInterface()); - } - - public function testIsWrapper() - { - $this->assertFalse($this->proxy->isWrapper()); - } - - public function testIsActivePhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->assertFalse($this->proxy->isActive()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testIsActivePhp54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - $this->assertFalse($this->proxy->isActive()); - session_start(); - $this->assertTrue($this->proxy->isActive()); - } - - public function testSetActivePhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->assertTrue($this->proxy->isActive()); - $this->proxy->setActive(false); - $this->assertFalse($this->proxy->isActive()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * @expectedException \LogicException - */ - public function testSetActivePhp54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - $this->proxy->setActive(true); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testName() - { - $this->assertEquals(session_name(), $this->proxy->getName()); - $this->proxy->setName('foo'); - $this->assertEquals('foo', $this->proxy->getName()); - $this->assertEquals(session_name(), $this->proxy->getName()); - } - - /** - * @expectedException \LogicException - */ - public function testNameExceptionPhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->proxy->setName('foo'); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * @expectedException \LogicException - */ - public function testNameExceptionPhp54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - session_start(); - $this->proxy->setName('foo'); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testId() - { - $this->assertEquals(session_id(), $this->proxy->getId()); - $this->proxy->setId('foo'); - $this->assertEquals('foo', $this->proxy->getId()); - $this->assertEquals(session_id(), $this->proxy->getId()); - } - - /** - * @expectedException \LogicException - */ - public function testIdExceptionPhp53() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); - } - - $this->proxy->setActive(true); - $this->proxy->setId('foo'); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * @expectedException \LogicException - */ - public function testIdExceptionPhp54() - { - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); - } - - session_start(); - $this->proxy->setId('foo'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/NativeProxyTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/NativeProxyTest.php deleted file mode 100644 index e9184ce06..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/NativeProxyTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy; - -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; - -/** - * Test class for NativeProxy. - * - * @author Drak - */ -class NativeProxyTest extends \PHPUnit_Framework_TestCase -{ - public function testIsWrapper() - { - $proxy = new NativeProxy(); - $this->assertFalse($proxy->isWrapper()); - } - - public function testGetSaveHandlerName() - { - $name = ini_get('session.save_handler'); - $proxy = new NativeProxy(); - $this->assertEquals($name, $proxy->getSaveHandlerName()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php deleted file mode 100644 index d2775a80a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ /dev/null @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy; - -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * Tests for SessionHandlerProxy class. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_Matcher - */ - private $mock; - - /** - * @var SessionHandlerProxy - */ - private $proxy; - - protected function setUp() - { - $this->mock = $this->getMock('SessionHandlerInterface'); - $this->proxy = new SessionHandlerProxy($this->mock); - } - - protected function tearDown() - { - $this->mock = null; - $this->proxy = null; - } - - public function testOpen() - { - $this->mock->expects($this->once()) - ->method('open') - ->will($this->returnValue(true)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->open('name', 'id'); - if (PHP_VERSION_ID < 50400) { - $this->assertTrue($this->proxy->isActive()); - } else { - $this->assertFalse($this->proxy->isActive()); - } - } - - public function testOpenFalse() - { - $this->mock->expects($this->once()) - ->method('open') - ->will($this->returnValue(false)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->open('name', 'id'); - $this->assertFalse($this->proxy->isActive()); - } - - public function testClose() - { - $this->mock->expects($this->once()) - ->method('close') - ->will($this->returnValue(true)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->close(); - $this->assertFalse($this->proxy->isActive()); - } - - public function testCloseFalse() - { - $this->mock->expects($this->once()) - ->method('close') - ->will($this->returnValue(false)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->close(); - $this->assertFalse($this->proxy->isActive()); - } - - public function testRead() - { - $this->mock->expects($this->once()) - ->method('read'); - - $this->proxy->read('id'); - } - - public function testWrite() - { - $this->mock->expects($this->once()) - ->method('write'); - - $this->proxy->write('id', 'data'); - } - - public function testDestroy() - { - $this->mock->expects($this->once()) - ->method('destroy'); - - $this->proxy->destroy('id'); - } - - public function testGc() - { - $this->mock->expects($this->once()) - ->method('gc'); - - $this->proxy->gc(86400); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php deleted file mode 100644 index 940f17cac..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * 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\Request; -use Symfony\Component\HttpFoundation\StreamedResponse; - -class StreamedResponseTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $response = new StreamedResponse(function () { echo 'foo'; }, 404, array('Content-Type' => 'text/plain')); - - $this->assertEquals(404, $response->getStatusCode()); - $this->assertEquals('text/plain', $response->headers->get('Content-Type')); - } - - public function testPrepareWith11Protocol() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $request = Request::create('/'); - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1'); - - $response->prepare($request); - - $this->assertEquals('1.1', $response->getProtocolVersion()); - $this->assertNotEquals('chunked', $response->headers->get('Transfer-Encoding'), 'Apache assumes responses with a Transfer-Encoding header set to chunked to already be encoded.'); - } - - public function testPrepareWith10Protocol() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $request = Request::create('/'); - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0'); - - $response->prepare($request); - - $this->assertEquals('1.0', $response->getProtocolVersion()); - $this->assertNull($response->headers->get('Transfer-Encoding')); - } - - public function testPrepareWithHeadRequest() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $request = Request::create('/', 'HEAD'); - - $response->prepare($request); - } - - public function testPrepareWithCacheHeaders() - { - $response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Cache-Control' => 'max-age=600, public')); - $request = Request::create('/', 'GET'); - - $response->prepare($request); - $this->assertEquals('max-age=600, public', $response->headers->get('Cache-Control')); - } - - public function testSendContent() - { - $called = 0; - - $response = new StreamedResponse(function () use (&$called) { ++$called; }); - - $response->sendContent(); - $this->assertEquals(1, $called); - - $response->sendContent(); - $this->assertEquals(1, $called); - } - - /** - * @expectedException \LogicException - */ - public function testSendContentWithNonCallable() - { - $response = new StreamedResponse(null); - $response->sendContent(); - } - - /** - * @expectedException \LogicException - */ - public function testSetCallbackNonCallable() - { - $response = new StreamedResponse(null); - $response->setCallback(null); - } - - /** - * @expectedException \LogicException - */ - public function testSetContent() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $response->setContent('foo'); - } - - public function testGetContent() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $this->assertFalse($response->getContent()); - } - - public function testCreate() - { - $response = StreamedResponse::create(function () {}, 204); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response); - $this->assertEquals(204, $response->getStatusCode()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json deleted file mode 100644 index ee5e4dd0b..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/composer.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "symfony/http-foundation", - "type": "library", - "description": "Symfony HttpFoundation Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7", - "symfony/expression-language": "~2.4" - }, - "autoload": { - "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.6-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/exclude.txt b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/exclude.txt deleted file mode 100644 index 9010fbf2e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/exclude.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -# The following source files are not re-distributed with the "build" of the application -# since they are used solely for constructing other files during the build process -# -Tests \ No newline at end of file diff --git a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist b/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist deleted file mode 100644 index b5b660a39..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderItemTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderItemTest.php deleted file mode 100644 index cb43bb351..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderItemTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\AcceptHeaderItem; - -class AcceptHeaderItemTest extends 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/lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php deleted file mode 100644 index 9929eac28..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/AcceptHeaderTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\AcceptHeader; -use Symfony\Component\HttpFoundation\AcceptHeaderItem; - -class AcceptHeaderTest extends 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/lib/silex/vendor/symfony/http-foundation/Tests/ApacheRequestTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/ApacheRequestTest.php deleted file mode 100644 index 157ab90ec..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/ApacheRequestTest.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\ApacheRequest; - -class ApacheRequestTest extends TestCase -{ - /** - * @dataProvider provideServerVars - */ - public function testUriMethods($server, $expectedRequestUri, $expectedBaseUrl, $expectedPathInfo) - { - $request = new ApacheRequest(); - $request->server->replace($server); - - $this->assertEquals($expectedRequestUri, $request->getRequestUri(), '->getRequestUri() is correct'); - $this->assertEquals($expectedBaseUrl, $request->getBaseUrl(), '->getBaseUrl() is correct'); - $this->assertEquals($expectedPathInfo, $request->getPathInfo(), '->getPathInfo() is correct'); - } - - public function provideServerVars() - { - return array( - array( - array( - 'REQUEST_URI' => '/foo/app_dev.php/bar', - 'SCRIPT_NAME' => '/foo/app_dev.php', - 'PATH_INFO' => '/bar', - ), - '/foo/app_dev.php/bar', - '/foo/app_dev.php', - '/bar', - ), - array( - array( - 'REQUEST_URI' => '/foo/bar', - 'SCRIPT_NAME' => '/foo/app_dev.php', - ), - '/foo/bar', - '/foo', - '/bar', - ), - array( - array( - 'REQUEST_URI' => '/app_dev.php/foo/bar', - 'SCRIPT_NAME' => '/app_dev.php', - 'PATH_INFO' => '/foo/bar', - ), - '/app_dev.php/foo/bar', - '/app_dev.php', - '/foo/bar', - ), - array( - array( - 'REQUEST_URI' => '/foo/bar', - 'SCRIPT_NAME' => '/app_dev.php', - ), - '/foo/bar', - '', - '/foo/bar', - ), - array( - array( - 'REQUEST_URI' => '/app_dev.php', - 'SCRIPT_NAME' => '/app_dev.php', - ), - '/app_dev.php', - '/app_dev.php', - '/', - ), - array( - array( - 'REQUEST_URI' => '/', - 'SCRIPT_NAME' => '/app_dev.php', - ), - '/', - '', - '/', - ), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php deleted file mode 100644 index 1b9e58991..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/BinaryFileResponseTest.php +++ /dev/null @@ -1,352 +0,0 @@ - - * - * 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\File\Stream; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\ResponseHeaderBag; -use Symfony\Component\HttpFoundation\Tests\File\FakeFile; - -class BinaryFileResponseTest extends ResponseTestCase -{ - public function testConstruction() - { - $file = __DIR__.'/../README.md'; - $response = new BinaryFileResponse($file, 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($file, 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')); - } - - public function testConstructWithNonAsciiFilename() - { - touch(sys_get_temp_dir().'/fööö.html'); - - $response = new BinaryFileResponse(sys_get_temp_dir().'/fööö.html', 200, array(), true, 'attachment'); - - @unlink(sys_get_temp_dir().'/fööö.html'); - - $this->assertSame('fööö.html', $response->getFile()->getFilename()); - } - - /** - * @expectedException \LogicException - */ - public function testSetContent() - { - $response = new BinaryFileResponse(__FILE__); - $response->setContent('foo'); - } - - public function testGetContent() - { - $response = new BinaryFileResponse(__FILE__); - $this->assertFalse($response->getContent()); - } - - public function testSetContentDispositionGeneratesSafeFallbackFilename() - { - $response = new BinaryFileResponse(__FILE__); - $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'föö.html'); - - $this->assertSame('attachment; filename="f__.html"; filename*=utf-8\'\'f%C3%B6%C3%B6.html', $response->headers->get('Content-Disposition')); - } - - public function testSetContentDispositionGeneratesSafeFallbackFilenameForWronglyEncodedFilename() - { - $response = new BinaryFileResponse(__FILE__); - - $iso88591EncodedFilename = utf8_decode('föö.html'); - $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $iso88591EncodedFilename); - - // the parameter filename* is invalid in this case (rawurldecode('f%F6%F6') does not provide a UTF-8 string but an ISO-8859-1 encoded one) - $this->assertSame('attachment; filename="f__.html"; filename*=utf-8\'\'f%F6%F6.html', $response->headers->get('Content-Disposition')); - } - - /** - * @dataProvider provideRanges - */ - public function testRequests($requestRange, $offset, $length, $responseRange) - { - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->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', $requestRange); - - $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); - fseek($file, $offset); - $data = fread($file, $length); - fclose($file); - - $this->expectOutputString($data); - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(206, $response->getStatusCode()); - $this->assertEquals($responseRange, $response->headers->get('Content-Range')); - $this->assertSame($length, $response->headers->get('Content-Length')); - } - - /** - * @dataProvider provideRanges - */ - public function testRequestsWithoutEtag($requestRange, $offset, $length, $responseRange) - { - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream')); - - // do a request to get the LastModified - $request = Request::create('/'); - $response->prepare($request); - $lastModified = $response->headers->get('Last-Modified'); - - // prepare a request for a range of the testing file - $request = Request::create('/'); - $request->headers->set('If-Range', $lastModified); - $request->headers->set('Range', $requestRange); - - $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); - fseek($file, $offset); - $data = fread($file, $length); - fclose($file); - - $this->expectOutputString($data); - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(206, $response->getStatusCode()); - $this->assertEquals($responseRange, $response->headers->get('Content-Range')); - } - - public function provideRanges() - { - return array( - array('bytes=1-4', 1, 4, 'bytes 1-4/35'), - array('bytes=-5', 30, 5, 'bytes 30-34/35'), - array('bytes=30-', 30, 5, 'bytes 30-34/35'), - array('bytes=30-30', 30, 1, 'bytes 30-30/35'), - array('bytes=30-34', 30, 5, 'bytes 30-34/35'), - ); - } - - public function testRangeRequestsWithoutLastModifiedDate() - { - // prevent auto last modified - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'), true, null, false, false); - - // prepare a request for a range of the testing file - $request = Request::create('/'); - $request->headers->set('If-Range', date('D, d M Y H:i:s').' GMT'); - $request->headers->set('Range', 'bytes=1-4'); - - $this->expectOutputString(file_get_contents(__DIR__.'/File/Fixtures/test.gif')); - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(200, $response->getStatusCode()); - $this->assertNull($response->headers->get('Content-Range')); - } - - /** - * @dataProvider provideFullFileRanges - */ - public function testFullFileRequests($requestRange) - { - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag(); - - // prepare a request for a range of the testing file - $request = Request::create('/'); - $request->headers->set('Range', $requestRange); - - $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); - $data = fread($file, 35); - fclose($file); - - $this->expectOutputString($data); - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(200, $response->getStatusCode()); - } - - public function provideFullFileRanges() - { - return array( - array('bytes=0-'), - array('bytes=0-34'), - array('bytes=-35'), - // Syntactical invalid range-request should also return the full resource - array('bytes=20-10'), - array('bytes=50-40'), - ); - } - - /** - * @dataProvider provideInvalidRanges - */ - public function testInvalidRequests($requestRange) - { - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag(); - - // prepare a request for a range of the testing file - $request = Request::create('/'); - $request->headers->set('Range', $requestRange); - - $response = clone $response; - $response->prepare($request); - $response->sendContent(); - - $this->assertEquals(416, $response->getStatusCode()); - $this->assertEquals('bytes */35', $response->headers->get('Content-Range')); - } - - public function provideInvalidRanges() - { - return array( - array('bytes=-40'), - array('bytes=30-40'), - ); - } - - /** - * @dataProvider provideXSendfileFiles - */ - public function testXSendfile($file) - { - $request = Request::create('/'); - $request->headers->set('X-Sendfile-Type', 'X-Sendfile'); - - BinaryFileResponse::trustXSendfileTypeHeader(); - $response = BinaryFileResponse::create($file, 200, array('Content-Type' => 'application/octet-stream')); - $response->prepare($request); - - $this->expectOutputString(''); - $response->sendContent(); - - $this->assertContains('README.md', $response->headers->get('X-Sendfile')); - } - - public function provideXSendfileFiles() - { - return array( - array(__DIR__.'/../README.md'), - array('file://'.__DIR__.'/../README.md'), - ); - } - - /** - * @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 = new FakeFile($realpath, __DIR__.'/File/Fixtures/test'); - - BinaryFileResponse::trustXSendfileTypeHeader(); - $response = new BinaryFileResponse($file, 200, array('Content-Type' => 'application/octet-stream')); - $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 testDeleteFileAfterSend() - { - $request = Request::create('/'); - - $path = __DIR__.'/File/Fixtures/to_delete'; - touch($path); - $realPath = realpath($path); - $this->assertFileExists($realPath); - - $response = new BinaryFileResponse($realPath, 200, array('Content-Type' => 'application/octet-stream')); - $response->deleteFileAfterSend(true); - - $response->prepare($request); - $response->sendContent(); - - $this->assertFileNotExists($path); - } - - public function testAcceptRangeOnUnsafeMethods() - { - $request = Request::create('/', 'POST'); - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream')); - $response->prepare($request); - - $this->assertEquals('none', $response->headers->get('Accept-Ranges')); - } - - public function testAcceptRangeNotOverriden() - { - $request = Request::create('/', 'POST'); - $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream')); - $response->headers->set('Accept-Ranges', 'foo'); - $response->prepare($request); - - $this->assertEquals('foo', $response->headers->get('Accept-Ranges')); - } - - public function getSampleXAccelMappings() - { - return array( - array('/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'), - array('/home/foo/bar.txt', '/var/www/=/files/,/home/foo/=/baz/', '/baz/bar.txt'), - ); - } - - public function testStream() - { - $request = Request::create('/'); - $response = new BinaryFileResponse(new Stream(__DIR__.'/../README.md'), 200, array('Content-Type' => 'text/plain')); - $response->prepare($request); - - $this->assertNull($response->headers->get('Content-Length')); - } - - protected function provideResponse() - { - return new BinaryFileResponse(__DIR__.'/../README.md', 200, array('Content-Type' => 'application/octet-stream')); - } - - public static function tearDownAfterClass() - { - $path = __DIR__.'/../Fixtures/to_delete'; - if (file_exists($path)) { - @unlink($path); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/CookieTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/CookieTest.php deleted file mode 100644 index 070b7dd42..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/CookieTest.php +++ /dev/null @@ -1,223 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Cookie; - -/** - * CookieTest. - * - * @author John Kary - * @author Hugo Hamon - * - * @group time-sensitive - */ -class CookieTest extends TestCase -{ - public function invalidNames() - { - return array( - array(''), - array(',MyName'), - array(';MyName'), - array(' MyName'), - array("\tMyName"), - array("\rMyName"), - array("\nMyName"), - array("\013MyName"), - array("\014MyName"), - ); - } - - /** - * @dataProvider invalidNames - * @expectedException \InvalidArgumentException - */ - public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidCharacters($name) - { - new Cookie($name); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidExpiration() - { - new Cookie('MyCookie', 'foo', 'bar'); - } - - public function testNegativeExpirationIsNotPossible() - { - $cookie = new Cookie('foo', 'bar', -100); - - $this->assertSame(0, $cookie->getExpiresTime()); - } - - public function testGetValue() - { - $value = 'MyValue'; - $cookie = new Cookie('MyCookie', $value); - - $this->assertSame($value, $cookie->getValue(), '->getValue() returns the proper value'); - } - - public function testGetPath() - { - $cookie = new Cookie('foo', 'bar'); - - $this->assertSame('/', $cookie->getPath(), '->getPath() returns / as the default path'); - } - - public function testGetExpiresTime() - { - $cookie = new Cookie('foo', 'bar'); - - $this->assertEquals(0, $cookie->getExpiresTime(), '->getExpiresTime() returns the default expire date'); - - $cookie = new Cookie('foo', 'bar', $expire = time() + 3600); - - $this->assertEquals($expire, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); - } - - public function testGetExpiresTimeIsCastToInt() - { - $cookie = new Cookie('foo', 'bar', 3600.9); - - $this->assertSame(3600, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date as an integer'); - } - - public function testConstructorWithDateTime() - { - $expire = new \DateTime(); - $cookie = new Cookie('foo', 'bar', $expire); - - $this->assertEquals($expire->format('U'), $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); - } - - /** - * @requires PHP 5.5 - */ - public function testConstructorWithDateTimeImmutable() - { - $expire = new \DateTimeImmutable(); - $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', 1); - } - - public function testGetDomain() - { - $cookie = new Cookie('foo', 'bar', 0, '/', '.myfoodomain.com'); - - $this->assertEquals('.myfoodomain.com', $cookie->getDomain(), '->getDomain() returns the domain name on which the cookie is valid'); - } - - public function testIsSecure() - { - $cookie = new Cookie('foo', 'bar', 0, '/', '.myfoodomain.com', true); - - $this->assertTrue($cookie->isSecure(), '->isSecure() returns whether the cookie is transmitted over HTTPS'); - } - - public function testIsHttpOnly() - { - $cookie = new Cookie('foo', 'bar', 0, '/', '.myfoodomain.com', false, true); - - $this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns whether the cookie is only transmitted over HTTP'); - } - - public function testCookieIsNotCleared() - { - $cookie = new Cookie('foo', 'bar', time() + 3600 * 24); - - $this->assertFalse($cookie->isCleared(), '->isCleared() returns false if the cookie did not expire yet'); - } - - public function testCookieIsCleared() - { - $cookie = new Cookie('foo', 'bar', time() - 20); - - $this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired'); - } - - public function testToString() - { - $cookie = new Cookie('foo', 'bar', $expire = strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true); - $this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; max-age='.($expire - time()).'; path=/; domain=.myfoodomain.com; secure; httponly', (string) $cookie, '->__toString() returns string representation of the cookie'); - - $cookie = new Cookie('foo', 'bar with white spaces', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true); - $this->assertEquals('foo=bar%20with%20white%20spaces; expires=Fri, 20-May-2011 15:25:52 GMT; max-age='.($expire - time()).'; path=/; domain=.myfoodomain.com; secure; httponly', (string) $cookie, '->__toString() encodes the value of the cookie according to RFC 3986 (white space = %20)'); - - $cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com'); - $this->assertEquals('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', $expire = time() - 31536001).'; max-age='.($expire - time()).'; path=/admin/; domain=.myfoodomain.com; httponly', (string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL'); - - $cookie = new Cookie('foo', 'bar', 0, '/', ''); - $this->assertEquals('foo=bar; path=/; httponly', (string) $cookie); - } - - public function testRawCookie() - { - $cookie = new Cookie('foo', 'b a r', 0, '/', null, false, false); - $this->assertFalse($cookie->isRaw()); - $this->assertEquals('foo=b%20a%20r; path=/', (string) $cookie); - - $cookie = new Cookie('foo', 'b+a+r', 0, '/', null, false, false, true); - $this->assertTrue($cookie->isRaw()); - $this->assertEquals('foo=b+a+r; path=/', (string) $cookie); - } - - public function testGetMaxAge() - { - $cookie = new Cookie('foo', 'bar'); - $this->assertEquals(0, $cookie->getMaxAge()); - - $cookie = new Cookie('foo', 'bar', $expire = time() + 100); - $this->assertEquals($expire - time(), $cookie->getMaxAge()); - - $cookie = new Cookie('foo', 'bar', $expire = time() - 100); - $this->assertEquals($expire - time(), $cookie->getMaxAge()); - } - - public function testFromString() - { - $cookie = Cookie::fromString('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly'); - $this->assertEquals(new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true, true, true), $cookie); - - $cookie = Cookie::fromString('foo=bar', true); - $this->assertEquals(new Cookie('foo', 'bar', 0, '/', null, false, false), $cookie); - } - - public function testFromStringWithHttpOnly() - { - $cookie = Cookie::fromString('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly'); - $this->assertTrue($cookie->isHttpOnly()); - - $cookie = Cookie::fromString('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure'); - $this->assertFalse($cookie->isHttpOnly()); - } - - public function testSameSiteAttributeIsCaseInsensitive() - { - $cookie = new Cookie('foo', 'bar', 0, '/', null, false, true, false, 'Lax'); - $this->assertEquals('lax', $cookie->getSameSite()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/ExpressionRequestMatcherTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/ExpressionRequestMatcherTest.php deleted file mode 100644 index 1152e46c0..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/ExpressionRequestMatcherTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\HttpFoundation\ExpressionRequestMatcher; -use Symfony\Component\HttpFoundation\Request; - -class ExpressionRequestMatcherTest extends TestCase -{ - /** - * @expectedException \LogicException - */ - public function testWhenNoExpressionIsSet() - { - $expressionRequestMatcher = new ExpressionRequestMatcher(); - $expressionRequestMatcher->matches(new Request()); - } - - /** - * @dataProvider provideExpressions - */ - public function testMatchesWhenParentMatchesIsTrue($expression, $expected) - { - $request = Request::create('/foo'); - $expressionRequestMatcher = new ExpressionRequestMatcher(); - - $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); - $this->assertSame($expected, $expressionRequestMatcher->matches($request)); - } - - /** - * @dataProvider provideExpressions - */ - public function testMatchesWhenParentMatchesIsFalse($expression) - { - $request = Request::create('/foo'); - $request->attributes->set('foo', 'foo'); - $expressionRequestMatcher = new ExpressionRequestMatcher(); - $expressionRequestMatcher->matchAttribute('foo', 'bar'); - - $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); - $this->assertFalse($expressionRequestMatcher->matches($request)); - } - - public function provideExpressions() - { - return array( - array('request.getMethod() == method', true), - array('request.getPathInfo() == path', true), - array('request.getHost() == host', true), - array('request.getClientIp() == ip', true), - array('request.attributes.all() == attributes', true), - array('request.getMethod() == method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', true), - array('request.getMethod() != method', false), - array('request.getMethod() != method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', false), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/FakeFile.php b/lib/silex/vendor/symfony/http-foundation/Tests/File/FakeFile.php deleted file mode 100644 index c415989f2..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/File/FakeFile.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File; - -use Symfony\Component\HttpFoundation\File\File as OrigFile; - -class FakeFile extends OrigFile -{ - private $realpath; - - public function __construct($realpath, $path) - { - $this->realpath = $realpath; - parent::__construct($path, false); - } - - public function isReadable() - { - return true; - } - - public function getRealpath() - { - return $this->realpath; - } - - public function getSize() - { - return 42; - } - - public function getMTime() - { - return time(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/FileTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/File/FileTest.php deleted file mode 100644 index dbd9c44bd..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/File/FileTest.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; - -class FileTest extends TestCase -{ - protected $file; - - public function testGetMimeTypeUsesMimeTypeGuessers() - { - $file = new File(__DIR__.'/Fixtures/test.gif'); - $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif'); - - MimeTypeGuesser::getInstance()->register($guesser); - - $this->assertEquals('image/gif', $file->getMimeType()); - } - - public function testGuessExtensionWithoutGuesser() - { - $file = new File(__DIR__.'/Fixtures/directory/.empty'); - - $this->assertNull($file->guessExtension()); - } - - public function testGuessExtensionIsBasedOnMimeType() - { - $file = new File(__DIR__.'/Fixtures/test'); - $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif'); - - MimeTypeGuesser::getInstance()->register($guesser); - - $this->assertEquals('gif', $file->guessExtension()); - } - - /** - * @requires extension fileinfo - */ - public function testGuessExtensionWithReset() - { - $file = new File(__DIR__.'/Fixtures/other-file.example'); - $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif'); - MimeTypeGuesser::getInstance()->register($guesser); - - $this->assertEquals('gif', $file->guessExtension()); - - MimeTypeGuesser::reset(); - - $this->assertNull($file->guessExtension()); - } - - public function testConstructWhenFileNotExists() - { - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - - new File(__DIR__.'/Fixtures/not_here'); - } - - public function testMove() - { - $path = __DIR__.'/Fixtures/test.copy.gif'; - $targetDir = __DIR__.'/Fixtures/directory'; - $targetPath = $targetDir.'/test.copy.gif'; - @unlink($path); - @unlink($targetPath); - copy(__DIR__.'/Fixtures/test.gif', $path); - - $file = new File($path); - $movedFile = $file->move($targetDir); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile); - - $this->assertFileExists($targetPath); - $this->assertFileNotExists($path); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @unlink($targetPath); - } - - public function testMoveWithNewName() - { - $path = __DIR__.'/Fixtures/test.copy.gif'; - $targetDir = __DIR__.'/Fixtures/directory'; - $targetPath = $targetDir.'/test.newname.gif'; - @unlink($path); - @unlink($targetPath); - copy(__DIR__.'/Fixtures/test.gif', $path); - - $file = new File($path); - $movedFile = $file->move($targetDir, 'test.newname.gif'); - - $this->assertFileExists($targetPath); - $this->assertFileNotExists($path); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @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->assertFileExists($targetPath); - $this->assertFileNotExists($path); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @unlink($targetPath); - } - - public function testMoveToAnUnexistentDirectory() - { - $sourcePath = __DIR__.'/Fixtures/test.copy.gif'; - $targetDir = __DIR__.'/Fixtures/directory/sub'; - $targetPath = $targetDir.'/test.copy.gif'; - @unlink($sourcePath); - @unlink($targetPath); - @rmdir($targetDir); - copy(__DIR__.'/Fixtures/test.gif', $sourcePath); - - $file = new File($sourcePath); - $movedFile = $file->move($targetDir); - - $this->assertFileExists($targetPath); - $this->assertFileNotExists($sourcePath); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @unlink($sourcePath); - @unlink($targetPath); - @rmdir($targetDir); - } - - protected function createMockGuesser($path, $mimeType) - { - $guesser = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface')->getMock(); - $guesser - ->expects($this->once()) - ->method('guess') - ->with($this->equalTo($path)) - ->will($this->returnValue($mimeType)) - ; - - return $guesser; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension b/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension deleted file mode 100644 index 4d1ae35ba..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/.unknownextension +++ /dev/null @@ -1 +0,0 @@ -f \ No newline at end of file diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty b/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/directory/.empty deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example b/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/other-file.example deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/test b/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/test deleted file mode 100644 index b636f4b8df536b0a85e7cea1a6cf3f0bd3179b96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35 jcmZ?wbh9u|WMp7uXkcLY4+c66KmZb9U}AD%WUvMRyAlZ1 diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif b/lib/silex/vendor/symfony/http-foundation/Tests/File/Fixtures/test.gif deleted file mode 100644 index b636f4b8df536b0a85e7cea1a6cf3f0bd3179b96..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35 jcmZ?wbh9u|WMp7uXkcLY4+c66KmZb9U}AD%WUvMRyAlZ1 diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php deleted file mode 100644 index b3f1f026a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File\MimeType; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser; - -/** - * @requires extension fileinfo - */ -class MimeTypeTest extends TestCase -{ - protected $path; - - public function testGuessImageWithoutExtension() - { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } - - public function testGuessImageWithDirectory() - { - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - - MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory'); - } - - public function testGuessImageWithFileBinaryMimeTypeGuesser() - { - $guesser = MimeTypeGuesser::getInstance(); - $guesser->register(new FileBinaryMimeTypeGuesser()); - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test')); - } - - public function testGuessImageWithKnownExtension() - { - $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif')); - } - - public function testGuessFileWithUnknownExtension() - { - $this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension')); - } - - public function testGuessWithIncorrectPath() - { - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here'); - } - - public function testGuessWithNonReadablePath() - { - if ('\\' === DIRECTORY_SEPARATOR) { - $this->markTestSkipped('Can not verify chmod operations on Windows'); - } - - if (!getenv('USER') || 'root' === getenv('USER')) { - $this->markTestSkipped('This test will fail if run under superuser'); - } - - $path = __DIR__.'/../Fixtures/to_delete'; - touch($path); - @chmod($path, 0333); - - if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) { - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException'); - MimeTypeGuesser::getInstance()->guess($path); - } else { - $this->markTestSkipped('Can not verify chmod operations, change of file permissions failed'); - } - } - - public static function tearDownAfterClass() - { - $path = __DIR__.'/../Fixtures/to_delete'; - if (file_exists($path)) { - @chmod($path, 0666); - @unlink($path); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php deleted file mode 100644 index 36f122fe7..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/File/UploadedFileTest.php +++ /dev/null @@ -1,273 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\File; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -class UploadedFileTest extends TestCase -{ - protected function setUp() - { - if (!ini_get('file_uploads')) { - $this->markTestSkipped('file_uploads is disabled in php.ini'); - } - } - - public function testConstructWhenFileNotExists() - { - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'); - - new UploadedFile( - __DIR__.'/Fixtures/not_here', - 'original.gif', - null - ); - } - - public function testFileUploadsWithNoMimeType() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK - ); - - $this->assertEquals('application/octet-stream', $file->getClientMimeType()); - - if (extension_loaded('fileinfo')) { - $this->assertEquals('image/gif', $file->getMimeType()); - } - } - - public function testFileUploadsWithUnknownMimeType() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/.unknownextension', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/.unknownextension'), - UPLOAD_ERR_OK - ); - - $this->assertEquals('application/octet-stream', $file->getClientMimeType()); - } - - public function testGuessClientExtension() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals('gif', $file->guessClientExtension()); - } - - public function testGuessClientExtensionWithIncorrectMimeType() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/jpeg', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals('jpeg', $file->guessClientExtension()); - } - - public function testErrorIsOkByDefault() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals(UPLOAD_ERR_OK, $file->getError()); - } - - public function testGetClientOriginalName() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $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 - */ - public function testMoveLocalFileIsNotAllowed() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK - ); - - $movedFile = $file->move(__DIR__.'/Fixtures/directory'); - } - - public function testMoveLocalFileIsAllowedInTestMode() - { - $path = __DIR__.'/Fixtures/test.copy.gif'; - $targetDir = __DIR__.'/Fixtures/directory'; - $targetPath = $targetDir.'/test.copy.gif'; - @unlink($path); - @unlink($targetPath); - copy(__DIR__.'/Fixtures/test.gif', $path); - - $file = new UploadedFile( - $path, - 'original.gif', - 'image/gif', - filesize($path), - UPLOAD_ERR_OK, - true - ); - - $movedFile = $file->move(__DIR__.'/Fixtures/directory'); - - $this->assertFileExists($targetPath); - $this->assertFileNotExists($path); - $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); - - @unlink($targetPath); - } - - public function testGetClientOriginalNameSanitizeFilename() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - '../../original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals('original.gif', $file->getClientOriginalName()); - } - - public function testGetSize() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - 'image/gif', - filesize(__DIR__.'/Fixtures/test.gif'), - null - ); - - $this->assertEquals(filesize(__DIR__.'/Fixtures/test.gif'), $file->getSize()); - - $file = new UploadedFile( - __DIR__.'/Fixtures/test', - 'original.gif', - 'image/gif' - ); - - $this->assertEquals(filesize(__DIR__.'/Fixtures/test'), $file->getSize()); - } - - public function testGetExtension() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null - ); - - $this->assertEquals('gif', $file->getExtension()); - } - - public function testIsValid() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK, - true - ); - - $this->assertTrue($file->isValid()); - } - - /** - * @dataProvider uploadedFileErrorProvider - */ - public function testIsInvalidOnUploadError($error) - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - $error - ); - - $this->assertFalse($file->isValid()); - } - - public function uploadedFileErrorProvider() - { - return array( - array(UPLOAD_ERR_INI_SIZE), - array(UPLOAD_ERR_FORM_SIZE), - array(UPLOAD_ERR_PARTIAL), - array(UPLOAD_ERR_NO_TMP_DIR), - array(UPLOAD_ERR_EXTENSION), - ); - } - - public function testIsInvalidIfNotHttpUpload() - { - $file = new UploadedFile( - __DIR__.'/Fixtures/test.gif', - 'original.gif', - null, - filesize(__DIR__.'/Fixtures/test.gif'), - UPLOAD_ERR_OK - ); - - $this->assertFalse($file->isValid()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/FileBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/FileBagTest.php deleted file mode 100644 index b1bbba0d3..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/FileBagTest.php +++ /dev/null @@ -1,175 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\FileBag; - -/** - * FileBagTest. - * - * @author Fabien Potencier - * @author Bulat Shakirzyanov - */ -class FileBagTest extends TestCase -{ - /** - * @expectedException \InvalidArgumentException - */ - public function testFileMustBeAnArrayOrUploadedFile() - { - new FileBag(array('file' => 'foo')); - } - - public function testShouldConvertsUploadedFiles() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array('file' => array( - 'name' => basename($tmpFile), - 'type' => 'text/plain', - 'tmp_name' => $tmpFile, - 'error' => 0, - 'size' => 100, - ))); - - $this->assertEquals($file, $bag->get('file')); - } - - public function testShouldSetEmptyUploadedFilesToNull() - { - $bag = new FileBag(array('file' => array( - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => UPLOAD_ERR_NO_FILE, - 'size' => 0, - ))); - - $this->assertNull($bag->get('file')); - } - - public function testShouldRemoveEmptyUploadedFilesForMultiUpload() - { - $bag = new FileBag(array('files' => array( - 'name' => array(''), - 'type' => array(''), - 'tmp_name' => array(''), - 'error' => array(UPLOAD_ERR_NO_FILE), - 'size' => array(0), - ))); - - $this->assertSame(array(), $bag->get('files')); - } - - public function testShouldNotRemoveEmptyUploadedFilesForAssociativeArray() - { - $bag = new FileBag(array('files' => array( - 'name' => array('file1' => ''), - 'type' => array('file1' => ''), - 'tmp_name' => array('file1' => ''), - 'error' => array('file1' => UPLOAD_ERR_NO_FILE), - 'size' => array('file1' => 0), - ))); - - $this->assertSame(array('file1' => null), $bag->get('files')); - } - - public function testShouldConvertUploadedFilesWithPhpBug() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array( - 'child' => array( - 'name' => array( - 'file' => basename($tmpFile), - ), - 'type' => array( - 'file' => 'text/plain', - ), - 'tmp_name' => array( - 'file' => $tmpFile, - ), - 'error' => array( - 'file' => 0, - ), - 'size' => array( - 'file' => 100, - ), - ), - )); - - $files = $bag->all(); - $this->assertEquals($file, $files['child']['file']); - } - - public function testShouldConvertNestedUploadedFilesWithPhpBug() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - - $bag = new FileBag(array( - 'child' => array( - 'name' => array( - 'sub' => array('file' => basename($tmpFile)), - ), - 'type' => array( - 'sub' => array('file' => 'text/plain'), - ), - 'tmp_name' => array( - 'sub' => array('file' => $tmpFile), - ), - 'error' => array( - 'sub' => array('file' => 0), - ), - 'size' => array( - 'sub' => array('file' => 100), - ), - ), - )); - - $files = $bag->all(); - $this->assertEquals($file, $files['child']['sub']['file']); - } - - public function testShouldNotConvertNestedUploadedFiles() - { - $tmpFile = $this->createTempFile(); - $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); - $bag = new FileBag(array('image' => array('file' => $file))); - - $files = $bag->all(); - $this->assertEquals($file, $files['image']['file']); - } - - protected function createTempFile() - { - return tempnam(sys_get_temp_dir().'/form_test', 'FormTest'); - } - - protected function setUp() - { - mkdir(sys_get_temp_dir().'/form_test', 0777, true); - } - - protected function tearDown() - { - foreach (glob(sys_get_temp_dir().'/form_test/*') as $file) { - unlink($file); - } - - rmdir(sys_get_temp_dir().'/form_test'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/HeaderBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/HeaderBagTest.php deleted file mode 100644 index 6d19ceb00..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/HeaderBagTest.php +++ /dev/null @@ -1,205 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\HeaderBag; - -class HeaderBagTest extends TestCase -{ - public function testConstructor() - { - $bag = new HeaderBag(array('foo' => 'bar')); - $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')); - } - - public function testAll() - { - $bag = new HeaderBag(array('foo' => 'bar')); - $this->assertEquals(array('foo' => array('bar')), $bag->all(), '->all() gets all the input'); - - $bag = new HeaderBag(array('FOO' => 'BAR')); - $this->assertEquals(array('foo' => array('BAR')), $bag->all(), '->all() gets all the input key are lower case'); - } - - public function testReplace() - { - $bag = new HeaderBag(array('foo' => 'bar')); - - $bag->replace(array('NOPE' => 'BAR')); - $this->assertEquals(array('nope' => array('BAR')), $bag->all(), '->replace() replaces the input with the argument'); - $this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input'); - } - - public function testGet() - { - $bag = new HeaderBag(array('foo' => 'bar', 'fuzz' => 'bizz')); - $this->assertEquals('bar', $bag->get('foo'), '->get return current value'); - $this->assertEquals('bar', $bag->get('FoO'), '->get key in case insensitive'); - $this->assertEquals(array('bar'), $bag->get('foo', 'nope', false), '->get return the value as array'); - - // defaults - $this->assertNull($bag->get('none'), '->get unknown values returns null'); - $this->assertEquals('default', $bag->get('none', 'default'), '->get unknown values returns default'); - $this->assertEquals(array('default'), $bag->get('none', 'default', false), '->get unknown values returns default as array'); - - $bag->set('foo', 'bor', false); - $this->assertEquals('bar', $bag->get('foo'), '->get return first value'); - $this->assertEquals(array('bar', 'bor'), $bag->get('foo', 'nope', false), '->get return all values as array'); - } - - public function testSetAssociativeArray() - { - $bag = new HeaderBag(); - $bag->set('foo', array('bad-assoc-index' => 'value')); - $this->assertSame('value', $bag->get('foo')); - $this->assertEquals(array('value'), $bag->get('foo', 'nope', false), 'assoc indices of multi-valued headers are ignored'); - } - - public function testContains() - { - $bag = new HeaderBag(array('foo' => 'bar', 'fuzz' => 'bizz')); - $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value'); - $this->assertTrue($bag->contains('fuzz', 'bizz'), '->contains second value'); - $this->assertFalse($bag->contains('nope', 'nope'), '->contains unknown value'); - $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value'); - - // Multiple values - $bag->set('foo', 'bor', false); - $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value'); - $this->assertTrue($bag->contains('foo', 'bor'), '->contains second value'); - $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value'); - } - - public function testCacheControlDirectiveAccessors() - { - $bag = new HeaderBag(); - $bag->addCacheControlDirective('public'); - - $this->assertTrue($bag->hasCacheControlDirective('public')); - $this->assertTrue($bag->getCacheControlDirective('public')); - $this->assertEquals('public', $bag->get('cache-control')); - - $bag->addCacheControlDirective('max-age', 10); - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); - $this->assertEquals('max-age=10, public', $bag->get('cache-control')); - - $bag->removeCacheControlDirective('max-age'); - $this->assertFalse($bag->hasCacheControlDirective('max-age')); - } - - public function testCacheControlDirectiveParsing() - { - $bag = new HeaderBag(array('cache-control' => 'public, max-age=10')); - $this->assertTrue($bag->hasCacheControlDirective('public')); - $this->assertTrue($bag->getCacheControlDirective('public')); - - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); - - $bag->addCacheControlDirective('s-maxage', 100); - $this->assertEquals('max-age=10, public, s-maxage=100', $bag->get('cache-control')); - } - - public function testCacheControlDirectiveParsingQuotedZero() - { - $bag = new HeaderBag(array('cache-control' => 'max-age="0"')); - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(0, $bag->getCacheControlDirective('max-age')); - } - - public function testCacheControlDirectiveOverrideWithReplace() - { - $bag = new HeaderBag(array('cache-control' => 'private, max-age=100')); - $bag->replace(array('cache-control' => 'public, max-age=10')); - $this->assertTrue($bag->hasCacheControlDirective('public')); - $this->assertTrue($bag->getCacheControlDirective('public')); - - $this->assertTrue($bag->hasCacheControlDirective('max-age')); - $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); - } - - public function testCacheControlClone() - { - $headers = array('foo' => 'bar'); - $bag1 = new HeaderBag($headers); - $bag2 = new HeaderBag($bag1->all()); - - $this->assertEquals($bag1->all(), $bag2->all()); - } - - public function testGetIterator() - { - $headers = array('foo' => 'bar', 'hello' => 'world', 'third' => 'charm'); - $headerBag = new HeaderBag($headers); - - $i = 0; - foreach ($headerBag as $key => $val) { - ++$i; - $this->assertEquals(array($headers[$key]), $val); - } - - $this->assertEquals(count($headers), $i); - } - - public function testCount() - { - $headers = array('foo' => 'bar', 'HELLO' => 'WORLD'); - $headerBag = new HeaderBag($headers); - - $this->assertCount(count($headers), $headerBag); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/IpUtilsTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/IpUtilsTest.php deleted file mode 100644 index 7a93f9947..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/IpUtilsTest.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\IpUtils; - -class IpUtilsTest extends TestCase -{ - /** - * @dataProvider getIpv4Data - */ - public function testIpv4($matches, $remoteAddr, $cidr) - { - $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr)); - } - - public function getIpv4Data() - { - return array( - array(true, '192.168.1.1', '192.168.1.1'), - array(true, '192.168.1.1', '192.168.1.1/1'), - array(true, '192.168.1.1', '192.168.1.0/24'), - array(false, '192.168.1.1', '1.2.3.4/1'), - array(false, '192.168.1.1', '192.168.1.1/33'), // invalid subnet - array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')), - array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')), - array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')), - array(true, '1.2.3.4', '0.0.0.0/0'), - array(true, '1.2.3.4', '192.168.1.0/0'), - array(false, '1.2.3.4', '256.256.256/0'), // invalid CIDR notation - array(false, 'an_invalid_ip', '192.168.1.0/24'), - ); - } - - /** - * @dataProvider getIpv6Data - */ - public function testIpv6($matches, $remoteAddr, $cidr) - { - if (!defined('AF_INET6')) { - $this->markTestSkipped('Only works when PHP is compiled without the option "disable-ipv6".'); - } - - $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr)); - } - - public function getIpv6Data() - { - return array( - array(true, '2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'), - array(false, '2a00:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'), - array(false, '2a01:198:603:0:396e:4789:8e99:890f', '::1'), - array(true, '0:0:0:0:0:0:0:1', '::1'), - array(false, '0:0:603:0:396e:4789:8e99:0001', '::1'), - array(true, '0:0:603:0:396e:4789:8e99:0001', '::/0'), - array(true, '0:0:603:0:396e:4789:8e99:0001', '2a01:198:603:0::/0'), - array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '2a01:198:603:0::/65')), - array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('2a01:198:603:0::/65', '::1')), - array(false, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '1a01:198:603:0::/65')), - array(false, '}__test|O:21:"JDatabaseDriverMysqli":3:{s:2', '::1'), - array(false, '2a01:198:603:0:396e:4789:8e99:890f', 'unknown'), - ); - } - - /** - * @expectedException \RuntimeException - * @requires extension sockets - */ - public function testAnIpv6WithOptionDisabledIpv6() - { - if (defined('AF_INET6')) { - $this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".'); - } - - IpUtils::checkIp('2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'); - } - - /** - * @dataProvider invalidIpAddressData - */ - public function testInvalidIpAddressesDoNotMatch($requestIp, $proxyIp) - { - $this->assertFalse(IpUtils::checkIp4($requestIp, $proxyIp)); - } - - public function invalidIpAddressData() - { - return array( - 'invalid proxy wildcard' => array('192.168.20.13', '*'), - 'invalid proxy missing netmask' => array('192.168.20.13', '0.0.0.0'), - 'invalid request IP with invalid proxy wildcard' => array('0.0.0.0', '*'), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/JsonResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/JsonResponseTest.php deleted file mode 100644 index 201839f89..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/JsonResponseTest.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\JsonResponse; - -class JsonResponseTest extends TestCase -{ - public function testConstructorEmptyCreatesJsonObject() - { - $response = new JsonResponse(); - $this->assertSame('{}', $response->getContent()); - } - - public function testConstructorWithArrayCreatesJsonArray() - { - $response = new JsonResponse(array(0, 1, 2, 3)); - $this->assertSame('[0,1,2,3]', $response->getContent()); - } - - public function testConstructorWithAssocArrayCreatesJsonObject() - { - $response = new JsonResponse(array('foo' => 'bar')); - $this->assertSame('{"foo":"bar"}', $response->getContent()); - } - - public function testConstructorWithSimpleTypes() - { - $response = new JsonResponse('foo'); - $this->assertSame('"foo"', $response->getContent()); - - $response = new JsonResponse(0); - $this->assertSame('0', $response->getContent()); - - $response = new JsonResponse(0.1); - $this->assertSame('0.1', $response->getContent()); - - $response = new JsonResponse(true); - $this->assertSame('true', $response->getContent()); - } - - public function testConstructorWithCustomStatus() - { - $response = new JsonResponse(array(), 202); - $this->assertSame(202, $response->getStatusCode()); - } - - public function testConstructorAddsContentTypeHeader() - { - $response = new JsonResponse(); - $this->assertSame('application/json', $response->headers->get('Content-Type')); - } - - public function testConstructorWithCustomHeaders() - { - $response = new JsonResponse(array(), 200, array('ETag' => 'foo')); - $this->assertSame('application/json', $response->headers->get('Content-Type')); - $this->assertSame('foo', $response->headers->get('ETag')); - } - - public function testConstructorWithCustomContentType() - { - $headers = array('Content-Type' => 'application/vnd.acme.blog-v1+json'); - - $response = new JsonResponse(array(), 200, $headers); - $this->assertSame('application/vnd.acme.blog-v1+json', $response->headers->get('Content-Type')); - } - - public function testSetJson() - { - $response = new JsonResponse('1', 200, array(), true); - $this->assertEquals('1', $response->getContent()); - - $response = new JsonResponse('[1]', 200, array(), true); - $this->assertEquals('[1]', $response->getContent()); - - $response = new JsonResponse(null, 200, array()); - $response->setJson('true'); - $this->assertEquals('true', $response->getContent()); - } - - public function testCreate() - { - $response = JsonResponse::create(array('foo' => 'bar'), 204); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response); - $this->assertEquals('{"foo":"bar"}', $response->getContent()); - $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'); - - $this->assertEquals('/**/callback({"foo":"bar"});', $response->getContent()); - $this->assertEquals('text/javascript', $response->headers->get('Content-Type')); - } - - public function testJsonEncodeFlags() - { - $response = new JsonResponse('<>\'&"'); - - $this->assertEquals('"\u003C\u003E\u0027\u0026\u0022"', $response->getContent()); - } - - public function testGetEncodingOptions() - { - $response = new JsonResponse(); - - $this->assertEquals(JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT, $response->getEncodingOptions()); - } - - public function testSetEncodingOptions() - { - $response = new JsonResponse(); - $response->setData(array(array(1, 2, 3))); - - $this->assertEquals('[[1,2,3]]', $response->getContent()); - - $response->setEncodingOptions(JSON_FORCE_OBJECT); - - $this->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response->getContent()); - } - - public function testItAcceptsJsonAsString() - { - $response = JsonResponse::fromJsonString('{"foo":"bar"}'); - $this->assertSame('{"foo":"bar"}', $response->getContent()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSetCallbackInvalidIdentifier() - { - $response = new JsonResponse('foo'); - $response->setCallback('+invalid'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSetContent() - { - JsonResponse::create("\xB1\x31"); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage This error is expected - */ - public function testSetContentJsonSerializeError() - { - if (!interface_exists('JsonSerializable', false)) { - $this->markTestSkipped('JsonSerializable is required.'); - } - - $serializable = new JsonSerializableObject(); - - JsonResponse::create($serializable); - } - - public function testSetComplexCallback() - { - $response = JsonResponse::create(array('foo' => 'bar')); - $response->setCallback('ಠ_ಠ["foo"].bar[0]'); - - $this->assertEquals('/**/ಠ_ಠ["foo"].bar[0]({"foo":"bar"});', $response->getContent()); - } -} - -if (interface_exists('JsonSerializable', false)) { - class JsonSerializableObject implements \JsonSerializable - { - public function jsonSerialize() - { - throw new \Exception('This error is expected'); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/ParameterBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/ParameterBagTest.php deleted file mode 100644 index ab908d8d3..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/ParameterBagTest.php +++ /dev/null @@ -1,194 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\ParameterBag; - -class ParameterBagTest extends TestCase -{ - public function testConstructor() - { - $this->testAll(); - } - - public function testAll() - { - $bag = new ParameterBag(array('foo' => 'bar')); - $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()); - } - - public function testReplace() - { - $bag = new ParameterBag(array('foo' => 'bar')); - - $bag->replace(array('FOO' => 'BAR')); - $this->assertEquals(array('FOO' => 'BAR'), $bag->all(), '->replace() replaces the input with the argument'); - $this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input'); - } - - public function testGet() - { - $bag = new ParameterBag(array('foo' => 'bar', 'null' => null)); - - $this->assertEquals('bar', $bag->get('foo'), '->get() gets the value of a parameter'); - $this->assertEquals('default', $bag->get('unknown', 'default'), '->get() returns second argument as default if a parameter is not defined'); - $this->assertNull($bag->get('null', 'default'), '->get() returns null if null is set'); - } - - public function testGetDoesNotUseDeepByDefault() - { - $bag = new ParameterBag(array('foo' => array('bar' => 'moo'))); - - $this->assertNull($bag->get('foo[bar]')); - } - - public function testSet() - { - $bag = new ParameterBag(array()); - - $bag->set('foo', 'bar'); - $this->assertEquals('bar', $bag->get('foo'), '->set() sets the value of parameter'); - - $bag->set('foo', 'baz'); - $this->assertEquals('baz', $bag->get('foo'), '->set() overrides previously set parameter'); - } - - public function testHas() - { - $bag = new ParameterBag(array('foo' => 'bar')); - - $this->assertTrue($bag->has('foo'), '->has() returns true if a parameter is defined'); - $this->assertFalse($bag->has('unknown'), '->has() return false if a parameter is not defined'); - } - - public function testGetAlpha() - { - $bag = new ParameterBag(array('word' => 'foo_BAR_012')); - - $this->assertEquals('fooBAR', $bag->getAlpha('word'), '->getAlpha() gets only alphabetic characters'); - $this->assertEquals('', $bag->getAlpha('unknown'), '->getAlpha() returns empty string if a parameter is not defined'); - } - - public function testGetAlnum() - { - $bag = new ParameterBag(array('word' => 'foo_BAR_012')); - - $this->assertEquals('fooBAR012', $bag->getAlnum('word'), '->getAlnum() gets only alphanumeric characters'); - $this->assertEquals('', $bag->getAlnum('unknown'), '->getAlnum() returns empty string if a parameter is not defined'); - } - - public function testGetDigits() - { - $bag = new ParameterBag(array('word' => 'foo_BAR_012')); - - $this->assertEquals('012', $bag->getDigits('word'), '->getDigits() gets only digits as string'); - $this->assertEquals('', $bag->getDigits('unknown'), '->getDigits() returns empty string if a parameter is not defined'); - } - - public function testGetInt() - { - $bag = new ParameterBag(array('digits' => '0123')); - - $this->assertEquals(123, $bag->getInt('digits'), '->getInt() gets a value of parameter as integer'); - $this->assertEquals(0, $bag->getInt('unknown'), '->getInt() returns zero if a parameter is not defined'); - } - - public function testFilter() - { - $bag = new ParameterBag(array( - 'digits' => '0123ab', - 'email' => 'example@example.com', - 'url' => 'http://example.com/foo', - 'dec' => '256', - 'hex' => '0x100', - 'array' => array('bang'), - )); - - $this->assertEmpty($bag->filter('nokey'), '->filter() should return empty by default if no key is found'); - - $this->assertEquals('0123', $bag->filter('digits', '', FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters'); - - $this->assertEquals('example@example.com', $bag->filter('email', '', FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email'); - - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, array('flags' => FILTER_FLAG_PATH_REQUIRED)), '->filter() gets a value of parameter as URL with a path'); - - // This test is repeated for code-coverage - $this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path'); - - $this->assertFalse($bag->filter('dec', '', FILTER_VALIDATE_INT, array( - 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff), - )), '->filter() gets a value of parameter as integer between boundaries'); - - $this->assertFalse($bag->filter('hex', '', FILTER_VALIDATE_INT, array( - 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff), - )), '->filter() gets a value of parameter as integer between boundaries'); - - $this->assertEquals(array('bang'), $bag->filter('array', ''), '->filter() gets a value of parameter as an array'); - } - - public function testGetIterator() - { - $parameters = array('foo' => 'bar', 'hello' => 'world'); - $bag = new ParameterBag($parameters); - - $i = 0; - foreach ($bag as $key => $val) { - ++$i; - $this->assertEquals($parameters[$key], $val); - } - - $this->assertEquals(count($parameters), $i); - } - - public function testCount() - { - $parameters = array('foo' => 'bar', 'hello' => 'world'); - $bag = new ParameterBag($parameters); - - $this->assertCount(count($parameters), $bag); - } - - public function testGetBoolean() - { - $parameters = array('string_true' => 'true', 'string_false' => 'false'); - $bag = new ParameterBag($parameters); - - $this->assertTrue($bag->getBoolean('string_true'), '->getBoolean() gets the string true as boolean true'); - $this->assertFalse($bag->getBoolean('string_false'), '->getBoolean() gets the string false as boolean false'); - $this->assertFalse($bag->getBoolean('unknown'), '->getBoolean() returns false if a parameter is not defined'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/RedirectResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/RedirectResponseTest.php deleted file mode 100644 index d389e83db..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/RedirectResponseTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\RedirectResponse; - -class RedirectResponseTest extends TestCase -{ - public function testGenerateMetaRedirect() - { - $response = new RedirectResponse('foo.bar'); - - $this->assertEquals(1, preg_match( - '##', - preg_replace(array('/\s+/', '/\'/'), array(' ', '"'), $response->getContent()) - )); - } - - /** - * @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'); - - $this->assertTrue($response->headers->has('Location')); - $this->assertEquals('foo.bar', $response->headers->get('Location')); - } - - public function testGetTargetUrl() - { - $response = new RedirectResponse('foo.bar'); - - $this->assertEquals('foo.bar', $response->getTargetUrl()); - } - - public function testSetTargetUrl() - { - $response = new RedirectResponse('foo.bar'); - $response->setTargetUrl('baz.beep'); - - $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); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); - $this->assertEquals(301, $response->getStatusCode()); - } - - public function testCacheHeaders() - { - $response = new RedirectResponse('foo.bar', 301); - $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); - - $response = new RedirectResponse('foo.bar', 301, array('cache-control' => 'max-age=86400')); - $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); - $this->assertTrue($response->headers->hasCacheControlDirective('max-age')); - - $response = new RedirectResponse('foo.bar', 302); - $this->assertTrue($response->headers->hasCacheControlDirective('no-cache')); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/RequestMatcherTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/RequestMatcherTest.php deleted file mode 100644 index b5d80048f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/RequestMatcherTest.php +++ /dev/null @@ -1,151 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\RequestMatcher; -use Symfony\Component\HttpFoundation\Request; - -class RequestMatcherTest extends TestCase -{ - /** - * @dataProvider getMethodData - */ - public function testMethod($requestMethod, $matcherMethod, $isMatch) - { - $matcher = new RequestMatcher(); - $matcher->matchMethod($matcherMethod); - $request = Request::create('', $requestMethod); - $this->assertSame($isMatch, $matcher->matches($request)); - - $matcher = new RequestMatcher(null, null, $matcherMethod); - $request = Request::create('', $requestMethod); - $this->assertSame($isMatch, $matcher->matches($request)); - } - - public function getMethodData() - { - 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 testScheme() - { - $httpRequest = $request = $request = Request::create(''); - $httpsRequest = $request = $request = Request::create('', 'get', array(), array(), array(), array('HTTPS' => 'on')); - - $matcher = new RequestMatcher(); - $matcher->matchScheme('https'); - $this->assertFalse($matcher->matches($httpRequest)); - $this->assertTrue($matcher->matches($httpsRequest)); - - $matcher->matchScheme('http'); - $this->assertFalse($matcher->matches($httpsRequest)); - $this->assertTrue($matcher->matches($httpRequest)); - - $matcher = new RequestMatcher(); - $this->assertTrue($matcher->matches($httpsRequest)); - $this->assertTrue($matcher->matches($httpRequest)); - } - - /** - * @dataProvider getHostData - */ - public function testHost($pattern, $isMatch) - { - $matcher = new RequestMatcher(); - $request = Request::create('', 'get', array(), array(), array(), array('HTTP_HOST' => 'foo.example.com')); - - $matcher->matchHost($pattern); - $this->assertSame($isMatch, $matcher->matches($request)); - - $matcher = new RequestMatcher(null, $pattern); - $this->assertSame($isMatch, $matcher->matches($request)); - } - - public function getHostData() - { - 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() - { - $matcher = new RequestMatcher(); - - $request = Request::create('/admin/foo'); - - $matcher->matchPath('/admin/.*'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchPath('/admin'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchPath('^/admin/.*$'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchMethod('/blog/.*'); - $this->assertFalse($matcher->matches($request)); - } - - public function testPathWithLocaleIsNotSupported() - { - $matcher = new RequestMatcher(); - $request = Request::create('/en/login'); - $request->setLocale('en'); - - $matcher->matchPath('^/{_locale}/login$'); - $this->assertFalse($matcher->matches($request)); - } - - public function testPathWithEncodedCharacters() - { - $matcher = new RequestMatcher(); - $request = Request::create('/admin/fo%20o'); - $matcher->matchPath('^/admin/fo o*$'); - $this->assertTrue($matcher->matches($request)); - } - - public function testAttributes() - { - $matcher = new RequestMatcher(); - - $request = Request::create('/admin/foo'); - $request->attributes->set('foo', 'foo_bar'); - - $matcher->matchAttribute('foo', 'foo_.*'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchAttribute('foo', 'foo'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchAttribute('foo', '^foo_bar$'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchAttribute('foo', 'babar'); - $this->assertFalse($matcher->matches($request)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/RequestStackTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/RequestStackTest.php deleted file mode 100644 index a84fb26f0..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/RequestStackTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; - -class RequestStackTest extends TestCase -{ - public function testGetCurrentRequest() - { - $requestStack = new RequestStack(); - $this->assertNull($requestStack->getCurrentRequest()); - - $request = Request::create('/foo'); - - $requestStack->push($request); - $this->assertSame($request, $requestStack->getCurrentRequest()); - - $this->assertSame($request, $requestStack->pop()); - $this->assertNull($requestStack->getCurrentRequest()); - - $this->assertNull($requestStack->pop()); - } - - public function testGetMasterRequest() - { - $requestStack = new RequestStack(); - $this->assertNull($requestStack->getMasterRequest()); - - $masterRequest = Request::create('/foo'); - $subRequest = Request::create('/bar'); - - $requestStack->push($masterRequest); - $requestStack->push($subRequest); - - $this->assertSame($masterRequest, $requestStack->getMasterRequest()); - } - - public function testGetParentRequest() - { - $requestStack = new RequestStack(); - $this->assertNull($requestStack->getParentRequest()); - - $masterRequest = Request::create('/foo'); - - $requestStack->push($masterRequest); - $this->assertNull($requestStack->getParentRequest()); - - $firstSubRequest = Request::create('/bar'); - - $requestStack->push($firstSubRequest); - $this->assertSame($masterRequest, $requestStack->getParentRequest()); - - $secondSubRequest = Request::create('/baz'); - - $requestStack->push($secondSubRequest); - $this->assertSame($firstSubRequest, $requestStack->getParentRequest()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/RequestTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/RequestTest.php deleted file mode 100644 index 72add9535..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/RequestTest.php +++ /dev/null @@ -1,2329 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Request; - -class RequestTest extends TestCase -{ - protected function tearDown() - { - // reset - Request::setTrustedProxies(array(), -1); - } - - public function testInitialize() - { - $request = new Request(); - - $request->initialize(array('foo' => 'bar')); - $this->assertEquals('bar', $request->query->get('foo'), '->initialize() takes an array of query parameters as its first argument'); - - $request->initialize(array(), array('foo' => 'bar')); - $this->assertEquals('bar', $request->request->get('foo'), '->initialize() takes an array of request parameters as its second argument'); - - $request->initialize(array(), array(), array('foo' => 'bar')); - $this->assertEquals('bar', $request->attributes->get('foo'), '->initialize() takes an array of attributes as its third argument'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_FOO' => 'bar')); - $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its sixth 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:password@test.com'); - $user = $request->getUser(); - - $this->assertEquals('user', $user); - } - - public function testGetPassword() - { - $request = Request::create('http://user:password@test.com'); - $password = $request->getPassword(); - - $this->assertEquals('password', $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); - } - - public function testCreate() - { - $request = Request::create('http://test.com/foo?bar=baz'); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/foo', 'GET', array('bar' => 'baz')); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/foo?bar=foo', 'GET', array('bar' => 'baz')); - $this->assertEquals('http://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('https://test.com/foo?bar=baz'); - $this->assertEquals('https://test.com/foo?bar=baz', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('bar=baz', $request->getQueryString()); - $this->assertEquals(443, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('test.com:90/foo'); - $this->assertEquals('http://test.com:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('test.com', $request->getHost()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('https://test.com:90/foo'); - $this->assertEquals('https://test.com:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('test.com', $request->getHost()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://127.0.0.1:90/foo'); - $this->assertEquals('https://127.0.0.1:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('127.0.0.1', $request->getHost()); - $this->assertEquals('127.0.0.1:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://[::1]:90/foo'); - $this->assertEquals('https://[::1]:90/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('[::1]', $request->getHost()); - $this->assertEquals('[::1]:90', $request->getHttpHost()); - $this->assertEquals(90, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $request = Request::create('https://[::1]/foo'); - $this->assertEquals('https://[::1]/foo', $request->getUri()); - $this->assertEquals('/foo', $request->getPathInfo()); - $this->assertEquals('[::1]', $request->getHost()); - $this->assertEquals('[::1]', $request->getHttpHost()); - $this->assertEquals(443, $request->getPort()); - $this->assertTrue($request->isSecure()); - - $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; - $request = Request::create('http://example.com/jsonrpc', 'POST', array(), array(), array(), array(), $json); - $this->assertEquals($json, $request->getContent()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com'); - $this->assertEquals('http://test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $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()); - $this->assertEquals('test=1', $request->getQueryString()); - $this->assertEquals(90, $request->getPort()); - $this->assertEquals('test.com:90', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://username:password@test.com'); - $this->assertEquals('http://test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('username', $request->getUser()); - $this->assertEquals('password', $request->getPassword()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://username@test.com'); - $this->assertEquals('http://test.com/', $request->getUri()); - $this->assertEquals('/', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('username', $request->getUser()); - $this->assertSame('', $request->getPassword()); - $this->assertFalse($request->isSecure()); - - $request = Request::create('http://test.com/?foo'); - $this->assertEquals('/?foo', $request->getRequestUri()); - $this->assertEquals(array('foo' => ''), $request->query->all()); - - // assume rewrite rule: (.*) --> app/app.php; app/ is a symlink to a symfony web/ directory - $request = Request::create('http://test.com/apparthotel-1234', 'GET', array(), array(), array(), - array( - 'DOCUMENT_ROOT' => '/var/www/www.test.com', - 'SCRIPT_FILENAME' => '/var/www/www.test.com/app/app.php', - 'SCRIPT_NAME' => '/app/app.php', - 'PHP_SELF' => '/app/app.php/apparthotel-1234', - )); - $this->assertEquals('http://test.com/apparthotel-1234', $request->getUri()); - $this->assertEquals('/apparthotel-1234', $request->getPathInfo()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals(80, $request->getPort()); - $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertFalse($request->isSecure()); - } - - public function testCreateCheckPrecedence() - { - // server is used by default - $request = Request::create('/', 'DELETE', array(), array(), array(), array( - 'HTTP_HOST' => 'example.com', - 'HTTPS' => 'on', - 'SERVER_PORT' => 443, - 'PHP_AUTH_USER' => 'fabien', - 'PHP_AUTH_PW' => 'pa$$', - 'QUERY_STRING' => 'foo=bar', - 'CONTENT_TYPE' => 'application/json', - )); - $this->assertEquals('example.com', $request->getHost()); - $this->assertEquals(443, $request->getPort()); - $this->assertTrue($request->isSecure()); - $this->assertEquals('fabien', $request->getUser()); - $this->assertEquals('pa$$', $request->getPassword()); - $this->assertEquals('', $request->getQueryString()); - $this->assertEquals('application/json', $request->headers->get('CONTENT_TYPE')); - - // URI has precedence over server - $request = Request::create('http://thomas:pokemon@example.net:8080/?foo=bar', 'GET', array(), array(), array(), array( - 'HTTP_HOST' => 'example.com', - 'HTTPS' => 'on', - 'SERVER_PORT' => 443, - )); - $this->assertEquals('example.net', $request->getHost()); - $this->assertEquals(8080, $request->getPort()); - $this->assertFalse($request->isSecure()); - $this->assertEquals('thomas', $request->getUser()); - $this->assertEquals('pokemon', $request->getPassword()); - $this->assertEquals('foo=bar', $request->getQueryString()); - } - - public function testDuplicate() - { - $request = new Request(array('foo' => 'bar'), array('foo' => 'bar'), array('foo' => 'bar'), array(), array(), array('HTTP_FOO' => 'bar')); - $dup = $request->duplicate(); - - $this->assertEquals($request->query->all(), $dup->query->all(), '->duplicate() duplicates a request an copy the current query parameters'); - $this->assertEquals($request->request->all(), $dup->request->all(), '->duplicate() duplicates a request an copy the current request parameters'); - $this->assertEquals($request->attributes->all(), $dup->attributes->all(), '->duplicate() duplicates a request an copy the current attributes'); - $this->assertEquals($request->headers->all(), $dup->headers->all(), '->duplicate() duplicates a request an copy the current HTTP headers'); - - $dup = $request->duplicate(array('foo' => 'foobar'), array('foo' => 'foobar'), array('foo' => 'foobar'), array(), array(), array('HTTP_FOO' => 'foobar')); - - $this->assertEquals(array('foo' => 'foobar'), $dup->query->all(), '->duplicate() overrides the query parameters if provided'); - $this->assertEquals(array('foo' => 'foobar'), $dup->request->all(), '->duplicate() overrides the request parameters if provided'); - $this->assertEquals(array('foo' => 'foobar'), $dup->attributes->all(), '->duplicate() overrides the attributes if provided'); - $this->assertEquals(array('foo' => array('foobar')), $dup->headers->all(), '->duplicate() overrides the HTTP header if provided'); - } - - public function testDuplicateWithFormat() - { - $request = new Request(array(), array(), array('_format' => 'json')); - $dup = $request->duplicate(); - - $this->assertEquals('json', $dup->getRequestFormat()); - $this->assertEquals('json', $dup->attributes->get('_format')); - - $request = new Request(); - $request->setRequestFormat('xml'); - $dup = $request->duplicate(); - - $this->assertEquals('xml', $dup->getRequestFormat()); - } - - /** - * @dataProvider getFormatToMimeTypeMapProviderWithAdditionalNullFormat - */ - public function testGetFormatFromMimeType($format, $mimeTypes) - { - $request = new Request(); - foreach ($mimeTypes as $mime) { - $this->assertEquals($format, $request->getFormat($mime)); - } - $request->setFormat($format, $mimeTypes); - foreach ($mimeTypes as $mime) { - $this->assertEquals($format, $request->getFormat($mime)); - - if (null !== $format) { - $this->assertEquals($mimeTypes[0], $request->getMimeType($format)); - } - } - } - - public function getFormatToMimeTypeMapProviderWithAdditionalNullFormat() - { - return array_merge( - array(array(null, array(null, 'unexistent-mime-type'))), - $this->getFormatToMimeTypeMapProvider() - ); - } - - public function testGetFormatFromMimeTypeWithParameters() - { - $request = new Request(); - $this->assertEquals('json', $request->getFormat('application/json; charset=utf-8')); - } - - /** - * @dataProvider getFormatToMimeTypeMapProvider - */ - public function testGetMimeTypeFromFormat($format, $mimeTypes) - { - $request = new Request(); - $this->assertEquals($mimeTypes[0], $request->getMimeType($format)); - } - - /** - * @dataProvider getFormatToMimeTypeMapProvider - */ - public function testGetMimeTypesFromFormat($format, $mimeTypes) - { - $this->assertEquals($mimeTypes, Request::getMimeTypes($format)); - } - - public function testGetMimeTypesFromInexistentFormat() - { - $request = new Request(); - $this->assertNull($request->getMimeType('foo')); - $this->assertEquals(array(), Request::getMimeTypes('foo')); - } - - public function testGetFormatWithCustomMimeType() - { - $request = new Request(); - $request->setFormat('custom', 'application/vnd.foo.api;myversion=2.3'); - $this->assertEquals('custom', $request->getFormat('application/vnd.foo.api;myversion=2.3')); - } - - public function getFormatToMimeTypeMapProvider() - { - return array( - array('txt', array('text/plain')), - array('js', array('application/javascript', 'application/x-javascript', 'text/javascript')), - array('css', array('text/css')), - array('json', array('application/json', 'application/x-json')), - array('jsonld', array('application/ld+json')), - array('xml', array('text/xml', 'application/xml', 'application/x-xml')), - array('rdf', array('application/rdf+xml')), - array('atom', array('application/atom+xml')), - ); - } - - public function testGetUri() - { - $server = array(); - - // Standard Request on non default PORT - // http://host:8080/index.php/path/info?query=string - - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/index.php/path/info?query=string'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PATH_INFO'] = '/path/info'; - $server['PATH_TRANSLATED'] = 'redirect:/index.php/path/info'; - $server['PHP_SELF'] = '/index_dev.php/path/info'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request = new Request(); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host:8080/index.php/path/info?query=string', $request->getUri(), '->getUri() with non default port'); - - // Use std port number - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/index.php/path/info?query=string', $request->getUri(), '->getUri() with default port without HOST_HEADER'); - - // Request with URL REWRITING (hide index.php) - // RewriteCond %{REQUEST_FILENAME} !-f - // RewriteRule ^(.*)$ index.php [QSA,L] - // http://host:8080/path/info?query=string - $server = array(); - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['REDIRECT_QUERY_STRING'] = 'query=string'; - $server['REDIRECT_URL'] = '/path/info'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/path/info?toto=test&1=1'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PHP_SELF'] = '/index.php'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://host:8080/path/info?query=string', $request->getUri(), '->getUri() with rewrite'); - - // Use std port number - // http://host/path/info?query=string - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/path/info?query=string', $request->getUri(), '->getUri() with rewrite and default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/path/info?query=string', $request->getUri(), '->getUri() with rewrite, default port without HOST_HEADER'); - - // With encoded characters - - $server = array( - 'HTTP_HOST' => 'host:8080', - 'SERVER_NAME' => 'servername', - 'SERVER_PORT' => '8080', - 'QUERY_STRING' => 'query=string', - 'REQUEST_URI' => '/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', - 'SCRIPT_NAME' => '/ba se/index_dev.php', - 'PATH_TRANSLATED' => 'redirect:/index.php/foo bar/in+fo', - 'PHP_SELF' => '/ba se/index_dev.php/path/info', - 'SCRIPT_FILENAME' => '/some/where/ba se/index_dev.php', - ); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals( - 'http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', - $request->getUri() - ); - - // with user info - - $server['PHP_AUTH_USER'] = 'fabien'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://host: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://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request->getUri()); - } - - public function testGetUriForPath() - { - $request = Request::create('http://test.com/foo?bar=baz'); - $this->assertEquals('http://test.com/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('http://test.com:90/foo?bar=baz'); - $this->assertEquals('http://test.com:90/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('https://test.com/foo?bar=baz'); - $this->assertEquals('https://test.com/some/path', $request->getUriForPath('/some/path')); - - $request = Request::create('https://test.com:90/foo?bar=baz'); - $this->assertEquals('https://test.com:90/some/path', $request->getUriForPath('/some/path')); - - $server = array(); - - // Standard Request on non default PORT - // http://host:8080/index.php/path/info?query=string - - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/index.php/path/info?query=string'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PATH_INFO'] = '/path/info'; - $server['PATH_TRANSLATED'] = 'redirect:/index.php/path/info'; - $server['PHP_SELF'] = '/index_dev.php/path/info'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request = new Request(); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host:8080/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with non default port'); - - // Use std port number - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/index.php/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with default port without HOST_HEADER'); - - // Request with URL REWRITING (hide index.php) - // RewriteCond %{REQUEST_FILENAME} !-f - // RewriteRule ^(.*)$ index.php [QSA,L] - // http://host:8080/path/info?query=string - $server = array(); - $server['HTTP_HOST'] = 'host:8080'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '8080'; - - $server['REDIRECT_QUERY_STRING'] = 'query=string'; - $server['REDIRECT_URL'] = '/path/info'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['QUERY_STRING'] = 'query=string'; - $server['REQUEST_URI'] = '/path/info?toto=test&1=1'; - $server['SCRIPT_NAME'] = '/index.php'; - $server['PHP_SELF'] = '/index.php'; - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://host:8080/some/path', $request->getUriForPath('/some/path'), '->getUri() with rewrite'); - - // Use std port number - // http://host/path/info?query=string - $server['HTTP_HOST'] = 'host'; - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://host/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite and default port'); - - // Without HOST HEADER - unset($server['HTTP_HOST']); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '80'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('http://servername/some/path', $request->getUriForPath('/some/path'), '->getUriForPath() with rewrite, default port without HOST_HEADER'); - $this->assertEquals('servername', $request->getHttpHost()); - - // with user info - - $server['PHP_AUTH_USER'] = 'fabien'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $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://servername/some/path', $request->getUriForPath('/some/path')); - } - - /** - * @dataProvider getRelativeUriForPathData() - */ - public function testGetRelativeUriForPath($expected, $pathinfo, $path) - { - $this->assertEquals($expected, Request::create($pathinfo)->getRelativeUriForPath($path)); - } - - public function getRelativeUriForPathData() - { - return array( - array('me.png', '/foo', '/me.png'), - array('../me.png', '/foo/bar', '/me.png'), - array('me.png', '/foo/bar', '/foo/me.png'), - array('../baz/me.png', '/foo/bar/b', '/foo/baz/me.png'), - array('../../fooz/baz/me.png', '/foo/bar/b', '/fooz/baz/me.png'), - array('baz/me.png', '/foo/bar/b', 'baz/me.png'), - ); - } - - public function testGetUserInfo() - { - $request = new Request(); - - $server = array('PHP_AUTH_USER' => 'fabien'); - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('fabien', $request->getUserInfo()); - - $server['PHP_AUTH_USER'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('0', $request->getUserInfo()); - - $server['PHP_AUTH_PW'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('0:0', $request->getUserInfo()); - } - - public function testGetSchemeAndHttpHost() - { - $request = new Request(); - - $server = array(); - $server['SERVER_NAME'] = 'servername'; - $server['SERVER_PORT'] = '90'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - - $server['PHP_AUTH_USER'] = 'fabien'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - - $server['PHP_AUTH_USER'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - - $server['PHP_AUTH_PW'] = '0'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('http://servername:90', $request->getSchemeAndHttpHost()); - } - - /** - * @dataProvider getQueryStringNormalizationData - */ - public function testGetQueryString($query, $expectedQuery, $msg) - { - $request = new Request(); - - $request->server->set('QUERY_STRING', $query); - $this->assertSame($expectedQuery, $request->getQueryString(), $msg); - } - - public function getQueryStringNormalizationData() - { - return array( - array('foo', 'foo', 'works with valueless parameters'), - array('foo=', 'foo=', 'includes a dangling equal sign'), - array('bar=&foo=bar', 'bar=&foo=bar', '->works with empty parameters'), - array('foo=bar&bar=', 'bar=&foo=bar', 'sorts keys alphabetically'), - - // GET parameters, that are submitted from a HTML form, encode spaces as "+" by default (as defined in enctype application/x-www-form-urlencoded). - // PHP also converts "+" to spaces when filling the global _GET or when using the function parse_str. - array('him=John%20Doe&her=Jane+Doe', 'her=Jane%20Doe&him=John%20Doe', 'normalizes spaces in both encodings "%20" and "+"'), - - array('foo[]=1&foo[]=2', 'foo%5B%5D=1&foo%5B%5D=2', 'allows array notation'), - array('foo=1&foo=2', 'foo=1&foo=2', 'allows repeated parameters'), - array('pa%3Dram=foo%26bar%3Dbaz&test=test', 'pa%3Dram=foo%26bar%3Dbaz&test=test', 'works with encoded delimiters'), - array('0', '0', 'allows "0"'), - array('Jane Doe&John%20Doe', 'Jane%20Doe&John%20Doe', 'normalizes encoding in keys'), - array('her=Jane Doe&him=John%20Doe', 'her=Jane%20Doe&him=John%20Doe', 'normalizes encoding in values'), - array('foo=bar&&&test&&', 'foo=bar&test', 'removes unneeded delimiters'), - array('formula=e=m*c^2', 'formula=e%3Dm%2Ac%5E2', 'correctly treats only the first "=" as delimiter and the next as value'), - - // Ignore pairs with empty key, even if there was a value, e.g. "=value", as such nameless values cannot be retrieved anyway. - // PHP also does not include them when building _GET. - array('foo=bar&=a=b&=x=y', 'foo=bar', 'removes params with empty key'), - ); - } - - public function testGetQueryStringReturnsNull() - { - $request = new Request(); - - $this->assertNull($request->getQueryString(), '->getQueryString() returns null for non-existent query string'); - - $request->server->set('QUERY_STRING', ''); - $this->assertNull($request->getQueryString(), '->getQueryString() returns null for empty query string'); - } - - public function testGetHost() - { - $request = new Request(); - - $request->initialize(array('foo' => 'bar')); - $this->assertEquals('', $request->getHost(), '->getHost() return empty string if not initialized'); - - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.example.com')); - $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from Host Header'); - - // Host header with port number - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.example.com:8080')); - $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from Host Header with port number'); - - // Server values - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.example.com')); - $this->assertEquals('www.example.com', $request->getHost(), '->getHost() from server name'); - - $request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.example.com', 'HTTP_HOST' => 'www.host.com')); - $this->assertEquals('www.host.com', $request->getHost(), '->getHost() value from Host header has priority over SERVER_NAME '); - } - - public function testGetPort() - { - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '443', - )); - $port = $request->getPort(); - - $this->assertEquals(80, $port, 'Without trusted proxies FORWARDED_PROTO and FORWARDED_PORT are ignored.'); - - Request::setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_ALL); - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '8443', - )); - $this->assertEquals(80, $request->getPort(), 'With PROTO and PORT on untrusted connection server value takes precedence.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(8443, $request->getPort(), 'With PROTO and PORT set PORT takes precedence.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https', - )); - $this->assertEquals(80, $request->getPort(), 'With only PROTO set getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(443, $request->getPort(), 'With only PROTO set getPort() defaults to 443.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'http', - )); - $this->assertEquals(80, $request->getPort(), 'If X_FORWARDED_PROTO is set to HTTP getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(80, $request->getPort(), 'If X_FORWARDED_PROTO is set to HTTP getPort() returns port of the original request.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'On', - )); - $this->assertEquals(80, $request->getPort(), 'With only PROTO set and value is On, getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(443, $request->getPort(), 'With only PROTO set and value is On, getPort() defaults to 443.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => '1', - )); - $this->assertEquals(80, $request->getPort(), 'With only PROTO set and value is 1, getPort() ignores trusted headers on untrusted connection.'); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertEquals(443, $request->getPort(), 'With only PROTO set and value is 1, getPort() defaults to 443.'); - - $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'something-else', - )); - $port = $request->getPort(); - $this->assertEquals(80, $port, 'With only PROTO set and value is not recognized, getPort() defaults to 80.'); - } - - /** - * @expectedException \RuntimeException - */ - public function testGetHostWithFakeHttpHostValue() - { - $request = new Request(); - $request->initialize(array(), array(), array(), array(), array(), array('HTTP_HOST' => 'www.host.com?query=string')); - $request->getHost(); - } - - public function testGetSetMethod() - { - $request = new Request(); - - $this->assertEquals('GET', $request->getMethod(), '->getMethod() returns GET if no method is defined'); - - $request->setMethod('get'); - $this->assertEquals('GET', $request->getMethod(), '->getMethod() returns an uppercased string'); - - $request->setMethod('PURGE'); - $this->assertEquals('PURGE', $request->getMethod(), '->getMethod() returns the method even if it is not a standard one'); - - $request->setMethod('POST'); - $this->assertEquals('POST', $request->getMethod(), '->getMethod() returns the method POST if no _method is defined'); - - $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'); - - $this->assertFalse(Request::getHttpMethodParameterOverride(), 'httpMethodParameterOverride should be disabled by default'); - - Request::enableHttpMethodParameterOverride(); - - $this->assertTrue(Request::getHttpMethodParameterOverride(), 'httpMethodParameterOverride should be enabled now but it is not'); - - $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->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'); - - $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 if defined and POST'); - } - - /** - * @dataProvider getClientIpsProvider - */ - public function testGetClientIp($expected, $remoteAddr, $httpForwardedFor, $trustedProxies) - { - $request = $this->getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies); - - $this->assertEquals($expected[0], $request->getClientIp()); - } - - /** - * @dataProvider getClientIpsProvider - */ - public function testGetClientIps($expected, $remoteAddr, $httpForwardedFor, $trustedProxies) - { - $request = $this->getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies); - - $this->assertEquals($expected, $request->getClientIps()); - } - - /** - * @dataProvider getClientIpsForwardedProvider - */ - public function testGetClientIpsForwarded($expected, $remoteAddr, $httpForwarded, $trustedProxies) - { - $request = $this->getRequestInstanceForClientIpsForwardedTests($remoteAddr, $httpForwarded, $trustedProxies); - - $this->assertEquals($expected, $request->getClientIps()); - } - - public function getClientIpsForwardedProvider() - { - // $expected $remoteAddr $httpForwarded $trustedProxies - return array( - array(array('127.0.0.1'), '127.0.0.1', 'for="_gazonk"', null), - array(array('127.0.0.1'), '127.0.0.1', 'for="_gazonk"', array('127.0.0.1')), - array(array('88.88.88.88'), '127.0.0.1', 'for="88.88.88.88:80"', array('127.0.0.1')), - array(array('192.0.2.60'), '::1', 'for=192.0.2.60;proto=http;by=203.0.113.43', array('::1')), - array(array('2620:0:1cfe:face:b00c::3', '192.0.2.43'), '::1', 'for=192.0.2.43, for=2620:0:1cfe:face:b00c::3', array('::1')), - array(array('2001:db8:cafe::17'), '::1', 'for="[2001:db8:cafe::17]:4711', array('::1')), - ); - } - - public function getClientIpsProvider() - { - // $expected $remoteAddr $httpForwardedFor $trustedProxies - return array( - // simple IPv4 - array(array('88.88.88.88'), '88.88.88.88', null, null), - // trust the IPv4 remote addr - array(array('88.88.88.88'), '88.88.88.88', null, array('88.88.88.88')), - - // simple IPv6 - array(array('::1'), '::1', null, null), - // trust the IPv6 remote addr - array(array('::1'), '::1', null, array('::1')), - - // forwarded for with remote IPv4 addr not trusted - array(array('127.0.0.1'), '127.0.0.1', '88.88.88.88', null), - // forwarded for with remote IPv4 addr trusted - array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88', array('127.0.0.1')), - // forwarded for with remote IPv4 and all FF addrs trusted - array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88', array('127.0.0.1', '88.88.88.88')), - // forwarded for with remote IPv4 range trusted - array(array('88.88.88.88'), '123.45.67.89', '88.88.88.88', array('123.45.67.0/24')), - - // forwarded for with remote IPv6 addr not trusted - array(array('1620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '2620:0:1cfe:face:b00c::3', null), - // forwarded for with remote IPv6 addr trusted - array(array('2620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3')), - // forwarded for with remote IPv6 range trusted - array(array('88.88.88.88'), '2a01:198:603:0:396e:4789:8e99:890f', '88.88.88.88', array('2a01:198:603:0::/65')), - - // multiple forwarded for with remote IPv4 addr trusted - array(array('88.88.88.88', '87.65.43.21', '127.0.0.1'), '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89')), - // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted - array(array('87.65.43.21', '127.0.0.1'), '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')), - // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted but in the middle - array(array('88.88.88.88', '127.0.0.1'), '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '87.65.43.21')), - // multiple forwarded for with remote IPv4 addr and all reverse proxies trusted - array(array('127.0.0.1'), '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '87.65.43.21', '88.88.88.88', '127.0.0.1')), - - // multiple forwarded for with remote IPv6 addr trusted - array(array('2620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3')), - // multiple forwarded for with remote IPv6 addr and some reverse proxies trusted - array(array('3620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3', '2620:0:1cfe:face:b00c::3')), - // multiple forwarded for with remote IPv4 addr and some reverse proxies trusted but in the middle - array(array('2620:0:1cfe:face:b00c::3', '4620:0:1cfe:face:b00c::3'), '1620:0:1cfe:face:b00c::3', '4620:0:1cfe:face:b00c::3,3620:0:1cfe:face:b00c::3,2620:0:1cfe:face:b00c::3', array('1620:0:1cfe:face:b00c::3', '3620:0:1cfe:face:b00c::3')), - - // client IP with port - array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88:12345, 127.0.0.1', array('127.0.0.1')), - - // invalid forwarded IP is ignored - array(array('88.88.88.88'), '127.0.0.1', 'unknown,88.88.88.88', array('127.0.0.1')), - array(array('88.88.88.88'), '127.0.0.1', '}__test|O:21:"JDatabaseDriverMysqli":3:{s:2,88.88.88.88', array('127.0.0.1')), - ); - } - - /** - * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException - * @dataProvider getClientIpsWithConflictingHeadersProvider - */ - public function testGetClientIpsWithConflictingHeaders($httpForwarded, $httpXForwardedFor) - { - $request = new Request(); - - $server = array( - 'REMOTE_ADDR' => '88.88.88.88', - 'HTTP_FORWARDED' => $httpForwarded, - 'HTTP_X_FORWARDED_FOR' => $httpXForwardedFor, - ); - - Request::setTrustedProxies(array('88.88.88.88'), Request::HEADER_X_FORWARDED_ALL | Request::HEADER_FORWARDED); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $request->getClientIps(); - } - - /** - * @dataProvider getClientIpsWithConflictingHeadersProvider - */ - public function testGetClientIpsOnlyXHttpForwardedForTrusted($httpForwarded, $httpXForwardedFor) - { - $request = new Request(); - - $server = array( - 'REMOTE_ADDR' => '88.88.88.88', - 'HTTP_FORWARDED' => $httpForwarded, - 'HTTP_X_FORWARDED_FOR' => $httpXForwardedFor, - ); - - Request::setTrustedProxies(array('88.88.88.88'), Request::HEADER_X_FORWARDED_FOR); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertSame(array_reverse(explode(',', $httpXForwardedFor)), $request->getClientIps()); - } - - public function getClientIpsWithConflictingHeadersProvider() - { - // $httpForwarded $httpXForwardedFor - return array( - array('for=87.65.43.21', '192.0.2.60'), - array('for=87.65.43.21, for=192.0.2.60', '192.0.2.60'), - array('for=192.0.2.60', '192.0.2.60,87.65.43.21'), - array('for="::face", for=192.0.2.60', '192.0.2.60,192.0.2.43'), - array('for=87.65.43.21, for=192.0.2.60', '192.0.2.60,87.65.43.21'), - ); - } - - /** - * @dataProvider getClientIpsWithAgreeingHeadersProvider - */ - public function testGetClientIpsWithAgreeingHeaders($httpForwarded, $httpXForwardedFor, $expectedIps) - { - $request = new Request(); - - $server = array( - 'REMOTE_ADDR' => '88.88.88.88', - 'HTTP_FORWARDED' => $httpForwarded, - 'HTTP_X_FORWARDED_FOR' => $httpXForwardedFor, - ); - - Request::setTrustedProxies(array('88.88.88.88'), Request::HEADER_X_FORWARDED_ALL); - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $clientIps = $request->getClientIps(); - - $this->assertSame($expectedIps, $clientIps); - } - - public function getClientIpsWithAgreeingHeadersProvider() - { - // $httpForwarded $httpXForwardedFor - return array( - array('for="192.0.2.60"', '192.0.2.60', array('192.0.2.60')), - array('for=192.0.2.60, for=87.65.43.21', '192.0.2.60,87.65.43.21', array('87.65.43.21', '192.0.2.60')), - array('for="[::face]", for=192.0.2.60', '::face,192.0.2.60', array('192.0.2.60', '::face')), - array('for="192.0.2.60:80"', '192.0.2.60', array('192.0.2.60')), - array('for=192.0.2.60;proto=http;by=203.0.113.43', '192.0.2.60', array('192.0.2.60')), - array('for="[2001:db8:cafe::17]:4711"', '2001:db8:cafe::17', array('2001:db8:cafe::17')), - ); - } - - public function testGetContentWorksTwiceInDefaultMode() - { - $req = new Request(); - $this->assertEquals('', $req->getContent()); - $this->assertEquals('', $req->getContent()); - } - - public function testGetContentReturnsResource() - { - $req = new Request(); - $retval = $req->getContent(true); - $this->assertInternalType('resource', $retval); - $this->assertEquals('', fread($retval, 1)); - $this->assertTrue(feof($retval)); - } - - public function testGetContentReturnsResourceWhenContentSetInConstructor() - { - $req = new Request(array(), array(), array(), array(), array(), array(), 'MyContent'); - $resource = $req->getContent(true); - - $this->assertInternalType('resource', $resource); - $this->assertEquals('MyContent', stream_get_contents($resource)); - } - - public function testContentAsResource() - { - $resource = fopen('php://memory', 'r+'); - fwrite($resource, 'My other content'); - rewind($resource); - - $req = new Request(array(), array(), array(), array(), array(), array(), $resource); - $this->assertEquals('My other content', stream_get_contents($req->getContent(true))); - $this->assertEquals('My other content', $req->getContent()); - } - - /** - * @expectedException \LogicException - * @dataProvider getContentCantBeCalledTwiceWithResourcesProvider - */ - public function testGetContentCantBeCalledTwiceWithResources($first, $second) - { - if (\PHP_VERSION_ID >= 50600) { - $this->markTestSkipped('PHP >= 5.6 allows to open php://input several times.'); - } - - $req = new Request(); - $req->getContent($first); - $req->getContent($second); - } - - public function getContentCantBeCalledTwiceWithResourcesProvider() - { - return array( - 'Resource then fetch' => array(true, false), - 'Resource then resource' => array(true, true), - ); - } - - /** - * @dataProvider getContentCanBeCalledTwiceWithResourcesProvider - * @requires PHP 5.6 - */ - public function testGetContentCanBeCalledTwiceWithResources($first, $second) - { - $req = new Request(); - $a = $req->getContent($first); - $b = $req->getContent($second); - - if ($first) { - $a = stream_get_contents($a); - } - - if ($second) { - $b = stream_get_contents($b); - } - - $this->assertSame($a, $b); - } - - public function getContentCanBeCalledTwiceWithResourcesProvider() - { - return array( - 'Fetch then fetch' => array(false, false), - 'Fetch then resource' => array(false, true), - 'Resource then fetch' => array(true, false), - 'Resource then resource' => array(true, true), - ); - } - - public function provideOverloadedMethods() - { - return array( - array('PUT'), - array('DELETE'), - array('PATCH'), - array('put'), - array('delete'), - array('patch'), - ); - } - - /** - * @dataProvider provideOverloadedMethods - */ - public function testCreateFromGlobals($method) - { - $normalizedMethod = strtoupper($method); - - $_GET['foo1'] = 'bar1'; - $_POST['foo2'] = 'bar2'; - $_COOKIE['foo3'] = 'bar3'; - $_FILES['foo4'] = array('bar4'); - $_SERVER['foo5'] = 'bar5'; - - $request = Request::createFromGlobals(); - $this->assertEquals('bar1', $request->query->get('foo1'), '::fromGlobals() uses values from $_GET'); - $this->assertEquals('bar2', $request->request->get('foo2'), '::fromGlobals() uses values from $_POST'); - $this->assertEquals('bar3', $request->cookies->get('foo3'), '::fromGlobals() uses values from $_COOKIE'); - $this->assertEquals(array('bar4'), $request->files->get('foo4'), '::fromGlobals() uses values from $_FILES'); - $this->assertEquals('bar5', $request->server->get('foo5'), '::fromGlobals() uses values from $_SERVER'); - - unset($_GET['foo1'], $_POST['foo2'], $_COOKIE['foo3'], $_FILES['foo4'], $_SERVER['foo5']); - - $_SERVER['REQUEST_METHOD'] = $method; - $_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; - $request = RequestContentProxy::createFromGlobals(); - $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'; - $request = Request::createFromGlobals(); - $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() - { - $request = new Request(); - $request->initialize(array('foo' => 'bar')); - - // as the Request::overrideGlobals really work, it erase $_SERVER, so we must backup it - $server = $_SERVER; - - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_GET); - - $request->initialize(array(), array('foo' => 'bar')); - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_POST); - - $this->assertArrayNotHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); - - $request->headers->set('X_FORWARDED_PROTO', 'https'); - - Request::setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_ALL); - $this->assertFalse($request->isSecure()); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $this->assertTrue($request->isSecure()); - - $request->overrideGlobals(); - - $this->assertArrayHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER); - - $request->headers->set('CONTENT_TYPE', 'multipart/form-data'); - $request->headers->set('CONTENT_LENGTH', 12345); - - $request->overrideGlobals(); - - $this->assertArrayHasKey('CONTENT_TYPE', $_SERVER); - $this->assertArrayHasKey('CONTENT_LENGTH', $_SERVER); - - $request->initialize(array('foo' => 'bar', 'baz' => 'foo')); - $request->query->remove('baz'); - - $request->overrideGlobals(); - - $this->assertEquals(array('foo' => 'bar'), $_GET); - $this->assertEquals('foo=bar', $_SERVER['QUERY_STRING']); - $this->assertEquals('foo=bar', $request->server->get('QUERY_STRING')); - - // restore initial $_SERVER array - $_SERVER = $server; - } - - public function testGetScriptName() - { - $request = new Request(); - $this->assertEquals('', $request->getScriptName()); - - $server = array(); - $server['SCRIPT_NAME'] = '/index.php'; - - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/index.php', $request->getScriptName()); - - $server = array(); - $server['ORIG_SCRIPT_NAME'] = '/frontend.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/frontend.php', $request->getScriptName()); - - $server = array(); - $server['SCRIPT_NAME'] = '/index.php'; - $server['ORIG_SCRIPT_NAME'] = '/frontend.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/index.php', $request->getScriptName()); - } - - public function testGetBasePath() - { - $request = new Request(); - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['SCRIPT_NAME'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['PHP_SELF'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - - $server = array(); - $server['SCRIPT_FILENAME'] = '/some/where/index.php'; - $server['ORIG_SCRIPT_NAME'] = '/index.php'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('', $request->getBasePath()); - } - - public function testGetPathInfo() - { - $request = new Request(); - $this->assertEquals('/', $request->getPathInfo()); - - $server = array(); - $server['REQUEST_URI'] = '/path/info'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/path/info', $request->getPathInfo()); - - $server = array(); - $server['REQUEST_URI'] = '/path%20test/info'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/path%20test/info', $request->getPathInfo()); - - $server = array(); - $server['REQUEST_URI'] = '?a=b'; - $request->initialize(array(), array(), array(), array(), array(), $server); - - $this->assertEquals('/', $request->getPathInfo()); - } - - public function testGetParameterPrecedence() - { - $request = new Request(); - $request->attributes->set('foo', 'attr'); - $request->query->set('foo', 'query'); - $request->request->set('foo', 'body'); - - $this->assertSame('attr', $request->get('foo')); - - $request->attributes->remove('foo'); - $this->assertSame('query', $request->get('foo')); - - $request->query->remove('foo'); - $this->assertSame('body', $request->get('foo')); - - $request->request->remove('foo'); - $this->assertNull($request->get('foo')); - } - - public function testGetPreferredLanguage() - { - $request = new Request(); - $this->assertNull($request->getPreferredLanguage()); - $this->assertNull($request->getPreferredLanguage(array())); - $this->assertEquals('fr', $request->getPreferredLanguage(array('fr'))); - $this->assertEquals('fr', $request->getPreferredLanguage(array('fr', 'en'))); - $this->assertEquals('en', $request->getPreferredLanguage(array('en', 'fr'))); - $this->assertEquals('fr-ch', $request->getPreferredLanguage(array('fr-ch', 'fr-fr'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $this->assertEquals('en', $request->getPreferredLanguage(array('en', 'en-us'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8'); - $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en'))); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, fr-fr; q=0.6, fr; q=0.5'); - $this->assertEquals('en', $request->getPreferredLanguage(array('fr', 'en'))); - } - - public function testIsXmlHttpRequest() - { - $request = new Request(); - $this->assertFalse($request->isXmlHttpRequest()); - - $request->headers->set('X-Requested-With', 'XMLHttpRequest'); - $this->assertTrue($request->isXmlHttpRequest()); - - $request->headers->remove('X-Requested-With'); - $this->assertFalse($request->isXmlHttpRequest()); - } - - /** - * @requires extension intl - */ - public function testIntlLocale() - { - $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(); - $this->assertEquals(array(), $request->getCharsets()); - $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6'); - $this->assertEquals(array(), $request->getCharsets()); // testing caching - - $request = new Request(); - $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6'); - $this->assertEquals(array('ISO-8859-1', 'US-ASCII', 'UTF-8', 'ISO-10646-UCS-2'), $request->getCharsets()); - - $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()); - } - - public function testGetEncodings() - { - $request = new Request(); - $this->assertEquals(array(), $request->getEncodings()); - $request->headers->set('Accept-Encoding', 'gzip,deflate,sdch'); - $this->assertEquals(array(), $request->getEncodings()); // testing caching - - $request = new Request(); - $request->headers->set('Accept-Encoding', 'gzip,deflate,sdch'); - $this->assertEquals(array('gzip', 'deflate', 'sdch'), $request->getEncodings()); - - $request = new Request(); - $request->headers->set('Accept-Encoding', 'gzip;q=0.4,deflate;q=0.9,compress;q=0.7'); - $this->assertEquals(array('deflate', 'compress', 'gzip'), $request->getEncodings()); - } - - public function testGetAcceptableContentTypes() - { - $request = new Request(); - $this->assertEquals(array(), $request->getAcceptableContentTypes()); - $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(), $request->getAcceptableContentTypes()); // testing caching - - $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('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() - { - $request = new Request(); - $this->assertEquals(array(), $request->getLanguages()); - - $request = new Request(); - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $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()); - } - - public function testGetRequestFormat() - { - $request = new Request(); - $this->assertEquals('html', $request->getRequestFormat()); - - // Ensure that setting different default values over time is possible, - // aka. setRequestFormat determines the state. - $this->assertEquals('json', $request->getRequestFormat('json')); - $this->assertEquals('html', $request->getRequestFormat('html')); - - $request = new Request(); - $this->assertNull($request->getRequestFormat(null)); - - $request = new Request(); - $this->assertNull($request->setRequestFormat('foo')); - $this->assertEquals('foo', $request->getRequestFormat(null)); - - $request = new Request(array('_format' => 'foo')); - $this->assertEquals('html', $request->getRequestFormat()); - } - - public function testHasSession() - { - $request = new Request(); - - $this->assertFalse($request->hasSession()); - $request->setSession(new Session(new MockArraySessionStorage())); - $this->assertTrue($request->hasSession()); - } - - public function testGetSession() - { - $request = new Request(); - - $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() - { - $request = new Request(); - - $this->assertFalse($request->hasPreviousSession()); - $request->cookies->set('MOCKSESSID', 'foo'); - $this->assertFalse($request->hasPreviousSession()); - $request->setSession(new Session(new MockArraySessionStorage())); - $this->assertTrue($request->hasPreviousSession()); - } - - public function testToString() - { - $request = new Request(); - - $request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6'); - $request->cookies->set('Foo', 'Bar'); - - $asString = (string) $request; - - $this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $asString); - $this->assertContains('Cookie: Foo=Bar', $asString); - - $request->cookies->set('Another', 'Cookie'); - - $asString = (string) $request; - - $this->assertContains('Cookie: Foo=Bar; Another=Cookie', $asString); - } - - public function testIsMethod() - { - $request = new Request(); - $request->setMethod('POST'); - $this->assertTrue($request->isMethod('POST')); - $this->assertTrue($request->isMethod('post')); - $this->assertFalse($request->isMethod('GET')); - $this->assertFalse($request->isMethod('get')); - - $request->setMethod('GET'); - $this->assertTrue($request->isMethod('GET')); - $this->assertTrue($request->isMethod('get')); - $this->assertFalse($request->isMethod('POST')); - $this->assertFalse($request->isMethod('post')); - } - - /** - * @dataProvider getBaseUrlData - */ - public function testGetBaseUrl($uri, $server, $expectedBaseUrl, $expectedPathInfo) - { - $request = Request::create($uri, 'GET', array(), array(), array(), $server); - - $this->assertSame($expectedBaseUrl, $request->getBaseUrl(), 'baseUrl'); - $this->assertSame($expectedPathInfo, $request->getPathInfo(), 'pathInfo'); - } - - public function getBaseUrlData() - { - return array( - array( - '/fruit/strawberry/1234index.php/blah', - array( - 'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/fruit/index.php', - 'SCRIPT_NAME' => '/fruit/index.php', - 'PHP_SELF' => '/fruit/index.php', - ), - '/fruit', - '/strawberry/1234index.php/blah', - ), - array( - '/fruit/strawberry/1234index.php/blah', - array( - 'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/index.php', - 'SCRIPT_NAME' => '/index.php', - 'PHP_SELF' => '/index.php', - ), - '', - '/fruit/strawberry/1234index.php/blah', - ), - array( - '/foo%20bar/', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar', - '/', - ), - array( - '/foo%20bar/home', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar', - '/home', - ), - array( - '/foo%20bar/app.php/home', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar/app.php', - '/home', - ), - array( - '/foo%20bar/app.php/home%3Dbaz', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php', - 'SCRIPT_NAME' => '/foo bar/app.php', - 'PHP_SELF' => '/foo bar/app.php', - ), - '/foo%20bar/app.php', - '/home%3Dbaz', - ), - array( - '/foo/bar+baz', - array( - 'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app.php', - 'SCRIPT_NAME' => '/foo/app.php', - 'PHP_SELF' => '/foo/app.php', - ), - '/foo', - '/bar+baz', - ), - ); - } - - /** - * @dataProvider urlencodedStringPrefixData - */ - public function testUrlencodedStringPrefix($string, $prefix, $expect) - { - $request = new Request(); - - $me = new \ReflectionMethod($request, 'getUrlencodedPrefix'); - $me->setAccessible(true); - - $this->assertSame($expect, $me->invoke($request, $string, $prefix)); - } - - public function urlencodedStringPrefixData() - { - return array( - array('foo', 'foo', 'foo'), - array('fo%6f', 'foo', 'fo%6f'), - array('foo/bar', 'foo', 'foo'), - array('fo%6f/bar', 'foo', 'fo%6f'), - array('f%6f%6f/bar', 'foo', 'f%6f%6f'), - array('%66%6F%6F/bar', 'foo', '%66%6F%6F'), - array('fo+o/bar', 'fo+o', 'fo+o'), - array('fo%2Bo/bar', 'fo+o', 'fo%2Bo'), - ); - } - - private function disableHttpMethodParameterOverride() - { - $class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request'); - $property = $class->getProperty('httpMethodParameterOverride'); - $property->setAccessible(true); - $property->setValue(false); - } - - private function getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies) - { - $request = new Request(); - - $server = array('REMOTE_ADDR' => $remoteAddr); - if (null !== $httpForwardedFor) { - $server['HTTP_X_FORWARDED_FOR'] = $httpForwardedFor; - } - - if ($trustedProxies) { - Request::setTrustedProxies($trustedProxies, Request::HEADER_X_FORWARDED_ALL); - } - - $request->initialize(array(), array(), array(), array(), array(), $server); - - return $request; - } - - private function getRequestInstanceForClientIpsForwardedTests($remoteAddr, $httpForwarded, $trustedProxies) - { - $request = new Request(); - - $server = array('REMOTE_ADDR' => $remoteAddr); - - if (null !== $httpForwarded) { - $server['HTTP_FORWARDED'] = $httpForwarded; - } - - if ($trustedProxies) { - Request::setTrustedProxies($trustedProxies, Request::HEADER_FORWARDED); - } - - $request->initialize(array(), array(), array(), array(), array(), $server); - - return $request; - } - - public function testTrustedProxiesXForwardedFor() - { - $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:1234, real.example.com:8080'); - $request->headers->set('X_FORWARDED_PROTO', 'https'); - $request->headers->set('X_FORWARDED_PORT', 443); - - // 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()); - - // disabling proxy trusting - Request::setTrustedProxies(array(), Request::HEADER_X_FORWARDED_ALL); - $this->assertEquals('3.3.3.3', $request->getClientIp()); - $this->assertEquals('example.com', $request->getHost()); - $this->assertEquals(80, $request->getPort()); - $this->assertFalse($request->isSecure()); - - // request is forwarded by a non-trusted proxy - Request::setTrustedProxies(array('2.2.2.2'), Request::HEADER_X_FORWARDED_ALL); - $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'), Request::HEADER_X_FORWARDED_ALL); - $this->assertEquals('1.1.1.1', $request->getClientIp()); - $this->assertEquals('foo.example.com', $request->getHost()); - $this->assertEquals(443, $request->getPort()); - $this->assertTrue($request->isSecure()); - - // trusted proxy via setTrustedProxies() - Request::setTrustedProxies(array('3.3.3.4', '2.2.2.2'), Request::HEADER_X_FORWARDED_ALL); - $this->assertEquals('3.3.3.3', $request->getClientIp()); - $this->assertEquals('example.com', $request->getHost()); - $this->assertEquals(80, $request->getPort()); - $this->assertFalse($request->isSecure()); - - // check various X_FORWARDED_PROTO header values - Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2'), Request::HEADER_X_FORWARDED_ALL); - $request->headers->set('X_FORWARDED_PROTO', 'ssl'); - $this->assertTrue($request->isSecure()); - - $request->headers->set('X_FORWARDED_PROTO', 'https, http'); - $this->assertTrue($request->isSecure()); - } - - /** - * @group legacy - * @expectedDeprecation The "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead. - */ - public function testLegacyTrustedProxies() - { - $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); - - Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2'), Request::HEADER_X_FORWARDED_ALL); - - // 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::setTrustedHeaderName(Request::HEADER_FORWARDED, 'FORWARDED'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_FORWARDED_FOR'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X_FORWARDED_HOST'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'X_FORWARDED_PORT'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X_FORWARDED_PROTO'); - } - - public function testTrustedProxiesForwarded() - { - $request = Request::create('http://example.com/'); - $request->server->set('REMOTE_ADDR', '3.3.3.3'); - $request->headers->set('FORWARDED', 'for=1.1.1.1, host=foo.example.com:8080, proto=https, for=2.2.2.2, host=real.example.com:8080'); - - // 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()); - - // disabling proxy trusting - Request::setTrustedProxies(array(), Request::HEADER_FORWARDED); - $this->assertEquals('3.3.3.3', $request->getClientIp()); - $this->assertEquals('example.com', $request->getHost()); - $this->assertEquals(80, $request->getPort()); - $this->assertFalse($request->isSecure()); - - // request is forwarded by a non-trusted proxy - Request::setTrustedProxies(array('2.2.2.2'), Request::HEADER_FORWARDED); - $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'), Request::HEADER_FORWARDED); - $this->assertEquals('1.1.1.1', $request->getClientIp()); - $this->assertEquals('foo.example.com', $request->getHost()); - $this->assertEquals(8080, $request->getPort()); - $this->assertTrue($request->isSecure()); - - // trusted proxy via setTrustedProxies() - Request::setTrustedProxies(array('3.3.3.4', '2.2.2.2'), Request::HEADER_FORWARDED); - $this->assertEquals('3.3.3.3', $request->getClientIp()); - $this->assertEquals('example.com', $request->getHost()); - $this->assertEquals(80, $request->getPort()); - $this->assertFalse($request->isSecure()); - - // check various X_FORWARDED_PROTO header values - Request::setTrustedProxies(array('3.3.3.3', '2.2.2.2'), Request::HEADER_FORWARDED); - $request->headers->set('FORWARDED', 'proto=ssl'); - $this->assertTrue($request->isSecure()); - - $request->headers->set('FORWARDED', 'proto=https, proto=http'); - $this->assertTrue($request->isSecure()); - } - - /** - * @group legacy - * @expectedException \InvalidArgumentException - */ - public function testSetTrustedProxiesInvalidHeaderName() - { - Request::create('http://example.com/'); - Request::setTrustedHeaderName('bogus name', 'X_MY_FOR'); - } - - /** - * @group legacy - * @expectedException \InvalidArgumentException - */ - public function testGetTrustedProxiesInvalidHeaderName() - { - Request::create('http://example.com/'); - Request::getTrustedHeaderName('bogus name'); - } - - /** - * @dataProvider iisRequestUriProvider - */ - public function testIISRequestUri($headers, $server, $expectedRequestUri) - { - $request = new Request(); - $request->headers->replace($headers); - $request->server->replace($server); - - $this->assertEquals($expectedRequestUri, $request->getRequestUri(), '->getRequestUri() is correct'); - - $subRequestUri = '/bar/foo'; - $subRequest = Request::create($subRequestUri, 'get', array(), array(), array(), $request->server->all()); - $this->assertEquals($subRequestUri, $subRequest->getRequestUri(), '->getRequestUri() is correct in sub request'); - } - - public function iisRequestUriProvider() - { - return array( - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array(), - '/foo/bar', - ), - array( - array( - 'X_REWRITE_URL' => '/foo/bar', - ), - array(), - '/foo/bar', - ), - array( - array(), - array( - 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array( - 'HTTP_X_ORIGINAL_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array( - 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array( - 'X_ORIGINAL_URL' => '/foo/bar', - ), - array( - 'HTTP_X_ORIGINAL_URL' => '/foo/bar', - 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array(), - array( - 'ORIG_PATH_INFO' => '/foo/bar', - ), - '/foo/bar', - ), - array( - array(), - array( - 'ORIG_PATH_INFO' => '/foo/bar', - 'QUERY_STRING' => 'foo=bar', - ), - '/foo/bar?foo=bar', - ), - ); - } - - public function testTrustedHosts() - { - // create a request - $request = Request::create('/'); - - // no trusted host set -> no host check - $request->headers->set('host', 'evil.com'); - $this->assertEquals('evil.com', $request->getHost()); - - // add a trusted domain and all its subdomains - Request::setTrustedHosts(array('^([a-z]{9}\.)?trusted\.com$')); - - // untrusted host - $request->headers->set('host', 'evil.com'); - try { - $request->getHost(); - $this->fail('Request::getHost() should throw an exception when host is not trusted.'); - } catch (SuspiciousOperationException $e) { - $this->assertEquals('Untrusted Host "evil.com".', $e->getMessage()); - } - - // trusted hosts - $request->headers->set('host', 'trusted.com'); - $this->assertEquals('trusted.com', $request->getHost()); - $this->assertEquals(80, $request->getPort()); - - $request->server->set('HTTPS', true); - $request->headers->set('host', 'trusted.com'); - $this->assertEquals('trusted.com', $request->getHost()); - $this->assertEquals(443, $request->getPort()); - $request->server->set('HTTPS', false); - - $request->headers->set('host', 'trusted.com:8000'); - $this->assertEquals('trusted.com', $request->getHost()); - $this->assertEquals(8000, $request->getPort()); - - $request->headers->set('host', 'subdomain.trusted.com'); - $this->assertEquals('subdomain.trusted.com', $request->getHost()); - - // reset request for following tests - Request::setTrustedHosts(array()); - } - - public function testFactory() - { - Request::setFactory(function (array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null) { - return new NewRequest(); - }); - - $this->assertEquals('foo', Request::create('/')->getFoo()); - - Request::setFactory(null); - } - - /** - * @dataProvider getLongHostNames - */ - public function testVeryLongHosts($host) - { - $start = microtime(true); - - $request = Request::create('/'); - $request->headers->set('host', $host); - $this->assertEquals($host, $request->getHost()); - $this->assertLessThan(5, microtime(true) - $start); - } - - /** - * @dataProvider getHostValidities - */ - public function testHostValidity($host, $isValid, $expectedHost = null, $expectedPort = null) - { - $request = Request::create('/'); - $request->headers->set('host', $host); - - if ($isValid) { - $this->assertSame($expectedHost ?: $host, $request->getHost()); - if ($expectedPort) { - $this->assertSame($expectedPort, $request->getPort()); - } - } else { - if (method_exists($this, 'expectException')) { - $this->expectException(SuspiciousOperationException::class); - $this->expectExceptionMessage('Invalid Host'); - } else { - $this->setExpectedException(SuspiciousOperationException::class, 'Invalid Host'); - } - - $request->getHost(); - } - } - - public function getHostValidities() - { - return array( - array('.a', false), - array('a..', false), - array('a.', true), - array("\xE9", false), - array('[::1]', true), - array('[::1]:80', true, '[::1]', 80), - array(str_repeat('.', 101), false), - ); - } - - public function getLongHostNames() - { - return array( - array('a'.str_repeat('.a', 40000)), - array(str_repeat(':', 101)), - ); - } - - /** - * @dataProvider methodIdempotentProvider - */ - public function testMethodIdempotent($method, $idempotent) - { - $request = new Request(); - $request->setMethod($method); - $this->assertEquals($idempotent, $request->isMethodIdempotent()); - } - - public function methodIdempotentProvider() - { - return array( - array('HEAD', true), - array('GET', true), - array('POST', false), - array('PUT', true), - array('PATCH', false), - array('DELETE', true), - array('PURGE', true), - array('OPTIONS', true), - array('TRACE', true), - array('CONNECT', false), - ); - } - - /** - * @dataProvider methodSafeProvider - */ - public function testMethodSafe($method, $safe) - { - $request = new Request(); - $request->setMethod($method); - $this->assertEquals($safe, $request->isMethodSafe(false)); - } - - public function methodSafeProvider() - { - return array( - array('HEAD', true), - array('GET', true), - array('POST', false), - array('PUT', false), - array('PATCH', false), - array('DELETE', false), - array('PURGE', false), - array('OPTIONS', true), - array('TRACE', true), - array('CONNECT', false), - ); - } - - /** - * @group legacy - * @expectedDeprecation Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since Symfony 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead. - */ - public function testMethodSafeChecksCacheable() - { - $request = new Request(); - $request->setMethod('OPTIONS'); - $this->assertFalse($request->isMethodSafe()); - } - - /** - * @dataProvider methodCacheableProvider - */ - public function testMethodCacheable($method, $chacheable) - { - $request = new Request(); - $request->setMethod($method); - $this->assertEquals($chacheable, $request->isMethodCacheable()); - } - - public function methodCacheableProvider() - { - return array( - array('HEAD', true), - array('GET', true), - array('POST', false), - array('PUT', false), - array('PATCH', false), - array('DELETE', false), - array('PURGE', false), - array('OPTIONS', false), - array('TRACE', false), - array('CONNECT', false), - ); - } - - /** - * @group legacy - */ - public function testGetTrustedHeaderName() - { - Request::setTrustedProxies(array('8.8.8.8'), Request::HEADER_X_FORWARDED_ALL); - - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_FORWARDED)); - $this->assertSame('X_FORWARDED_FOR', Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)); - $this->assertSame('X_FORWARDED_HOST', Request::getTrustedHeaderName(Request::HEADER_CLIENT_HOST)); - $this->assertSame('X_FORWARDED_PORT', Request::getTrustedHeaderName(Request::HEADER_CLIENT_PORT)); - $this->assertSame('X_FORWARDED_PROTO', Request::getTrustedHeaderName(Request::HEADER_CLIENT_PROTO)); - - Request::setTrustedProxies(array('8.8.8.8'), Request::HEADER_FORWARDED); - - $this->assertSame('FORWARDED', Request::getTrustedHeaderName(Request::HEADER_FORWARDED)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_HOST)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_PORT)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_PROTO)); - - Request::setTrustedHeaderName(Request::HEADER_FORWARDED, 'A'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'B'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'C'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'D'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'E'); - - Request::setTrustedProxies(array('8.8.8.8'), Request::HEADER_FORWARDED); - - $this->assertSame('A', Request::getTrustedHeaderName(Request::HEADER_FORWARDED)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_HOST)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_PORT)); - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_CLIENT_PROTO)); - - Request::setTrustedProxies(array('8.8.8.8'), Request::HEADER_X_FORWARDED_ALL); - - $this->assertNull(Request::getTrustedHeaderName(Request::HEADER_FORWARDED)); - $this->assertSame('B', Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)); - $this->assertSame('C', Request::getTrustedHeaderName(Request::HEADER_CLIENT_HOST)); - $this->assertSame('D', Request::getTrustedHeaderName(Request::HEADER_CLIENT_PORT)); - $this->assertSame('E', Request::getTrustedHeaderName(Request::HEADER_CLIENT_PROTO)); - - Request::setTrustedProxies(array('8.8.8.8'), Request::HEADER_FORWARDED); - - $this->assertSame('A', Request::getTrustedHeaderName(Request::HEADER_FORWARDED)); - - //reset - Request::setTrustedHeaderName(Request::HEADER_FORWARDED, 'FORWARDED'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_FORWARDED_FOR'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X_FORWARDED_HOST'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'X_FORWARDED_PORT'); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X_FORWARDED_PROTO'); - } - - /** - * @dataProvider protocolVersionProvider - */ - public function testProtocolVersion($serverProtocol, $trustedProxy, $via, $expected) - { - if ($trustedProxy) { - Request::setTrustedProxies(array('1.1.1.1'), -1); - } - - $request = new Request(); - $request->server->set('SERVER_PROTOCOL', $serverProtocol); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $request->headers->set('Via', $via); - - $this->assertSame($expected, $request->getProtocolVersion()); - } - - public function protocolVersionProvider() - { - return array( - 'untrusted without via' => array('HTTP/2.0', false, '', 'HTTP/2.0'), - 'untrusted with via' => array('HTTP/2.0', false, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/2.0'), - 'trusted without via' => array('HTTP/2.0', true, '', 'HTTP/2.0'), - 'trusted with via' => array('HTTP/2.0', true, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'), - 'trusted with via and protocol name' => array('HTTP/2.0', true, 'HTTP/1.0 fred, HTTP/1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'), - 'trusted with broken via' => array('HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'), - 'trusted with partially-broken via' => array('HTTP/2.0', true, '1.0 fred, foo', 'HTTP/1.0'), - ); - } - - public function nonstandardRequestsData() - { - return array( - array('', '', '/', 'http://host:8080/', ''), - array('/', '', '/', 'http://host:8080/', ''), - - array('hello/app.php/x', '', '/x', 'http://host:8080/hello/app.php/x', '/hello', '/hello/app.php'), - array('/hello/app.php/x', '', '/x', 'http://host:8080/hello/app.php/x', '/hello', '/hello/app.php'), - - array('', 'a=b', '/', 'http://host:8080/?a=b'), - array('?a=b', 'a=b', '/', 'http://host:8080/?a=b'), - array('/?a=b', 'a=b', '/', 'http://host:8080/?a=b'), - - array('x', 'a=b', '/x', 'http://host:8080/x?a=b'), - array('x?a=b', 'a=b', '/x', 'http://host:8080/x?a=b'), - array('/x?a=b', 'a=b', '/x', 'http://host:8080/x?a=b'), - - array('hello/x', '', '/x', 'http://host:8080/hello/x', '/hello'), - array('/hello/x', '', '/x', 'http://host:8080/hello/x', '/hello'), - - array('hello/app.php/x', 'a=b', '/x', 'http://host:8080/hello/app.php/x?a=b', '/hello', '/hello/app.php'), - array('hello/app.php/x?a=b', 'a=b', '/x', 'http://host:8080/hello/app.php/x?a=b', '/hello', '/hello/app.php'), - array('/hello/app.php/x?a=b', 'a=b', '/x', 'http://host:8080/hello/app.php/x?a=b', '/hello', '/hello/app.php'), - ); - } - - /** - * @dataProvider nonstandardRequestsData - */ - public function testNonstandardRequests($requestUri, $queryString, $expectedPathInfo, $expectedUri, $expectedBasePath = '', $expectedBaseUrl = null) - { - if (null === $expectedBaseUrl) { - $expectedBaseUrl = $expectedBasePath; - } - - $server = array( - 'HTTP_HOST' => 'host:8080', - 'SERVER_PORT' => '8080', - 'QUERY_STRING' => $queryString, - 'PHP_SELF' => '/hello/app.php', - 'SCRIPT_FILENAME' => '/some/path/app.php', - 'REQUEST_URI' => $requestUri, - ); - - $request = new Request(array(), array(), array(), array(), array(), $server); - - $this->assertEquals($expectedPathInfo, $request->getPathInfo()); - $this->assertEquals($expectedUri, $request->getUri()); - $this->assertEquals($queryString, $request->getQueryString()); - $this->assertEquals(8080, $request->getPort()); - $this->assertEquals('host:8080', $request->getHttpHost()); - $this->assertEquals($expectedBaseUrl, $request->getBaseUrl()); - $this->assertEquals($expectedBasePath, $request->getBasePath()); - } -} - -class RequestContentProxy extends Request -{ - public function getContent($asResource = false) - { - return http_build_query(array('_method' => 'PUT', 'content' => 'mycontent')); - } -} - -class NewRequest extends Request -{ - public function getFoo() - { - return 'foo'; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php deleted file mode 100644 index ce8553590..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php +++ /dev/null @@ -1,363 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\ResponseHeaderBag; -use Symfony\Component\HttpFoundation\Cookie; - -/** - * @group time-sensitive - */ -class ResponseHeaderBagTest extends TestCase -{ - public function testAllPreserveCase() - { - $headers = array( - 'fOo' => 'BAR', - 'ETag' => 'xyzzy', - 'Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ==', - 'P3P' => 'CP="CAO PSA OUR"', - 'WWW-Authenticate' => 'Basic realm="WallyWorld"', - 'X-UA-Compatible' => 'IE=edge,chrome=1', - 'X-XSS-Protection' => '1; mode=block', - ); - - $bag = new ResponseHeaderBag($headers); - $allPreservedCase = $bag->allPreserveCase(); - - foreach (array_keys($headers) as $headerName) { - $this->assertArrayHasKey($headerName, $allPreservedCase, '->allPreserveCase() gets all input keys in original case'); - } - } - - public function testCacheControlHeader() - { - $bag = new ResponseHeaderBag(array()); - $this->assertEquals('no-cache, private', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('no-cache')); - - $bag = new ResponseHeaderBag(array('Cache-Control' => 'public')); - $this->assertEquals('public', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('public')); - - $bag = new ResponseHeaderBag(array('ETag' => 'abcde')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('private')); - $this->assertTrue($bag->hasCacheControlDirective('must-revalidate')); - $this->assertFalse($bag->hasCacheControlDirective('max-age')); - - $bag = new ResponseHeaderBag(array('Expires' => 'Wed, 16 Feb 2011 14:17:43 GMT')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array( - 'Expires' => 'Wed, 16 Feb 2011 14:17:43 GMT', - 'Cache-Control' => 'max-age=3600', - )); - $this->assertEquals('max-age=3600, private', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('Last-Modified' => 'abcde')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('Etag' => 'abcde', 'Last-Modified' => 'abcde')); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 'max-age=100')); - $this->assertEquals('max-age=100, private', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 's-maxage=100')); - $this->assertEquals('s-maxage=100', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 'private, max-age=100')); - $this->assertEquals('max-age=100, private', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(array('cache-control' => 'public, max-age=100')); - $this->assertEquals('max-age=100, public', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(); - $bag->set('Last-Modified', 'abcde'); - $this->assertEquals('private, must-revalidate', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(); - $bag->set('Cache-Control', array('public', 'must-revalidate')); - $this->assertCount(1, $bag->get('Cache-Control', null, false)); - $this->assertEquals('must-revalidate, public', $bag->get('Cache-Control')); - - $bag = new ResponseHeaderBag(); - $bag->set('Cache-Control', 'public'); - $bag->set('Cache-Control', 'must-revalidate', false); - $this->assertCount(1, $bag->get('Cache-Control', null, false)); - $this->assertEquals('must-revalidate, public', $bag->get('Cache-Control')); - } - - public function testCacheControlClone() - { - $headers = array('foo' => 'bar'); - $bag1 = new ResponseHeaderBag($headers); - $bag2 = new ResponseHeaderBag($bag1->allPreserveCase()); - $this->assertEquals($bag1->allPreserveCase(), $bag2->allPreserveCase()); - } - - public function testToStringIncludesCookieHeaders() - { - $bag = new ResponseHeaderBag(array()); - $bag->setCookie(new Cookie('foo', 'bar')); - - $this->assertSetCookieHeader('foo=bar; path=/; httponly', $bag); - - $bag->clearCookie('foo'); - - $this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; max-age=-31536001; path=/; httponly', $bag); - } - - public function testClearCookieSecureNotHttpOnly() - { - $bag = new ResponseHeaderBag(array()); - - $bag->clearCookie('foo', '/', null, true, false); - - $this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; max-age=-31536001; path=/; secure', $bag); - } - - public function testReplace() - { - $bag = new ResponseHeaderBag(array()); - $this->assertEquals('no-cache, private', $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, private', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('no-cache')); - - $bag->remove('Cache-Control'); - $bag->replace(array()); - $this->assertEquals('no-cache, private', $bag->get('Cache-Control')); - $this->assertTrue($bag->hasCacheControlDirective('no-cache')); - } - - public function testCookiesWithSameNames() - { - $bag = new ResponseHeaderBag(); - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/foo', 'foo.bar')); - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'foo.bar')); - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'bar.foo')); - $bag->setCookie(new Cookie('foo', 'bar')); - - $this->assertCount(4, $bag->getCookies()); - $this->assertEquals('foo=bar; path=/path/foo; domain=foo.bar; httponly', $bag->get('set-cookie')); - $this->assertEquals(array( - 'foo=bar; path=/path/foo; domain=foo.bar; httponly', - 'foo=bar; path=/path/bar; domain=foo.bar; httponly', - 'foo=bar; path=/path/bar; domain=bar.foo; httponly', - 'foo=bar; path=/; httponly', - ), $bag->get('set-cookie', null, false)); - - $this->assertSetCookieHeader('foo=bar; path=/path/foo; domain=foo.bar; httponly', $bag); - $this->assertSetCookieHeader('foo=bar; path=/path/bar; domain=foo.bar; httponly', $bag); - $this->assertSetCookieHeader('foo=bar; path=/path/bar; domain=bar.foo; httponly', $bag); - $this->assertSetCookieHeader('foo=bar; path=/; httponly', $bag); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - - $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/foo']); - $this->assertArrayHasKey('foo', $cookies['foo.bar']['/path/bar']); - $this->assertArrayHasKey('foo', $cookies['bar.foo']['/path/bar']); - $this->assertArrayHasKey('foo', $cookies['']['/']); - } - - public function testRemoveCookie() - { - $bag = new ResponseHeaderBag(); - $this->assertFalse($bag->has('set-cookie')); - - $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/foo', 'foo.bar')); - $bag->setCookie(new Cookie('bar', 'foo', 0, '/path/bar', 'foo.bar')); - $this->assertTrue($bag->has('set-cookie')); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertArrayHasKey('/path/foo', $cookies['foo.bar']); - - $bag->removeCookie('foo', '/path/foo', 'foo.bar'); - $this->assertTrue($bag->has('set-cookie')); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertArrayNotHasKey('/path/foo', $cookies['foo.bar']); - - $bag->removeCookie('bar', '/path/bar', 'foo.bar'); - $this->assertFalse($bag->has('set-cookie')); - - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertArrayNotHasKey('foo.bar', $cookies); - } - - 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->assertArrayHasKey('/', $cookies['']); - - $bag->removeCookie('foo', null); - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertArrayNotHasKey('foo', $cookies['']['/']); - - $bag->removeCookie('bar', null); - $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY); - $this->assertFalse(isset($cookies['']['/']['bar'])); - } - - public function testSetCookieHeader() - { - $bag = new ResponseHeaderBag(); - $bag->set('set-cookie', 'foo=bar'); - $this->assertEquals(array(new Cookie('foo', 'bar', 0, '/', null, false, false, true)), $bag->getCookies()); - - $bag->set('set-cookie', 'foo2=bar2', false); - $this->assertEquals(array( - new Cookie('foo', 'bar', 0, '/', null, false, false, true), - new Cookie('foo2', 'bar2', 0, '/', null, false, false, true), - ), $bag->getCookies()); - - $bag->remove('set-cookie'); - $this->assertEquals(array(), $bag->getCookies()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetCookiesWithInvalidArgument() - { - $bag = new ResponseHeaderBag(); - - $bag->getCookies('invalid_argument'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testMakeDispositionInvalidDisposition() - { - $headers = new ResponseHeaderBag(); - - $headers->makeDisposition('invalid', 'foo.html'); - } - - /** - * @dataProvider provideMakeDisposition - */ - public function testMakeDisposition($disposition, $filename, $filenameFallback, $expected) - { - $headers = new ResponseHeaderBag(); - - $this->assertEquals($expected, $headers->makeDisposition($disposition, $filename, $filenameFallback)); - } - - public function testToStringDoesntMessUpHeaders() - { - $headers = new ResponseHeaderBag(); - - $headers->set('Location', 'http://www.symfony.com'); - $headers->set('Content-type', 'text/html'); - - (string) $headers; - - $allHeaders = $headers->allPreserveCase(); - $this->assertEquals(array('http://www.symfony.com'), $allHeaders['Location']); - $this->assertEquals(array('text/html'), $allHeaders['Content-type']); - } - - public function provideMakeDisposition() - { - return array( - array('attachment', 'foo.html', 'foo.html', 'attachment; filename="foo.html"'), - array('attachment', 'foo.html', '', 'attachment; filename="foo.html"'), - array('attachment', 'foo bar.html', '', 'attachment; filename="foo bar.html"'), - array('attachment', 'foo "bar".html', '', 'attachment; filename="foo \\"bar\\".html"'), - array('attachment', 'foo%20bar.html', 'foo bar.html', 'attachment; filename="foo bar.html"; filename*=utf-8\'\'foo%2520bar.html'), - array('attachment', 'föö.html', 'foo.html', 'attachment; filename="foo.html"; filename*=utf-8\'\'f%C3%B6%C3%B6.html'), - ); - } - - /** - * @dataProvider provideMakeDispositionFail - * @expectedException \InvalidArgumentException - */ - public function testMakeDispositionFail($disposition, $filename) - { - $headers = new ResponseHeaderBag(); - - $headers->makeDisposition($disposition, $filename); - } - - public function provideMakeDispositionFail() - { - return array( - array('attachment', 'foo%20bar.html'), - array('attachment', 'foo/bar.html'), - array('attachment', '/foo.html'), - array('attachment', 'foo\bar.html'), - array('attachment', '\foo.html'), - array('attachment', 'föö.html'), - ); - } - - public function testDateHeaderAddedOnCreation() - { - $now = time(); - - $bag = new ResponseHeaderBag(); - $this->assertTrue($bag->has('Date')); - - $this->assertEquals($now, $bag->getDate('Date')->getTimestamp()); - } - - public function testDateHeaderCanBeSetOnCreation() - { - $someDate = 'Thu, 23 Mar 2017 09:15:12 GMT'; - $bag = new ResponseHeaderBag(array('Date' => $someDate)); - - $this->assertEquals($someDate, $bag->get('Date')); - } - - public function testDateHeaderWillBeRecreatedWhenRemoved() - { - $someDate = 'Thu, 23 Mar 2017 09:15:12 GMT'; - $bag = new ResponseHeaderBag(array('Date' => $someDate)); - $bag->remove('Date'); - - // a (new) Date header is still present - $this->assertTrue($bag->has('Date')); - $this->assertNotEquals($someDate, $bag->get('Date')); - } - - public function testDateHeaderWillBeRecreatedWhenHeadersAreReplaced() - { - $bag = new ResponseHeaderBag(); - $bag->replace(array()); - - $this->assertTrue($bag->has('Date')); - } - - private function assertSetCookieHeader($expected, ResponseHeaderBag $actual) - { - $this->assertRegExp('#^Set-Cookie:\s+'.preg_quote($expected, '#').'$#m', str_replace("\r\n", "\n", (string) $actual)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/ResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/ResponseTest.php deleted file mode 100644 index 350d972a9..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/ResponseTest.php +++ /dev/null @@ -1,1003 +0,0 @@ - - * - * 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\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * @group time-sensitive - */ -class ResponseTest extends ResponseTestCase -{ - public function testCreate() - { - $response = Response::create('foo', 301, array('Foo' => 'bar')); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - $this->assertEquals(301, $response->getStatusCode()); - $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, private', $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 testIsCacheableWithErrorCode() - { - $response = new Response('', 500); - $this->assertFalse($response->isCacheable()); - } - - public function testIsCacheableWithNoStoreDirective() - { - $response = new Response(); - $response->headers->set('cache-control', 'private'); - $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 testMustRevalidateWithMustRevalidateCacheControlHeader() - { - $response = new Response(); - $response->headers->set('cache-control', 'must-revalidate'); - - $this->assertTrue($response->mustRevalidate()); - } - - public function testMustRevalidateWithProxyRevalidateCacheControlHeader() - { - $response = new Response(); - $response->headers->set('cache-control', 'proxy-revalidate'); - - $this->assertTrue($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 testIsNotModifiedNotSafe() - { - $request = Request::create('/homepage', 'POST'); - - $response = new Response(); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsNotModifiedLastModified() - { - $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; - $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; - $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; - - $request = new Request(); - $request->headers->set('If-Modified-Since', $modified); - - $response = new Response(); - - $response->headers->set('Last-Modified', $modified); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('Last-Modified', $before); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('Last-Modified', $after); - $this->assertFalse($response->isNotModified($request)); - - $response->headers->set('Last-Modified', ''); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsNotModifiedEtag() - { - $etagOne = 'randomly_generated_etag'; - $etagTwo = 'randomly_generated_etag_2'; - - $request = new Request(); - $request->headers->set('if_none_match', sprintf('%s, %s, %s', $etagOne, $etagTwo, 'etagThree')); - - $response = new Response(); - - $response->headers->set('ETag', $etagOne); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('ETag', $etagTwo); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('ETag', ''); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsNotModifiedLastModifiedAndEtag() - { - $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; - $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; - $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; - $etag = 'randomly_generated_etag'; - - $request = new Request(); - $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); - $request->headers->set('If-Modified-Since', $modified); - - $response = new Response(); - - $response->headers->set('ETag', $etag); - $response->headers->set('Last-Modified', $after); - $this->assertFalse($response->isNotModified($request)); - - $response->headers->set('ETag', 'non-existent-etag'); - $response->headers->set('Last-Modified', $before); - $this->assertFalse($response->isNotModified($request)); - - $response->headers->set('ETag', $etag); - $response->headers->set('Last-Modified', $modified); - $this->assertTrue($response->isNotModified($request)); - } - - public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified() - { - $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; - $etag = 'randomly_generated_etag'; - - $request = new Request(); - $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); - $request->headers->set('If-Modified-Since', $modified); - - $response = new Response(); - - $response->headers->set('ETag', $etag); - $this->assertTrue($response->isNotModified($request)); - - $response->headers->set('ETag', 'non-existent-etag'); - $this->assertFalse($response->isNotModified($request)); - } - - public function testIsValidateable() - { - $response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $this->assertTrue($response->isValidateable(), '->isValidateable() returns true if Last-Modified is present'); - - $response = new Response('', 200, array('ETag' => '"12345"')); - $this->assertTrue($response->isValidateable(), '->isValidateable() returns true if ETag is present'); - - $response = new Response(); - $this->assertFalse($response->isValidateable(), '->isValidateable() returns false when no validator is present'); - } - - public function testGetDate() - { - $oneHourAgo = $this->createDateTimeOneHourAgo(); - $response = new Response('', 200, array('Date' => $oneHourAgo->format(DATE_RFC2822))); - $date = $response->getDate(); - $this->assertEquals($oneHourAgo->getTimestamp(), $date->getTimestamp(), '->getDate() returns the Date header if present'); - - $response = new Response(); - $date = $response->getDate(); - $this->assertEquals(time(), $date->getTimestamp(), '->getDate() returns the current Date if no Date header present'); - - $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $now = $this->createDateTimeNow(); - $response->headers->set('Date', $now->format(DATE_RFC2822)); - $date = $response->getDate(); - $this->assertEquals($now->getTimestamp(), $date->getTimestamp(), '->getDate() returns the date when the header has been modified'); - - $response = new Response('', 200); - $now = $this->createDateTimeNow(); - $response->headers->remove('Date'); - $date = $response->getDate(); - $this->assertEquals($now->getTimestamp(), $date->getTimestamp(), '->getDate() returns the current Date when the header has previously been removed'); - } - - public function testGetMaxAge() - { - $response = new Response(); - $response->headers->set('Cache-Control', 's-maxage=600, max-age=0'); - $this->assertEquals(600, $response->getMaxAge(), '->getMaxAge() uses s-maxage cache control directive when present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=600'); - $this->assertEquals(600, $response->getMaxAge(), '->getMaxAge() falls back to max-age when no s-maxage directive present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'must-revalidate'); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertEquals(3600, $response->getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'must-revalidate'); - $response->headers->set('Expires', -1); - $this->assertEquals('Sat, 01 Jan 00 00:00:00 +0000', $response->getExpires()->format(DATE_RFC822)); - - $response = new Response(); - $this->assertNull($response->getMaxAge(), '->getMaxAge() returns null if no freshness information available'); - } - - public function testSetSharedMaxAge() - { - $response = new Response(); - $response->setSharedMaxAge(20); - - $cacheControl = $response->headers->get('Cache-Control'); - $this->assertEquals('public, s-maxage=20', $cacheControl); - } - - public function testIsPrivate() - { - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100'); - $response->setPrivate(); - $this->assertEquals(100, $response->headers->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertTrue($response->headers->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'public, max-age=100'); - $response->setPrivate(); - $this->assertEquals(100, $response->headers->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertTrue($response->headers->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true'); - $this->assertFalse($response->headers->hasCacheControlDirective('public'), '->isPrivate() removes the public Cache-Control directive'); - } - - public function testExpire() - { - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100'); - $response->expire(); - $this->assertEquals(100, $response->headers->get('Age'), '->expire() sets the Age to max-age when present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=100, s-maxage=500'); - $response->expire(); - $this->assertEquals(500, $response->headers->get('Age'), '->expire() sets the Age to s-maxage when both max-age and s-maxage are present'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=5, s-maxage=500'); - $response->headers->set('Age', '1000'); - $response->expire(); - $this->assertEquals(1000, $response->headers->get('Age'), '->expire() does nothing when the response is already stale/expired'); - - $response = new Response(); - $response->expire(); - $this->assertFalse($response->headers->has('Age'), '->expire() does nothing when the response does not include freshness information'); - - $response = new Response(); - $response->headers->set('Expires', -1); - $response->expire(); - $this->assertNull($response->headers->get('Age'), '->expire() does not set the Age when the response is expired'); - } - - public function testGetTtl() - { - $response = new Response(); - $this->assertNull($response->getTtl(), '->getTtl() returns null when no Expires or Cache-Control headers are present'); - - $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertEquals(3600, $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); - - $response = new Response(); - $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)); - $this->assertLessThan(0, $response->getTtl(), '->getTtl() returns negative values when Expires is in past'); - - $response = new Response(); - $response->headers->set('Expires', $response->getDate()->format(DATE_RFC2822)); - $response->headers->set('Age', 0); - $this->assertSame(0, $response->getTtl(), '->getTtl() correctly handles zero'); - - $response = new Response(); - $response->headers->set('Cache-Control', 'max-age=60'); - $this->assertEquals(60, $response->getTtl(), '->getTtl() uses Cache-Control max-age when present'); - } - - public function testSetClientTtl() - { - $response = new Response(); - $response->setClientTtl(10); - - $this->assertEquals($response->getMaxAge(), $response->getAge() + 10); - } - - public function testGetSetProtocolVersion() - { - $response = new Response(); - - $this->assertEquals('1.0', $response->getProtocolVersion()); - - $response->setProtocolVersion('1.1'); - - $this->assertEquals('1.1', $response->getProtocolVersion()); - } - - public function testGetVary() - { - $response = new Response(); - $this->assertEquals(array(), $response->getVary(), '->getVary() returns an empty array if no Vary header is present'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language'); - $this->assertEquals(array('Accept-Language'), $response->getVary(), '->getVary() parses a single header name value'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language User-Agent X-Foo'); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by spaces'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language,User-Agent, X-Foo'); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by commas'); - - $vary = array('Accept-Language', 'User-Agent', 'X-foo'); - - $response = new Response(); - $response->headers->set('Vary', $vary); - $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); - - $response = new Response(); - $response->headers->set('Vary', 'Accept-Language, User-Agent, X-foo'); - $this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays'); - } - - public function testSetVary() - { - $response = new Response(); - $response->setVary('Accept-Language'); - $this->assertEquals(array('Accept-Language'), $response->getVary()); - - $response->setVary('Accept-Language, User-Agent'); - $this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() replace the vary header by default'); - - $response->setVary('X-Foo', false); - $this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false'); - } - - public function testDefaultContentType() - { - $headerMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->setMethods(array('set'))->getMock(); - $headerMock->expects($this->at(0)) - ->method('set') - ->with('Content-Type', 'text/html'); - $headerMock->expects($this->at(1)) - ->method('set') - ->with('Content-Type', 'text/html; charset=UTF-8'); - - $response = new Response('foo'); - $response->headers = $headerMock; - - $response->prepare(new Request()); - } - - public function testContentTypeCharset() - { - $response = new Response(); - $response->headers->set('Content-Type', 'text/css'); - - // force fixContentType() to be called - $response->prepare(new Request()); - - $this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type')); - } - - public function testPrepareDoesNothingIfContentTypeIsSet() - { - $response = new Response('foo'); - $response->headers->set('Content-Type', 'text/plain'); - - $response->prepare(new Request()); - - $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('content-type')); - } - - public function testPrepareDoesNothingIfRequestFormatIsNotDefined() - { - $response = new Response('foo'); - - $response->prepare(new Request()); - - $this->assertEquals('text/html; charset=UTF-8', $response->headers->get('content-type')); - } - - public function testPrepareSetContentType() - { - $response = new Response('foo'); - $request = Request::create('/'); - $request->setRequestFormat('json'); - - $response->prepare($request); - - $this->assertEquals('application/json', $response->headers->get('content-type')); - } - - public function testPrepareRemovesContentForHeadRequests() - { - $response = new Response('foo'); - $request = Request::create('/', 'HEAD'); - - $length = 12345; - $response->headers->set('Content-Length', $length); - $response->prepare($request); - - $this->assertEquals('', $response->getContent()); - $this->assertEquals($length, $response->headers->get('Content-Length'), 'Content-Length should be as if it was GET; see RFC2616 14.13'); - } - - public function testPrepareRemovesContentForInformationalResponse() - { - $response = new Response('foo'); - $request = Request::create('/'); - - $response->setContent('content'); - $response->setStatusCode(101); - $response->prepare($request); - $this->assertEquals('', $response->getContent()); - $this->assertFalse($response->headers->has('Content-Type')); - $this->assertFalse($response->headers->has('Content-Type')); - - $response->setContent('content'); - $response->setStatusCode(304); - $response->prepare($request); - $this->assertEquals('', $response->getContent()); - $this->assertFalse($response->headers->has('Content-Type')); - $this->assertFalse($response->headers->has('Content-Length')); - } - - public function testPrepareRemovesContentLength() - { - $response = new Response('foo'); - $request = Request::create('/'); - - $response->headers->set('Content-Length', 12345); - $response->prepare($request); - $this->assertEquals(12345, $response->headers->get('Content-Length')); - - $response->headers->set('Transfer-Encoding', 'chunked'); - $response->prepare($request); - $this->assertFalse($response->headers->has('Content-Length')); - } - - public function testPrepareSetsPragmaOnHttp10Only() - { - $request = Request::create('/', 'GET'); - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0'); - - $response = new Response('foo'); - $response->prepare($request); - $this->assertEquals('no-cache', $response->headers->get('pragma')); - $this->assertEquals('-1', $response->headers->get('expires')); - - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1'); - $response = new Response('foo'); - $response->prepare($request); - $this->assertFalse($response->headers->has('pragma')); - $this->assertFalse($response->headers->has('expires')); - } - - public function testSetCache() - { - $response = new Response(); - //array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public') - try { - $response->setCache(array('wrong option' => 'value')); - $this->fail('->setCache() throws an InvalidArgumentException if an option is not supported'); - } catch (\Exception $e) { - $this->assertInstanceOf('InvalidArgumentException', $e, '->setCache() throws an InvalidArgumentException if an option is not supported'); - $this->assertContains('"wrong option"', $e->getMessage()); - } - - $options = array('etag' => '"whatever"'); - $response->setCache($options); - $this->assertEquals($response->getEtag(), '"whatever"'); - - $now = $this->createDateTimeNow(); - $options = array('last_modified' => $now); - $response->setCache($options); - $this->assertEquals($response->getLastModified()->getTimestamp(), $now->getTimestamp()); - - $options = array('max_age' => 100); - $response->setCache($options); - $this->assertEquals($response->getMaxAge(), 100); - - $options = array('s_maxage' => 200); - $response->setCache($options); - $this->assertEquals($response->getMaxAge(), 200); - - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('public' => true)); - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('public' => false)); - $this->assertFalse($response->headers->hasCacheControlDirective('public')); - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('private' => true)); - $this->assertFalse($response->headers->hasCacheControlDirective('public')); - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('private' => false)); - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - - $response->setCache(array('immutable' => true)); - $this->assertTrue($response->headers->hasCacheControlDirective('immutable')); - - $response->setCache(array('immutable' => false)); - $this->assertFalse($response->headers->hasCacheControlDirective('immutable')); - } - - public function testSendContent() - { - $response = new Response('test response rendering', 200); - - ob_start(); - $response->sendContent(); - $string = ob_get_clean(); - $this->assertContains('test response rendering', $string); - } - - public function testSetPublic() - { - $response = new Response(); - $response->setPublic(); - - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - } - - public function testSetImmutable() - { - $response = new Response(); - $response->setImmutable(); - - $this->assertTrue($response->headers->hasCacheControlDirective('immutable')); - } - - public function testIsImmutable() - { - $response = new Response(); - $response->setImmutable(); - - $this->assertTrue($response->isImmutable()); - } - - public function testSetExpires() - { - $response = new Response(); - $response->setExpires(null); - - $this->assertNull($response->getExpires(), '->setExpires() remove the header when passed null'); - - $now = $this->createDateTimeNow(); - $response->setExpires($now); - - $this->assertEquals($response->getExpires()->getTimestamp(), $now->getTimestamp()); - } - - public function testSetLastModified() - { - $response = new Response(); - $response->setLastModified($this->createDateTimeNow()); - $this->assertNotNull($response->getLastModified()); - - $response->setLastModified(null); - $this->assertNull($response->getLastModified()); - } - - public function testIsInvalid() - { - $response = new Response(); - - try { - $response->setStatusCode(99); - $this->fail(); - } catch (\InvalidArgumentException $e) { - $this->assertTrue($response->isInvalid()); - } - - try { - $response->setStatusCode(650); - $this->fail(); - } catch (\InvalidArgumentException $e) { - $this->assertTrue($response->isInvalid()); - } - - $response = new Response('', 200); - $this->assertFalse($response->isInvalid()); - } - - /** - * @dataProvider getStatusCodeFixtures - */ - public function testSetStatusCode($code, $text, $expectedText) - { - $response = new Response(); - - $response->setStatusCode($code, $text); - - $statusText = new \ReflectionProperty($response, 'statusText'); - $statusText->setAccessible(true); - - $this->assertEquals($expectedText, $statusText->getValue($response)); - } - - public function getStatusCodeFixtures() - { - return array( - array('200', null, 'OK'), - array('200', false, ''), - array('200', 'foo', 'foo'), - array('199', null, 'unknown status'), - array('199', false, ''), - array('199', 'foo', 'foo'), - ); - } - - public function testIsInformational() - { - $response = new Response('', 100); - $this->assertTrue($response->isInformational()); - - $response = new Response('', 200); - $this->assertFalse($response->isInformational()); - } - - public function testIsRedirectRedirection() - { - foreach (array(301, 302, 303, 307) as $code) { - $response = new Response('', $code); - $this->assertTrue($response->isRedirection()); - $this->assertTrue($response->isRedirect()); - } - - $response = new Response('', 304); - $this->assertTrue($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 200); - $this->assertFalse($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 404); - $this->assertFalse($response->isRedirection()); - $this->assertFalse($response->isRedirect()); - - $response = new Response('', 301, array('Location' => '/good-uri')); - $this->assertFalse($response->isRedirect('/bad-uri')); - $this->assertTrue($response->isRedirect('/good-uri')); - } - - public function testIsNotFound() - { - $response = new Response('', 404); - $this->assertTrue($response->isNotFound()); - - $response = new Response('', 200); - $this->assertFalse($response->isNotFound()); - } - - public function testIsEmpty() - { - foreach (array(204, 304) as $code) { - $response = new Response('', $code); - $this->assertTrue($response->isEmpty()); - } - - $response = new Response('', 200); - $this->assertFalse($response->isEmpty()); - } - - public function testIsForbidden() - { - $response = new Response('', 403); - $this->assertTrue($response->isForbidden()); - - $response = new Response('', 200); - $this->assertFalse($response->isForbidden()); - } - - public function testIsOk() - { - $response = new Response('', 200); - $this->assertTrue($response->isOk()); - - $response = new Response('', 404); - $this->assertFalse($response->isOk()); - } - - public function testIsServerOrClientError() - { - $response = new Response('', 404); - $this->assertTrue($response->isClientError()); - $this->assertFalse($response->isServerError()); - - $response = new Response('', 500); - $this->assertFalse($response->isClientError()); - $this->assertTrue($response->isServerError()); - } - - public function testHasVary() - { - $response = new Response(); - $this->assertFalse($response->hasVary()); - - $response->setVary('User-Agent'); - $this->assertTrue($response->hasVary()); - } - - public function testSetEtag() - { - $response = new Response('', 200, array('ETag' => '"12345"')); - $response->setEtag(); - - $this->assertNull($response->headers->get('Etag'), '->setEtag() removes Etags when call with null'); - } - - /** - * @dataProvider validContentProvider - */ - public function testSetContent($content) - { - $response = new Response(); - $response->setContent($content); - $this->assertEquals((string) $content, $response->getContent()); - } - - /** - * @expectedException \UnexpectedValueException - * @dataProvider invalidContentProvider - */ - public function testSetContentInvalid($content) - { - $response = new Response(); - $response->setContent($content); - } - - public function testSettersAreChainable() - { - $response = new Response(); - - $setters = array( - 'setProtocolVersion' => '1.0', - 'setCharset' => 'UTF-8', - 'setPublic' => null, - 'setPrivate' => null, - 'setDate' => $this->createDateTimeNow(), - 'expire' => null, - 'setMaxAge' => 1, - 'setSharedMaxAge' => 1, - 'setTtl' => 1, - 'setClientTtl' => 1, - ); - - foreach ($setters as $setter => $arg) { - $this->assertEquals($response, $response->{$setter}($arg)); - } - } - - public function testNoDeprecationsAreTriggered() - { - new DefaultResponse(); - $this->getMockBuilder(Response::class)->getMock(); - - // we just need to ensure that subclasses of Response can be created without any deprecations - // being triggered if the subclass does not override any final methods - $this->addToAssertionCount(1); - } - - public function validContentProvider() - { - return array( - 'obj' => array(new StringableObject()), - 'string' => array('Foo'), - 'int' => array(2), - ); - } - - public function invalidContentProvider() - { - return array( - 'obj' => array(new \stdClass()), - 'array' => array(array()), - 'bool' => array(true, '1'), - ); - } - - protected function createDateTimeOneHourAgo() - { - return $this->createDateTimeNow()->sub(new \DateInterval('PT1H')); - } - - protected function createDateTimeOneHourLater() - { - return $this->createDateTimeNow()->add(new \DateInterval('PT1H')); - } - - protected function createDateTimeNow() - { - $date = new \DateTime(); - - return $date->setTimestamp(time()); - } - - protected function provideResponse() - { - return new Response(); - } - - /** - * @see http://github.com/zendframework/zend-diactoros for the canonical source repository - * - * @author Fábio Pacheco - * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com) - * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License - */ - public function ianaCodesReasonPhrasesProvider() - { - if (!in_array('https', stream_get_wrappers(), true)) { - $this->markTestSkipped('The "https" wrapper is not available'); - } - - $ianaHttpStatusCodes = new \DOMDocument(); - - libxml_set_streams_context(stream_context_create(array( - 'http' => array( - 'method' => 'GET', - 'timeout' => 30, - ), - ))); - - $ianaHttpStatusCodes->load('https://www.iana.org/assignments/http-status-codes/http-status-codes.xml'); - if (!$ianaHttpStatusCodes->relaxNGValidate(__DIR__.'/schema/http-status-codes.rng')) { - self::fail('Invalid IANA\'s HTTP status code list.'); - } - - $ianaCodesReasonPhrases = array(); - - $xpath = new \DOMXPath($ianaHttpStatusCodes); - $xpath->registerNamespace('ns', 'http://www.iana.org/assignments'); - - $records = $xpath->query('//ns:record'); - foreach ($records as $record) { - $value = $xpath->query('.//ns:value', $record)->item(0)->nodeValue; - $description = $xpath->query('.//ns:description', $record)->item(0)->nodeValue; - - if (in_array($description, array('Unassigned', '(Unused)'), true)) { - continue; - } - - if (preg_match('/^([0-9]+)\s*\-\s*([0-9]+)$/', $value, $matches)) { - for ($value = $matches[1]; $value <= $matches[2]; ++$value) { - $ianaCodesReasonPhrases[] = array($value, $description); - } - } else { - $ianaCodesReasonPhrases[] = array($value, $description); - } - } - - return $ianaCodesReasonPhrases; - } - - /** - * @dataProvider ianaCodesReasonPhrasesProvider - */ - public function testReasonPhraseDefaultsAgainstIana($code, $reasonPhrase) - { - $this->assertEquals($reasonPhrase, Response::$statusTexts[$code]); - } -} - -class StringableObject -{ - public function __toString() - { - return 'Foo'; - } -} - -class DefaultResponse extends Response -{ -} - -class ExtendedResponse extends Response -{ - public function setLastModified(\DateTime $date = null) - { - } - - public function getDate() - { - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/ResponseTestCase.php b/lib/silex/vendor/symfony/http-foundation/Tests/ResponseTestCase.php deleted file mode 100644 index 4ead34c10..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/ResponseTestCase.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; - -abstract class ResponseTestCase extends TestCase -{ - public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE() - { - // Check for HTTPS and IE 8 - $request = new Request(); - $request->server->set('HTTPS', true); - $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertFalse($response->headers->has('Cache-Control')); - - // Check for IE 10 and HTTPS - $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for IE 9 and HTTPS - $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for IE 9 and HTTP - $request->server->set('HTTPS', false); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for IE 8 and HTTP - $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for non-IE and HTTPS - $request->server->set('HTTPS', true); - $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17'); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - - // Check for non-IE and HTTP - $request->server->set('HTTPS', false); - - $response = $this->provideResponse(); - $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); - $response->prepare($request); - - $this->assertTrue($response->headers->has('Cache-Control')); - } - - abstract protected function provideResponse(); -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/ServerBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/ServerBagTest.php deleted file mode 100644 index f8becec5a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/ServerBagTest.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\ServerBag; - -/** - * ServerBagTest. - * - * @author Bulat Shakirzyanov - */ -class ServerBagTest extends TestCase -{ - public function testShouldExtractHeadersFromServerArray() - { - $server = array( - 'SOME_SERVER_VARIABLE' => 'value', - 'SOME_SERVER_VARIABLE2' => 'value', - 'ROOT' => 'value', - 'HTTP_CONTENT_TYPE' => 'text/html', - 'HTTP_CONTENT_LENGTH' => '0', - 'HTTP_ETAG' => 'asdf', - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar', - ); - - $bag = new ServerBag($server); - - $this->assertEquals(array( - 'CONTENT_TYPE' => 'text/html', - 'CONTENT_LENGTH' => '0', - 'ETAG' => 'asdf', - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar', - ), $bag->getHeaders()); - } - - public function testHttpPasswordIsOptional() - { - $bag = new ServerBag(array('PHP_AUTH_USER' => 'foo')); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '', - ), $bag->getHeaders()); - } - - public function testHttpBasicAuthWithPhpCgi() - { - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'))); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar', - ), $bag->getHeaders()); - } - - public function testHttpBasicAuthWithPhpCgiBogus() - { - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'))); - - // Username and passwords should not be set as the header is bogus - $headers = $bag->getHeaders(); - $this->assertArrayNotHasKey('PHP_AUTH_USER', $headers); - $this->assertArrayNotHasKey('PHP_AUTH_PW', $headers); - } - - public function testHttpBasicAuthWithPhpCgiRedirect() - { - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'))); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'), - 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'pass:word', - ), $bag->getHeaders()); - } - - public function testHttpBasicAuthWithPhpCgiEmptyPassword() - { - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:'))); - - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '', - ), $bag->getHeaders()); - } - - public function testHttpDigestAuthWithPhpCgi() - { - $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $digest, - 'PHP_AUTH_DIGEST' => $digest, - ), $bag->getHeaders()); - } - - public function testHttpDigestAuthWithPhpCgiBogus() - { - $digest = 'Digest_username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); - - // Username and passwords should not be set as the header is bogus - $headers = $bag->getHeaders(); - $this->assertArrayNotHasKey('PHP_AUTH_USER', $headers); - $this->assertArrayNotHasKey('PHP_AUTH_PW', $headers); - } - - public function testHttpDigestAuthWithPhpCgiRedirect() - { - $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => $digest)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $digest, - 'PHP_AUTH_DIGEST' => $digest, - ), $bag->getHeaders()); - } - - public function testOAuthBearerAuth() - { - $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo'; - $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $headerContent)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $headerContent, - ), $bag->getHeaders()); - } - - public function testOAuthBearerAuthWithRedirect() - { - $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo'; - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => $headerContent)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $headerContent, - ), $bag->getHeaders()); - } - - /** - * @see https://github.com/symfony/symfony/issues/17345 - */ - public function testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet() - { - $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo'; - $bag = new ServerBag(array('PHP_AUTH_USER' => 'foo', 'HTTP_AUTHORIZATION' => $headerContent)); - - $this->assertEquals(array( - 'AUTHORIZATION' => $headerContent, - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '', - ), $bag->getHeaders()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/AttributeBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/AttributeBagTest.php deleted file mode 100644 index 724a0b984..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/AttributeBagTest.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Attribute; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Tests AttributeBag. - * - * @author Drak - */ -class AttributeBagTest extends TestCase -{ - private $array = array(); - - /** - * @var AttributeBag - */ - private $bag; - - protected function setUp() - { - $this->array = array( - 'hello' => 'world', - 'always' => 'be happy', - 'user.login' => 'drak', - 'csrf.token' => array( - 'a' => '1234', - 'b' => '4321', - ), - 'category' => array( - 'fishing' => array( - 'first' => 'cod', - 'second' => 'sole', - ), - ), - ); - $this->bag = new AttributeBag('_sf2'); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - $this->array = array(); - } - - public function testInitialize() - { - $bag = new AttributeBag(); - $bag->initialize($this->array); - $this->assertEquals($this->array, $bag->all()); - $array = array('should' => 'change'); - $bag->initialize($array); - $this->assertEquals($array, $bag->all()); - } - - public function testGetStorageKey() - { - $this->assertEquals('_sf2', $this->bag->getStorageKey()); - $attributeBag = new AttributeBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - public function testGetSetName() - { - $this->assertEquals('attributes', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - /** - * @dataProvider attributesProvider - */ - public function testHas($key, $value, $exists) - { - $this->assertEquals($exists, $this->bag->has($key)); - } - - /** - * @dataProvider attributesProvider - */ - public function testGet($key, $value, $expected) - { - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testGetDefaults() - { - $this->assertNull($this->bag->get('user2.login')); - $this->assertEquals('default', $this->bag->get('user2.login', 'default')); - } - - /** - * @dataProvider attributesProvider - */ - public function testSet($key, $value, $expected) - { - $this->bag->set($key, $value); - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testAll() - { - $this->assertEquals($this->array, $this->bag->all()); - - $this->bag->set('hello', 'fabien'); - $array = $this->array; - $array['hello'] = 'fabien'; - $this->assertEquals($array, $this->bag->all()); - } - - public function testReplace() - { - $array = array(); - $array['name'] = 'jack'; - $array['foo.bar'] = 'beep'; - $this->bag->replace($array); - $this->assertEquals($array, $this->bag->all()); - $this->assertNull($this->bag->get('hello')); - $this->assertNull($this->bag->get('always')); - $this->assertNull($this->bag->get('user.login')); - } - - public function testRemove() - { - $this->assertEquals('world', $this->bag->get('hello')); - $this->bag->remove('hello'); - $this->assertNull($this->bag->get('hello')); - - $this->assertEquals('be happy', $this->bag->get('always')); - $this->bag->remove('always'); - $this->assertNull($this->bag->get('always')); - - $this->assertEquals('drak', $this->bag->get('user.login')); - $this->bag->remove('user.login'); - $this->assertNull($this->bag->get('user.login')); - } - - public function testClear() - { - $this->bag->clear(); - $this->assertEquals(array(), $this->bag->all()); - } - - public function attributesProvider() - { - return array( - array('hello', 'world', true), - array('always', 'be happy', true), - array('user.login', 'drak', true), - array('csrf.token', array('a' => '1234', 'b' => '4321'), true), - array('category', array('fishing' => array('first' => 'cod', 'second' => 'sole')), true), - array('user2.login', null, false), - array('never', null, false), - array('bye', null, false), - array('bye/for/now', null, false), - ); - } - - public function testGetIterator() - { - $i = 0; - foreach ($this->bag as $key => $val) { - $this->assertEquals($this->array[$key], $val); - ++$i; - } - - $this->assertEquals(count($this->array), $i); - } - - public function testCount() - { - $this->assertCount(count($this->array), $this->bag); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php deleted file mode 100644 index f074ce1b2..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Attribute; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag; - -/** - * Tests NamespacedAttributeBag. - * - * @author Drak - */ -class NamespacedAttributeBagTest extends TestCase -{ - private $array = array(); - - /** - * @var NamespacedAttributeBag - */ - private $bag; - - protected function setUp() - { - $this->array = array( - 'hello' => 'world', - 'always' => 'be happy', - 'user.login' => 'drak', - 'csrf.token' => array( - 'a' => '1234', - 'b' => '4321', - ), - 'category' => array( - 'fishing' => array( - 'first' => 'cod', - 'second' => 'sole', - ), - ), - ); - $this->bag = new NamespacedAttributeBag('_sf2', '/'); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - $this->array = array(); - } - - public function testInitialize() - { - $bag = new NamespacedAttributeBag(); - $bag->initialize($this->array); - $this->assertEquals($this->array, $this->bag->all()); - $array = array('should' => 'not stick'); - $bag->initialize($array); - - // should have remained the same - $this->assertEquals($this->array, $this->bag->all()); - } - - public function testGetStorageKey() - { - $this->assertEquals('_sf2', $this->bag->getStorageKey()); - $attributeBag = new NamespacedAttributeBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - /** - * @dataProvider attributesProvider - */ - public function testHas($key, $value, $exists) - { - $this->assertEquals($exists, $this->bag->has($key)); - } - - /** - * @dataProvider attributesProvider - */ - public function testGet($key, $value, $expected) - { - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testGetDefaults() - { - $this->assertNull($this->bag->get('user2.login')); - $this->assertEquals('default', $this->bag->get('user2.login', 'default')); - } - - /** - * @dataProvider attributesProvider - */ - public function testSet($key, $value, $expected) - { - $this->bag->set($key, $value); - $this->assertEquals($value, $this->bag->get($key)); - } - - public function testAll() - { - $this->assertEquals($this->array, $this->bag->all()); - - $this->bag->set('hello', 'fabien'); - $array = $this->array; - $array['hello'] = 'fabien'; - $this->assertEquals($array, $this->bag->all()); - } - - public function testReplace() - { - $array = array(); - $array['name'] = 'jack'; - $array['foo.bar'] = 'beep'; - $this->bag->replace($array); - $this->assertEquals($array, $this->bag->all()); - $this->assertNull($this->bag->get('hello')); - $this->assertNull($this->bag->get('always')); - $this->assertNull($this->bag->get('user.login')); - } - - public function testRemove() - { - $this->assertEquals('world', $this->bag->get('hello')); - $this->bag->remove('hello'); - $this->assertNull($this->bag->get('hello')); - - $this->assertEquals('be happy', $this->bag->get('always')); - $this->bag->remove('always'); - $this->assertNull($this->bag->get('always')); - - $this->assertEquals('drak', $this->bag->get('user.login')); - $this->bag->remove('user.login'); - $this->assertNull($this->bag->get('user.login')); - } - - public function testRemoveExistingNamespacedAttribute() - { - $this->assertSame('cod', $this->bag->remove('category/fishing/first')); - } - - public function testRemoveNonexistingNamespacedAttribute() - { - $this->assertNull($this->bag->remove('foo/bar/baz')); - } - - public function testClear() - { - $this->bag->clear(); - $this->assertEquals(array(), $this->bag->all()); - } - - public function attributesProvider() - { - return array( - array('hello', 'world', true), - array('always', 'be happy', true), - array('user.login', 'drak', true), - array('csrf.token', array('a' => '1234', 'b' => '4321'), true), - array('csrf.token/a', '1234', true), - array('csrf.token/b', '4321', true), - array('category', array('fishing' => array('first' => 'cod', 'second' => 'sole')), true), - array('category/fishing', array('first' => 'cod', 'second' => 'sole'), true), - array('category/fishing/missing/first', null, false), - array('category/fishing/first', 'cod', true), - array('category/fishing/second', 'sole', true), - array('category/fishing/missing/second', null, false), - array('user2.login', null, false), - array('never', null, false), - array('bye', null, false), - array('bye/for/now', null, false), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/AutoExpireFlashBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/AutoExpireFlashBagTest.php deleted file mode 100644 index fa8626ab9..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/AutoExpireFlashBagTest.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Flash; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag as FlashBag; - -/** - * AutoExpireFlashBagTest. - * - * @author Drak - */ -class AutoExpireFlashBagTest extends TestCase -{ - /** - * @var \Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag - */ - private $bag; - - protected $array = array(); - - protected function setUp() - { - parent::setUp(); - $this->bag = new FlashBag(); - $this->array = array('new' => array('notice' => array('A previous flash message'))); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - parent::tearDown(); - } - - public function testInitialize() - { - $bag = new FlashBag(); - $array = array('new' => array('notice' => array('A previous flash message'))); - $bag->initialize($array); - $this->assertEquals(array('A previous flash message'), $bag->peek('notice')); - $array = array('new' => array( - 'notice' => array('Something else'), - 'error' => array('a'), - )); - $bag->initialize($array); - $this->assertEquals(array('Something else'), $bag->peek('notice')); - $this->assertEquals(array('a'), $bag->peek('error')); - } - - public function testGetStorageKey() - { - $this->assertEquals('_symfony_flashes', $this->bag->getStorageKey()); - $attributeBag = new FlashBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - public function testGetSetName() - { - $this->assertEquals('flashes', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - public function testPeek() - { - $this->assertEquals(array(), $this->bag->peek('non_existing')); - $this->assertEquals(array('default'), $this->bag->peek('non_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - } - - public function testSet() - { - $this->bag->set('notice', 'Foo'); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - } - - public function testHas() - { - $this->assertFalse($this->bag->has('nothing')); - $this->assertTrue($this->bag->has('notice')); - } - - public function testKeys() - { - $this->assertEquals(array('notice'), $this->bag->keys()); - } - - public function testPeekAll() - { - $array = array( - 'new' => array( - 'notice' => 'Foo', - 'error' => 'Bar', - ), - ); - - $this->bag->initialize($array); - $this->assertEquals(array( - 'notice' => 'Foo', - 'error' => 'Bar', - ), $this->bag->peekAll() - ); - - $this->assertEquals(array( - 'notice' => 'Foo', - 'error' => 'Bar', - ), $this->bag->peekAll() - ); - } - - public function testGet() - { - $this->assertEquals(array(), $this->bag->get('non_existing')); - $this->assertEquals(array('default'), $this->bag->get('non_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->get('notice')); - $this->assertEquals(array(), $this->bag->get('notice')); - } - - public function testSetAll() - { - $this->bag->setAll(array('a' => 'first', 'b' => 'second')); - $this->assertFalse($this->bag->has('a')); - $this->assertFalse($this->bag->has('b')); - } - - public function testAll() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('error', 'Bar'); - $this->assertEquals(array( - 'notice' => array('A previous flash message'), - ), $this->bag->all() - ); - - $this->assertEquals(array(), $this->bag->all()); - } - - public function testClear() - { - $this->assertEquals(array('notice' => array('A previous flash message')), $this->bag->clear()); - } - - public function testDoNotRemoveTheNewFlashesWhenDisplayingTheExistingOnes() - { - $this->bag->add('success', 'Something'); - $this->bag->all(); - - $this->assertEquals(array('new' => array('success' => array('Something')), 'display' => array()), $this->array); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/FlashBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/FlashBagTest.php deleted file mode 100644 index c4e75b1b1..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Flash/FlashBagTest.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Flash; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; - -/** - * FlashBagTest. - * - * @author Drak - */ -class FlashBagTest extends TestCase -{ - /** - * @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface - */ - private $bag; - - protected $array = array(); - - protected function setUp() - { - parent::setUp(); - $this->bag = new FlashBag(); - $this->array = array('notice' => array('A previous flash message')); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->bag = null; - parent::tearDown(); - } - - public function testInitialize() - { - $bag = new FlashBag(); - $bag->initialize($this->array); - $this->assertEquals($this->array, $bag->peekAll()); - $array = array('should' => array('change')); - $bag->initialize($array); - $this->assertEquals($array, $bag->peekAll()); - } - - public function testGetStorageKey() - { - $this->assertEquals('_symfony_flashes', $this->bag->getStorageKey()); - $attributeBag = new FlashBag('test'); - $this->assertEquals('test', $attributeBag->getStorageKey()); - } - - public function testGetSetName() - { - $this->assertEquals('flashes', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - public function testPeek() - { - $this->assertEquals(array(), $this->bag->peek('non_existing')); - $this->assertEquals(array('default'), $this->bag->peek('not_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); - } - - public function testGet() - { - $this->assertEquals(array(), $this->bag->get('non_existing')); - $this->assertEquals(array('default'), $this->bag->get('not_existing', array('default'))); - $this->assertEquals(array('A previous flash message'), $this->bag->get('notice')); - $this->assertEquals(array(), $this->bag->get('notice')); - } - - public function testAll() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('error', 'Bar'); - $this->assertEquals(array( - 'notice' => array('Foo'), - 'error' => array('Bar'), ), $this->bag->all() - ); - - $this->assertEquals(array(), $this->bag->all()); - } - - public function testSet() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('notice', 'Bar'); - $this->assertEquals(array('Bar'), $this->bag->peek('notice')); - } - - public function testHas() - { - $this->assertFalse($this->bag->has('nothing')); - $this->assertTrue($this->bag->has('notice')); - } - - public function testKeys() - { - $this->assertEquals(array('notice'), $this->bag->keys()); - } - - public function testPeekAll() - { - $this->bag->set('notice', 'Foo'); - $this->bag->set('error', 'Bar'); - $this->assertEquals(array( - 'notice' => array('Foo'), - 'error' => array('Bar'), - ), $this->bag->peekAll() - ); - $this->assertTrue($this->bag->has('notice')); - $this->assertTrue($this->bag->has('error')); - $this->assertEquals(array( - 'notice' => array('Foo'), - 'error' => array('Bar'), - ), $this->bag->peekAll() - ); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/SessionTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/SessionTest.php deleted file mode 100644 index 41720e4b6..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/SessionTest.php +++ /dev/null @@ -1,242 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; - -/** - * SessionTest. - * - * @author Fabien Potencier - * @author Robert Schönthal - * @author Drak - */ -class SessionTest extends TestCase -{ - /** - * @var \Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface - */ - protected $storage; - - /** - * @var \Symfony\Component\HttpFoundation\Session\SessionInterface - */ - protected $session; - - protected function setUp() - { - $this->storage = new MockArraySessionStorage(); - $this->session = new Session($this->storage, new AttributeBag(), new FlashBag()); - } - - protected function tearDown() - { - $this->storage = null; - $this->session = null; - } - - public function testStart() - { - $this->assertEquals('', $this->session->getId()); - $this->assertTrue($this->session->start()); - $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 - $this->assertNull($this->session->get('foo')); - $this->assertEquals(1, $this->session->get('foo', 1)); - } - - /** - * @dataProvider setProvider - */ - public function testSet($key, $value) - { - $this->session->set($key, $value); - $this->assertEquals($value, $this->session->get($key)); - } - - /** - * @dataProvider setProvider - */ - public function testHas($key, $value) - { - $this->session->set($key, $value); - $this->assertTrue($this->session->has($key)); - $this->assertFalse($this->session->has($key.'non_value')); - } - - public function testReplace() - { - $this->session->replace(array('happiness' => 'be good', 'symfony' => 'awesome')); - $this->assertEquals(array('happiness' => 'be good', 'symfony' => 'awesome'), $this->session->all()); - $this->session->replace(array()); - $this->assertEquals(array(), $this->session->all()); - } - - /** - * @dataProvider setProvider - */ - public function testAll($key, $value, $result) - { - $this->session->set($key, $value); - $this->assertEquals($result, $this->session->all()); - } - - /** - * @dataProvider setProvider - */ - public function testClear($key, $value) - { - $this->session->set('hi', 'fabien'); - $this->session->set($key, $value); - $this->session->clear(); - $this->assertEquals(array(), $this->session->all()); - } - - public function setProvider() - { - return array( - array('foo', 'bar', array('foo' => 'bar')), - array('foo.bar', 'too much beer', array('foo.bar' => 'too much beer')), - array('great', 'symfony is great', array('great' => 'symfony is great')), - ); - } - - /** - * @dataProvider setProvider - */ - public function testRemove($key, $value) - { - $this->session->set('hi.world', 'have a nice day'); - $this->session->set($key, $value); - $this->session->remove($key); - $this->assertEquals(array('hi.world' => 'have a nice day'), $this->session->all()); - } - - public function testInvalidate() - { - $this->session->set('invalidate', 123); - $this->session->invalidate(); - $this->assertEquals(array(), $this->session->all()); - } - - public function testMigrate() - { - $this->session->set('migrate', 321); - $this->session->migrate(); - $this->assertEquals(321, $this->session->get('migrate')); - } - - public function testMigrateDestroy() - { - $this->session->set('migrate', 333); - $this->session->migrate(true); - $this->assertEquals(333, $this->session->get('migrate')); - } - - public function testSave() - { - $this->session->start(); - $this->session->save(); - - $this->assertFalse($this->session->isStarted()); - } - - public function testGetId() - { - $this->assertEquals('', $this->session->getId()); - $this->session->start(); - $this->assertNotEquals('', $this->session->getId()); - } - - public function testGetFlashBag() - { - $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag()); - } - - public function testGetIterator() - { - $attributes = array('hello' => 'world', 'symfony' => 'rocks'); - foreach ($attributes as $key => $val) { - $this->session->set($key, $val); - } - - $i = 0; - foreach ($this->session as $key => $val) { - $this->assertEquals($attributes[$key], $val); - ++$i; - } - - $this->assertEquals(count($attributes), $i); - } - - public function testGetCount() - { - $this->session->set('hello', 'world'); - $this->session->set('symfony', 'rocks'); - - $this->assertCount(2, $this->session); - } - - public function testGetMeta() - { - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\MetadataBag', $this->session->getMetadataBag()); - } - - public function testIsEmpty() - { - $this->assertTrue($this->session->isEmpty()); - - $this->session->set('hello', 'world'); - $this->assertFalse($this->session->isEmpty()); - - $this->session->remove('hello'); - $this->assertTrue($this->session->isEmpty()); - - $flash = $this->session->getFlashBag(); - $flash->set('hello', 'world'); - $this->assertFalse($this->session->isEmpty()); - - $flash->get('hello'); - $this->assertTrue($this->session->isEmpty()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php deleted file mode 100644 index 3ac081e38..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/AbstractSessionHandlerTest.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; - -/** - * @requires PHP 7.0 - */ -class AbstractSessionHandlerTest extends TestCase -{ - private static $server; - - public static function setUpBeforeClass() - { - $spec = array( - 1 => array('file', '/dev/null', 'w'), - 2 => array('file', '/dev/null', 'w'), - ); - if (!self::$server = @proc_open('exec php -S localhost:8053', $spec, $pipes, __DIR__.'/Fixtures')) { - self::markTestSkipped('PHP server unable to start.'); - } - sleep(1); - } - - public static function tearDownAfterClass() - { - if (self::$server) { - proc_terminate(self::$server); - proc_close(self::$server); - } - } - - /** - * @dataProvider provideSession - */ - public function testSession($fixture) - { - $context = array('http' => array('header' => "Cookie: sid=123abc\r\n")); - $context = stream_context_create($context); - $result = file_get_contents(sprintf('http://localhost:8053/%s.php', $fixture), false, $context); - - $this->assertStringEqualsFile(__DIR__.sprintf('/Fixtures/%s.expected', $fixture), $result); - } - - public function provideSession() - { - foreach (glob(__DIR__.'/Fixtures/*.php') as $file) { - yield array(pathinfo($file, PATHINFO_FILENAME)); - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/common.inc b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/common.inc deleted file mode 100644 index 7a064c7f3..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/common.inc +++ /dev/null @@ -1,151 +0,0 @@ -data = $data; - } - - public function open($path, $name) - { - echo __FUNCTION__, "\n"; - - return parent::open($path, $name); - } - - public function validateId($sessionId) - { - echo __FUNCTION__, "\n"; - - return parent::validateId($sessionId); - } - - /** - * {@inheritdoc} - */ - public function read($sessionId) - { - echo __FUNCTION__, "\n"; - - return parent::read($sessionId); - } - - /** - * {@inheritdoc} - */ - public function updateTimestamp($sessionId, $data) - { - echo __FUNCTION__, "\n"; - - return true; - } - - /** - * {@inheritdoc} - */ - public function write($sessionId, $data) - { - echo __FUNCTION__, "\n"; - - return parent::write($sessionId, $data); - } - - /** - * {@inheritdoc} - */ - public function destroy($sessionId) - { - echo __FUNCTION__, "\n"; - - return parent::destroy($sessionId); - } - - public function close() - { - echo __FUNCTION__, "\n"; - - return true; - } - - public function gc($maxLifetime) - { - echo __FUNCTION__, "\n"; - - return true; - } - - protected function doRead($sessionId) - { - echo __FUNCTION__.': ', $this->data, "\n"; - - return $this->data; - } - - protected function doWrite($sessionId, $data) - { - echo __FUNCTION__.': ', $data, "\n"; - - return true; - } - - protected function doDestroy($sessionId) - { - echo __FUNCTION__, "\n"; - - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.expected b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.expected deleted file mode 100644 index 820371474..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.expected +++ /dev/null @@ -1,17 +0,0 @@ -open -validateId -read -doRead: abc|i:123; -read - -write -destroy -doDestroy -close -Array -( - [0] => Content-Type: text/plain; charset=utf-8 - [1] => Cache-Control: max-age=10800, private, must-revalidate - [2] => Set-Cookie: sid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; secure; HttpOnly -) -shutdown diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.php deleted file mode 100644 index 3cfc1250a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/empty_destroys.php +++ /dev/null @@ -1,8 +0,0 @@ - Content-Type: text/plain; charset=utf-8 - [1] => Cache-Control: max-age=10800, private, must-revalidate -) -shutdown diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/read_only.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/read_only.php deleted file mode 100644 index 3e62fb9ec..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/read_only.php +++ /dev/null @@ -1,8 +0,0 @@ - Content-Type: text/plain; charset=utf-8 - [1] => Cache-Control: max-age=10800, private, must-revalidate - [2] => Set-Cookie: sid=random_session_id; path=/; secure; HttpOnly -) -shutdown diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/regenerate.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/regenerate.php deleted file mode 100644 index a0f635c87..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/regenerate.php +++ /dev/null @@ -1,10 +0,0 @@ - bar -) -$_SESSION is not empty -write -destroy -close -$_SESSION is not empty -Array -( - [0] => Content-Type: text/plain; charset=utf-8 - [1] => Cache-Control: max-age=0, private, must-revalidate -) -shutdown diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/storage.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/storage.php deleted file mode 100644 index 96dca3c2c..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/storage.php +++ /dev/null @@ -1,24 +0,0 @@ -setSaveHandler(new TestSessionHandler()); -$flash = new FlashBag(); -$storage->registerBag($flash); -$storage->start(); - -$flash->add('foo', 'bar'); - -print_r($flash->get('foo')); -echo empty($_SESSION) ? '$_SESSION is empty' : '$_SESSION is not empty'; -echo "\n"; - -$storage->save(); - -echo empty($_SESSION) ? '$_SESSION is empty' : '$_SESSION is not empty'; - -ob_start(function ($buffer) { return str_replace(session_id(), 'random_session_id', $buffer); }); diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.expected b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.expected deleted file mode 100644 index 33da0a5be..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.expected +++ /dev/null @@ -1,15 +0,0 @@ -open -validateId -read -doRead: abc|i:123; -read - -updateTimestamp -close -Array -( - [0] => Content-Type: text/plain; charset=utf-8 - [1] => Cache-Control: max-age=10800, private, must-revalidate - [2] => Set-Cookie: abc=def -) -shutdown diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.php deleted file mode 100644 index ffb5b20a3..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie.php +++ /dev/null @@ -1,8 +0,0 @@ - Content-Type: text/plain; charset=utf-8 - [1] => Cache-Control: max-age=10800, private, must-revalidate - [2] => Set-Cookie: abc=def -) -shutdown diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie_and_session.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie_and_session.php deleted file mode 100644 index ec5119323..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/Fixtures/with_cookie_and_session.php +++ /dev/null @@ -1,13 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler; - -/** - * @requires extension memcache - * @group time-sensitive - * @group legacy - */ -class MemcacheSessionHandlerTest extends TestCase -{ - const PREFIX = 'prefix_'; - const TTL = 1000; - - /** - * @var MemcacheSessionHandler - */ - protected $storage; - - protected $memcache; - - protected function setUp() - { - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('PHPUnit_MockObject cannot mock the Memcache class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); - } - - parent::setUp(); - $this->memcache = $this->getMockBuilder('Memcache')->getMock(); - $this->storage = new MemcacheSessionHandler( - $this->memcache, - array('prefix' => self::PREFIX, 'expiretime' => self::TTL) - ); - } - - protected function tearDown() - { - $this->memcache = null; - $this->storage = null; - parent::tearDown(); - } - - public function testOpenSession() - { - $this->assertTrue($this->storage->open('', '')); - } - - public function testCloseSession() - { - $this->assertTrue($this->storage->close()); - } - - public function testReadSession() - { - $this->memcache - ->expects($this->once()) - ->method('get') - ->with(self::PREFIX.'id') - ; - - $this->assertEquals('', $this->storage->read('id')); - } - - public function testWriteSession() - { - $this->memcache - ->expects($this->once()) - ->method('set') - ->with(self::PREFIX.'id', 'data', 0, $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->write('id', 'data')); - } - - public function testDestroySession() - { - $this->memcache - ->expects($this->once()) - ->method('delete') - ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->destroy('id')); - } - - public function testGcSession() - { - $this->assertTrue($this->storage->gc(123)); - } - - /** - * @dataProvider getOptionFixtures - */ - public function testSupportedOptions($options, $supported) - { - try { - new MemcacheSessionHandler($this->memcache, $options); - $this->assertTrue($supported); - } catch (\InvalidArgumentException $e) { - $this->assertFalse($supported); - } - } - - public function getOptionFixtures() - { - return array( - array(array('prefix' => 'session'), true), - array(array('expiretime' => 100), true), - array(array('prefix' => 'session', 'expiretime' => 200), true), - array(array('expiretime' => 100, 'foo' => 'bar'), false), - ); - } - - public function testGetConnection() - { - $method = new \ReflectionMethod($this->storage, 'getMemcache'); - $method->setAccessible(true); - - $this->assertInstanceOf('\Memcache', $method->invoke($this->storage)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php deleted file mode 100644 index 2e7be359e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler; - -/** - * @requires extension memcached - * @group time-sensitive - */ -class MemcachedSessionHandlerTest extends TestCase -{ - const PREFIX = 'prefix_'; - const TTL = 1000; - - /** - * @var MemcachedSessionHandler - */ - protected $storage; - - protected $memcached; - - protected function setUp() - { - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('PHPUnit_MockObject cannot mock the Memcached class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); - } - - parent::setUp(); - - if (version_compare(phpversion('memcached'), '2.2.0', '>=') && version_compare(phpversion('memcached'), '3.0.0b1', '<')) { - $this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower, or 3.0.0b1 or higher'); - } - - $this->memcached = $this->getMockBuilder('Memcached')->getMock(); - $this->storage = new MemcachedSessionHandler( - $this->memcached, - array('prefix' => self::PREFIX, 'expiretime' => self::TTL) - ); - } - - protected function tearDown() - { - $this->memcached = null; - $this->storage = null; - parent::tearDown(); - } - - public function testOpenSession() - { - $this->assertTrue($this->storage->open('', '')); - } - - public function testCloseSession() - { - $this->assertTrue($this->storage->close()); - } - - public function testReadSession() - { - $this->memcached - ->expects($this->once()) - ->method('get') - ->with(self::PREFIX.'id') - ; - - $this->assertEquals('', $this->storage->read('id')); - } - - public function testWriteSession() - { - $this->memcached - ->expects($this->once()) - ->method('set') - ->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->write('id', 'data')); - } - - public function testDestroySession() - { - $this->memcached - ->expects($this->once()) - ->method('delete') - ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) - ; - - $this->assertTrue($this->storage->destroy('id')); - } - - public function testGcSession() - { - $this->assertTrue($this->storage->gc(123)); - } - - /** - * @dataProvider getOptionFixtures - */ - public function testSupportedOptions($options, $supported) - { - try { - new MemcachedSessionHandler($this->memcached, $options); - $this->assertTrue($supported); - } catch (\InvalidArgumentException $e) { - $this->assertFalse($supported); - } - } - - public function getOptionFixtures() - { - return array( - array(array('prefix' => 'session'), true), - array(array('expiretime' => 100), true), - array(array('prefix' => 'session', 'expiretime' => 200), true), - array(array('expiretime' => 100, 'foo' => 'bar'), false), - ); - } - - public function testGetConnection() - { - $method = new \ReflectionMethod($this->storage, 'getMemcached'); - $method->setAccessible(true); - - $this->assertInstanceOf('\Memcached', $method->invoke($this->storage)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php deleted file mode 100644 index da051096c..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ /dev/null @@ -1,333 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; - -/** - * @author Markus Bachmann - * @group time-sensitive - * @group legacy - */ -class MongoDbSessionHandlerTest extends TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $mongo; - private $storage; - public $options; - - protected function setUp() - { - parent::setUp(); - - if (extension_loaded('mongodb')) { - if (!class_exists('MongoDB\Client')) { - $this->markTestSkipped('The mongodb/mongodb package is required.'); - } - } elseif (!extension_loaded('mongo')) { - $this->markTestSkipped('The Mongo or MongoDB extension is required.'); - } - - if (phpversion('mongodb')) { - $mongoClass = 'MongoDB\Client'; - } else { - $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient'; - } - - $this->mongo = $this->getMockBuilder($mongoClass) - ->disableOriginalConstructor() - ->getMock(); - - $this->options = array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'expiry_field' => 'expires_at', - 'database' => 'sf2-test', - 'collection' => 'session-test', - ); - - $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testConstructorShouldThrowExceptionForInvalidMongo() - { - new MongoDbSessionHandler(new \stdClass(), $this->options); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testConstructorShouldThrowExceptionForMissingOptions() - { - new MongoDbSessionHandler($this->mongo, array()); - } - - public function testOpenMethodAlwaysReturnTrue() - { - $this->assertTrue($this->storage->open('test', 'test'), 'The "open" method should always return true'); - } - - public function testCloseMethodAlwaysReturnTrue() - { - $this->assertTrue($this->storage->close(), 'The "close" method should always return true'); - } - - public function testRead() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - // defining the timeout before the actual method call - // allows to test for "greater than" values in the $criteria - $testTimeout = time() + 1; - - $collection->expects($this->once()) - ->method('findOne') - ->will($this->returnCallback(function ($criteria) use ($testTimeout) { - $this->assertArrayHasKey($this->options['id_field'], $criteria); - $this->assertEquals($criteria[$this->options['id_field']], 'foo'); - - $this->assertArrayHasKey($this->options['expiry_field'], $criteria); - $this->assertArrayHasKey('$gte', $criteria[$this->options['expiry_field']]); - - if (phpversion('mongodb')) { - $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$this->options['expiry_field']]['$gte']); - $this->assertGreaterThanOrEqual(round((string) $criteria[$this->options['expiry_field']]['$gte'] / 1000), $testTimeout); - } else { - $this->assertInstanceOf('MongoDate', $criteria[$this->options['expiry_field']]['$gte']); - $this->assertGreaterThanOrEqual($criteria[$this->options['expiry_field']]['$gte']->sec, $testTimeout); - } - - $fields = array( - $this->options['id_field'] => 'foo', - ); - - if (phpversion('mongodb')) { - $fields[$this->options['data_field']] = new \MongoDB\BSON\Binary('bar', \MongoDB\BSON\Binary::TYPE_OLD_BINARY); - $fields[$this->options['id_field']] = new \MongoDB\BSON\UTCDateTime(time() * 1000); - } else { - $fields[$this->options['data_field']] = new \MongoBinData('bar', \MongoBinData::BYTE_ARRAY); - $fields[$this->options['id_field']] = new \MongoDate(); - } - - return $fields; - })); - - $this->assertEquals('bar', $this->storage->read('foo')); - } - - public function testWrite() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $data = array(); - - $methodName = phpversion('mongodb') ? 'updateOne' : 'update'; - - $collection->expects($this->once()) - ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { - $this->assertEquals(array($this->options['id_field'] => 'foo'), $criteria); - - if (phpversion('mongodb')) { - $this->assertEquals(array('upsert' => true), $options); - } else { - $this->assertEquals(array('upsert' => true, 'multiple' => false), $options); - } - - $data = $updateData['$set']; - })); - - $expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime'); - $this->assertTrue($this->storage->write('foo', 'bar')); - - if (phpversion('mongodb')) { - $this->assertEquals('bar', $data[$this->options['data_field']]->getData()); - $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$this->options['time_field']]); - $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$this->options['expiry_field']]); - $this->assertGreaterThanOrEqual($expectedExpiry, round((string) $data[$this->options['expiry_field']] / 1000)); - } else { - $this->assertEquals('bar', $data[$this->options['data_field']]->bin); - $this->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); - $this->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); - $this->assertGreaterThanOrEqual($expectedExpiry, $data[$this->options['expiry_field']]->sec); - } - } - - public function testWriteWhenUsingExpiresField() - { - $this->options = array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'database' => 'sf2-test', - 'collection' => 'session-test', - 'expiry_field' => 'expiresAt', - ); - - $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); - - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $data = array(); - - $methodName = phpversion('mongodb') ? 'updateOne' : 'update'; - - $collection->expects($this->once()) - ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { - $this->assertEquals(array($this->options['id_field'] => 'foo'), $criteria); - - if (phpversion('mongodb')) { - $this->assertEquals(array('upsert' => true), $options); - } else { - $this->assertEquals(array('upsert' => true, 'multiple' => false), $options); - } - - $data = $updateData['$set']; - })); - - $this->assertTrue($this->storage->write('foo', 'bar')); - - if (phpversion('mongodb')) { - $this->assertEquals('bar', $data[$this->options['data_field']]->getData()); - $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$this->options['time_field']]); - $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$this->options['expiry_field']]); - } else { - $this->assertEquals('bar', $data[$this->options['data_field']]->bin); - $this->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); - $this->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); - } - } - - public function testReplaceSessionData() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $data = array(); - - $methodName = phpversion('mongodb') ? 'updateOne' : 'update'; - - $collection->expects($this->exactly(2)) - ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { - $data = $updateData; - })); - - $this->storage->write('foo', 'bar'); - $this->storage->write('foo', 'foobar'); - - if (phpversion('mongodb')) { - $this->assertEquals('foobar', $data['$set'][$this->options['data_field']]->getData()); - } else { - $this->assertEquals('foobar', $data['$set'][$this->options['data_field']]->bin); - } - } - - public function testDestroy() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $methodName = phpversion('mongodb') ? 'deleteOne' : 'remove'; - - $collection->expects($this->once()) - ->method($methodName) - ->with(array($this->options['id_field'] => 'foo')); - - $this->assertTrue($this->storage->destroy('foo')); - } - - public function testGc() - { - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $methodName = phpversion('mongodb') ? 'deleteMany' : 'remove'; - - $collection->expects($this->once()) - ->method($methodName) - ->will($this->returnCallback(function ($criteria) { - if (phpversion('mongodb')) { - $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$this->options['expiry_field']]['$lt']); - $this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000)); - } else { - $this->assertInstanceOf('MongoDate', $criteria[$this->options['expiry_field']]['$lt']); - $this->assertGreaterThanOrEqual(time() - 1, $criteria[$this->options['expiry_field']]['$lt']->sec); - } - })); - - $this->assertTrue($this->storage->gc(1)); - } - - public function testGetConnection() - { - $method = new \ReflectionMethod($this->storage, 'getMongo'); - $method->setAccessible(true); - - if (phpversion('mongodb')) { - $mongoClass = 'MongoDB\Client'; - } else { - $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient'; - } - - $this->assertInstanceOf($mongoClass, $method->invoke($this->storage)); - } - - private function createMongoCollectionMock() - { - $collectionClass = 'MongoCollection'; - if (phpversion('mongodb')) { - $collectionClass = 'MongoDB\Collection'; - } - - $collection = $this->getMockBuilder($collectionClass) - ->disableOriginalConstructor() - ->getMock(); - - return $collection; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php deleted file mode 100644 index a6264e51d..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeFileSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class NativeFileSessionHandlerTest extends TestCase -{ - public function testConstruct() - { - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); - - $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - - $this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } - - /** - * @dataProvider savePathDataProvider - */ - public function testConstructSavePath($savePath, $expectedSavePath, $path) - { - $handler = new NativeFileSessionHandler($savePath); - $this->assertEquals($expectedSavePath, ini_get('session.save_path')); - $this->assertTrue(is_dir(realpath($path))); - - rmdir($path); - } - - public function savePathDataProvider() - { - $base = sys_get_temp_dir(); - - return array( - array("$base/foo", "$base/foo", "$base/foo"), - array("5;$base/foo", "5;$base/foo", "$base/foo"), - array("5;0600;$base/foo", "5;0600;$base/foo", "$base/foo"), - ); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testConstructException() - { - $handler = new NativeFileSessionHandler('something;invalid;with;too-many-args'); - } - - public function testConstructDefault() - { - $path = ini_get('session.save_path'); - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler()); - - $this->assertEquals($path, ini_get('session.save_path')); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php deleted file mode 100644 index 1a68d575e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler; - -/** - * Test class for NativeSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - * @group legacy - */ -class NativeSessionHandlerTest extends TestCase -{ - /** - * @expectedDeprecation The Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler class is deprecated since Symfony 3.4 and will be removed in 4.0. Use the \SessionHandler class instead. - */ - public function testConstruct() - { - $handler = new NativeSessionHandler(); - - $this->assertTrue($handler instanceof \SessionHandler); - $this->assertTrue($handler instanceof NativeSessionHandler); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php deleted file mode 100644 index 718fd0f83..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/NullSessionHandlerTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Session; - -/** - * Test class for NullSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class NullSessionHandlerTest extends TestCase -{ - public function testSaveHandlers() - { - $storage = $this->getStorage(); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - public function testSession() - { - session_id('nullsessionstorage'); - $storage = $this->getStorage(); - $session = new Session($storage); - $this->assertNull($session->get('something')); - $session->set('something', 'unique'); - $this->assertEquals('unique', $session->get('something')); - } - - public function testNothingIsPersisted() - { - session_id('nullsessionstorage'); - $storage = $this->getStorage(); - $session = new Session($storage); - $session->start(); - $this->assertEquals('nullsessionstorage', $session->getId()); - $this->assertNull($session->get('something')); - } - - public function getStorage() - { - return new NativeSessionStorage(array(), new NullSessionHandler()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php deleted file mode 100644 index a0d7529f0..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ /dev/null @@ -1,376 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - -/** - * @requires extension pdo_sqlite - * @group time-sensitive - */ -class PdoSessionHandlerTest extends TestCase -{ - private $dbFile; - - protected function tearDown() - { - // make sure the temporary database file is deleted when it has been created (even when a test fails) - if ($this->dbFile) { - @unlink($this->dbFile); - } - parent::tearDown(); - } - - protected function getPersistentSqliteDsn() - { - $this->dbFile = tempnam(sys_get_temp_dir(), 'sf2_sqlite_sessions'); - - return 'sqlite:'.$this->dbFile; - } - - protected function getMemorySqlitePdo() - { - $pdo = new \PDO('sqlite::memory:'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - $storage = new PdoSessionHandler($pdo); - $storage->createTable(); - - return $pdo; - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testWrongPdoErrMode() - { - $pdo = $this->getMemorySqlitePdo(); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); - - $storage = new PdoSessionHandler($pdo); - } - - /** - * @expectedException \RuntimeException - */ - public function testInexistentTable() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo(), array('db_table' => 'inexistent_table')); - $storage->open('', 'sid'); - $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - } - - /** - * @expectedException \RuntimeException - */ - public function testCreateTableTwice() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->createTable(); - } - - public function testWithLazyDsnConnection() - { - $dsn = $this->getPersistentSqliteDsn(); - - $storage = new PdoSessionHandler($dsn); - $storage->createTable(); - $storage->open('', 'sid'); - $data = $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - $this->assertSame('', $data, 'New session returns empty string data'); - - $storage->open('', 'sid'); - $data = $storage->read('id'); - $storage->close(); - $this->assertSame('data', $data, 'Written value can be read back correctly'); - } - - public function testWithLazySavePathConnection() - { - $dsn = $this->getPersistentSqliteDsn(); - - // Open is called with what ini_set('session.save_path', $dsn) would mean - $storage = new PdoSessionHandler(null); - $storage->open($dsn, 'sid'); - $storage->createTable(); - $data = $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - $this->assertSame('', $data, 'New session returns empty string data'); - - $storage->open($dsn, 'sid'); - $data = $storage->read('id'); - $storage->close(); - $this->assertSame('data', $data, 'Written value can be read back correctly'); - } - - public function testReadWriteReadWithNullByte() - { - $sessionData = 'da'."\0".'ta'; - - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->open('', 'sid'); - $readData = $storage->read('id'); - $storage->write('id', $sessionData); - $storage->close(); - $this->assertSame('', $readData, 'New session returns empty string data'); - - $storage->open('', 'sid'); - $readData = $storage->read('id'); - $storage->close(); - $this->assertSame($sessionData, $readData, 'Written value can be read back correctly'); - } - - public function testReadConvertsStreamToString() - { - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('PHPUnit_MockObject cannot mock the PDOStatement class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); - } - - $pdo = new MockPdo('pgsql'); - $pdo->prepareResult = $this->getMockBuilder('PDOStatement')->getMock(); - - $content = 'foobar'; - $stream = $this->createStream($content); - - $pdo->prepareResult->expects($this->once())->method('fetchAll') - ->will($this->returnValue(array(array($stream, 42, time())))); - - $storage = new PdoSessionHandler($pdo); - $result = $storage->read('foo'); - - $this->assertSame($content, $result); - } - - public function testReadLockedConvertsStreamToString() - { - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('PHPUnit_MockObject cannot mock the PDOStatement class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); - } - if (ini_get('session.use_strict_mode')) { - $this->markTestSkipped('Strict mode needs no locking for new sessions.'); - } - - $pdo = new MockPdo('pgsql'); - $selectStmt = $this->getMockBuilder('PDOStatement')->getMock(); - $insertStmt = $this->getMockBuilder('PDOStatement')->getMock(); - - $pdo->prepareResult = function ($statement) use ($selectStmt, $insertStmt) { - return 0 === strpos($statement, 'INSERT') ? $insertStmt : $selectStmt; - }; - - $content = 'foobar'; - $stream = $this->createStream($content); - $exception = null; - - $selectStmt->expects($this->atLeast(2))->method('fetchAll') - ->will($this->returnCallback(function () use (&$exception, $stream) { - return $exception ? array(array($stream, 42, time())) : array(); - })); - - $insertStmt->expects($this->once())->method('execute') - ->will($this->returnCallback(function () use (&$exception) { - throw $exception = new \PDOException('', '23'); - })); - - $storage = new PdoSessionHandler($pdo); - $result = $storage->read('foo'); - - $this->assertSame($content, $result); - } - - public function testReadingRequiresExactlySameId() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->open('', 'sid'); - $storage->write('id', 'data'); - $storage->write('test', 'data'); - $storage->write('space ', 'data'); - $storage->close(); - - $storage->open('', 'sid'); - $readDataCaseSensitive = $storage->read('ID'); - $readDataNoCharFolding = $storage->read('tést'); - $readDataKeepSpace = $storage->read('space '); - $readDataExtraSpace = $storage->read('space '); - $storage->close(); - - $this->assertSame('', $readDataCaseSensitive, 'Retrieval by ID should be case-sensitive (collation setting)'); - $this->assertSame('', $readDataNoCharFolding, 'Retrieval by ID should not do character folding (collation setting)'); - $this->assertSame('data', $readDataKeepSpace, 'Retrieval by ID requires spaces as-is'); - $this->assertSame('', $readDataExtraSpace, 'Retrieval by ID requires spaces as-is'); - } - - /** - * Simulates session_regenerate_id(true) which will require an INSERT or UPDATE (replace). - */ - public function testWriteDifferentSessionIdThanRead() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->open('', 'sid'); - $storage->read('id'); - $storage->destroy('id'); - $storage->write('new_id', 'data_of_new_session_id'); - $storage->close(); - - $storage->open('', 'sid'); - $data = $storage->read('new_id'); - $storage->close(); - - $this->assertSame('data_of_new_session_id', $data, 'Data of regenerated session id is available'); - } - - public function testWrongUsageStillWorks() - { - // wrong method sequence that should no happen, but still works - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - $storage->write('id', 'data'); - $storage->write('other_id', 'other_data'); - $storage->destroy('inexistent'); - $storage->open('', 'sid'); - $data = $storage->read('id'); - $otherData = $storage->read('other_id'); - $storage->close(); - - $this->assertSame('data', $data); - $this->assertSame('other_data', $otherData); - } - - public function testSessionDestroy() - { - $pdo = $this->getMemorySqlitePdo(); - $storage = new PdoSessionHandler($pdo); - - $storage->open('', 'sid'); - $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - $this->assertEquals(1, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); - - $storage->open('', 'sid'); - $storage->read('id'); - $storage->destroy('id'); - $storage->close(); - $this->assertEquals(0, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); - - $storage->open('', 'sid'); - $data = $storage->read('id'); - $storage->close(); - $this->assertSame('', $data, 'Destroyed session returns empty string'); - } - - /** - * @runInSeparateProcess - */ - public function testSessionGC() - { - $previousLifeTime = ini_set('session.gc_maxlifetime', 1000); - $pdo = $this->getMemorySqlitePdo(); - $storage = new PdoSessionHandler($pdo); - - $storage->open('', 'sid'); - $storage->read('id'); - $storage->write('id', 'data'); - $storage->close(); - - $storage->open('', 'sid'); - $storage->read('gc_id'); - ini_set('session.gc_maxlifetime', -1); // test that you can set lifetime of a session after it has been read - $storage->write('gc_id', 'data'); - $storage->close(); - $this->assertEquals(2, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn(), 'No session pruned because gc not called'); - - $storage->open('', 'sid'); - $data = $storage->read('gc_id'); - $storage->gc(-1); - $storage->close(); - - ini_set('session.gc_maxlifetime', $previousLifeTime); - - $this->assertSame('', $data, 'Session already considered garbage, so not returning data even if it is not pruned yet'); - $this->assertEquals(1, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn(), 'Expired session is pruned'); - } - - public function testGetConnection() - { - $storage = new PdoSessionHandler($this->getMemorySqlitePdo()); - - $method = new \ReflectionMethod($storage, 'getConnection'); - $method->setAccessible(true); - - $this->assertInstanceOf('\PDO', $method->invoke($storage)); - } - - public function testGetConnectionConnectsIfNeeded() - { - $storage = new PdoSessionHandler('sqlite::memory:'); - - $method = new \ReflectionMethod($storage, 'getConnection'); - $method->setAccessible(true); - - $this->assertInstanceOf('\PDO', $method->invoke($storage)); - } - - private function createStream($content) - { - $stream = tmpfile(); - fwrite($stream, $content); - fseek($stream, 0); - - return $stream; - } -} - -class MockPdo extends \PDO -{ - public $prepareResult; - private $driverName; - private $errorMode; - - public function __construct($driverName = null, $errorMode = null) - { - $this->driverName = $driverName; - $this->errorMode = null !== $errorMode ?: \PDO::ERRMODE_EXCEPTION; - } - - public function getAttribute($attribute) - { - if (\PDO::ATTR_ERRMODE === $attribute) { - return $this->errorMode; - } - - if (\PDO::ATTR_DRIVER_NAME === $attribute) { - return $this->driverName; - } - - return parent::getAttribute($attribute); - } - - public function prepare($statement, $driverOptions = array()) - { - return is_callable($this->prepareResult) - ? call_user_func($this->prepareResult, $statement, $driverOptions) - : $this->prepareResult; - } - - public function beginTransaction() - { - } - - public function rollBack() - { - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php deleted file mode 100644 index b02c41ae8..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php +++ /dev/null @@ -1,189 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler; - -class StrictSessionHandlerTest extends TestCase -{ - public function testOpen() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('open') - ->with('path', 'name')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertInstanceOf('SessionUpdateTimestampHandlerInterface', $proxy); - $this->assertInstanceOf(AbstractSessionHandler::class, $proxy); - $this->assertTrue($proxy->open('path', 'name')); - } - - public function testCloseSession() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('close') - ->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->close()); - } - - public function testValidateIdOK() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn('data'); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->validateId('id')); - } - - public function testValidateIdKO() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn(''); - $proxy = new StrictSessionHandler($handler); - - $this->assertFalse($proxy->validateId('id')); - } - - public function testRead() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn('data'); - $proxy = new StrictSessionHandler($handler); - - $this->assertSame('data', $proxy->read('id')); - } - - public function testReadWithValidateIdOK() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn('data'); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->validateId('id')); - $this->assertSame('data', $proxy->read('id')); - } - - public function testReadWithValidateIdMismatch() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->exactly(2))->method('read') - ->withConsecutive(array('id1'), array('id2')) - ->will($this->onConsecutiveCalls('data1', 'data2')); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->validateId('id1')); - $this->assertSame('data2', $proxy->read('id2')); - } - - public function testUpdateTimestamp() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('write') - ->with('id', 'data')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->updateTimestamp('id', 'data')); - } - - public function testWrite() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('write') - ->with('id', 'data')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->write('id', 'data')); - } - - public function testWriteEmptyNewSession() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn(''); - $handler->expects($this->never())->method('write'); - $handler->expects($this->once())->method('destroy')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertFalse($proxy->validateId('id')); - $this->assertSame('', $proxy->read('id')); - $this->assertTrue($proxy->write('id', '')); - } - - public function testWriteEmptyExistingSession() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn('data'); - $handler->expects($this->never())->method('write'); - $handler->expects($this->once())->method('destroy')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertSame('data', $proxy->read('id')); - $this->assertTrue($proxy->write('id', '')); - } - - public function testDestroy() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('destroy') - ->with('id')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->destroy('id')); - } - - public function testDestroyNewSession() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn(''); - $handler->expects($this->once())->method('destroy')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertSame('', $proxy->read('id')); - $this->assertTrue($proxy->destroy('id')); - } - - public function testDestroyNonEmptyNewSession() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('read') - ->with('id')->willReturn(''); - $handler->expects($this->once())->method('write') - ->with('id', 'data')->willReturn(true); - $handler->expects($this->once())->method('destroy') - ->with('id')->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertSame('', $proxy->read('id')); - $this->assertTrue($proxy->write('id', 'data')); - $this->assertTrue($proxy->destroy('id')); - } - - public function testGc() - { - $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $handler->expects($this->once())->method('gc') - ->with(123)->willReturn(true); - $proxy = new StrictSessionHandler($handler); - - $this->assertTrue($proxy->gc(123)); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php deleted file mode 100644 index 898a7d11a..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler; - -/** - * @author Adrien Brault - * - * @group legacy - */ -class WriteCheckSessionHandlerTest extends TestCase -{ - public function test() - { - $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('close') - ->with() - ->will($this->returnValue(true)) - ; - - $this->assertTrue($writeCheckSessionHandler->close()); - } - - public function testWrite() - { - $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('write') - ->with('foo', 'bar') - ->will($this->returnValue(true)) - ; - - $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); - } - - public function testSkippedWrite() - { - $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('read') - ->with('foo') - ->will($this->returnValue('bar')) - ; - - $wrappedSessionHandlerMock - ->expects($this->never()) - ->method('write') - ; - - $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); - $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); - } - - public function testNonSkippedWrite() - { - $wrappedSessionHandlerMock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $writeCheckSessionHandler = new WriteCheckSessionHandler($wrappedSessionHandlerMock); - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('read') - ->with('foo') - ->will($this->returnValue('bar')) - ; - - $wrappedSessionHandlerMock - ->expects($this->once()) - ->method('write') - ->with('foo', 'baZZZ') - ->will($this->returnValue(true)) - ; - - $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); - $this->assertTrue($writeCheckSessionHandler->write('foo', 'baZZZ')); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MetadataBagTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MetadataBagTest.php deleted file mode 100644 index 69cf6163c..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MetadataBagTest.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; - -/** - * Test class for MetadataBag. - * - * @group time-sensitive - */ -class MetadataBagTest extends TestCase -{ - /** - * @var MetadataBag - */ - protected $bag; - - protected $array = array(); - - protected function setUp() - { - parent::setUp(); - $this->bag = new MetadataBag(); - $this->array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 0); - $this->bag->initialize($this->array); - } - - protected function tearDown() - { - $this->array = array(); - $this->bag = null; - parent::tearDown(); - } - - public function testInitialize() - { - $sessionMetadata = array(); - - $bag1 = new MetadataBag(); - $bag1->initialize($sessionMetadata); - $this->assertGreaterThanOrEqual(time(), $bag1->getCreated()); - $this->assertEquals($bag1->getCreated(), $bag1->getLastUsed()); - - sleep(1); - $bag2 = new MetadataBag(); - $bag2->initialize($sessionMetadata); - $this->assertEquals($bag1->getCreated(), $bag2->getCreated()); - $this->assertEquals($bag1->getLastUsed(), $bag2->getLastUsed()); - $this->assertEquals($bag2->getCreated(), $bag2->getLastUsed()); - - sleep(1); - $bag3 = new MetadataBag(); - $bag3->initialize($sessionMetadata); - $this->assertEquals($bag1->getCreated(), $bag3->getCreated()); - $this->assertGreaterThan($bag2->getLastUsed(), $bag3->getLastUsed()); - $this->assertNotEquals($bag3->getCreated(), $bag3->getLastUsed()); - } - - public function testGetSetName() - { - $this->assertEquals('__metadata', $this->bag->getName()); - $this->bag->setName('foo'); - $this->assertEquals('foo', $this->bag->getName()); - } - - 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()); - } - - public function testGetLastUsed() - { - $this->assertLessThanOrEqual(time(), $this->bag->getLastUsed()); - } - - public function testClear() - { - $this->bag->clear(); - - // the clear method has no side effects, we just want to ensure it doesn't trigger any exceptions - $this->addToAssertionCount(1); - } - - public function testSkipLastUsedUpdate() - { - $bag = new MetadataBag('', 30); - $timeStamp = time(); - - $created = $timeStamp - 15; - $sessionMetadata = array( - MetadataBag::CREATED => $created, - MetadataBag::UPDATED => $created, - MetadataBag::LIFETIME => 1000, - ); - $bag->initialize($sessionMetadata); - - $this->assertEquals($created, $sessionMetadata[MetadataBag::UPDATED]); - } - - public function testDoesNotSkipLastUsedUpdate() - { - $bag = new MetadataBag('', 30); - $timeStamp = time(); - - $created = $timeStamp - 45; - $sessionMetadata = array( - MetadataBag::CREATED => $created, - MetadataBag::UPDATED => $created, - MetadataBag::LIFETIME => 1000, - ); - $bag->initialize($sessionMetadata); - - $this->assertEquals($timeStamp, $sessionMetadata[MetadataBag::UPDATED]); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockArraySessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockArraySessionStorageTest.php deleted file mode 100644 index 82df5543e..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockArraySessionStorageTest.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; - -/** - * Test class for MockArraySessionStorage. - * - * @author Drak - */ -class MockArraySessionStorageTest extends TestCase -{ - /** - * @var MockArraySessionStorage - */ - private $storage; - - /** - * @var AttributeBag - */ - private $attributes; - - /** - * @var FlashBag - */ - private $flashes; - - private $data; - - protected function setUp() - { - $this->attributes = new AttributeBag(); - $this->flashes = new FlashBag(); - - $this->data = array( - $this->attributes->getStorageKey() => array('foo' => 'bar'), - $this->flashes->getStorageKey() => array('notice' => 'hello'), - ); - - $this->storage = new MockArraySessionStorage(); - $this->storage->registerBag($this->flashes); - $this->storage->registerBag($this->attributes); - $this->storage->setSessionData($this->data); - } - - protected function tearDown() - { - $this->data = null; - $this->flashes = null; - $this->attributes = null; - $this->storage = null; - } - - public function testStart() - { - $this->assertEquals('', $this->storage->getId()); - $this->storage->start(); - $id = $this->storage->getId(); - $this->assertNotEquals('', $id); - $this->storage->start(); - $this->assertEquals($id, $this->storage->getId()); - } - - public function testRegenerate() - { - $this->storage->start(); - $id = $this->storage->getId(); - $this->storage->regenerate(); - $this->assertNotEquals($id, $this->storage->getId()); - $this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all()); - $this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll()); - - $id = $this->storage->getId(); - $this->storage->regenerate(true); - $this->assertNotEquals($id, $this->storage->getId()); - $this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all()); - $this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll()); - } - - public function testGetId() - { - $this->assertEquals('', $this->storage->getId()); - $this->storage->start(); - $this->assertNotEquals('', $this->storage->getId()); - } - - public function testClearClearsBags() - { - $this->storage->clear(); - - $this->assertSame(array(), $this->storage->getBag('attributes')->all()); - $this->assertSame(array(), $this->storage->getBag('flashes')->peekAll()); - } - - public function testClearStartsSession() - { - $this->storage->clear(); - - $this->assertTrue($this->storage->isStarted()); - } - - public function testClearWithNoBagsStartsSession() - { - $storage = new MockArraySessionStorage(); - - $storage->clear(); - - $this->assertTrue($storage->isStarted()); - } - - /** - * @expectedException \RuntimeException - */ - public function testUnstartedSave() - { - $this->storage->save(); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockFileSessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockFileSessionStorageTest.php deleted file mode 100644 index 53accd384..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/MockFileSessionStorageTest.php +++ /dev/null @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Test class for MockFileSessionStorage. - * - * @author Drak - */ -class MockFileSessionStorageTest extends TestCase -{ - /** - * @var string - */ - private $sessionDir; - - /** - * @var MockFileSessionStorage - */ - protected $storage; - - protected function setUp() - { - $this->sessionDir = sys_get_temp_dir().'/sf2test'; - $this->storage = $this->getStorage(); - } - - protected function tearDown() - { - $this->sessionDir = null; - $this->storage = null; - array_map('unlink', glob($this->sessionDir.'/*.session')); - if (is_dir($this->sessionDir)) { - rmdir($this->sessionDir); - } - } - - public function testStart() - { - $this->assertEquals('', $this->storage->getId()); - $this->assertTrue($this->storage->start()); - $id = $this->storage->getId(); - $this->assertNotEquals('', $this->storage->getId()); - $this->assertTrue($this->storage->start()); - $this->assertEquals($id, $this->storage->getId()); - } - - public function testRegenerate() - { - $this->storage->start(); - $this->storage->getBag('attributes')->set('regenerate', 1234); - $this->storage->regenerate(); - $this->assertEquals(1234, $this->storage->getBag('attributes')->get('regenerate')); - $this->storage->regenerate(true); - $this->assertEquals(1234, $this->storage->getBag('attributes')->get('regenerate')); - } - - public function testGetId() - { - $this->assertEquals('', $this->storage->getId()); - $this->storage->start(); - $this->assertNotEquals('', $this->storage->getId()); - } - - public function testSave() - { - $this->storage->start(); - $id = $this->storage->getId(); - $this->assertNotEquals('108', $this->storage->getBag('attributes')->get('new')); - $this->assertFalse($this->storage->getBag('flashes')->has('newkey')); - $this->storage->getBag('attributes')->set('new', '108'); - $this->storage->getBag('flashes')->set('newkey', 'test'); - $this->storage->save(); - - $storage = $this->getStorage(); - $storage->setId($id); - $storage->start(); - $this->assertEquals('108', $storage->getBag('attributes')->get('new')); - $this->assertTrue($storage->getBag('flashes')->has('newkey')); - $this->assertEquals(array('test'), $storage->getBag('flashes')->peek('newkey')); - } - - public function testMultipleInstances() - { - $storage1 = $this->getStorage(); - $storage1->start(); - $storage1->getBag('attributes')->set('foo', 'bar'); - $storage1->save(); - - $storage2 = $this->getStorage(); - $storage2->setId($storage1->getId()); - $storage2->start(); - $this->assertEquals('bar', $storage2->getBag('attributes')->get('foo'), 'values persist between instances'); - } - - /** - * @expectedException \RuntimeException - */ - public function testSaveWithoutStart() - { - $storage1 = $this->getStorage(); - $storage1->save(); - } - - private function getStorage() - { - $storage = new MockFileSessionStorage($this->sessionDir); - $storage->registerBag(new FlashBag()); - $storage->registerBag(new AttributeBag()); - - return $storage; - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/NativeSessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/NativeSessionStorageTest.php deleted file mode 100644 index 8fb8b4222..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ /dev/null @@ -1,277 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * Test class for NativeSessionStorage. - * - * @author Drak - * - * These tests require separate processes. - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class NativeSessionStorageTest extends TestCase -{ - private $savePath; - - protected function setUp() - { - $this->iniSet('session.save_handler', 'files'); - $this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test'); - if (!is_dir($this->savePath)) { - mkdir($this->savePath); - } - } - - protected function tearDown() - { - session_write_close(); - array_map('unlink', glob($this->savePath.'/*')); - if (is_dir($this->savePath)) { - rmdir($this->savePath); - } - - $this->savePath = null; - } - - /** - * @return NativeSessionStorage - */ - protected function getStorage(array $options = array()) - { - $storage = new NativeSessionStorage($options); - $storage->registerBag(new AttributeBag()); - - return $storage; - } - - public function testBag() - { - $storage = $this->getStorage(); - $bag = new FlashBag(); - $storage->registerBag($bag); - $this->assertSame($bag, $storage->getBag($bag->getName())); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRegisterBagException() - { - $storage = $this->getStorage(); - $storage->getBag('non_existing'); - } - - /** - * @expectedException \LogicException - */ - public function testRegisterBagForAStartedSessionThrowsException() - { - $storage = $this->getStorage(); - $storage->start(); - $storage->registerBag(new AttributeBag()); - } - - public function testGetId() - { - $storage = $this->getStorage(); - $this->assertSame('', $storage->getId(), 'Empty ID before starting session'); - - $storage->start(); - $id = $storage->getId(); - $this->assertInternalType('string', $id); - $this->assertNotSame('', $id); - - $storage->save(); - $this->assertSame($id, $storage->getId(), 'ID stays after saving session'); - } - - public function testRegenerate() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('lucky', 7); - $storage->regenerate(); - $this->assertNotEquals($id, $storage->getId()); - $this->assertEquals(7, $storage->getBag('attributes')->get('lucky')); - } - - public function testRegenerateDestroy() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('legs', 11); - $storage->regenerate(true); - $this->assertNotEquals($id, $storage->getId()); - $this->assertEquals(11, $storage->getBag('attributes')->get('legs')); - } - - public function testSessionGlobalIsUpToDateAfterIdRegeneration() - { - $storage = $this->getStorage(); - $storage->start(); - $storage->getBag('attributes')->set('lucky', 7); - $storage->regenerate(); - $storage->getBag('attributes')->set('lucky', 42); - - $this->assertEquals(42, $_SESSION['_sf2_attributes']['lucky']); - } - - public function testRegenerationFailureDoesNotFlagStorageAsStarted() - { - $storage = $this->getStorage(); - $this->assertFalse($storage->regenerate()); - $this->assertFalse($storage->isStarted()); - } - - public function testDefaultSessionCacheLimiter() - { - $this->iniSet('session.cache_limiter', 'nocache'); - - $storage = new NativeSessionStorage(); - $this->assertEquals('', ini_get('session.cache_limiter')); - } - - public function testExplicitSessionCacheLimiter() - { - $this->iniSet('session.cache_limiter', 'nocache'); - - $storage = new NativeSessionStorage(array('cache_limiter' => 'public')); - $this->assertEquals('public', ini_get('session.cache_limiter')); - } - - public function testCookieOptions() - { - $options = array( - 'cookie_lifetime' => 123456, - 'cookie_path' => '/my/cookie/path', - 'cookie_domain' => 'symfony.example.com', - 'cookie_secure' => true, - 'cookie_httponly' => false, - ); - - $this->getStorage($options); - $temp = session_get_cookie_params(); - $gco = array(); - - foreach ($temp as $key => $value) { - $gco['cookie_'.$key] = $value; - } - - $this->assertEquals($options, $gco); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSetSaveHandlerException() - { - $storage = $this->getStorage(); - $storage->setSaveHandler(new \stdClass()); - } - - public function testSetSaveHandler() - { - $this->iniSet('session.save_handler', 'files'); - $storage = $this->getStorage(); - $storage->setSaveHandler(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(null); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NativeFileSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler())); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - $storage->setSaveHandler(new NullSessionHandler()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler()); - } - - /** - * @expectedException \RuntimeException - */ - public function testStarted() - { - $storage = $this->getStorage(); - - $this->assertFalse($storage->getSaveHandler()->isActive()); - $this->assertFalse($storage->isStarted()); - - session_start(); - $this->assertTrue(isset($_SESSION)); - $this->assertTrue($storage->getSaveHandler()->isActive()); - - // PHP session might have started, but the storage driver has not, so false is correct here - $this->assertFalse($storage->isStarted()); - - $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertArrayNotHasKey($key, $_SESSION); - $storage->start(); - } - - public function testRestart() - { - $storage = $this->getStorage(); - $storage->start(); - $id = $storage->getId(); - $storage->getBag('attributes')->set('lucky', 7); - $storage->save(); - $storage->start(); - $this->assertSame($id, $storage->getId(), 'Same session ID after restarting'); - $this->assertSame(7, $storage->getBag('attributes')->get('lucky'), 'Data still available'); - } - - public function testCanCreateNativeSessionStorageWhenSessionAlreadyStarted() - { - session_start(); - $this->getStorage(); - - // Assert no exception has been thrown by `getStorage()` - $this->addToAssertionCount(1); - } - - public function testSetSessionOptionsOnceSessionStartedIsIgnored() - { - session_start(); - $this->getStorage(array( - 'name' => 'something-else', - )); - - // Assert no exception has been thrown by `getStorage()` - $this->addToAssertionCount(1); - } - - public function testGetBagsOnceSessionStartedIsIgnored() - { - session_start(); - $bag = new AttributeBag(); - $bag->setName('flashes'); - - $storage = $this->getStorage(); - $storage->registerBag($bag); - - $this->assertEquals($storage->getBag('flashes'), $bag); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php deleted file mode 100644 index 958dc0bc0..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage; -use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; - -/** - * Test class for PhpSessionStorage. - * - * @author Drak - * - * These tests require separate processes. - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class PhpBridgeSessionStorageTest extends TestCase -{ - private $savePath; - - protected function setUp() - { - $this->iniSet('session.save_handler', 'files'); - $this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test'); - if (!is_dir($this->savePath)) { - mkdir($this->savePath); - } - } - - protected function tearDown() - { - session_write_close(); - array_map('unlink', glob($this->savePath.'/*')); - if (is_dir($this->savePath)) { - rmdir($this->savePath); - } - - $this->savePath = null; - } - - /** - * @return PhpBridgeSessionStorage - */ - protected function getStorage() - { - $storage = new PhpBridgeSessionStorage(); - $storage->registerBag(new AttributeBag()); - - return $storage; - } - - public function testPhpSession() - { - $storage = $this->getStorage(); - - $this->assertFalse($storage->getSaveHandler()->isActive()); - $this->assertFalse($storage->isStarted()); - - session_start(); - $this->assertTrue(isset($_SESSION)); - // in PHP 5.4 we can reliably detect a session started - $this->assertTrue($storage->getSaveHandler()->isActive()); - // PHP session might have started, but the storage driver has not, so false is correct here - $this->assertFalse($storage->isStarted()); - - $key = $storage->getMetadataBag()->getStorageKey(); - $this->assertArrayNotHasKey($key, $_SESSION); - $storage->start(); - $this->assertArrayHasKey($key, $_SESSION); - } - - public function testClear() - { - $storage = $this->getStorage(); - session_start(); - $_SESSION['drak'] = 'loves symfony'; - $storage->getBag('attributes')->set('symfony', 'greatness'); - $key = $storage->getBag('attributes')->getStorageKey(); - $this->assertEquals($_SESSION[$key], array('symfony' => 'greatness')); - $this->assertEquals($_SESSION['drak'], 'loves symfony'); - $storage->clear(); - $this->assertEquals($_SESSION[$key], array()); - $this->assertEquals($_SESSION['drak'], 'loves symfony'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php deleted file mode 100644 index cbb291f19..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * Test class for AbstractProxy. - * - * @author Drak - */ -class AbstractProxyTest extends TestCase -{ - /** - * @var AbstractProxy - */ - protected $proxy; - - protected function setUp() - { - $this->proxy = $this->getMockForAbstractClass(AbstractProxy::class); - } - - protected function tearDown() - { - $this->proxy = null; - } - - public function testGetSaveHandlerName() - { - $this->assertNull($this->proxy->getSaveHandlerName()); - } - - public function testIsSessionHandlerInterface() - { - $this->assertFalse($this->proxy->isSessionHandlerInterface()); - $sh = new SessionHandlerProxy(new \SessionHandler()); - $this->assertTrue($sh->isSessionHandlerInterface()); - } - - public function testIsWrapper() - { - $this->assertFalse($this->proxy->isWrapper()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testIsActive() - { - $this->assertFalse($this->proxy->isActive()); - session_start(); - $this->assertTrue($this->proxy->isActive()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testName() - { - $this->assertEquals(session_name(), $this->proxy->getName()); - $this->proxy->setName('foo'); - $this->assertEquals('foo', $this->proxy->getName()); - $this->assertEquals(session_name(), $this->proxy->getName()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * @expectedException \LogicException - */ - public function testNameException() - { - session_start(); - $this->proxy->setName('foo'); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testId() - { - $this->assertEquals(session_id(), $this->proxy->getId()); - $this->proxy->setId('foo'); - $this->assertEquals('foo', $this->proxy->getId()); - $this->assertEquals(session_id(), $this->proxy->getId()); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * @expectedException \LogicException - */ - public function testIdException() - { - session_start(); - $this->proxy->setId('foo'); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/NativeProxyTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/NativeProxyTest.php deleted file mode 100644 index ed4fee6bf..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/NativeProxyTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy; - -/** - * Test class for NativeProxy. - * - * @group legacy - * - * @author Drak - */ -class NativeProxyTest extends TestCase -{ - public function testIsWrapper() - { - $proxy = new NativeProxy(); - $this->assertFalse($proxy->isWrapper()); - } - - public function testGetSaveHandlerName() - { - $name = ini_get('session.save_handler'); - $proxy = new NativeProxy(); - $this->assertEquals($name, $proxy->getSaveHandlerName()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php deleted file mode 100644 index 682825356..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy; - -/** - * Tests for SessionHandlerProxy class. - * - * @author Drak - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class SessionHandlerProxyTest extends TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_Matcher - */ - private $mock; - - /** - * @var SessionHandlerProxy - */ - private $proxy; - - protected function setUp() - { - $this->mock = $this->getMockBuilder('SessionHandlerInterface')->getMock(); - $this->proxy = new SessionHandlerProxy($this->mock); - } - - protected function tearDown() - { - $this->mock = null; - $this->proxy = null; - } - - public function testOpenTrue() - { - $this->mock->expects($this->once()) - ->method('open') - ->will($this->returnValue(true)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->open('name', 'id'); - $this->assertFalse($this->proxy->isActive()); - } - - public function testOpenFalse() - { - $this->mock->expects($this->once()) - ->method('open') - ->will($this->returnValue(false)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->open('name', 'id'); - $this->assertFalse($this->proxy->isActive()); - } - - public function testClose() - { - $this->mock->expects($this->once()) - ->method('close') - ->will($this->returnValue(true)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->close(); - $this->assertFalse($this->proxy->isActive()); - } - - public function testCloseFalse() - { - $this->mock->expects($this->once()) - ->method('close') - ->will($this->returnValue(false)); - - $this->assertFalse($this->proxy->isActive()); - $this->proxy->close(); - $this->assertFalse($this->proxy->isActive()); - } - - public function testRead() - { - $this->mock->expects($this->once()) - ->method('read'); - - $this->proxy->read('id'); - } - - public function testWrite() - { - $this->mock->expects($this->once()) - ->method('write'); - - $this->proxy->write('id', 'data'); - } - - public function testDestroy() - { - $this->mock->expects($this->once()) - ->method('destroy'); - - $this->proxy->destroy('id'); - } - - public function testGc() - { - $this->mock->expects($this->once()) - ->method('gc'); - - $this->proxy->gc(86400); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/StreamedResponseTest.php b/lib/silex/vendor/symfony/http-foundation/Tests/StreamedResponseTest.php deleted file mode 100644 index c2ded996f..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/StreamedResponseTest.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\StreamedResponse; - -class StreamedResponseTest extends TestCase -{ - public function testConstructor() - { - $response = new StreamedResponse(function () { echo 'foo'; }, 404, array('Content-Type' => 'text/plain')); - - $this->assertEquals(404, $response->getStatusCode()); - $this->assertEquals('text/plain', $response->headers->get('Content-Type')); - } - - public function testPrepareWith11Protocol() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $request = Request::create('/'); - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1'); - - $response->prepare($request); - - $this->assertEquals('1.1', $response->getProtocolVersion()); - $this->assertNotEquals('chunked', $response->headers->get('Transfer-Encoding'), 'Apache assumes responses with a Transfer-Encoding header set to chunked to already be encoded.'); - } - - public function testPrepareWith10Protocol() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $request = Request::create('/'); - $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0'); - - $response->prepare($request); - - $this->assertEquals('1.0', $response->getProtocolVersion()); - $this->assertNull($response->headers->get('Transfer-Encoding')); - } - - public function testPrepareWithHeadRequest() - { - $response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Content-Length' => '123')); - $request = Request::create('/', 'HEAD'); - - $response->prepare($request); - - $this->assertSame('123', $response->headers->get('Content-Length')); - } - - public function testPrepareWithCacheHeaders() - { - $response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Cache-Control' => 'max-age=600, public')); - $request = Request::create('/', 'GET'); - - $response->prepare($request); - $this->assertEquals('max-age=600, public', $response->headers->get('Cache-Control')); - } - - public function testSendContent() - { - $called = 0; - - $response = new StreamedResponse(function () use (&$called) { ++$called; }); - - $response->sendContent(); - $this->assertEquals(1, $called); - - $response->sendContent(); - $this->assertEquals(1, $called); - } - - /** - * @expectedException \LogicException - */ - public function testSendContentWithNonCallable() - { - $response = new StreamedResponse(null); - $response->sendContent(); - } - - /** - * @expectedException \LogicException - */ - public function testSetContent() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $response->setContent('foo'); - } - - public function testGetContent() - { - $response = new StreamedResponse(function () { echo 'foo'; }); - $this->assertFalse($response->getContent()); - } - - public function testCreate() - { - $response = StreamedResponse::create(function () {}, 204); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response); - $this->assertEquals(204, $response->getStatusCode()); - } - - public function testReturnThis() - { - $response = new StreamedResponse(function () {}); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent()); - - $response = new StreamedResponse(function () {}); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders()); - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/schema/http-status-codes.rng b/lib/silex/vendor/symfony/http-foundation/Tests/schema/http-status-codes.rng deleted file mode 100644 index 73708ca68..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/schema/http-status-codes.rng +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/silex/vendor/symfony/http-foundation/Tests/schema/iana-registry.rng b/lib/silex/vendor/symfony/http-foundation/Tests/schema/iana-registry.rng deleted file mode 100644 index b9c3ca9d9..000000000 --- a/lib/silex/vendor/symfony/http-foundation/Tests/schema/iana-registry.rng +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uri - - - - rfc - - - (rfc|bcp|std)\d+ - - - - - rfc-errata - - - - draft - - - (draft|RFC)(-[a-zA-Z0-9]+)+ - - - - - registry - - - - person - - - - text - - - note - - - - unicode - - - ucd\d+\.\d+\.\d+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (\d+|0x[\da-fA-F]+)(\s*-\s*(\d+|0x[\da-fA-F]+))? - - - - - - - - - - - - - 0x[0-9]{8} - - - - - - [0-1]+ - - - - - - - - - - - - - - - - - - - - - - legacy - mib - template - json - - - - - - - - - - diff --git a/lib/silex/vendor/symfony/http-foundation/composer.json b/lib/silex/vendor/symfony/http-foundation/composer.json deleted file mode 100644 index f6c6f2e62..000000000 --- a/lib/silex/vendor/symfony/http-foundation/composer.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "symfony/http-foundation", - "type": "library", - "description": "Symfony HttpFoundation Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php70": "~1.6" - }, - "require-dev": { - "symfony/expression-language": "~2.8|~3.0|~4.0" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\HttpFoundation\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/http-foundation/phpunit.xml.dist b/lib/silex/vendor/symfony/http-foundation/phpunit.xml.dist deleted file mode 100644 index c1d61f8bf..000000000 --- a/lib/silex/vendor/symfony/http-foundation/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/symfony/http-kernel/.gitignore b/lib/silex/vendor/symfony/http-kernel/.gitignore deleted file mode 100644 index 94a6a2528..000000000 --- a/lib/silex/vendor/symfony/http-kernel/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vendor/ -composer.lock -phpunit.xml -Tests/Fixtures/cache/ -Tests/Fixtures/logs/ diff --git a/lib/silex/vendor/symfony/http-kernel/Bundle/Bundle.php b/lib/silex/vendor/symfony/http-kernel/Bundle/Bundle.php deleted file mode 100644 index cfa576c36..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Bundle/Bundle.php +++ /dev/null @@ -1,229 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Bundle; - -use Symfony\Component\DependencyInjection\ContainerAwareTrait; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\Console\Application; -use Symfony\Component\Finder\Finder; -use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; - -/** - * An implementation of BundleInterface that adds a few conventions - * for DependencyInjection extensions and Console commands. - * - * @author Fabien Potencier - */ -abstract class Bundle implements BundleInterface -{ - use ContainerAwareTrait; - - protected $name; - protected $extension; - protected $path; - private $namespace; - - /** - * Boots the Bundle. - */ - public function boot() - { - } - - /** - * Shutdowns the Bundle. - */ - public function shutdown() - { - } - - /** - * Builds the bundle. - * - * It is only ever called once when the cache is empty. - * - * This method can be overridden to register compilation passes, - * other extensions, ... - */ - public function build(ContainerBuilder $container) - { - } - - /** - * Returns the bundle's container extension. - * - * @return ExtensionInterface|null The container extension - * - * @throws \LogicException - */ - public function getContainerExtension() - { - if (null === $this->extension) { - $extension = $this->createContainerExtension(); - - if (null !== $extension) { - if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_class($extension))); - } - - // check naming convention - $basename = preg_replace('/Bundle$/', '', $this->getName()); - $expectedAlias = Container::underscore($basename); - - if ($expectedAlias != $extension->getAlias()) { - throw new \LogicException(sprintf( - 'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', - $expectedAlias, $extension->getAlias() - )); - } - - $this->extension = $extension; - } else { - $this->extension = false; - } - } - - if ($this->extension) { - return $this->extension; - } - } - - /** - * Gets the Bundle namespace. - * - * @return string The Bundle namespace - */ - public function getNamespace() - { - if (null === $this->namespace) { - $this->parseClassName(); - } - - return $this->namespace; - } - - /** - * Gets the Bundle directory path. - * - * @return string The Bundle absolute path - */ - public function getPath() - { - if (null === $this->path) { - $reflected = new \ReflectionObject($this); - $this->path = dirname($reflected->getFileName()); - } - - return $this->path; - } - - /** - * Returns the bundle parent name. - * - * @return string|null The Bundle parent name it overrides or null if no parent - */ - public function getParent() - { - } - - /** - * Returns the bundle name (the class short name). - * - * @return string The Bundle name - */ - final public function getName() - { - if (null === $this->name) { - $this->parseClassName(); - } - - return $this->name; - } - - /** - * Finds and registers Commands. - * - * Override this method if your bundle commands do not follow the conventions: - * - * * Commands are in the 'Command' sub-directory - * * Commands extend Symfony\Component\Console\Command\Command - */ - public function registerCommands(Application $application) - { - if (!is_dir($dir = $this->getPath().'/Command')) { - return; - } - - if (!class_exists('Symfony\Component\Finder\Finder')) { - throw new \RuntimeException('You need the symfony/finder component to register bundle commands.'); - } - - $finder = new Finder(); - $finder->files()->name('*Command.php')->in($dir); - - $prefix = $this->getNamespace().'\\Command'; - foreach ($finder as $file) { - $ns = $prefix; - if ($relativePath = $file->getRelativePath()) { - $ns .= '\\'.str_replace('/', '\\', $relativePath); - } - $class = $ns.'\\'.$file->getBasename('.php'); - if ($this->container) { - $commandIds = $this->container->hasParameter('console.command.ids') ? $this->container->getParameter('console.command.ids') : array(); - $alias = 'console.command.'.strtolower(str_replace('\\', '_', $class)); - if (isset($commandIds[$alias]) || $this->container->has($alias)) { - continue; - } - } - $r = new \ReflectionClass($class); - if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) { - @trigger_error(sprintf('Auto-registration of the command "%s" is deprecated since Symfony 3.4 and won\'t be supported in 4.0. Use PSR-4 based service discovery instead.', $class), E_USER_DEPRECATED); - - $application->add($r->newInstance()); - } - } - } - - /** - * Returns the bundle's container extension class. - * - * @return string - */ - protected function getContainerExtensionClass() - { - $basename = preg_replace('/Bundle$/', '', $this->getName()); - - return $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension'; - } - - /** - * Creates the bundle's container extension. - * - * @return ExtensionInterface|null - */ - protected function createContainerExtension() - { - if (class_exists($class = $this->getContainerExtensionClass())) { - return new $class(); - } - } - - private function parseClassName() - { - $pos = strrpos(static::class, '\\'); - $this->namespace = false === $pos ? '' : substr(static::class, 0, $pos); - if (null === $this->name) { - $this->name = false === $pos ? static::class : substr(static::class, $pos + 1); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Bundle/BundleInterface.php b/lib/silex/vendor/symfony/http-kernel/Bundle/BundleInterface.php deleted file mode 100644 index 14a7f6f4f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Bundle/BundleInterface.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Bundle; - -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; - -/** - * BundleInterface. - * - * @author Fabien Potencier - */ -interface BundleInterface extends ContainerAwareInterface -{ - /** - * Boots the Bundle. - */ - public function boot(); - - /** - * Shutdowns the Bundle. - */ - public function shutdown(); - - /** - * Builds the bundle. - * - * It is only ever called once when the cache is empty. - */ - public function build(ContainerBuilder $container); - - /** - * Returns the container extension that should be implicitly loaded. - * - * @return ExtensionInterface|null The default extension or null if there is none - */ - public function getContainerExtension(); - - /** - * Returns the bundle name that this bundle overrides. - * - * Despite its name, this method does not imply any parent/child relationship - * between the bundles, just a way to extend and override an existing - * bundle. - * - * @return string The Bundle name it overrides or null if no parent - * - * @deprecated This method is deprecated as of 3.4 and will be removed in 4.0. - */ - public function getParent(); - - /** - * Returns the bundle name (the class short name). - * - * @return string The Bundle name - */ - public function getName(); - - /** - * Gets the Bundle namespace. - * - * @return string The Bundle namespace - */ - public function getNamespace(); - - /** - * Gets the Bundle directory path. - * - * The path should always be returned as a Unix path (with /). - * - * @return string The Bundle absolute path - */ - public function getPath(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/CHANGELOG.md b/lib/silex/vendor/symfony/http-kernel/CHANGELOG.md deleted file mode 100644 index fb29f7696..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CHANGELOG.md +++ /dev/null @@ -1,151 +0,0 @@ -CHANGELOG -========= - -3.4.0 ------ - - * added a minimalist PSR-3 `Logger` class that writes in `stderr` - * made kernels implementing `CompilerPassInterface` able to process the container - * deprecated bundle inheritance - * added `RebootableInterface` and implemented it in `Kernel` - * deprecated commands auto registration - * deprecated `EnvParametersResource` - * added `Symfony\Component\HttpKernel\Client::catchExceptions()` - * deprecated the `ChainCacheClearer::add()` method - * deprecated the `CacheaWarmerAggregate::add()` and `setWarmers()` methods - * made `CacheWarmerAggregate` and `ChainCacheClearer` classes final - * added the possibility to reset the profiler to its initial state - * deprecated data collectors without a `reset()` method - * deprecated implementing `DebugLoggerInterface` without a `clear()` method - -3.3.0 ------ - - * added `kernel.project_dir` and `Kernel::getProjectDir()` - * deprecated `kernel.root_dir` and `Kernel::getRootDir()` - * deprecated `Kernel::getEnvParameters()` - * deprecated the special `SYMFONY__` environment variables - * added the possibility to change the query string parameter used by `UriSigner` - * deprecated `LazyLoadingFragmentHandler::addRendererService()` - * deprecated `Extension::addClassesToCompile()` and `Extension::getClassesToCompile()` - * deprecated `Psr6CacheClearer::addPool()` - -3.2.0 ------ - - * deprecated `DataCollector::varToString()`, use `cloneVar()` instead - * changed surrogate capability name in `AbstractSurrogate::addSurrogateCapability` to 'symfony' - * Added `ControllerArgumentValueResolverPass` - -3.1.0 ------ - * deprecated passing objects as URI attributes to the ESI and SSI renderers - * deprecated `ControllerResolver::getArguments()` - * added `Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface` - * added `Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface` as argument to `HttpKernel` - * added `Symfony\Component\HttpKernel\Controller\ArgumentResolver` - * added `Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::getMethod()` - * added `Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::getRedirect()` - * added the `kernel.controller_arguments` event, triggered after controller arguments have been resolved - -3.0.0 ------ - - * removed `Symfony\Component\HttpKernel\Kernel::init()` - * removed `Symfony\Component\HttpKernel\Kernel::isClassInActiveBundle()` and `Symfony\Component\HttpKernel\KernelInterface::isClassInActiveBundle()` - * removed `Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher::setProfiler()` - * removed `Symfony\Component\HttpKernel\EventListener\FragmentListener::getLocalIpAddresses()` - * removed `Symfony\Component\HttpKernel\EventListener\LocaleListener::setRequest()` - * removed `Symfony\Component\HttpKernel\EventListener\RouterListener::setRequest()` - * removed `Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest()` - * removed `Symfony\Component\HttpKernel\Fragment\FragmentHandler::setRequest()` - * removed `Symfony\Component\HttpKernel\HttpCache\Esi::hasSurrogateEsiCapability()` - * removed `Symfony\Component\HttpKernel\HttpCache\Esi::addSurrogateEsiCapability()` - * removed `Symfony\Component\HttpKernel\HttpCache\Esi::needsEsiParsing()` - * removed `Symfony\Component\HttpKernel\HttpCache\HttpCache::getEsi()` - * removed `Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel` - * removed `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass` - * removed `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener` - * removed `Symfony\Component\HttpKernel\EventListener\EsiListener` - * removed `Symfony\Component\HttpKernel\HttpCache\EsiResponseCacheStrategy` - * removed `Symfony\Component\HttpKernel\HttpCache\EsiResponseCacheStrategyInterface` - * removed `Symfony\Component\HttpKernel\Log\LoggerInterface` - * removed `Symfony\Component\HttpKernel\Log\NullLogger` - * removed `Symfony\Component\HttpKernel\Profiler::import()` - * removed `Symfony\Component\HttpKernel\Profiler::export()` - -2.8.0 ------ - - * deprecated `Profiler::import` and `Profiler::export` - -2.7.0 ------ - - * added the HTTP status code to profiles - -2.6.0 ------ - - * deprecated `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener`, use `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` instead - * deprecated unused method `Symfony\Component\HttpKernel\Kernel::isClassInActiveBundle` and `Symfony\Component\HttpKernel\KernelInterface::isClassInActiveBundle` - -2.5.0 ------ - - * deprecated `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass`, use `Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass` instead - -2.4.0 ------ - - * added event listeners for the session - * added the KernelEvents::FINISH_REQUEST event - -2.3.0 ------ - - * [BC BREAK] renamed `Symfony\Component\HttpKernel\EventListener\DeprecationLoggerListener` to `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener` and changed its constructor - * deprecated `Symfony\Component\HttpKernel\Debug\ErrorHandler`, `Symfony\Component\HttpKernel\Debug\ExceptionHandler`, - `Symfony\Component\HttpKernel\Exception\FatalErrorException` and `Symfony\Component\HttpKernel\Exception\FlattenException` - * deprecated `Symfony\Component\HttpKernel\Kernel::init()` - * added the possibility to specify an id an extra attributes to hinclude tags - * added the collect of data if a controller is a Closure in the Request collector - * pass exceptions from the ExceptionListener to the logger using the logging context to allow for more - detailed messages - -2.2.0 ------ - - * [BC BREAK] the path info for sub-request is now always _fragment (or whatever you configured instead of the default) - * added Symfony\Component\HttpKernel\EventListener\FragmentListener - * added Symfony\Component\HttpKernel\UriSigner - * added Symfony\Component\HttpKernel\FragmentRenderer and rendering strategies (in Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface) - * added Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel - * added ControllerReference to create reference of Controllers (used in the FragmentRenderer class) - * [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 ------ - - * [BC BREAK] the charset is now configured via the Kernel::getCharset() method - * [BC BREAK] the current locale for the user is not stored anymore in the session - * added the HTTP method to the profiler storage - * updated all listeners to implement EventSubscriberInterface - * added TimeDataCollector - * added ContainerAwareTraceableEventDispatcher - * moved TraceableEventDispatcherInterface to the EventDispatcher component - * added RouterListener, LocaleListener, and StreamedResponseListener - * added CacheClearerInterface (and ChainCacheClearer) - * added a kernel.terminate event (via TerminableInterface and PostResponseEvent) - * added a Stopwatch class - * added WarmableInterface - * improved extensibility between bundles - * added profiler storages for Memcache(d), File-based, MongoDB, Redis - * moved Filesystem class to its own component diff --git a/lib/silex/vendor/symfony/http-kernel/CacheClearer/CacheClearerInterface.php b/lib/silex/vendor/symfony/http-kernel/CacheClearer/CacheClearerInterface.php deleted file mode 100644 index 675c58423..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CacheClearer/CacheClearerInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheClearer; - -/** - * CacheClearerInterface. - * - * @author Dustin Dobervich - */ -interface CacheClearerInterface -{ - /** - * Clears any caches necessary. - * - * @param string $cacheDir The cache directory - */ - public function clear($cacheDir); -} diff --git a/lib/silex/vendor/symfony/http-kernel/CacheClearer/ChainCacheClearer.php b/lib/silex/vendor/symfony/http-kernel/CacheClearer/ChainCacheClearer.php deleted file mode 100644 index 8ee4275b1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CacheClearer/ChainCacheClearer.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheClearer; - -/** - * ChainCacheClearer. - * - * @author Dustin Dobervich - * - * @final since version 3.4 - */ -class ChainCacheClearer implements CacheClearerInterface -{ - protected $clearers; - - /** - * Constructs a new instance of ChainCacheClearer. - * - * @param array $clearers The initial clearers - */ - public function __construct($clearers = array()) - { - $this->clearers = $clearers; - } - - /** - * {@inheritdoc} - */ - public function clear($cacheDir) - { - foreach ($this->clearers as $clearer) { - $clearer->clear($cacheDir); - } - } - - /** - * Adds a cache clearer to the aggregate. - * - * @deprecated since version 3.4, to be removed in 4.0, inject the list of clearers as a constructor argument instead. - */ - public function add(CacheClearerInterface $clearer) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED); - - $this->clearers[] = $clearer; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/CacheClearer/Psr6CacheClearer.php b/lib/silex/vendor/symfony/http-kernel/CacheClearer/Psr6CacheClearer.php deleted file mode 100644 index d413d2c9d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CacheClearer/Psr6CacheClearer.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheClearer; - -use Psr\Cache\CacheItemPoolInterface; - -/** - * @author Nicolas Grekas - */ -class Psr6CacheClearer implements CacheClearerInterface -{ - private $pools = array(); - - public function __construct(array $pools = array()) - { - $this->pools = $pools; - } - - public function addPool(CacheItemPoolInterface $pool) - { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead.', __METHOD__), E_USER_DEPRECATED); - - $this->pools[] = $pool; - } - - public function hasPool($name) - { - return isset($this->pools[$name]); - } - - public function clearPool($name) - { - if (!isset($this->pools[$name])) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); - } - - return $this->pools[$name]->clear(); - } - - /** - * {@inheritdoc} - */ - public function clear($cacheDir) - { - foreach ($this->pools as $pool) { - $pool->clear(); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmer.php b/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmer.php deleted file mode 100644 index dba35a639..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmer.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Abstract cache warmer that knows how to write a file to the cache. - * - * @author Fabien Potencier - */ -abstract class CacheWarmer implements CacheWarmerInterface -{ - protected function writeCacheFile($file, $content) - { - $tmpFile = @tempnam(dirname($file), basename($file)); - if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { - @chmod($file, 0666 & ~umask()); - - return; - } - - throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php b/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php deleted file mode 100644 index ca3911ed5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Aggregates several cache warmers into a single one. - * - * @author Fabien Potencier - * - * @final since version 3.4 - */ -class CacheWarmerAggregate implements CacheWarmerInterface -{ - protected $warmers = array(); - protected $optionalsEnabled = false; - private $triggerDeprecation = false; - - public function __construct($warmers = array()) - { - foreach ($warmers as $warmer) { - $this->add($warmer); - } - $this->triggerDeprecation = true; - } - - public function enableOptionalWarmers() - { - $this->optionalsEnabled = true; - } - - /** - * Warms up the cache. - * - * @param string $cacheDir The cache directory - */ - public function warmUp($cacheDir) - { - foreach ($this->warmers as $warmer) { - if (!$this->optionalsEnabled && $warmer->isOptional()) { - continue; - } - - $warmer->warmUp($cacheDir); - } - } - - /** - * Checks whether this warmer is optional or not. - * - * @return bool always false - */ - public function isOptional() - { - return false; - } - - /** - * @deprecated since version 3.4, to be removed in 4.0, inject the list of clearers as a constructor argument instead. - */ - public function setWarmers(array $warmers) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED); - - $this->warmers = array(); - foreach ($warmers as $warmer) { - $this->add($warmer); - } - } - - /** - * @deprecated since version 3.4, to be removed in 4.0, inject the list of clearers as a constructor argument instead. - */ - public function add(CacheWarmerInterface $warmer) - { - if ($this->triggerDeprecation) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED); - } - - $this->warmers[] = $warmer; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerInterface.php b/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerInterface.php deleted file mode 100644 index 8fece5e95..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Interface for classes able to warm up the cache. - * - * @author Fabien Potencier - */ -interface CacheWarmerInterface extends WarmableInterface -{ - /** - * Checks whether this warmer is optional or not. - * - * Optional warmers can be ignored on certain conditions. - * - * A warmer should return true if the cache can be - * generated incrementally and on-demand. - * - * @return bool true if the warmer is optional, false otherwise - */ - public function isOptional(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/WarmableInterface.php b/lib/silex/vendor/symfony/http-kernel/CacheWarmer/WarmableInterface.php deleted file mode 100644 index 25d8ee8f6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/CacheWarmer/WarmableInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Interface for classes that support warming their cache. - * - * @author Fabien Potencier - */ -interface WarmableInterface -{ - /** - * Warms up the cache. - * - * @param string $cacheDir The cache directory - */ - public function warmUp($cacheDir); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Client.php b/lib/silex/vendor/symfony/http-kernel/Client.php deleted file mode 100644 index 7979722d1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Client.php +++ /dev/null @@ -1,205 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\BrowserKit\Client as BaseClient; -use Symfony\Component\BrowserKit\Request as DomRequest; -use Symfony\Component\BrowserKit\Response as DomResponse; -use Symfony\Component\BrowserKit\History; -use Symfony\Component\BrowserKit\CookieJar; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Client simulates a browser and makes requests to a Kernel object. - * - * @author Fabien Potencier - * - * @method Request|null getRequest() A Request instance - * @method Response|null getResponse() A Response instance - */ -class Client extends BaseClient -{ - protected $kernel; - private $catchExceptions = true; - - /** - * @param HttpKernelInterface $kernel An HttpKernel instance - * @param array $server The server parameters (equivalent of $_SERVER) - * @param History $history A History instance to store the browser history - * @param CookieJar $cookieJar A CookieJar instance to store the cookies - */ - public function __construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null) - { - // These class properties must be set before calling the parent constructor, as it may depend on it. - $this->kernel = $kernel; - $this->followRedirects = false; - - parent::__construct($server, $history, $cookieJar); - } - - /** - * Sets whether to catch exceptions when the kernel is handling a request. - * - * @param bool $catchExceptions Whether to catch exceptions - */ - public function catchExceptions($catchExceptions) - { - $this->catchExceptions = $catchExceptions; - } - - /** - * Makes a request. - * - * @return Response A Response instance - */ - protected function doRequest($request) - { - $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions); - - if ($this->kernel instanceof TerminableInterface) { - $this->kernel->terminate($request, $response); - } - - return $response; - } - - /** - * Returns the script to execute when the request must be insulated. - * - * @return string - */ - protected function getScript($request) - { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); - $errorReporting = error_reporting(); - - $requires = ''; - foreach (get_declared_classes() as $class) { - if (0 === strpos($class, 'ComposerAutoloaderInit')) { - $r = new \ReflectionClass($class); - $file = dirname(dirname($r->getFileName())).'/autoload.php'; - if (file_exists($file)) { - $requires .= "require_once '".str_replace("'", "\\'", $file)."';\n"; - } - } - } - - if (!$requires) { - throw new \RuntimeException('Composer autoloader not found.'); - } - - $code = <<getHandleScript(); - } - - protected function getHandleScript() - { - return <<<'EOF' -$response = $kernel->handle($request); - -if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) { - $kernel->terminate($request, $response); -} - -echo serialize($response); -EOF; - } - - /** - * Converts the BrowserKit request to a HttpKernel request. - * - * @return Request A Request instance - */ - protected function filterRequest(DomRequest $request) - { - $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent()); - - foreach ($this->filterFiles($httpRequest->files->all()) as $key => $value) { - $httpRequest->files->set($key, $value); - } - - return $httpRequest; - } - - /** - * Filters an array of files. - * - * This method created test instances of UploadedFile so that the move() - * method can be called on those instances. - * - * If the size of a file is greater than the allowed size (from php.ini) then - * an invalid UploadedFile is returned with an error set to UPLOAD_ERR_INI_SIZE. - * - * @see UploadedFile - * - * @return array An array with all uploaded files marked as already moved - */ - protected function filterFiles(array $files) - { - $filtered = array(); - foreach ($files as $key => $value) { - if (is_array($value)) { - $filtered[$key] = $this->filterFiles($value); - } elseif ($value instanceof UploadedFile) { - if ($value->isValid() && $value->getSize() > UploadedFile::getMaxFilesize()) { - $filtered[$key] = new UploadedFile( - '', - $value->getClientOriginalName(), - $value->getClientMimeType(), - 0, - UPLOAD_ERR_INI_SIZE, - true - ); - } else { - $filtered[$key] = new UploadedFile( - $value->getPathname(), - $value->getClientOriginalName(), - $value->getClientMimeType(), - $value->getClientSize(), - $value->getError(), - true - ); - } - } - } - - return $filtered; - } - - /** - * Converts the HttpKernel response to a BrowserKit response. - * - * @return DomResponse A DomResponse instance - */ - protected function filterResponse($response) - { - // this is needed to support StreamedResponse - ob_start(); - $response->sendContent(); - $content = ob_get_clean(); - - return new DomResponse($content, $response->getStatusCode(), $response->headers->all()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Config/EnvParametersResource.php b/lib/silex/vendor/symfony/http-kernel/Config/EnvParametersResource.php deleted file mode 100644 index f8d2a72b2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Config/EnvParametersResource.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Config; - -use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; - -/** - * EnvParametersResource represents resources stored in prefixed environment variables. - * - * @author Chris Wilkinson - * - * @deprecated since version 3.4, to be removed in 4.0 - */ -class EnvParametersResource implements SelfCheckingResourceInterface, \Serializable -{ - /** - * @var string - */ - private $prefix; - - /** - * @var string - */ - private $variables; - - /** - * @param string $prefix - */ - public function __construct($prefix) - { - $this->prefix = $prefix; - $this->variables = $this->findVariables(); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return serialize($this->getResource()); - } - - /** - * @return array An array with two keys: 'prefix' for the prefix used and 'variables' containing all the variables watched by this resource - */ - public function getResource() - { - return array('prefix' => $this->prefix, 'variables' => $this->variables); - } - - /** - * {@inheritdoc} - */ - public function isFresh($timestamp) - { - return $this->findVariables() === $this->variables; - } - - public function serialize() - { - return serialize(array('prefix' => $this->prefix, 'variables' => $this->variables)); - } - - public function unserialize($serialized) - { - if (\PHP_VERSION_ID >= 70000) { - $unserialized = unserialize($serialized, array('allowed_classes' => false)); - } else { - $unserialized = unserialize($serialized); - } - - $this->prefix = $unserialized['prefix']; - $this->variables = $unserialized['variables']; - } - - private function findVariables() - { - $variables = array(); - - foreach ($_SERVER as $key => $value) { - if (0 === strpos($key, $this->prefix)) { - $variables[$key] = $value; - } - } - - ksort($variables); - - return $variables; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Config/FileLocator.php b/lib/silex/vendor/symfony/http-kernel/Config/FileLocator.php deleted file mode 100644 index fb1f913bd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Config/FileLocator.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Config; - -use Symfony\Component\Config\FileLocator as BaseFileLocator; -use Symfony\Component\HttpKernel\KernelInterface; - -/** - * FileLocator uses the KernelInterface to locate resources in bundles. - * - * @author Fabien Potencier - */ -class FileLocator extends BaseFileLocator -{ - private $kernel; - private $path; - - /** - * @param KernelInterface $kernel A KernelInterface instance - * @param null|string $path The path the global resource directory - * @param array $paths An array of paths where to look for resources - */ - public function __construct(KernelInterface $kernel, $path = null, array $paths = array()) - { - $this->kernel = $kernel; - if (null !== $path) { - $this->path = $path; - $paths[] = $path; - } - - parent::__construct($paths); - } - - /** - * {@inheritdoc} - */ - public function locate($file, $currentPath = null, $first = true) - { - if (isset($file[0]) && '@' === $file[0]) { - return $this->kernel->locateResource($file, $this->path, $first); - } - - return parent::locate($file, $currentPath, $first); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver.php deleted file mode 100644 index 2c17125c5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * 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\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\SessionValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\VariadicValueResolver; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactoryInterface; - -/** - * Responsible for resolving the arguments passed to an action. - * - * @author Iltar van der Berg - */ -final class ArgumentResolver implements ArgumentResolverInterface -{ - private $argumentMetadataFactory; - - /** - * @var iterable|ArgumentValueResolverInterface[] - */ - private $argumentValueResolvers; - - public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, $argumentValueResolvers = array()) - { - $this->argumentMetadataFactory = $argumentMetadataFactory ?: new ArgumentMetadataFactory(); - $this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers(); - } - - /** - * {@inheritdoc} - */ - public function getArguments(Request $request, $controller) - { - $arguments = array(); - - foreach ($this->argumentMetadataFactory->createArgumentMetadata($controller) as $metadata) { - foreach ($this->argumentValueResolvers as $resolver) { - if (!$resolver->supports($request, $metadata)) { - continue; - } - - $resolved = $resolver->resolve($request, $metadata); - - if (!$resolved instanceof \Generator) { - throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', get_class($resolver))); - } - - foreach ($resolved as $append) { - $arguments[] = $append; - } - - // continue to the next controller argument - continue 2; - } - - $representative = $controller; - - if (is_array($representative)) { - $representative = sprintf('%s::%s()', get_class($representative[0]), $representative[1]); - } elseif (is_object($representative)) { - $representative = get_class($representative); - } - - throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.', $representative, $metadata->getName())); - } - - return $arguments; - } - - public static function getDefaultArgumentValueResolvers() - { - return array( - new RequestAttributeValueResolver(), - new RequestValueResolver(), - new SessionValueResolver(), - new DefaultValueResolver(), - new VariadicValueResolver(), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/DefaultValueResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/DefaultValueResolver.php deleted file mode 100644 index e58fd3ab2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/DefaultValueResolver.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Yields the default value defined in the action signature when no value has been given. - * - * @author Iltar van der Berg - */ -final class DefaultValueResolver implements ArgumentValueResolverInterface -{ - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic()); - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - yield $argument->hasDefaultValue() ? $argument->getDefaultValue() : null; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php deleted file mode 100644 index 05be372d8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestAttributeValueResolver.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Yields a non-variadic argument's value from the request attributes. - * - * @author Iltar van der Berg - */ -final class RequestAttributeValueResolver implements ArgumentValueResolverInterface -{ - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - return !$argument->isVariadic() && $request->attributes->has($argument->getName()); - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - yield $request->attributes->get($argument->getName()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestValueResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestValueResolver.php deleted file mode 100644 index 2a5060a61..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/RequestValueResolver.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Yields the same instance as the request object passed along. - * - * @author Iltar van der Berg - */ -final class RequestValueResolver implements ArgumentValueResolverInterface -{ - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class); - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - yield $request; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php deleted file mode 100644 index c55564c04..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; - -use Psr\Container\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Yields a service keyed by _controller and argument name. - * - * @author Nicolas Grekas - */ -final class ServiceValueResolver implements ArgumentValueResolverInterface -{ - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - $controller = $request->attributes->get('_controller'); - - if (\is_array($controller) && \is_callable($controller, true) && \is_string($controller[0])) { - $controller = $controller[0].'::'.$controller[1]; - } - - return \is_string($controller) && $this->container->has($controller) && $this->container->get($controller)->has($argument->getName()); - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - if (\is_array($controller = $request->attributes->get('_controller'))) { - $controller = $controller[0].'::'.$controller[1]; - } - - yield $this->container->get($controller)->get($argument->getName()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php deleted file mode 100644 index 9e656d281..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/SessionValueResolver.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Yields the Session. - * - * @author Iltar van der Berg - */ -final class SessionValueResolver implements ArgumentValueResolverInterface -{ - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - $type = $argument->getType(); - if (SessionInterface::class !== $type && !is_subclass_of($type, SessionInterface::class)) { - return false; - } - - return $request->getSession() instanceof $type; - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - yield $request->getSession(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/VariadicValueResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/VariadicValueResolver.php deleted file mode 100644 index 56ae5f191..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolver/VariadicValueResolver.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Controller\ArgumentResolver; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Yields a variadic argument's values from the request attributes. - * - * @author Iltar van der Berg - */ -final class VariadicValueResolver implements ArgumentValueResolverInterface -{ - /** - * {@inheritdoc} - */ - public function supports(Request $request, ArgumentMetadata $argument) - { - return $argument->isVariadic() && $request->attributes->has($argument->getName()); - } - - /** - * {@inheritdoc} - */ - public function resolve(Request $request, ArgumentMetadata $argument) - { - $values = $request->attributes->get($argument->getName()); - - if (!is_array($values)) { - throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), gettype($values))); - } - - foreach ($values as $value) { - yield $value; - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolverInterface.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolverInterface.php deleted file mode 100644 index 5c5123096..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentResolverInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * 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\HttpFoundation\Request; - -/** - * An ArgumentResolverInterface instance knows how to determine the - * arguments for a specific action. - * - * @author Fabien Potencier - */ -interface ArgumentResolverInterface -{ - /** - * Returns the arguments to pass to the controller. - * - * @param Request $request - * @param callable $controller - * - * @return array An array of arguments to pass to the controller - * - * @throws \RuntimeException When no value could be provided for a required argument - */ - public function getArguments(Request $request, $controller); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentValueResolverInterface.php b/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentValueResolverInterface.php deleted file mode 100644 index fd7b09ecf..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ArgumentValueResolverInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * 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\HttpFoundation\Request; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -/** - * Responsible for resolving the value of an argument based on its metadata. - * - * @author Iltar van der Berg - */ -interface ArgumentValueResolverInterface -{ - /** - * Whether this resolver can resolve the value for the given ArgumentMetadata. - * - * @param Request $request - * @param ArgumentMetadata $argument - * - * @return bool - */ - public function supports(Request $request, ArgumentMetadata $argument); - - /** - * Returns the possible value(s). - * - * @param Request $request - * @param ArgumentMetadata $argument - * - * @return \Generator - */ - public function resolve(Request $request, ArgumentMetadata $argument); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php deleted file mode 100644 index 186583d7b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * 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 Psr\Container\ContainerInterface; -use Psr\Log\LoggerInterface; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\HttpFoundation\Request; - -/** - * A controller resolver searching for a controller in a psr-11 container when using the "service:method" notation. - * - * @author Fabien Potencier - * @author Maxime Steinhausser - */ -class ContainerControllerResolver extends ControllerResolver -{ - protected $container; - - public function __construct(ContainerInterface $container, LoggerInterface $logger = null) - { - $this->container = $container; - - parent::__construct($logger); - } - - /** - * {@inheritdoc} - */ - public function getController(Request $request) - { - $controller = parent::getController($request); - - if (is_array($controller) && isset($controller[0]) && is_string($controller[0]) && $this->container->has($controller[0])) { - $controller[0] = $this->instantiateController($controller[0]); - } - - return $controller; - } - - /** - * Returns a callable for the given controller. - * - * @param string $controller A Controller string - * - * @return mixed A PHP callable - * - * @throws \LogicException When the name could not be parsed - * @throws \InvalidArgumentException When the controller class does not exist - */ - protected function createController($controller) - { - if (false !== strpos($controller, '::')) { - return parent::createController($controller); - } - - $method = null; - if (1 == substr_count($controller, ':')) { - // controller in the "service:method" notation - list($controller, $method) = explode(':', $controller, 2); - } - - if (!$this->container->has($controller)) { - $this->throwExceptionIfControllerWasRemoved($controller); - - throw new \LogicException(sprintf('Controller not found: service "%s" does not exist.', $controller)); - } - - $service = $this->container->get($controller); - if (null !== $method) { - return array($service, $method); - } - - if (!method_exists($service, '__invoke')) { - throw new \LogicException(sprintf('Controller "%s" cannot be called without a method name. Did you forget an "__invoke" method?', $controller)); - } - - return $service; - } - - /** - * {@inheritdoc} - */ - protected function instantiateController($class) - { - if ($this->container->has($class)) { - return $this->container->get($class); - } - - try { - return parent::instantiateController($class); - } catch (\ArgumentCountError $e) { - } catch (\ErrorException $e) { - } catch (\TypeError $e) { - } - - $this->throwExceptionIfControllerWasRemoved($class, $e); - - throw $e; - } - - /** - * @param string $controller - * @param \Exception|\Throwable|null $previous - */ - private function throwExceptionIfControllerWasRemoved($controller, $previous = null) - { - if ($this->container instanceof Container && isset($this->container->getRemovedIds()[$controller])) { - throw new \LogicException(sprintf('Controller "%s" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?', $controller), 0, $previous); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ControllerReference.php b/lib/silex/vendor/symfony/http-kernel/Controller/ControllerReference.php deleted file mode 100644 index fae4e7fa4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ControllerReference.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * 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\HttpKernel\Fragment\FragmentRendererInterface; - -/** - * Acts as a marker and a data holder for a Controller. - * - * Some methods in Symfony accept both a URI (as a string) or a controller as - * an argument. In the latter case, instead of passing an array representing - * the controller, you can use an instance of this class. - * - * @author Fabien Potencier - * - * @see FragmentRendererInterface - */ -class ControllerReference -{ - public $controller; - public $attributes = array(); - public $query = array(); - - /** - * @param string $controller The controller name - * @param array $attributes An array of parameters to add to the Request attributes - * @param array $query An array of parameters to add to the Request query string - */ - public function __construct($controller, array $attributes = array(), array $query = array()) - { - $this->controller = $controller; - $this->attributes = $attributes; - $this->query = $query; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolver.php deleted file mode 100644 index b9d9f9fa2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolver.php +++ /dev/null @@ -1,258 +0,0 @@ - - * - * 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 Psr\Log\LoggerInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * This implementation uses the '_controller' request attribute to determine - * the controller to execute and uses the request attributes to determine - * the controller method arguments. - * - * @author Fabien Potencier - */ -class ControllerResolver implements ArgumentResolverInterface, ControllerResolverInterface -{ - private $logger; - - /** - * If the ...$arg functionality is available. - * - * Requires at least PHP 5.6.0 or HHVM 3.9.1 - * - * @var bool - */ - private $supportsVariadic; - - /** - * If scalar types exists. - * - * @var bool - */ - private $supportsScalarTypes; - - public function __construct(LoggerInterface $logger = null) - { - $this->logger = $logger; - - $this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic'); - $this->supportsScalarTypes = method_exists('ReflectionParameter', 'getType'); - } - - /** - * {@inheritdoc} - * - * This method looks for a '_controller' request attribute that represents - * the controller name (a string like ClassName::MethodName). - */ - public function getController(Request $request) - { - if (!$controller = $request->attributes->get('_controller')) { - if (null !== $this->logger) { - $this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing.'); - } - - return false; - } - - if (is_array($controller)) { - return $controller; - } - - if (is_object($controller)) { - if (method_exists($controller, '__invoke')) { - return $controller; - } - - throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', get_class($controller), $request->getPathInfo())); - } - - if (false === strpos($controller, ':')) { - if (method_exists($controller, '__invoke')) { - return $this->instantiateController($controller); - } elseif (function_exists($controller)) { - return $controller; - } - } - - $callable = $this->createController($controller); - - if (!is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable))); - } - - return $callable; - } - - /** - * {@inheritdoc} - * - * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead. - */ - public function getArguments(Request $request, $controller) - { - @trigger_error(sprintf('%s is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED); - - if (is_array($controller)) { - $r = new \ReflectionMethod($controller[0], $controller[1]); - } elseif (is_object($controller) && !$controller instanceof \Closure) { - $r = new \ReflectionObject($controller); - $r = $r->getMethod('__invoke'); - } else { - $r = new \ReflectionFunction($controller); - } - - return $this->doGetArguments($request, $controller, $r->getParameters()); - } - - /** - * @param Request $request - * @param callable $controller - * @param \ReflectionParameter[] $parameters - * - * @return array The arguments to use when calling the action - * - * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead. - */ - protected function doGetArguments(Request $request, $controller, array $parameters) - { - @trigger_error(sprintf('%s is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED); - - $attributes = $request->attributes->all(); - $arguments = array(); - foreach ($parameters as $param) { - if (array_key_exists($param->name, $attributes)) { - if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) { - $arguments = array_merge($arguments, array_values($attributes[$param->name])); - } else { - $arguments[] = $attributes[$param->name]; - } - } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { - $arguments[] = $request; - } elseif ($param->isDefaultValueAvailable()) { - $arguments[] = $param->getDefaultValue(); - } elseif ($this->supportsScalarTypes && $param->hasType() && $param->allowsNull()) { - $arguments[] = null; - } else { - if (is_array($controller)) { - $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); - } elseif (is_object($controller)) { - $repr = get_class($controller); - } else { - $repr = $controller; - } - - throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->name)); - } - } - - return $arguments; - } - - /** - * Returns a callable for the given controller. - * - * @param string $controller A Controller string - * - * @return callable A PHP callable - * - * @throws \InvalidArgumentException - */ - protected function createController($controller) - { - if (false === strpos($controller, '::')) { - throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller)); - } - - list($class, $method) = explode('::', $controller, 2); - - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); - } - - return array($this->instantiateController($class), $method); - } - - /** - * Returns an instantiated controller. - * - * @param string $class A class name - * - * @return object - */ - protected function instantiateController($class) - { - return new $class(); - } - - private function getControllerError($callable) - { - if (is_string($callable)) { - if (false !== strpos($callable, '::')) { - $callable = explode('::', $callable); - } - - if (class_exists($callable) && !method_exists($callable, '__invoke')) { - return sprintf('Class "%s" does not have a method "__invoke".', $callable); - } - - if (!function_exists($callable)) { - return sprintf('Function "%s" does not exist.', $callable); - } - } - - if (!is_array($callable)) { - return sprintf('Invalid type for controller given, expected string or array, got "%s".', gettype($callable)); - } - - if (2 !== count($callable)) { - return 'Invalid format for controller, expected array(controller, method) or controller::method.'; - } - - list($controller, $method) = $callable; - - if (is_string($controller) && !class_exists($controller)) { - return sprintf('Class "%s" does not exist.', $controller); - } - - $className = is_object($controller) ? get_class($controller) : $controller; - - if (method_exists($controller, $method)) { - return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className); - } - - $collection = get_class_methods($controller); - - $alternatives = array(); - - foreach ($collection as $item) { - $lev = levenshtein($method, $item); - - if ($lev <= strlen($method) / 3 || false !== strpos($item, $method)) { - $alternatives[] = $item; - } - } - - asort($alternatives); - - $message = sprintf('Expected method "%s" on class "%s"', $method, $className); - - if (count($alternatives) > 0) { - $message .= sprintf(', did you mean "%s"?', implode('", "', $alternatives)); - } else { - $message .= sprintf('. Available methods: "%s".', implode('", "', $collection)); - } - - return $message; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolverInterface.php b/lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolverInterface.php deleted file mode 100644 index afe9fb733..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/ControllerResolverInterface.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * 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\HttpFoundation\Request; - -/** - * A ControllerResolverInterface implementation knows how to determine the - * controller to execute based on a Request object. - * - * It can also determine the arguments to pass to the Controller. - * - * A Controller can be any valid PHP callable. - * - * @author Fabien Potencier - */ -interface ControllerResolverInterface -{ - /** - * Returns the Controller instance associated with a Request. - * - * As several resolvers can exist for a single application, a resolver must - * return false when it is not able to determine the controller. - * - * The resolver must only throw an exception when it should be able to load - * controller but cannot because of some errors made by the developer. - * - * @return callable|false A PHP callable representing the Controller, - * or false if this resolver is not able to determine the controller - * - * @throws \LogicException If the controller can't be found - */ - public function getController(Request $request); - - /** - * Returns the arguments to pass to the controller. - * - * @param Request $request A Request instance - * @param callable $controller A PHP callable - * - * @return array An array of arguments to pass to the controller - * - * @throws \RuntimeException When value for argument given is not provided - * - * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Please use the {@see ArgumentResolverInterface} instead. - */ - public function getArguments(Request $request, $controller); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Controller/TraceableArgumentResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/TraceableArgumentResolver.php deleted file mode 100644 index 6fb0fa66a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/TraceableArgumentResolver.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * 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; - -/** - * @author Fabien Potencier - */ -class TraceableArgumentResolver implements ArgumentResolverInterface -{ - private $resolver; - private $stopwatch; - - public function __construct(ArgumentResolverInterface $resolver, Stopwatch $stopwatch) - { - $this->resolver = $resolver; - $this->stopwatch = $stopwatch; - } - - /** - * {@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/lib/silex/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php b/lib/silex/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php deleted file mode 100644 index 750107714..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * 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; - -/** - * @author Fabien Potencier - */ -class TraceableControllerResolver implements ControllerResolverInterface, ArgumentResolverInterface -{ - private $resolver; - private $stopwatch; - private $argumentResolver; - - public function __construct(ControllerResolverInterface $resolver, Stopwatch $stopwatch, ArgumentResolverInterface $argumentResolver = null) - { - $this->resolver = $resolver; - $this->stopwatch = $stopwatch; - $this->argumentResolver = $argumentResolver; - - // BC - if (null === $this->argumentResolver) { - $this->argumentResolver = $resolver; - } - - if (!$this->argumentResolver instanceof TraceableArgumentResolver) { - $this->argumentResolver = new TraceableArgumentResolver($this->argumentResolver, $this->stopwatch); - } - } - - /** - * {@inheritdoc} - */ - public function getController(Request $request) - { - $e = $this->stopwatch->start('controller.get_callable'); - - $ret = $this->resolver->getController($request); - - $e->stop(); - - return $ret; - } - - /** - * {@inheritdoc} - * - * @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. - */ - public function getArguments(Request $request, $controller) - { - @trigger_error(sprintf('The %s method is deprecated as of 3.1 and will be removed in 4.0. Please use the %s instead.', __METHOD__, TraceableArgumentResolver::class), E_USER_DEPRECATED); - - $ret = $this->argumentResolver->getArguments($request, $controller); - - return $ret; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadata.php b/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadata.php deleted file mode 100644 index 32316a8d5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadata.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\ControllerMetadata; - -/** - * Responsible for storing metadata of an argument. - * - * @author Iltar van der Berg - */ -class ArgumentMetadata -{ - private $name; - private $type; - private $isVariadic; - private $hasDefaultValue; - private $defaultValue; - private $isNullable; - - /** - * @param string $name - * @param string $type - * @param bool $isVariadic - * @param bool $hasDefaultValue - * @param mixed $defaultValue - * @param bool $isNullable - */ - public function __construct($name, $type, $isVariadic, $hasDefaultValue, $defaultValue, $isNullable = false) - { - $this->name = $name; - $this->type = $type; - $this->isVariadic = $isVariadic; - $this->hasDefaultValue = $hasDefaultValue; - $this->defaultValue = $defaultValue; - $this->isNullable = $isNullable || null === $type || ($hasDefaultValue && null === $defaultValue); - } - - /** - * Returns the name as given in PHP, $foo would yield "foo". - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Returns the type of the argument. - * - * The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+. - * - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Returns whether the argument is defined as "...$variadic". - * - * @return bool - */ - public function isVariadic() - { - return $this->isVariadic; - } - - /** - * Returns whether the argument has a default value. - * - * Implies whether an argument is optional. - * - * @return bool - */ - public function hasDefaultValue() - { - return $this->hasDefaultValue; - } - - /** - * Returns whether the argument accepts null values. - * - * @return bool - */ - public function isNullable() - { - return $this->isNullable; - } - - /** - * Returns the default value of the argument. - * - * @throws \LogicException if no default value is present; {@see self::hasDefaultValue()} - * - * @return mixed - */ - public function getDefaultValue() - { - if (!$this->hasDefaultValue) { - throw new \LogicException(sprintf('Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this exception.', $this->name, __CLASS__)); - } - - return $this->defaultValue; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactory.php b/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactory.php deleted file mode 100644 index d1e7af206..000000000 --- a/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactory.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\ControllerMetadata; - -/** - * Builds {@see ArgumentMetadata} objects based on the given Controller. - * - * @author Iltar van der Berg - */ -final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface -{ - /** - * If the ...$arg functionality is available. - * - * Requires at least PHP 5.6.0 or HHVM 3.9.1 - * - * @var bool - */ - private $supportsVariadic; - - /** - * If the reflection supports the getType() method to resolve types. - * - * Requires at least PHP 7.0.0 or HHVM 3.11.0 - * - * @var bool - */ - private $supportsParameterType; - - public function __construct() - { - $this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic'); - $this->supportsParameterType = method_exists('ReflectionParameter', 'getType'); - } - - /** - * {@inheritdoc} - */ - public function createArgumentMetadata($controller) - { - $arguments = array(); - - if (is_array($controller)) { - $reflection = new \ReflectionMethod($controller[0], $controller[1]); - } elseif (is_object($controller) && !$controller instanceof \Closure) { - $reflection = (new \ReflectionObject($controller))->getMethod('__invoke'); - } else { - $reflection = new \ReflectionFunction($controller); - } - - foreach ($reflection->getParameters() as $param) { - $arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param), $param->allowsNull()); - } - - return $arguments; - } - - /** - * Returns whether an argument is variadic. - * - * @param \ReflectionParameter $parameter - * - * @return bool - */ - private function isVariadic(\ReflectionParameter $parameter) - { - return $this->supportsVariadic && $parameter->isVariadic(); - } - - /** - * Determines whether an argument has a default value. - * - * @param \ReflectionParameter $parameter - * - * @return bool - */ - private function hasDefaultValue(\ReflectionParameter $parameter) - { - return $parameter->isDefaultValueAvailable(); - } - - /** - * Returns a default value if available. - * - * @param \ReflectionParameter $parameter - * - * @return mixed|null - */ - private function getDefaultValue(\ReflectionParameter $parameter) - { - return $this->hasDefaultValue($parameter) ? $parameter->getDefaultValue() : null; - } - - /** - * Returns an associated type to the given parameter if available. - * - * @param \ReflectionParameter $parameter - * - * @return null|string - */ - private function getType(\ReflectionParameter $parameter) - { - if ($this->supportsParameterType) { - if (!$type = $parameter->getType()) { - return; - } - $typeName = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); - if ('array' === $typeName && !$type->isBuiltin()) { - // Special case for HHVM with variadics - return; - } - - return $typeName; - } - - if (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $parameter, $info)) { - return $info[1]; - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php b/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php deleted file mode 100644 index 6ea179d78..000000000 --- a/lib/silex/vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\ControllerMetadata; - -/** - * Builds method argument data. - * - * @author Iltar van der Berg - */ -interface ArgumentMetadataFactoryInterface -{ - /** - * @param mixed $controller The controller to resolve the arguments for - * - * @return ArgumentMetadata[] - */ - public function createArgumentMetadata($controller); -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/AjaxDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/AjaxDataCollector.php deleted file mode 100644 index 370a874fe..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/AjaxDataCollector.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * AjaxDataCollector. - * - * @author Bart van den Burg - */ -class AjaxDataCollector extends DataCollector -{ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - // all collecting is done client side - } - - public function reset() - { - // all collecting is done client side - } - - public function getName() - { - return 'ajax'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/ConfigDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/ConfigDataCollector.php deleted file mode 100644 index 5675f0736..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/ConfigDataCollector.php +++ /dev/null @@ -1,332 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\VarDumper\Caster\LinkStub; - -/** - * @author Fabien Potencier - */ -class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface -{ - /** - * @var KernelInterface - */ - private $kernel; - private $name; - private $version; - private $hasVarDumper; - - /** - * @param string $name The name of the application using the web profiler - * @param string $version The version of the application using the web profiler - */ - public function __construct($name = null, $version = null) - { - $this->name = $name; - $this->version = $version; - $this->hasVarDumper = class_exists(LinkStub::class); - } - - /** - * Sets the Kernel associated with this Request. - */ - public function setKernel(KernelInterface $kernel = null) - { - $this->kernel = $kernel; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $this->data = array( - 'app_name' => $this->name, - 'app_version' => $this->version, - 'token' => $response->headers->get('X-Debug-Token'), - 'symfony_version' => Kernel::VERSION, - 'symfony_state' => 'unknown', - '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, - 'php_architecture' => PHP_INT_SIZE * 8, - 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', - 'php_timezone' => date_default_timezone_get(), - 'xdebug_enabled' => extension_loaded('xdebug'), - 'apcu_enabled' => extension_loaded('apcu') && ini_get('apc.enabled'), - 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), - 'bundles' => array(), - 'sapi_name' => PHP_SAPI, - ); - - if (isset($this->kernel)) { - foreach ($this->kernel->getBundles() as $name => $bundle) { - $this->data['bundles'][$name] = $this->hasVarDumper ? new LinkStub($bundle->getPath()) : $bundle->getPath(); - } - - $this->data['symfony_state'] = $this->determineSymfonyState(); - $this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION); - $eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE); - $eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE); - $this->data['symfony_eom'] = $eom->format('F Y'); - $this->data['symfony_eol'] = $eol->format('F Y'); - } - - if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) { - $this->data['php_version'] = $matches[1]; - $this->data['php_version_extra'] = $matches[2]; - } - } - - /** - * {@inheritdoc} - */ - public function reset() - { - $this->data = array(); - } - - public function lateCollect() - { - $this->data = $this->cloneVar($this->data); - } - - public function getApplicationName() - { - return $this->data['app_name']; - } - - public function getApplicationVersion() - { - return $this->data['app_version']; - } - - /** - * Gets the token. - * - * @return string The token - */ - public function getToken() - { - return $this->data['token']; - } - - /** - * Gets the Symfony version. - * - * @return string The Symfony version - */ - public function getSymfonyVersion() - { - return $this->data['symfony_version']; - } - - /** - * Returns the state of the current Symfony release. - * - * @return string One of: unknown, dev, stable, eom, eol - */ - public function getSymfonyState() - { - return $this->data['symfony_state']; - } - - /** - * Returns the minor Symfony version used (without patch numbers of extra - * suffix like "RC", "beta", etc.). - * - * @return string - */ - public function getSymfonyMinorVersion() - { - return $this->data['symfony_minor_version']; - } - - /** - * Returns the human redable date when this Symfony version ends its - * maintenance period. - * - * @return string - */ - public function getSymfonyEom() - { - return $this->data['symfony_eom']; - } - - /** - * Returns the human redable date when this Symfony version reaches its - * "end of life" and won't receive bugs or security fixes. - * - * @return string - */ - public function getSymfonyEol() - { - return $this->data['symfony_eol']; - } - - /** - * Gets the PHP version. - * - * @return string The PHP version - */ - public function getPhpVersion() - { - return $this->data['php_version']; - } - - /** - * Gets the PHP version extra part. - * - * @return string|null The extra part - */ - public function getPhpVersionExtra() - { - return isset($this->data['php_version_extra']) ? $this->data['php_version_extra'] : null; - } - - /** - * @return int The PHP architecture as number of bits (e.g. 32 or 64) - */ - public function getPhpArchitecture() - { - return $this->data['php_architecture']; - } - - /** - * @return string - */ - public function getPhpIntlLocale() - { - return $this->data['php_intl_locale']; - } - - /** - * @return string - */ - public function getPhpTimezone() - { - return $this->data['php_timezone']; - } - - /** - * Gets the application name. - * - * @return string The application name - */ - public function getAppName() - { - return $this->data['name']; - } - - /** - * Gets the environment. - * - * @return string The environment - */ - public function getEnv() - { - return $this->data['env']; - } - - /** - * Returns true if the debug is enabled. - * - * @return bool true if debug is enabled, false otherwise - */ - public function isDebug() - { - return $this->data['debug']; - } - - /** - * Returns true if the XDebug is enabled. - * - * @return bool true if XDebug is enabled, false otherwise - */ - public function hasXDebug() - { - return $this->data['xdebug_enabled']; - } - - /** - * Returns true if APCu is enabled. - * - * @return bool true if APCu is enabled, false otherwise - */ - public function hasApcu() - { - return $this->data['apcu_enabled']; - } - - /** - * Returns true if Zend OPcache is enabled. - * - * @return bool true if Zend OPcache is enabled, false otherwise - */ - public function hasZendOpcache() - { - return $this->data['zend_opcache_enabled']; - } - - public function getBundles() - { - return $this->data['bundles']; - } - - /** - * Gets the PHP SAPI name. - * - * @return string The environment - */ - public function getSapiName() - { - return $this->data['sapi_name']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'config'; - } - - /** - * Tries to retrieve information about the current Symfony version. - * - * @return string One of: dev, stable, eom, eol - */ - private function determineSymfonyState() - { - $now = new \DateTime(); - $eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE)->modify('last day of this month'); - $eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE)->modify('last day of this month'); - - if ($now > $eol) { - $versionState = 'eol'; - } elseif ($now > $eom) { - $versionState = 'eom'; - } elseif ('' !== Kernel::EXTRA_VERSION) { - $versionState = 'dev'; - } else { - $versionState = 'stable'; - } - - return $versionState; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollector.php deleted file mode 100644 index 30887ab91..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollector.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; -use Symfony\Component\VarDumper\Caster\CutStub; -use Symfony\Component\VarDumper\Cloner\ClonerInterface; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Cloner\Stub; -use Symfony\Component\VarDumper\Cloner\VarCloner; - -/** - * DataCollector. - * - * Children of this class must store the collected data in the data property. - * - * @author Fabien Potencier - * @author Bernhard Schussek - */ -abstract class DataCollector implements DataCollectorInterface, \Serializable -{ - protected $data = array(); - - /** - * @var ValueExporter - */ - private $valueExporter; - - /** - * @var ClonerInterface - */ - private $cloner; - - public function serialize() - { - return serialize($this->data); - } - - public function unserialize($data) - { - $this->data = unserialize($data); - } - - /** - * Converts the variable into a serializable Data instance. - * - * This array can be displayed in the template using - * the VarDumper component. - * - * @param mixed $var - * - * @return Data - */ - protected function cloneVar($var) - { - if ($var instanceof Data) { - return $var; - } - if (null === $this->cloner) { - if (class_exists(CutStub::class)) { - $this->cloner = new VarCloner(); - $this->cloner->setMaxItems(-1); - $this->cloner->addCasters($this->getCasters()); - } else { - @trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since Symfony 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED); - $this->cloner = false; - } - } - if (false === $this->cloner) { - if (null === $this->valueExporter) { - $this->valueExporter = new ValueExporter(); - } - - return $this->valueExporter->exportValue($var); - } - - return $this->cloner->cloneVar($var); - } - - /** - * Converts a PHP variable to a string. - * - * @param mixed $var A PHP variable - * - * @return string The string representation of the variable - * - * @deprecated since version 3.2, to be removed in 4.0. Use cloneVar() instead. - */ - protected function varToString($var) - { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), E_USER_DEPRECATED); - - if (null === $this->valueExporter) { - $this->valueExporter = new ValueExporter(); - } - - return $this->valueExporter->exportValue($var); - } - - /** - * @return callable[] The casters to add to the cloner - */ - protected function getCasters() - { - return array( - '*' => function ($v, array $a, Stub $s, $isNested) { - if (!$v instanceof Stub) { - foreach ($a as $k => $v) { - if (is_object($v) && !$v instanceof \DateTimeInterface && !$v instanceof Stub) { - $a[$k] = new CutStub($v); - } - } - } - - return $a; - }, - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollectorInterface.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollectorInterface.php deleted file mode 100644 index 2470089b8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/DataCollectorInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * DataCollectorInterface. - * - * @author Fabien Potencier - * - * @method reset() Resets this data collector to its initial state. - */ -interface DataCollectorInterface -{ - /** - * Collects data for the given Request and Response. - */ - public function collect(Request $request, Response $response, \Exception $exception = null); - - /** - * Returns the name of the collector. - * - * @return string The collector name - */ - public function getName(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php deleted file mode 100644 index d0ca671e0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/DumpDataCollector.php +++ /dev/null @@ -1,315 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; -use Symfony\Component\VarDumper\Dumper\HtmlDumper; -use Symfony\Component\VarDumper\Dumper\DataDumperInterface; -use Twig\Template; - -/** - * @author Nicolas Grekas - */ -class DumpDataCollector extends DataCollector implements DataDumperInterface -{ - private $stopwatch; - private $fileLinkFormat; - private $dataCount = 0; - private $isCollected = true; - private $clonesCount = 0; - private $clonesIndex = 0; - private $rootRefs; - private $charset; - private $requestStack; - private $dumper; - private $dumperIsInjected; - - public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $charset = null, RequestStack $requestStack = null, DataDumperInterface $dumper = null) - { - $this->stopwatch = $stopwatch; - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - $this->charset = $charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8'; - $this->requestStack = $requestStack; - $this->dumper = $dumper; - $this->dumperIsInjected = null !== $dumper; - - // All clones share these properties by reference: - $this->rootRefs = array( - &$this->data, - &$this->dataCount, - &$this->isCollected, - &$this->clonesCount, - ); - } - - public function __clone() - { - $this->clonesIndex = ++$this->clonesCount; - } - - public function dump(Data $data) - { - if ($this->stopwatch) { - $this->stopwatch->start('dump'); - } - if ($this->isCollected) { - $this->isCollected = false; - } - - $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 7); - - $file = $trace[0]['file']; - $line = $trace[0]['line']; - $name = false; - $fileExcerpt = false; - - for ($i = 1; $i < 7; ++$i) { - if (isset($trace[$i]['class'], $trace[$i]['function']) - && 'dump' === $trace[$i]['function'] - && 'Symfony\Component\VarDumper\VarDumper' === $trace[$i]['class'] - ) { - $file = $trace[$i]['file']; - $line = $trace[$i]['line']; - - while (++$i < 7) { - if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && 0 !== strpos($trace[$i]['function'], 'call_user_func')) { - $file = $trace[$i]['file']; - $line = $trace[$i]['line']; - - break; - } elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof Template) { - $template = $trace[$i]['object']; - $name = $template->getTemplateName(); - $src = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : false); - $info = $template->getDebugInfo(); - if (isset($info[$trace[$i - 1]['line']])) { - $line = $info[$trace[$i - 1]['line']]; - $file = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getPath() : null; - - if ($src) { - $src = explode("\n", $src); - $fileExcerpt = array(); - - for ($i = max($line - 3, 1), $max = min($line + 3, count($src)); $i <= $max; ++$i) { - $fileExcerpt[] = ''.$this->htmlEncode($src[$i - 1]).''; - } - - $fileExcerpt = '
    '.implode("\n", $fileExcerpt).'
'; - } - } - break; - } - } - break; - } - } - - if (false === $name) { - $name = str_replace('\\', '/', $file); - $name = substr($name, strrpos($name, '/') + 1); - } - - if ($this->dumper) { - $this->doDump($data, $name, $file, $line); - } - - $this->data[] = compact('data', 'name', 'file', 'line', 'fileExcerpt'); - ++$this->dataCount; - - if ($this->stopwatch) { - $this->stopwatch->stop('dump'); - } - } - - public function collect(Request $request, Response $response, \Exception $exception = null) - { - // Sub-requests and programmatic calls stay in the collected profile. - if ($this->dumper || ($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) { - return; - } - - // In all other conditions that remove the web debug toolbar, dumps are written on the output. - if (!$this->requestStack - || !$response->headers->has('X-Debug-Token') - || $response->isRedirection() - || ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html')) - || 'html' !== $request->getRequestFormat() - || false === strripos($response->getContent(), '') - ) { - if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) { - $this->dumper = new HtmlDumper('php://output', $this->charset); - $this->dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat)); - } else { - $this->dumper = new CliDumper('php://output', $this->charset); - } - - foreach ($this->data as $dump) { - $this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']); - } - } - } - - public function reset() - { - if ($this->stopwatch) { - $this->stopwatch->reset(); - } - $this->data = array(); - $this->dataCount = 0; - $this->isCollected = false; - $this->clonesCount = 0; - $this->clonesIndex = 0; - } - - public function serialize() - { - if ($this->clonesCount !== $this->clonesIndex) { - return 'a:0:{}'; - } - - $this->data[] = $this->fileLinkFormat; - $this->data[] = $this->charset; - $ser = serialize($this->data); - $this->data = array(); - $this->dataCount = 0; - $this->isCollected = true; - if (!$this->dumperIsInjected) { - $this->dumper = null; - } - - return $ser; - } - - public function unserialize($data) - { - parent::unserialize($data); - $charset = array_pop($this->data); - $fileLinkFormat = array_pop($this->data); - $this->dataCount = count($this->data); - self::__construct($this->stopwatch, $fileLinkFormat, $charset); - } - - public function getDumpsCount() - { - return $this->dataCount; - } - - public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) - { - $data = fopen('php://memory', 'r+b'); - - if ('html' === $format) { - $dumper = new HtmlDumper($data, $this->charset); - $dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat)); - } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format)); - } - $dumps = array(); - - foreach ($this->data as $dump) { - $dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth)); - $dump['data'] = stream_get_contents($data, -1, 0); - ftruncate($data, 0); - rewind($data); - $dumps[] = $dump; - } - - return $dumps; - } - - public function getName() - { - return 'dump'; - } - - public function __destruct() - { - if (0 === $this->clonesCount-- && !$this->isCollected && $this->data) { - $this->clonesCount = 0; - $this->isCollected = true; - - $h = headers_list(); - $i = count($h); - array_unshift($h, 'Content-Type: '.ini_get('default_mimetype')); - while (0 !== stripos($h[$i], 'Content-Type:')) { - --$i; - } - - if ('cli' !== PHP_SAPI && stripos($h[$i], 'html')) { - $this->dumper = new HtmlDumper('php://output', $this->charset); - $this->dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat)); - } else { - $this->dumper = new CliDumper('php://output', $this->charset); - } - - foreach ($this->data as $i => $dump) { - $this->data[$i] = null; - $this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']); - } - - $this->data = array(); - $this->dataCount = 0; - } - } - - private function doDump($data, $name, $file, $line) - { - if ($this->dumper instanceof CliDumper) { - $contextDumper = function ($name, $file, $line, $fmt) { - if ($this instanceof HtmlDumper) { - if ($file) { - $s = $this->style('meta', '%s'); - $f = strip_tags($this->style('', $file)); - $name = strip_tags($this->style('', $name)); - if ($fmt && $link = is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line)) { - $name = sprintf(''.$s.'', strip_tags($this->style('', $link)), $f, $name); - } else { - $name = sprintf(''.$s.'', $f, $name); - } - } else { - $name = $this->style('meta', $name); - } - $this->line = $name.' on line '.$this->style('meta', $line).':'; - } else { - $this->line = $this->style('meta', $name).' on line '.$this->style('meta', $line).':'; - } - $this->dumpLine(0); - }; - $contextDumper = $contextDumper->bindTo($this->dumper, $this->dumper); - $contextDumper($name, $file, $line, $this->fileLinkFormat); - } else { - $cloner = new VarCloner(); - $this->dumper->dump($cloner->cloneVar($name.' on line '.$line.':')); - } - $this->dumper->dump($data); - } - - private function htmlEncode($s) - { - $html = ''; - - $dumper = new HtmlDumper(function ($line) use (&$html) { $html .= $line; }, $this->charset); - $dumper->setDumpHeader(''); - $dumper->setDumpBoundaries('', ''); - - $cloner = new VarCloner(); - $dumper->dump($cloner->cloneVar($s)); - - return substr(strip_tags($html), 1, -1); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/EventDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/EventDataCollector.php deleted file mode 100644 index 0a095ab68..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/EventDataCollector.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; - -/** - * EventDataCollector. - * - * @author Fabien Potencier - */ -class EventDataCollector extends DataCollector implements LateDataCollectorInterface -{ - protected $dispatcher; - - public function __construct(EventDispatcherInterface $dispatcher = null) - { - if ($dispatcher instanceof TraceableEventDispatcherInterface && !method_exists($dispatcher, 'reset')) { - @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', TraceableEventDispatcherInterface::class, \get_class($dispatcher)), E_USER_DEPRECATED); - } - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $this->data = array( - 'called_listeners' => array(), - 'not_called_listeners' => array(), - ); - } - - public function reset() - { - $this->data = array(); - - if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { - if (!method_exists($this->dispatcher, 'reset')) { - return; // @deprecated - } - - $this->dispatcher->reset(); - } - } - - public function lateCollect() - { - if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { - $this->setCalledListeners($this->dispatcher->getCalledListeners()); - $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners()); - } - $this->data = $this->cloneVar($this->data); - } - - /** - * 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. - * - * @return array An array of called listeners - * - * @see TraceableEventDispatcherInterface - */ - 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. - * - * @return array An array of not called listeners - * - * @see TraceableEventDispatcherInterface - */ - public function getNotCalledListeners() - { - return $this->data['not_called_listeners']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'events'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/ExceptionDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/ExceptionDataCollector.php deleted file mode 100644 index 7a25f1492..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/ExceptionDataCollector.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * ExceptionDataCollector. - * - * @author Fabien Potencier - */ -class ExceptionDataCollector extends DataCollector -{ - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if (null !== $exception) { - $this->data = array( - 'exception' => FlattenException::create($exception), - ); - } - } - - /** - * {@inheritdoc} - */ - public function reset() - { - $this->data = array(); - } - - /** - * Checks if the exception is not null. - * - * @return bool true if the exception is not null, false otherwise - */ - public function hasException() - { - return isset($this->data['exception']); - } - - /** - * Gets the exception. - * - * @return \Exception The exception - */ - public function getException() - { - return $this->data['exception']; - } - - /** - * Gets the exception message. - * - * @return string The exception message - */ - public function getMessage() - { - return $this->data['exception']->getMessage(); - } - - /** - * Gets the exception code. - * - * @return int The exception code - */ - public function getCode() - { - return $this->data['exception']->getCode(); - } - - /** - * Gets the status code. - * - * @return int The status code - */ - public function getStatusCode() - { - return $this->data['exception']->getStatusCode(); - } - - /** - * Gets the exception trace. - * - * @return array The exception trace - */ - public function getTrace() - { - return $this->data['exception']->getTrace(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'exception'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/LateDataCollectorInterface.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/LateDataCollectorInterface.php deleted file mode 100644 index 012332de4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/LateDataCollectorInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -/** - * LateDataCollectorInterface. - * - * @author Fabien Potencier - */ -interface LateDataCollectorInterface -{ - /** - * Collects data as late as possible. - */ - public function lateCollect(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php deleted file mode 100644 index 03bfa5d84..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php +++ /dev/null @@ -1,278 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\Debug\Exception\SilencedErrorContext; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; - -/** - * LogDataCollector. - * - * @author Fabien Potencier - */ -class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface -{ - private $logger; - private $containerPathPrefix; - - public function __construct($logger = null, $containerPathPrefix = null) - { - if (null !== $logger && $logger instanceof DebugLoggerInterface) { - if (!method_exists($logger, 'clear')) { - @trigger_error(sprintf('Implementing "%s" without the "clear()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', DebugLoggerInterface::class, \get_class($logger)), E_USER_DEPRECATED); - } - - $this->logger = $logger; - } - - $this->containerPathPrefix = $containerPathPrefix; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - // everything is done as late as possible - } - - /** - * {@inheritdoc} - */ - public function reset() - { - if ($this->logger && method_exists($this->logger, 'clear')) { - $this->logger->clear(); - } - $this->data = array(); - } - - /** - * {@inheritdoc} - */ - public function lateCollect() - { - if (null !== $this->logger) { - $containerDeprecationLogs = $this->getContainerDeprecationLogs(); - $this->data = $this->computeErrorsCount($containerDeprecationLogs); - $this->data['compiler_logs'] = $this->getContainerCompilerLogs(); - $this->data['logs'] = $this->sanitizeLogs(array_merge($this->logger->getLogs(), $containerDeprecationLogs)); - $this->data = $this->cloneVar($this->data); - } - } - - /** - * Gets the logs. - * - * @return array An array of logs - */ - public function getLogs() - { - return isset($this->data['logs']) ? $this->data['logs'] : array(); - } - - public function getPriorities() - { - return isset($this->data['priorities']) ? $this->data['priorities'] : array(); - } - - public function countErrors() - { - return isset($this->data['error_count']) ? $this->data['error_count'] : 0; - } - - public function countDeprecations() - { - return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0; - } - - public function countWarnings() - { - return isset($this->data['warning_count']) ? $this->data['warning_count'] : 0; - } - - public function countScreams() - { - return isset($this->data['scream_count']) ? $this->data['scream_count'] : 0; - } - - public function getCompilerLogs() - { - return isset($this->data['compiler_logs']) ? $this->data['compiler_logs'] : array(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'logger'; - } - - private function getContainerDeprecationLogs() - { - if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Deprecations.log')) { - return array(); - } - - $bootTime = filemtime($file); - $logs = array(); - foreach (unserialize(file_get_contents($file)) as $log) { - $log['context'] = array('exception' => new SilencedErrorContext($log['type'], $log['file'], $log['line'], $log['trace'], $log['count'])); - $log['timestamp'] = $bootTime; - $log['priority'] = 100; - $log['priorityName'] = 'DEBUG'; - $log['channel'] = '-'; - $log['scream'] = false; - unset($log['type'], $log['file'], $log['line'], $log['trace'], $log['trace'], $log['count']); - $logs[] = $log; - } - - return $logs; - } - - private function getContainerCompilerLogs() - { - if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Compiler.log')) { - return array(); - } - - $logs = array(); - foreach (file($file, FILE_IGNORE_NEW_LINES) as $log) { - $log = explode(': ', $log, 2); - if (!isset($log[1]) || !preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $log[0])) { - $log = array('Unknown Compiler Pass', implode(': ', $log)); - } - - $logs[$log[0]][] = array('message' => $log[1]); - } - - return $logs; - } - - private function sanitizeLogs($logs) - { - $sanitizedLogs = array(); - $silencedLogs = array(); - - foreach ($logs as $log) { - if (!$this->isSilencedOrDeprecationErrorLog($log)) { - $sanitizedLogs[] = $log; - - continue; - } - - $message = $log['message']; - $exception = $log['context']['exception']; - - if ($exception instanceof SilencedErrorContext) { - if (isset($silencedLogs[$h = spl_object_hash($exception)])) { - continue; - } - $silencedLogs[$h] = true; - - if (!isset($sanitizedLogs[$message])) { - $sanitizedLogs[$message] = $log + array( - 'errorCount' => 0, - 'scream' => true, - ); - } - $sanitizedLogs[$message]['errorCount'] += $exception->count; - - continue; - } - - $errorId = md5("{$exception->getSeverity()}/{$exception->getLine()}/{$exception->getFile()}\0{$message}", true); - - if (isset($sanitizedLogs[$errorId])) { - ++$sanitizedLogs[$errorId]['errorCount']; - } else { - $log += array( - 'errorCount' => 1, - 'scream' => false, - ); - - $sanitizedLogs[$errorId] = $log; - } - } - - return array_values($sanitizedLogs); - } - - private function isSilencedOrDeprecationErrorLog(array $log) - { - if (!isset($log['context']['exception'])) { - return false; - } - - $exception = $log['context']['exception']; - - if ($exception instanceof SilencedErrorContext) { - return true; - } - - if ($exception instanceof \ErrorException && in_array($exception->getSeverity(), array(E_DEPRECATED, E_USER_DEPRECATED), true)) { - return true; - } - - return false; - } - - private function computeErrorsCount(array $containerDeprecationLogs) - { - $silencedLogs = array(); - $count = array( - 'error_count' => $this->logger->countErrors(), - 'deprecation_count' => 0, - 'warning_count' => 0, - 'scream_count' => 0, - 'priorities' => array(), - ); - - foreach ($this->logger->getLogs() as $log) { - if (isset($count['priorities'][$log['priority']])) { - ++$count['priorities'][$log['priority']]['count']; - } else { - $count['priorities'][$log['priority']] = array( - 'count' => 1, - 'name' => $log['priorityName'], - ); - } - if ('WARNING' === $log['priorityName']) { - ++$count['warning_count']; - } - - if ($this->isSilencedOrDeprecationErrorLog($log)) { - $exception = $log['context']['exception']; - if ($exception instanceof SilencedErrorContext) { - if (isset($silencedLogs[$h = spl_object_hash($exception)])) { - continue; - } - $silencedLogs[$h] = true; - $count['scream_count'] += $exception->count; - } else { - ++$count['deprecation_count']; - } - } - } - - foreach ($containerDeprecationLogs as $deprecationLog) { - $count['deprecation_count'] += $deprecationLog['context']['exception']->count; - } - - ksort($count['priorities']); - - return $count; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/MemoryDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/MemoryDataCollector.php deleted file mode 100644 index 8d8cc1a04..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/MemoryDataCollector.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * MemoryDataCollector. - * - * @author Fabien Potencier - */ -class MemoryDataCollector extends DataCollector implements LateDataCollectorInterface -{ - public function __construct() - { - $this->reset(); - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $this->updateMemoryUsage(); - } - - /** - * {@inheritdoc} - */ - public function reset() - { - $this->data = array( - 'memory' => 0, - 'memory_limit' => $this->convertToBytes(ini_get('memory_limit')), - ); - } - - /** - * {@inheritdoc} - */ - public function lateCollect() - { - $this->updateMemoryUsage(); - } - - /** - * Gets the memory. - * - * @return int The memory - */ - public function getMemory() - { - return $this->data['memory']; - } - - /** - * Gets the PHP memory limit. - * - * @return int The memory limit - */ - public function getMemoryLimit() - { - return $this->data['memory_limit']; - } - - /** - * Updates the memory usage data. - */ - public function updateMemoryUsage() - { - $this->data['memory'] = memory_get_peak_usage(true); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'memory'; - } - - private function convertToBytes($memoryLimit) - { - if ('-1' === $memoryLimit) { - return -1; - } - - $memoryLimit = strtolower($memoryLimit); - $max = strtolower(ltrim($memoryLimit, '+')); - if (0 === strpos($max, '0x')) { - $max = intval($max, 16); - } elseif (0 === strpos($max, '0')) { - $max = intval($max, 8); - } else { - $max = (int) $max; - } - - switch (substr($memoryLimit, -1)) { - case 't': $max *= 1024; - // no break - case 'g': $max *= 1024; - // no break - case 'm': $max *= 1024; - // no break - case 'k': $max *= 1024; - } - - return $max; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php deleted file mode 100644 index 54d17d28c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php +++ /dev/null @@ -1,404 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * @author Fabien Potencier - */ -class RequestDataCollector extends DataCollector implements EventSubscriberInterface, LateDataCollectorInterface -{ - protected $controllers; - - public function __construct() - { - $this->controllers = new \SplObjectStorage(); - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - // attributes are serialized and as they can be anything, they need to be converted to strings. - $attributes = array(); - $route = ''; - foreach ($request->attributes->all() as $key => $value) { - if ('_route' === $key) { - $route = is_object($value) ? $value->getPath() : $value; - $attributes[$key] = $route; - } else { - $attributes[$key] = $value; - } - } - - $content = null; - try { - $content = $request->getContent(); - } catch (\LogicException $e) { - // the user already got the request content as a resource - $content = false; - } - - $sessionMetadata = array(); - $sessionAttributes = array(); - $session = null; - $flashes = array(); - if ($request->hasSession()) { - $session = $request->getSession(); - if ($session->isStarted()) { - $sessionMetadata['Created'] = date(DATE_RFC822, $session->getMetadataBag()->getCreated()); - $sessionMetadata['Last used'] = date(DATE_RFC822, $session->getMetadataBag()->getLastUsed()); - $sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime(); - $sessionAttributes = $session->all(); - $flashes = $session->getFlashBag()->peekAll(); - } - } - - $statusCode = $response->getStatusCode(); - - $responseCookies = array(); - foreach ($response->headers->getCookies() as $cookie) { - $responseCookies[$cookie->getName()] = $cookie; - } - - $this->data = array( - 'method' => $request->getMethod(), - 'format' => $request->getRequestFormat(), - 'content' => $content, - 'content_type' => $response->headers->get('Content-Type', 'text/html'), - 'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '', - 'status_code' => $statusCode, - 'request_query' => $request->query->all(), - 'request_request' => $request->request->all(), - 'request_headers' => $request->headers->all(), - 'request_server' => $request->server->all(), - 'request_cookies' => $request->cookies->all(), - 'request_attributes' => $attributes, - 'route' => $route, - 'response_headers' => $response->headers->all(), - 'response_cookies' => $responseCookies, - 'session_metadata' => $sessionMetadata, - 'session_attributes' => $sessionAttributes, - 'flashes' => $flashes, - 'path_info' => $request->getPathInfo(), - 'controller' => 'n/a', - 'locale' => $request->getLocale(), - ); - - if (isset($this->data['request_headers']['php-auth-pw'])) { - $this->data['request_headers']['php-auth-pw'] = '******'; - } - - if (isset($this->data['request_server']['PHP_AUTH_PW'])) { - $this->data['request_server']['PHP_AUTH_PW'] = '******'; - } - - if (isset($this->data['request_request']['_password'])) { - $this->data['request_request']['_password'] = '******'; - } - - foreach ($this->data as $key => $value) { - if (!is_array($value)) { - continue; - } - if ('request_headers' === $key || 'response_headers' === $key) { - $this->data[$key] = array_map(function ($v) { return isset($v[0]) && !isset($v[1]) ? $v[0] : $v; }, $value); - } - } - - if (isset($this->controllers[$request])) { - $this->data['controller'] = $this->parseController($this->controllers[$request]); - unset($this->controllers[$request]); - } - - if ($request->attributes->has('_redirected') && $redirectCookie = $request->cookies->get('sf_redirect')) { - $this->data['redirect'] = json_decode($redirectCookie, true); - - $response->headers->clearCookie('sf_redirect'); - } - - if ($response->isRedirect()) { - $response->headers->setCookie(new Cookie( - 'sf_redirect', - json_encode(array( - 'token' => $response->headers->get('x-debug-token'), - 'route' => $request->attributes->get('_route', 'n/a'), - 'method' => $request->getMethod(), - 'controller' => $this->parseController($request->attributes->get('_controller')), - 'status_code' => $statusCode, - 'status_text' => Response::$statusTexts[(int) $statusCode], - )) - )); - } - - $this->data['identifier'] = $this->data['route'] ?: (is_array($this->data['controller']) ? $this->data['controller']['class'].'::'.$this->data['controller']['method'].'()' : $this->data['controller']); - } - - public function lateCollect() - { - $this->data = $this->cloneVar($this->data); - } - - public function reset() - { - $this->data = array(); - $this->controllers = new \SplObjectStorage(); - } - - public function getMethod() - { - return $this->data['method']; - } - - public function getPathInfo() - { - return $this->data['path_info']; - } - - public function getRequestRequest() - { - return new ParameterBag($this->data['request_request']->getValue()); - } - - public function getRequestQuery() - { - return new ParameterBag($this->data['request_query']->getValue()); - } - - public function getRequestHeaders() - { - return new ParameterBag($this->data['request_headers']->getValue()); - } - - public function getRequestServer($raw = false) - { - return new ParameterBag($this->data['request_server']->getValue($raw)); - } - - public function getRequestCookies($raw = false) - { - return new ParameterBag($this->data['request_cookies']->getValue($raw)); - } - - public function getRequestAttributes() - { - return new ParameterBag($this->data['request_attributes']->getValue()); - } - - public function getResponseHeaders() - { - return new ParameterBag($this->data['response_headers']->getValue()); - } - - public function getResponseCookies() - { - return new ParameterBag($this->data['response_cookies']->getValue()); - } - - public function getSessionMetadata() - { - return $this->data['session_metadata']->getValue(); - } - - public function getSessionAttributes() - { - return $this->data['session_attributes']->getValue(); - } - - public function getFlashes() - { - return $this->data['flashes']->getValue(); - } - - public function getContent() - { - return $this->data['content']; - } - - public function getContentType() - { - return $this->data['content_type']; - } - - public function getStatusText() - { - return $this->data['status_text']; - } - - public function getStatusCode() - { - return $this->data['status_code']; - } - - public function getFormat() - { - return $this->data['format']; - } - - public function getLocale() - { - return $this->data['locale']; - } - - /** - * Gets the route name. - * - * The _route request attributes is automatically set by the Router Matcher. - * - * @return string The route - */ - public function getRoute() - { - return $this->data['route']; - } - - public function getIdentifier() - { - return $this->data['identifier']; - } - - /** - * Gets the route parameters. - * - * The _route_params request attributes is automatically set by the RouterListener. - * - * @return array The parameters - */ - public function getRouteParams() - { - return isset($this->data['request_attributes']['_route_params']) ? $this->data['request_attributes']['_route_params']->getValue() : array(); - } - - /** - * Gets the parsed controller. - * - * @return array|string The controller as a string or array of data - * with keys 'class', 'method', 'file' and 'line' - */ - public function getController() - { - return $this->data['controller']; - } - - /** - * Gets the previous request attributes. - * - * @return array|bool A legacy array of data from the previous redirection response - * or false otherwise - */ - public function getRedirect() - { - return isset($this->data['redirect']) ? $this->data['redirect'] : false; - } - - public function onKernelController(FilterControllerEvent $event) - { - $this->controllers[$event->getRequest()] = $event->getController(); - } - - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - if ($event->getRequest()->cookies->has('sf_redirect')) { - $event->getRequest()->attributes->set('_redirected', true); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::CONTROLLER => 'onKernelController', - KernelEvents::RESPONSE => 'onKernelResponse', - ); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'request'; - } - - /** - * Parse a controller. - * - * @param mixed $controller The controller to parse - * - * @return array|string An array of controller data or a simple string - */ - protected function parseController($controller) - { - if (is_string($controller) && false !== strpos($controller, '::')) { - $controller = explode('::', $controller); - } - - if (is_array($controller)) { - try { - $r = new \ReflectionMethod($controller[0], $controller[1]); - - return array( - 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], - 'method' => $controller[1], - 'file' => $r->getFileName(), - 'line' => $r->getStartLine(), - ); - } catch (\ReflectionException $e) { - if (is_callable($controller)) { - // using __call or __callStatic - return array( - 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], - 'method' => $controller[1], - 'file' => 'n/a', - 'line' => 'n/a', - ); - } - } - } - - if ($controller instanceof \Closure) { - $r = new \ReflectionFunction($controller); - - return array( - 'class' => $r->getName(), - 'method' => null, - 'file' => $r->getFileName(), - 'line' => $r->getStartLine(), - ); - } - - if (is_object($controller)) { - $r = new \ReflectionClass($controller); - - return array( - 'class' => $r->getName(), - 'method' => null, - 'file' => $r->getFileName(), - 'line' => $r->getStartLine(), - ); - } - - return is_string($controller) ? $controller : 'n/a'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/RouterDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/RouterDataCollector.php deleted file mode 100644 index afd34f8af..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/RouterDataCollector.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; - -/** - * RouterDataCollector. - * - * @author Fabien Potencier - */ -class RouterDataCollector extends DataCollector -{ - /** - * @var \SplObjectStorage - */ - protected $controllers; - - public function __construct() - { - $this->reset(); - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if ($response instanceof RedirectResponse) { - $this->data['redirect'] = true; - $this->data['url'] = $response->getTargetUrl(); - - if ($this->controllers->contains($request)) { - $this->data['route'] = $this->guessRoute($request, $this->controllers[$request]); - } - } - - unset($this->controllers[$request]); - } - - public function reset() - { - $this->controllers = new \SplObjectStorage(); - - $this->data = array( - 'redirect' => false, - 'url' => null, - 'route' => null, - ); - } - - protected function guessRoute(Request $request, $controller) - { - return 'n/a'; - } - - /** - * Remembers the controller associated to each request. - */ - public function onKernelController(FilterControllerEvent $event) - { - $this->controllers[$event->getRequest()] = $event->getController(); - } - - /** - * @return bool Whether this request will result in a redirect - */ - public function getRedirect() - { - return $this->data['redirect']; - } - - /** - * @return string|null The target URL - */ - public function getTargetUrl() - { - return $this->data['url']; - } - - /** - * @return string|null The target route - */ - public function getTargetRoute() - { - return $this->data['route']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'router'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/TimeDataCollector.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/TimeDataCollector.php deleted file mode 100644 index e489d7759..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/TimeDataCollector.php +++ /dev/null @@ -1,149 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\Stopwatch\Stopwatch; - -/** - * TimeDataCollector. - * - * @author Fabien Potencier - */ -class TimeDataCollector extends DataCollector implements LateDataCollectorInterface -{ - protected $kernel; - protected $stopwatch; - - public function __construct(KernelInterface $kernel = null, Stopwatch $stopwatch = null) - { - $this->kernel = $kernel; - $this->stopwatch = $stopwatch; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if (null !== $this->kernel) { - $startTime = $this->kernel->getStartTime(); - } else { - $startTime = $request->server->get('REQUEST_TIME_FLOAT'); - } - - $this->data = array( - 'token' => $response->headers->get('X-Debug-Token'), - 'start_time' => $startTime * 1000, - 'events' => array(), - ); - } - - /** - * {@inheritdoc} - */ - public function reset() - { - $this->data = array(); - - if (null !== $this->stopwatch) { - $this->stopwatch->reset(); - } - } - - /** - * {@inheritdoc} - */ - public function lateCollect() - { - if (null !== $this->stopwatch && isset($this->data['token'])) { - $this->setEvents($this->stopwatch->getSectionEvents($this->data['token'])); - } - unset($this->data['token']); - } - - /** - * Sets the request events. - * - * @param array $events The request events - */ - public function setEvents(array $events) - { - foreach ($events as $event) { - $event->ensureStopped(); - } - - $this->data['events'] = $events; - } - - /** - * Gets the request events. - * - * @return array The request events - */ - public function getEvents() - { - return $this->data['events']; - } - - /** - * Gets the request elapsed time. - * - * @return float The elapsed time - */ - public function getDuration() - { - if (!isset($this->data['events']['__section__'])) { - return 0; - } - - $lastEvent = $this->data['events']['__section__']; - - return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime(); - } - - /** - * Gets the initialization time. - * - * This is the time spent until the beginning of the request handling. - * - * @return float The elapsed time - */ - public function getInitTime() - { - if (!isset($this->data['events']['__section__'])) { - return 0; - } - - return $this->data['events']['__section__']->getOrigin() - $this->getStartTime(); - } - - /** - * Gets the request time. - * - * @return int The time - */ - public function getStartTime() - { - return $this->data['start_time']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'time'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DataCollector/Util/ValueExporter.php b/lib/silex/vendor/symfony/http-kernel/DataCollector/Util/ValueExporter.php deleted file mode 100644 index a71c00db9..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DataCollector/Util/ValueExporter.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector\Util; - -@trigger_error('The '.__NAMESPACE__.'\ValueExporter class is deprecated since Symfony 3.2 and will be removed in 4.0. Use the VarDumper component instead.', E_USER_DEPRECATED); - -/** - * @author Bernhard Schussek - * - * @deprecated since version 3.2, to be removed in 4.0. Use the VarDumper component instead. - */ -class ValueExporter -{ - /** - * Converts a PHP value to a string. - * - * @param mixed $value The PHP value - * @param int $depth Only for internal usage - * @param bool $deep Only for internal usage - * - * @return string The string representation of the given value - */ - public function exportValue($value, $depth = 1, $deep = false) - { - if ($value instanceof \__PHP_Incomplete_Class) { - return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value)); - } - - if (is_object($value)) { - if ($value instanceof \DateTimeInterface) { - return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ATOM)); - } - - return sprintf('Object(%s)', get_class($value)); - } - - if (is_array($value)) { - if (empty($value)) { - return '[]'; - } - - $indent = str_repeat(' ', $depth); - - $a = array(); - foreach ($value as $k => $v) { - if (is_array($v)) { - $deep = true; - } - $a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep)); - } - - if ($deep) { - return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1)); - } - - $s = sprintf('[%s]', implode(', ', $a)); - - if (80 > strlen($s)) { - return $s; - } - - return sprintf("[\n%s%s\n]", $indent, implode(sprintf(",\n%s", $indent), $a)); - } - - if (is_resource($value)) { - return sprintf('Resource(%s#%d)', get_resource_type($value), $value); - } - - if (null === $value) { - return 'null'; - } - - if (false === $value) { - return 'false'; - } - - if (true === $value) { - return 'true'; - } - - return (string) $value; - } - - private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) - { - $array = new \ArrayObject($value); - - return $array['__PHP_Incomplete_Class_Name']; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Debug/FileLinkFormatter.php b/lib/silex/vendor/symfony/http-kernel/Debug/FileLinkFormatter.php deleted file mode 100644 index c340d9b67..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Debug/FileLinkFormatter.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * 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\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Formats debug file links. - * - * @author Jérémy Romey - */ -class FileLinkFormatter implements \Serializable -{ - private $fileLinkFormat; - private $requestStack; - private $baseDir; - private $urlFormat; - - public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) - { - $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - if ($fileLinkFormat && !is_array($fileLinkFormat)) { - $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f); - $fileLinkFormat = array(substr($f, 0, $i)) + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE); - } - - $this->fileLinkFormat = $fileLinkFormat; - $this->requestStack = $requestStack; - $this->baseDir = $baseDir; - $this->urlFormat = $urlFormat; - } - - public function format($file, $line) - { - if ($fmt = $this->getFileLinkFormat()) { - for ($i = 1; isset($fmt[$i]); ++$i) { - if (0 === strpos($file, $k = $fmt[$i++])) { - $file = substr_replace($file, $fmt[$i], 0, strlen($k)); - break; - } - } - - return strtr($fmt[0], array('%f' => $file, '%l' => $line)); - } - - return false; - } - - public function serialize() - { - return serialize($this->getFileLinkFormat()); - } - - public function unserialize($serialized) - { - if (\PHP_VERSION_ID >= 70000) { - $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); - } else { - $this->fileLinkFormat = unserialize($serialized); - } - } - - private function getFileLinkFormat() - { - if ($this->fileLinkFormat) { - return $this->fileLinkFormat; - } - if ($this->requestStack && $this->baseDir && $this->urlFormat) { - $request = $this->requestStack->getMasterRequest(); - if ($request instanceof Request) { - return array( - $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, - $this->baseDir.DIRECTORY_SEPARATOR, '', - ); - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Debug/TraceableEventDispatcher.php b/lib/silex/vendor/symfony/http-kernel/Debug/TraceableEventDispatcher.php deleted file mode 100644 index fbc49dffc..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Debug/TraceableEventDispatcher.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * 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\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\Event; - -/** - * Collects some data about event listeners. - * - * This event dispatcher delegates the dispatching to another one. - * - * @author Fabien Potencier - */ -class TraceableEventDispatcher extends BaseTraceableEventDispatcher -{ - /** - * {@inheritdoc} - */ - protected function preDispatch($eventName, Event $event) - { - switch ($eventName) { - case KernelEvents::REQUEST: - $this->stopwatch->openSection(); - break; - case KernelEvents::VIEW: - case KernelEvents::RESPONSE: - // stop only if a controller has been executed - if ($this->stopwatch->isStarted('controller')) { - $this->stopwatch->stop('controller'); - } - break; - case KernelEvents::TERMINATE: - $token = $event->getResponse()->headers->get('X-Debug-Token'); - // There is a very special case when using built-in AppCache class as kernel wrapper, in the case - // of an ESI request leading to a `stale` response [B] inside a `fresh` cached response [A]. - // In this case, `$token` contains the [B] debug token, but the open `stopwatch` section ID - // is equal to the [A] debug token. Trying to reopen section with the [B] token throws an exception - // which must be caught. - try { - $this->stopwatch->openSection($token); - } catch (\LogicException $e) { - } - break; - } - } - - /** - * {@inheritdoc} - */ - protected function postDispatch($eventName, Event $event) - { - switch ($eventName) { - case KernelEvents::CONTROLLER_ARGUMENTS: - $this->stopwatch->start('controller', 'section'); - break; - case KernelEvents::RESPONSE: - $token = $event->getResponse()->headers->get('X-Debug-Token'); - $this->stopwatch->stopSection($token); - break; - case KernelEvents::TERMINATE: - // In the special case described in the `preDispatch` method above, the `$token` section - // does not exist, then closing it throws an exception which must be caught. - $token = $event->getResponse()->headers->get('X-Debug-Token'); - try { - $this->stopwatch->stopSection($token); - } catch (\LogicException $e) { - } - break; - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php deleted file mode 100644 index b1ecebdc9..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Composer\Autoload\ClassLoader; -use Symfony\Component\Debug\DebugClassLoader; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\HttpKernel\Kernel; - -/** - * Sets the classes to compile in the cache for the container. - * - * @author Fabien Potencier - */ -class AddAnnotatedClassesToCachePass implements CompilerPassInterface -{ - private $kernel; - - public function __construct(Kernel $kernel) - { - $this->kernel = $kernel; - } - - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) - { - $classes = array(); - $annotatedClasses = array(); - foreach ($container->getExtensions() as $extension) { - if ($extension instanceof Extension) { - if (\PHP_VERSION_ID < 70000) { - $classes = array_merge($classes, $extension->getClassesToCompile()); - } - $annotatedClasses = array_merge($annotatedClasses, $extension->getAnnotatedClassesToCompile()); - } - } - - $existingClasses = $this->getClassesInComposerClassMaps(); - - if (\PHP_VERSION_ID < 70000) { - $classes = $container->getParameterBag()->resolveValue($classes); - $this->kernel->setClassCache($this->expandClasses($classes, $existingClasses)); - } - $annotatedClasses = $container->getParameterBag()->resolveValue($annotatedClasses); - $this->kernel->setAnnotatedClassCache($this->expandClasses($annotatedClasses, $existingClasses)); - } - - /** - * Expands the given class patterns using a list of existing classes. - * - * @param array $patterns The class patterns to expand - * @param array $classes The existing classes to match against the patterns - * - * @return array A list of classes derivated from the patterns - */ - private function expandClasses(array $patterns, array $classes) - { - $expanded = array(); - - // Explicit classes declared in the patterns are returned directly - foreach ($patterns as $key => $pattern) { - if ('\\' !== substr($pattern, -1) && false === strpos($pattern, '*')) { - unset($patterns[$key]); - $expanded[] = ltrim($pattern, '\\'); - } - } - - // Match patterns with the classes list - $regexps = $this->patternsToRegexps($patterns); - - foreach ($classes as $class) { - $class = ltrim($class, '\\'); - - if ($this->matchAnyRegexps($class, $regexps)) { - $expanded[] = $class; - } - } - - return array_unique($expanded); - } - - private function getClassesInComposerClassMaps() - { - $classes = array(); - - foreach (spl_autoload_functions() as $function) { - if (!is_array($function)) { - continue; - } - - if ($function[0] instanceof DebugClassLoader) { - $function = $function[0]->getClassLoader(); - } - - if (is_array($function) && $function[0] instanceof ClassLoader) { - $classes += array_filter($function[0]->getClassMap()); - } - } - - return array_keys($classes); - } - - private function patternsToRegexps($patterns) - { - $regexps = array(); - - foreach ($patterns as $pattern) { - // Escape user input - $regex = preg_quote(ltrim($pattern, '\\')); - - // Wildcards * and ** - $regex = strtr($regex, array('\\*\\*' => '.*?', '\\*' => '[^\\\\]*?')); - - // If this class does not end by a slash, anchor the end - if ('\\' !== substr($regex, -1)) { - $regex .= '$'; - } - - $regexps[] = '{^\\\\'.$regex.'}'; - } - - return $regexps; - } - - private function matchAnyRegexps($class, $regexps) - { - $blacklisted = false !== strpos($class, 'Test'); - - foreach ($regexps as $regex) { - if ($blacklisted && false === strpos($regex, 'Test')) { - continue; - } - - if (preg_match($regex, '\\'.$class)) { - return true; - } - } - - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddClassesToCachePass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddClassesToCachePass.php deleted file mode 100644 index 8ae78e0d8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/AddClassesToCachePass.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -@trigger_error('The '.__NAMESPACE__.'\AddClassesToCachePass class is deprecated since Symfony 3.3 and will be removed in 4.0.', E_USER_DEPRECATED); - -/** - * Sets the classes to compile in the cache for the container. - * - * @author Fabien Potencier - * - * @deprecated since version 3.3, to be removed in 4.0. - */ -class AddClassesToCachePass extends AddAnnotatedClassesToCachePass -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ConfigurableExtension.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ConfigurableExtension.php deleted file mode 100644 index 072c35f1c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ConfigurableExtension.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * This extension sub-class provides first-class integration with the - * Config/Definition Component. - * - * You can use this as base class if - * - * a) you use the Config/Definition component for configuration, - * b) your configuration class is named "Configuration", and - * c) the configuration class resides in the DependencyInjection sub-folder. - * - * @author Johannes M. Schmitt - */ -abstract class ConfigurableExtension extends Extension -{ - /** - * {@inheritdoc} - */ - final public function load(array $configs, ContainerBuilder $container) - { - $this->loadInternal($this->processConfiguration($this->getConfiguration($configs, $container), $configs), $container); - } - - /** - * Configures the passed container according to the merged configuration. - */ - abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container); -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ControllerArgumentValueResolverPass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ControllerArgumentValueResolverPass.php deleted file mode 100644 index 343e217b9..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ControllerArgumentValueResolverPass.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Argument\IteratorArgument; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Gathers and configures the argument value resolvers. - * - * @author Iltar van der Berg - */ -class ControllerArgumentValueResolverPass implements CompilerPassInterface -{ - use PriorityTaggedServiceTrait; - - private $argumentResolverService; - private $argumentValueResolverTag; - - public function __construct($argumentResolverService = 'argument_resolver', $argumentValueResolverTag = 'controller.argument_value_resolver') - { - $this->argumentResolverService = $argumentResolverService; - $this->argumentValueResolverTag = $argumentValueResolverTag; - } - - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition($this->argumentResolverService)) { - return; - } - - $container - ->getDefinition($this->argumentResolverService) - ->replaceArgument(1, new IteratorArgument($this->findAndSortTaggedServices($this->argumentValueResolverTag, $container))) - ; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/Extension.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/Extension.php deleted file mode 100644 index a382c15d6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/Extension.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Extension\Extension as BaseExtension; - -/** - * Allow adding classes to the class cache. - * - * @author Fabien Potencier - */ -abstract class Extension extends BaseExtension -{ - private $classes = array(); - private $annotatedClasses = array(); - - /** - * Gets the classes to cache. - * - * @return array An array of classes - * - * @deprecated since version 3.3, to be removed in 4.0. - */ - public function getClassesToCompile() - { - if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); - } - - return $this->classes; - } - - /** - * Gets the annotated classes to cache. - * - * @return array An array of classes - */ - public function getAnnotatedClassesToCompile() - { - return $this->annotatedClasses; - } - - /** - * Adds classes to the class cache. - * - * @param array $classes An array of class patterns - * - * @deprecated since version 3.3, to be removed in 4.0. - */ - public function addClassesToCompile(array $classes) - { - if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); - } - - $this->classes = array_merge($this->classes, $classes); - } - - /** - * Adds annotated classes to the class cache. - * - * @param array $annotatedClasses An array of class patterns - */ - public function addAnnotatedClassesToCompile(array $annotatedClasses) - { - $this->annotatedClasses = array_merge($this->annotatedClasses, $annotatedClasses); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/FragmentRendererPass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/FragmentRendererPass.php deleted file mode 100644 index ac52c8732..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/FragmentRendererPass.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface; - -/** - * Adds services tagged kernel.fragment_renderer as HTTP content rendering strategies. - * - * @author Fabien Potencier - */ -class FragmentRendererPass implements CompilerPassInterface -{ - private $handlerService; - private $rendererTag; - - /** - * @param string $handlerService Service name of the fragment handler in the container - * @param string $rendererTag Tag name used for fragments - */ - public function __construct($handlerService = 'fragment.handler', $rendererTag = 'kernel.fragment_renderer') - { - $this->handlerService = $handlerService; - $this->rendererTag = $rendererTag; - } - - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition($this->handlerService)) { - return; - } - - $definition = $container->getDefinition($this->handlerService); - $renderers = array(); - foreach ($container->findTaggedServiceIds($this->rendererTag, true) as $id => $tags) { - $def = $container->getDefinition($id); - $class = $container->getParameterBag()->resolveValue($def->getClass()); - - if (!$r = $container->getReflectionClass($class)) { - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); - } - if (!$r->isSubclassOf(FragmentRendererInterface::class)) { - throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, FragmentRendererInterface::class)); - } - - foreach ($tags as $tag) { - $renderers[$tag['alias']] = new Reference($id); - } - } - - $definition->replaceArgument(0, ServiceLocatorTagPass::register($container, $renderers)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php deleted file mode 100644 index 00b05959c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/LazyLoadingFragmentHandler.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Psr\Container\ContainerInterface; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Fragment\FragmentHandler; - -/** - * Lazily loads fragment renderers from the dependency injection container. - * - * @author Fabien Potencier - */ -class LazyLoadingFragmentHandler extends FragmentHandler -{ - private $container; - /** - * @deprecated since version 3.3, to be removed in 4.0 - */ - private $rendererIds = array(); - private $initialized = array(); - - /** - * @param ContainerInterface $container A container - * @param RequestStack $requestStack The Request stack that controls the lifecycle of requests - * @param bool $debug Whether the debug mode is enabled or not - */ - public function __construct(ContainerInterface $container, RequestStack $requestStack, $debug = false) - { - $this->container = $container; - - parent::__construct($requestStack, array(), $debug); - } - - /** - * Adds a service as a fragment renderer. - * - * @param string $name The service name - * @param string $renderer The render service id - * - * @deprecated since version 3.3, to be removed in 4.0 - */ - public function addRendererService($name, $renderer) - { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); - - $this->rendererIds[$name] = $renderer; - } - - /** - * {@inheritdoc} - */ - public function render($uri, $renderer = 'inline', array $options = array()) - { - // BC 3.x, to be removed in 4.0 - if (isset($this->rendererIds[$renderer])) { - $this->addRenderer($this->container->get($this->rendererIds[$renderer])); - unset($this->rendererIds[$renderer]); - - return parent::render($uri, $renderer, $options); - } - - if (!isset($this->initialized[$renderer]) && $this->container->has($renderer)) { - $this->addRenderer($this->container->get($renderer)); - $this->initialized[$renderer] = true; - } - - return parent::render($uri, $renderer, $options); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/LoggerPass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/LoggerPass.php deleted file mode 100644 index 2ad7f3222..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/LoggerPass.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Log\Logger; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Registers the default logger if necessary. - * - * @author Kévin Dunglas - */ -class LoggerPass implements CompilerPassInterface -{ - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) - { - $container->setAlias(LoggerInterface::class, 'logger') - ->setPublic(false); - - if ($container->has('logger')) { - return; - } - - $container->register('logger', Logger::class) - ->setPublic(false); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php deleted file mode 100644 index dcd73828d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass as BaseMergeExtensionConfigurationPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Ensures certain extensions are always loaded. - * - * @author Kris Wallsmith - */ -class MergeExtensionConfigurationPass extends BaseMergeExtensionConfigurationPass -{ - private $extensions; - - public function __construct(array $extensions) - { - $this->extensions = $extensions; - } - - public function process(ContainerBuilder $container) - { - foreach ($this->extensions as $extension) { - if (!count($container->getExtensionConfig($extension))) { - $container->loadFromExtension($extension, array()); - } - } - - parent::process($container); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php deleted file mode 100644 index 985dfb71d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ /dev/null @@ -1,174 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\DependencyInjection\ChildDefinition; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\TypedReference; - -/** - * Creates the service-locators required by ServiceValueResolver. - * - * @author Nicolas Grekas - */ -class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface -{ - private $resolverServiceId; - private $controllerTag; - - public function __construct($resolverServiceId = 'argument_resolver.service', $controllerTag = 'controller.service_arguments') - { - $this->resolverServiceId = $resolverServiceId; - $this->controllerTag = $controllerTag; - } - - public function process(ContainerBuilder $container) - { - if (false === $container->hasDefinition($this->resolverServiceId)) { - return; - } - - $parameterBag = $container->getParameterBag(); - $controllers = array(); - - foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) { - $def = $container->getDefinition($id); - $def->setPublic(true); - $class = $def->getClass(); - $autowire = $def->isAutowired(); - $bindings = $def->getBindings(); - - // resolve service class, taking parent definitions into account - while ($def instanceof ChildDefinition) { - $def = $container->findDefinition($def->getParent()); - $class = $class ?: $def->getClass(); - $bindings = $def->getBindings(); - } - $class = $parameterBag->resolveValue($class); - - if (!$r = $container->getReflectionClass($class)) { - throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); - } - $isContainerAware = $r->implementsInterface(ContainerAwareInterface::class) || is_subclass_of($class, AbstractController::class); - - // get regular public methods - $methods = array(); - $arguments = array(); - foreach ($r->getMethods(\ReflectionMethod::IS_PUBLIC) as $r) { - if ('setContainer' === $r->name && $isContainerAware) { - continue; - } - if (!$r->isConstructor() && !$r->isDestructor() && !$r->isAbstract()) { - $methods[strtolower($r->name)] = array($r, $r->getParameters()); - } - } - - // validate and collect explicit per-actions and per-arguments service references - foreach ($tags as $attributes) { - if (!isset($attributes['action']) && !isset($attributes['argument']) && !isset($attributes['id'])) { - $autowire = true; - continue; - } - foreach (array('action', 'argument', 'id') as $k) { - if (!isset($attributes[$k][0])) { - throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, JSON_UNESCAPED_UNICODE), $id)); - } - } - if (!isset($methods[$action = strtolower($attributes['action'])])) { - throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "%s" for service "%s": no public "%s()" method found on class "%s".', $this->controllerTag, $id, $attributes['action'], $class)); - } - list($r, $parameters) = $methods[$action]; - $found = false; - - foreach ($parameters as $p) { - if ($attributes['argument'] === $p->name) { - if (!isset($arguments[$r->name][$p->name])) { - $arguments[$r->name][$p->name] = $attributes['id']; - } - $found = true; - break; - } - } - - if (!$found) { - throw new InvalidArgumentException(sprintf('Invalid "%s" tag for service "%s": method "%s()" has no "%s" argument on class "%s".', $this->controllerTag, $id, $r->name, $attributes['argument'], $class)); - } - } - - foreach ($methods as list($r, $parameters)) { - /** @var \ReflectionMethod $r */ - - // create a per-method map of argument-names to service/type-references - $args = array(); - foreach ($parameters as $p) { - /** @var \ReflectionParameter $p */ - $type = $target = ProxyHelper::getTypeHint($r, $p, true); - $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; - - if (isset($arguments[$r->name][$p->name])) { - $target = $arguments[$r->name][$p->name]; - if ('?' !== $target[0]) { - $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; - } elseif ('' === $target = (string) substr($target, 1)) { - throw new InvalidArgumentException(sprintf('A "%s" tag must have non-empty "id" attributes for service "%s".', $this->controllerTag, $id)); - } elseif ($p->allowsNull() && !$p->isOptional()) { - $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; - } - } elseif (isset($bindings[$bindingName = '$'.$p->name]) || isset($bindings[$bindingName = $type])) { - $binding = $bindings[$bindingName]; - - list($bindingValue, $bindingId) = $binding->getValues(); - - if (!$bindingValue instanceof Reference) { - continue; - } - - $binding->setValues(array($bindingValue, $bindingId, true)); - $args[$p->name] = $bindingValue; - - continue; - } elseif (!$type || !$autowire) { - continue; - } - - if ($type && !$p->isOptional() && !$p->allowsNull() && !class_exists($type) && !interface_exists($type, false)) { - $message = sprintf('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s".', $class, $r->name, $p->name, $type); - - // see if the type-hint lives in the same namespace as the controller - if (0 === strncmp($type, $class, strrpos($class, '\\'))) { - $message .= ' Did you forget to add a use statement?'; - } - - throw new InvalidArgumentException($message); - } - - $args[$p->name] = $type ? new TypedReference($target, $type, $r->class, $invalidBehavior) : new Reference($target, $invalidBehavior); - } - // register the maps as a per-method service-locators - if ($args) { - $controllers[$id.':'.$r->name] = ServiceLocatorTagPass::register($container, $args); - } - } - } - - $container->getDefinition($this->resolverServiceId) - ->replaceArgument(0, ServiceLocatorTagPass::register($container, $controllers)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php deleted file mode 100644 index ab50cec35..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Removes empty service-locators registered for ServiceValueResolver. - * - * @author Nicolas Grekas - */ -class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface -{ - private $resolverServiceId; - - public function __construct($resolverServiceId = 'argument_resolver.service') - { - $this->resolverServiceId = $resolverServiceId; - } - - public function process(ContainerBuilder $container) - { - if (false === $container->hasDefinition($this->resolverServiceId)) { - return; - } - - $serviceResolver = $container->getDefinition($this->resolverServiceId); - $controllerLocator = $container->getDefinition((string) $serviceResolver->getArgument(0)); - $controllers = $controllerLocator->getArgument(0); - - foreach ($controllers as $controller => $argumentRef) { - $argumentLocator = $container->getDefinition((string) $argumentRef->getValues()[0]); - - if (!$argumentLocator->getArgument(0)) { - // remove empty argument locators - $reason = sprintf('Removing service-argument resolver for controller "%s": no corresponding services exist for the referenced types.', $controller); - } else { - // any methods listed for call-at-instantiation cannot be actions - $reason = false; - $action = substr(strrchr($controller, ':'), 1); - $id = substr($controller, 0, -1 - strlen($action)); - $controllerDef = $container->getDefinition($id); - foreach ($controllerDef->getMethodCalls() as list($method)) { - if (0 === strcasecmp($action, $method)) { - $reason = sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id); - break; - } - } - if (!$reason) { - if ($controllerDef->getClass() === $id) { - $controllers[$id.'::'.$action] = $argumentRef; - } - if ('__invoke' === $action) { - $controllers[$id] = $argumentRef; - } - continue; - } - } - - unset($controllers[$controller]); - $container->log($this, $reason); - } - - $controllerLocator->replaceArgument(0, $controllers); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ResettableServicePass.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ResettableServicePass.php deleted file mode 100644 index 29433a6d5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ResettableServicePass.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Argument\IteratorArgument; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Reference; - -/** - * @author Alexander M. Turek - */ -class ResettableServicePass implements CompilerPassInterface -{ - private $tagName; - - public function __construct($tagName = 'kernel.reset') - { - $this->tagName = $tagName; - } - - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) - { - if (!$container->has('services_resetter')) { - return; - } - - $services = $methods = array(); - - foreach ($container->findTaggedServiceIds($this->tagName, true) as $id => $tags) { - $services[$id] = new Reference($id, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE); - $attributes = $tags[0]; - - if (!isset($attributes['method'])) { - throw new RuntimeException(sprintf('Tag %s requires the "method" attribute to be set.', $this->tagName)); - } - - $methods[$id] = $attributes['method']; - } - - if (empty($services)) { - $container->removeAlias('services_resetter'); - $container->removeDefinition('services_resetter'); - - return; - } - - $container->findDefinition('services_resetter') - ->setArgument(0, new IteratorArgument($services)) - ->setArgument(1, $methods); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ServicesResetter.php b/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ServicesResetter.php deleted file mode 100644 index b82d2fef3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/DependencyInjection/ServicesResetter.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -/** - * Resets provided services. - * - * @author Alexander M. Turek - * @author Nicolas Grekas - * - * @internal - */ -class ServicesResetter -{ - private $resettableServices; - private $resetMethods; - - public function __construct(\Traversable $resettableServices, array $resetMethods) - { - $this->resettableServices = $resettableServices; - $this->resetMethods = $resetMethods; - } - - public function reset() - { - foreach ($this->resettableServices as $id => $service) { - $service->{$this->resetMethods[$id]}(); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/FilterControllerArgumentsEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/FilterControllerArgumentsEvent.php deleted file mode 100644 index 2b08f2d77..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/FilterControllerArgumentsEvent.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows filtering of controller arguments. - * - * You can call getController() to retrieve the controller and getArguments - * to retrieve the current arguments. With setArguments() you can replace - * arguments that are used to call the controller. - * - * Arguments set in the event must be compatible with the signature of the - * controller. - * - * @author Christophe Coevoet - */ -class FilterControllerArgumentsEvent extends FilterControllerEvent -{ - private $arguments; - - public function __construct(HttpKernelInterface $kernel, callable $controller, array $arguments, Request $request, $requestType) - { - parent::__construct($kernel, $controller, $request, $requestType); - - $this->arguments = $arguments; - } - - /** - * @return array - */ - public function getArguments() - { - return $this->arguments; - } - - public function setArguments(array $arguments) - { - $this->arguments = $arguments; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/FilterControllerEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/FilterControllerEvent.php deleted file mode 100644 index 84cbc2eaf..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/FilterControllerEvent.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows filtering of a controller callable. - * - * You can call getController() to retrieve the current controller. With - * setController() you can set a new controller that is used in the processing - * of the request. - * - * Controllers should be callables. - * - * @author Bernhard Schussek - */ -class FilterControllerEvent extends KernelEvent -{ - private $controller; - - public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, $requestType) - { - parent::__construct($kernel, $request, $requestType); - - $this->setController($controller); - } - - /** - * Returns the current controller. - * - * @return callable - */ - public function getController() - { - return $this->controller; - } - - public function setController(callable $controller) - { - $this->controller = $controller; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/FilterResponseEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/FilterResponseEvent.php deleted file mode 100644 index 53a7efce7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/FilterResponseEvent.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to filter a Response object. - * - * You can call getResponse() to retrieve the current response. With - * setResponse() you can set a new response that will be returned to the - * browser. - * - * @author Bernhard Schussek - */ -class FilterResponseEvent extends KernelEvent -{ - private $response; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, Response $response) - { - parent::__construct($kernel, $request, $requestType); - - $this->setResponse($response); - } - - /** - * Returns the current response object. - * - * @return Response - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a new response object. - */ - public function setResponse(Response $response) - { - $this->response = $response; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/FinishRequestEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/FinishRequestEvent.php deleted file mode 100644 index ee724843c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/FinishRequestEvent.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -/** - * Triggered whenever a request is fully processed. - * - * @author Benjamin Eberlei - */ -class FinishRequestEvent extends KernelEvent -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/GetResponseEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/GetResponseEvent.php deleted file mode 100644 index f7745ea3d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/GetResponseEvent.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to create a response for a request. - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * @author Bernhard Schussek - */ -class GetResponseEvent extends KernelEvent -{ - private $response; - - /** - * Returns the response object. - * - * @return Response - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a response and stops event propagation. - */ - public function setResponse(Response $response) - { - $this->response = $response; - - $this->stopPropagation(); - } - - /** - * Returns whether a response was set. - * - * @return bool Whether a response was set - */ - public function hasResponse() - { - return null !== $this->response; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/GetResponseForControllerResultEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/GetResponseForControllerResultEvent.php deleted file mode 100644 index f70ce09e0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/GetResponseForControllerResultEvent.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows to create a response for the return value of a controller. - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * @author Bernhard Schussek - */ -class GetResponseForControllerResultEvent extends GetResponseEvent -{ - /** - * The return value of the controller. - * - * @var mixed - */ - private $controllerResult; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, $controllerResult) - { - parent::__construct($kernel, $request, $requestType); - - $this->controllerResult = $controllerResult; - } - - /** - * Returns the return value of the controller. - * - * @return mixed The controller return value - */ - public function getControllerResult() - { - return $this->controllerResult; - } - - /** - * Assigns the return value of the controller. - * - * @param mixed $controllerResult The controller return value - */ - public function setControllerResult($controllerResult) - { - $this->controllerResult = $controllerResult; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/GetResponseForExceptionEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/GetResponseForExceptionEvent.php deleted file mode 100644 index 751b74515..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/GetResponseForExceptionEvent.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows to create a response for a thrown exception. - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * You can also call setException() to replace the thrown exception. This - * exception will be thrown if no response is set during processing of this - * event. - * - * @author Bernhard Schussek - */ -class GetResponseForExceptionEvent extends GetResponseEvent -{ - /** - * The exception object. - * - * @var \Exception - */ - private $exception; - - /** - * @var bool - */ - private $allowCustomResponseCode = false; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, \Exception $e) - { - parent::__construct($kernel, $request, $requestType); - - $this->setException($e); - } - - /** - * Returns the thrown exception. - * - * @return \Exception The thrown exception - */ - public function getException() - { - return $this->exception; - } - - /** - * Replaces the thrown exception. - * - * This exception will be thrown if no response is set in the event. - * - * @param \Exception $exception The thrown exception - */ - public function setException(\Exception $exception) - { - $this->exception = $exception; - } - - /** - * Mark the event as allowing a custom response code. - */ - public function allowCustomResponseCode() - { - $this->allowCustomResponseCode = true; - } - - /** - * Returns true if the event allows a custom response code. - * - * @return bool - */ - public function isAllowingCustomResponseCode() - { - return $this->allowCustomResponseCode; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/KernelEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/KernelEvent.php deleted file mode 100644 index 992f6b4dc..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/KernelEvent.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\Event; - -/** - * Base class for events thrown in the HttpKernel component. - * - * @author Bernhard Schussek - */ -class KernelEvent extends Event -{ - private $kernel; - private $request; - private $requestType; - - /** - * @param HttpKernelInterface $kernel The kernel in which this event was thrown - * @param Request $request The request the kernel is currently processing - * @param int $requestType The request type the kernel is currently processing; one of - * HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST - */ - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType) - { - $this->kernel = $kernel; - $this->request = $request; - $this->requestType = $requestType; - } - - /** - * Returns the kernel in which this event was thrown. - * - * @return HttpKernelInterface - */ - public function getKernel() - { - return $this->kernel; - } - - /** - * Returns the request the kernel is currently processing. - * - * @return Request - */ - public function getRequest() - { - return $this->request; - } - - /** - * Returns the request type the kernel is currently processing. - * - * @return int One of HttpKernelInterface::MASTER_REQUEST and - * HttpKernelInterface::SUB_REQUEST - */ - public function getRequestType() - { - return $this->requestType; - } - - /** - * Checks if this is a master request. - * - * @return bool True if the request is a master request - */ - public function isMasterRequest() - { - return HttpKernelInterface::MASTER_REQUEST === $this->requestType; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Event/PostResponseEvent.php b/lib/silex/vendor/symfony/http-kernel/Event/PostResponseEvent.php deleted file mode 100644 index 2406fddbe..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Event/PostResponseEvent.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to execute logic after a response was sent. - * - * Since it's only triggered on master requests, the `getRequestType()` method - * will always return the value of `HttpKernelInterface::MASTER_REQUEST`. - * - * @author Jordi Boggiano - */ -class PostResponseEvent extends KernelEvent -{ - private $response; - - public function __construct(HttpKernelInterface $kernel, Request $request, Response $response) - { - parent::__construct($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $this->response = $response; - } - - /** - * Returns the response for which this event was thrown. - * - * @return Response - */ - public function getResponse() - { - return $this->response; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php deleted file mode 100644 index dff29ee80..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Sets the session in the request. - * - * @author Johannes M. Schmitt - */ -abstract class AbstractSessionListener implements EventSubscriberInterface -{ - public function onKernelRequest(GetResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $request = $event->getRequest(); - $session = $this->getSession(); - if (null === $session || $request->hasSession()) { - return; - } - - $request->setSession($session); - } - - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - if (!$session = $event->getRequest()->getSession()) { - return; - } - - if ($session->isStarted() || ($session instanceof Session && $session->hasBeenStarted())) { - $event->getResponse() - ->setPrivate() - ->setMaxAge(0) - ->headers->addCacheControlDirective('must-revalidate'); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 128), - // low priority to come after regular response listeners, same as SaveSessionListener - KernelEvents::RESPONSE => array('onKernelResponse', -1000), - ); - } - - /** - * Gets the session object. - * - * @return SessionInterface|null A SessionInterface instance or null if no session is available - */ - abstract protected function getSession(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/AbstractTestSessionListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/AbstractTestSessionListener.php deleted file mode 100644 index 5f0ea5c0a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/AbstractTestSessionListener.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * TestSessionListener. - * - * Saves session in test environment. - * - * @author Bulat Shakirzyanov - * @author Fabien Potencier - */ -abstract class AbstractTestSessionListener implements EventSubscriberInterface -{ - public function onKernelRequest(GetResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - // bootstrap the session - $session = $this->getSession(); - if (!$session) { - return; - } - - $cookies = $event->getRequest()->cookies; - - if ($cookies->has($session->getName())) { - $session->setId($cookies->get($session->getName())); - } - } - - /** - * Checks if session was initialized and saves if current request is master - * Runs on 'kernel.response' in test environment. - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - if (!$session = $event->getRequest()->getSession()) { - return; - } - - if ($wasStarted = $session->isStarted()) { - $session->save(); - } - - if ($session instanceof Session ? !$session->isEmpty() : $wasStarted) { - $params = session_get_cookie_params(); - $event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'])); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 192), - KernelEvents::RESPONSE => array('onKernelResponse', -128), - ); - } - - /** - * Gets the session object. - * - * @return SessionInterface|null A SessionInterface instance or null if no session is available - */ - abstract protected function getSession(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/AddRequestFormatsListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/AddRequestFormatsListener.php deleted file mode 100644 index f21fc6ab7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/AddRequestFormatsListener.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; - -/** - * Adds configured formats to each request. - * - * @author Gildas Quemener - */ -class AddRequestFormatsListener implements EventSubscriberInterface -{ - protected $formats; - - public function __construct(array $formats) - { - $this->formats = $formats; - } - - /** - * Adds request formats. - */ - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - foreach ($this->formats as $format => $mimeTypes) { - $request->setFormat($format, $mimeTypes); - } - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return array(KernelEvents::REQUEST => array('onKernelRequest', 1)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php deleted file mode 100644 index 2911caa11..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php +++ /dev/null @@ -1,156 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\KernelEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\Console\Event\ConsoleEvent; -use Symfony\Component\Console\Output\ConsoleOutputInterface; - -/** - * Configures errors and exceptions handlers. - * - * @author Nicolas Grekas - */ -class DebugHandlersListener implements EventSubscriberInterface -{ - private $exceptionHandler; - private $logger; - private $levels; - private $throwAt; - private $scream; - private $fileLinkFormat; - private $scope; - private $firstCall = true; - private $hasTerminatedWithException; - - /** - * @param callable|null $exceptionHandler A handler that will be called on Exception - * @param LoggerInterface|null $logger A PSR-3 logger - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants - * @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value - * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged - * @param string|array $fileLinkFormat The format for links to source files - * @param bool $scope Enables/disables scoping mode - */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, $throwAt = E_ALL, $scream = true, $fileLinkFormat = null, $scope = true) - { - $this->exceptionHandler = $exceptionHandler; - $this->logger = $logger; - $this->levels = null === $levels ? E_ALL : $levels; - $this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null)); - $this->scream = (bool) $scream; - $this->fileLinkFormat = $fileLinkFormat; - $this->scope = (bool) $scope; - } - - /** - * Configures the error handler. - */ - public function configure(Event $event = null) - { - if (!$event instanceof KernelEvent ? !$this->firstCall : !$event->isMasterRequest()) { - return; - } - $this->firstCall = $this->hasTerminatedWithException = false; - - $handler = set_exception_handler('var_dump'); - $handler = is_array($handler) ? $handler[0] : null; - restore_exception_handler(); - - if ($this->logger || null !== $this->throwAt) { - if ($handler instanceof ErrorHandler) { - if ($this->logger) { - $handler->setDefaultLogger($this->logger, $this->levels); - if (is_array($this->levels)) { - $levels = 0; - foreach ($this->levels as $type => $log) { - $levels |= $type; - } - } else { - $levels = $this->levels; - } - if ($this->scream) { - $handler->screamAt($levels); - } - if ($this->scope) { - $handler->scopeAt($levels & ~E_USER_DEPRECATED & ~E_DEPRECATED); - } else { - $handler->scopeAt(0, true); - } - $this->logger = $this->levels = null; - } - if (null !== $this->throwAt) { - $handler->throwAt($this->throwAt, true); - } - } - } - if (!$this->exceptionHandler) { - if ($event instanceof KernelEvent) { - if (method_exists($kernel = $event->getKernel(), 'terminateWithException')) { - $request = $event->getRequest(); - $hasRun = &$this->hasTerminatedWithException; - $this->exceptionHandler = function (\Exception $e) use ($kernel, $request, &$hasRun) { - if ($hasRun) { - throw $e; - } - $hasRun = true; - $kernel->terminateWithException($e, $request); - }; - } - } elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) { - $output = $event->getOutput(); - if ($output instanceof ConsoleOutputInterface) { - $output = $output->getErrorOutput(); - } - $this->exceptionHandler = function ($e) use ($app, $output) { - $app->renderException($e, $output); - }; - } - } - if ($this->exceptionHandler) { - if ($handler instanceof ErrorHandler) { - $h = $handler->setExceptionHandler('var_dump'); - if (is_array($h) && $h[0] instanceof ExceptionHandler) { - $handler->setExceptionHandler($h); - $handler = $h[0]; - } else { - $handler->setExceptionHandler($this->exceptionHandler); - } - } - if ($handler instanceof ExceptionHandler) { - $handler->setHandler($this->exceptionHandler); - if (null !== $this->fileLinkFormat) { - $handler->setFileLinkFormat($this->fileLinkFormat); - } - } - $this->exceptionHandler = null; - } - } - - public static function getSubscribedEvents() - { - $events = array(KernelEvents::REQUEST => array('configure', 2048)); - - if ('cli' === PHP_SAPI && defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) { - $events[ConsoleEvents::COMMAND] = array('configure', 2048); - } - - return $events; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/DumpListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/DumpListener.php deleted file mode 100644 index de19e1311..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/DumpListener.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\VarDumper\Cloner\ClonerInterface; -use Symfony\Component\VarDumper\Dumper\DataDumperInterface; -use Symfony\Component\VarDumper\VarDumper; - -/** - * Configures dump() handler. - * - * @author Nicolas Grekas - */ -class DumpListener implements EventSubscriberInterface -{ - private $cloner; - private $dumper; - - public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper) - { - $this->cloner = $cloner; - $this->dumper = $dumper; - } - - public function configure() - { - $cloner = $this->cloner; - $dumper = $this->dumper; - - VarDumper::setHandler(function ($var) use ($cloner, $dumper) { - $dumper->dump($cloner->cloneVar($var)); - }); - } - - public static function getSubscribedEvents() - { - if (!class_exists(ConsoleEvents::class)) { - return array(); - } - - // Register early to have a working dump() as early as possible - return array(ConsoleEvents::COMMAND => array('configure', 1024)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/ExceptionListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/ExceptionListener.php deleted file mode 100644 index f18e42c7d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/ExceptionListener.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * ExceptionListener. - * - * @author Fabien Potencier - */ -class ExceptionListener implements EventSubscriberInterface -{ - protected $controller; - protected $logger; - protected $debug; - - public function __construct($controller, LoggerInterface $logger = null, $debug = false) - { - $this->controller = $controller; - $this->logger = $logger; - $this->debug = $debug; - } - - public function onKernelException(GetResponseForExceptionEvent $event) - { - $exception = $event->getException(); - $request = $event->getRequest(); - $eventDispatcher = func_num_args() > 2 ? func_get_arg(2) : null; - - $this->logException($exception, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); - - $request = $this->duplicateRequest($exception, $request); - - try { - $response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false); - } catch (\Exception $e) { - $this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())); - - $wrapper = $e; - - while ($prev = $wrapper->getPrevious()) { - if ($exception === $wrapper = $prev) { - throw $e; - } - } - - $prev = new \ReflectionProperty('Exception', 'previous'); - $prev->setAccessible(true); - $prev->setValue($wrapper, $exception); - - throw $e; - } - - $event->setResponse($response); - - if ($this->debug && $eventDispatcher instanceof EventDispatcherInterface) { - $cspRemovalListener = function (FilterResponseEvent $event) use (&$cspRemovalListener, $eventDispatcher) { - $event->getResponse()->headers->remove('Content-Security-Policy'); - $eventDispatcher->removeListener(KernelEvents::RESPONSE, $cspRemovalListener); - }; - $eventDispatcher->addListener(KernelEvents::RESPONSE, $cspRemovalListener, -128); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::EXCEPTION => array('onKernelException', -128), - ); - } - - /** - * Logs an exception. - * - * @param \Exception $exception The \Exception instance - * @param string $message The error message to log - */ - protected function logException(\Exception $exception, $message) - { - if (null !== $this->logger) { - if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) { - $this->logger->critical($message, array('exception' => $exception)); - } else { - $this->logger->error($message, array('exception' => $exception)); - } - } - } - - /** - * Clones the request for the exception. - * - * @param \Exception $exception The thrown exception - * @param Request $request The original request - * - * @return Request $request The cloned request - */ - protected function duplicateRequest(\Exception $exception, Request $request) - { - $attributes = array( - '_controller' => $this->controller, - 'exception' => FlattenException::create($exception), - 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, - ); - $request = $request->duplicate(null, null, $attributes); - $request->setMethod('GET'); - - return $request; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/FragmentListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/FragmentListener.php deleted file mode 100644 index da518fcc8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/FragmentListener.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\HttpKernel\UriSigner; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Handles content fragments represented by special URIs. - * - * All URL paths starting with /_fragment are handled as - * content fragments by this listener. - * - * If throws an AccessDeniedHttpException exception if the request - * is not signed or if it is not an internal sub-request. - * - * @author Fabien Potencier - */ -class FragmentListener implements EventSubscriberInterface -{ - private $signer; - private $fragmentPath; - - /** - * @param UriSigner $signer A UriSigner instance - * @param string $fragmentPath The path that triggers this listener - */ - public function __construct(UriSigner $signer, $fragmentPath = '/_fragment') - { - $this->signer = $signer; - $this->fragmentPath = $fragmentPath; - } - - /** - * Fixes request attributes when the path is '/_fragment'. - * - * @throws AccessDeniedHttpException if the request does not come from a trusted IP - */ - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - - if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) { - return; - } - - if ($request->attributes->has('_controller')) { - // Is a sub-request: no need to parse _path but it should still be removed from query parameters as below. - $request->query->remove('_path'); - - return; - } - - if ($event->isMasterRequest()) { - $this->validateRequest($request); - } - - parse_str($request->query->get('_path', ''), $attributes); - $request->attributes->add($attributes); - $request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes)); - $request->query->remove('_path'); - } - - protected function validateRequest(Request $request) - { - // is the Request safe? - if (!$request->isMethodSafe(false)) { - throw new AccessDeniedHttpException(); - } - - // is the Request signed? - // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering) - if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) { - return; - } - - throw new AccessDeniedHttpException(); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 48)), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/LocaleListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/LocaleListener.php deleted file mode 100644 index 427ea82fc..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/LocaleListener.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Initializes the locale based on the current request. - * - * @author Fabien Potencier - */ -class LocaleListener implements EventSubscriberInterface -{ - private $router; - private $defaultLocale; - private $requestStack; - - /** - * @param RequestStack $requestStack A RequestStack instance - * @param string $defaultLocale The default locale - * @param RequestContextAwareInterface|null $router The router - */ - public function __construct(RequestStack $requestStack, $defaultLocale = 'en', RequestContextAwareInterface $router = null) - { - $this->defaultLocale = $defaultLocale; - $this->requestStack = $requestStack; - $this->router = $router; - } - - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - $request->setDefaultLocale($this->defaultLocale); - - $this->setLocale($request); - $this->setRouterContext($request); - } - - public function onKernelFinishRequest(FinishRequestEvent $event) - { - if (null !== $parentRequest = $this->requestStack->getParentRequest()) { - $this->setRouterContext($parentRequest); - } - } - - private function setLocale(Request $request) - { - if ($locale = $request->attributes->get('_locale')) { - $request->setLocale($locale); - } - } - - private function setRouterContext(Request $request) - { - if (null !== $this->router) { - $this->router->getContext()->setParameter('_locale', $request->getLocale()); - } - } - - public static function getSubscribedEvents() - { - return array( - // must be registered after the Router to have access to the _locale - KernelEvents::REQUEST => array(array('onKernelRequest', 16)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/ProfilerListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/ProfilerListener.php deleted file mode 100644 index e3e4e7620..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/ProfilerListener.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\RequestMatcherInterface; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * ProfilerListener collects data for the current request by listening to the kernel events. - * - * @author Fabien Potencier - */ -class ProfilerListener implements EventSubscriberInterface -{ - protected $profiler; - protected $matcher; - protected $onlyException; - protected $onlyMasterRequests; - protected $exception; - protected $profiles; - protected $requestStack; - protected $parents; - - /** - * @param Profiler $profiler A Profiler instance - * @param RequestStack $requestStack A RequestStack instance - * @param RequestMatcherInterface|null $matcher A RequestMatcher instance - * @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise - * @param bool $onlyMasterRequests True if the profiler only collects data when the request is a master request, false otherwise - */ - public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false) - { - $this->profiler = $profiler; - $this->matcher = $matcher; - $this->onlyException = (bool) $onlyException; - $this->onlyMasterRequests = (bool) $onlyMasterRequests; - $this->profiles = new \SplObjectStorage(); - $this->parents = new \SplObjectStorage(); - $this->requestStack = $requestStack; - } - - /** - * Handles the onKernelException event. - */ - public function onKernelException(GetResponseForExceptionEvent $event) - { - if ($this->onlyMasterRequests && !$event->isMasterRequest()) { - return; - } - - $this->exception = $event->getException(); - } - - /** - * Handles the onKernelResponse event. - */ - public function onKernelResponse(FilterResponseEvent $event) - { - $master = $event->isMasterRequest(); - if ($this->onlyMasterRequests && !$master) { - return; - } - - if ($this->onlyException && null === $this->exception) { - return; - } - - $request = $event->getRequest(); - $exception = $this->exception; - $this->exception = null; - - if (null !== $this->matcher && !$this->matcher->matches($request)) { - return; - } - - if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) { - return; - } - - $this->profiles[$request] = $profile; - - $this->parents[$request] = $this->requestStack->getParentRequest(); - } - - public function onKernelTerminate(PostResponseEvent $event) - { - // attach children to parents - foreach ($this->profiles as $request) { - if (null !== $parentRequest = $this->parents[$request]) { - if (isset($this->profiles[$parentRequest])) { - $this->profiles[$parentRequest]->addChild($this->profiles[$request]); - } - } - } - - // save profiles - foreach ($this->profiles as $request) { - $this->profiler->saveProfile($this->profiles[$request]); - } - - $this->profiles = new \SplObjectStorage(); - $this->parents = new \SplObjectStorage(); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::RESPONSE => array('onKernelResponse', -100), - KernelEvents::EXCEPTION => 'onKernelException', - KernelEvents::TERMINATE => array('onKernelTerminate', -1024), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/ResponseListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/ResponseListener.php deleted file mode 100644 index 6d56197a7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/ResponseListener.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * ResponseListener fixes the Response headers based on the Request. - * - * @author Fabien Potencier - */ -class ResponseListener implements EventSubscriberInterface -{ - private $charset; - - public function __construct($charset) - { - $this->charset = $charset; - } - - /** - * Filters the Response. - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $response = $event->getResponse(); - - if (null === $response->getCharset()) { - $response->setCharset($this->charset); - } - - $response->prepare($event->getRequest()); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::RESPONSE => 'onKernelResponse', - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/RouterListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/RouterListener.php deleted file mode 100644 index caaf80f86..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/RouterListener.php +++ /dev/null @@ -1,171 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\NoConfigurationException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; -use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Initializes the context from the request and sets request attributes based on a matching route. - * - * @author Fabien Potencier - * @author Yonel Ceruto - */ -class RouterListener implements EventSubscriberInterface -{ - private $matcher; - private $context; - private $logger; - private $requestStack; - private $projectDir; - private $debug; - - /** - * @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher - * @param RequestStack $requestStack A RequestStack instance - * @param RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface) - * @param LoggerInterface|null $logger The logger - * @param string $projectDir - * @param bool $debug - * - * @throws \InvalidArgumentException - */ - public function __construct($matcher, RequestStack $requestStack, RequestContext $context = null, LoggerInterface $logger = null, $projectDir = null, $debug = true) - { - if (!$matcher instanceof UrlMatcherInterface && !$matcher instanceof RequestMatcherInterface) { - throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.'); - } - - if (null === $context && !$matcher instanceof RequestContextAwareInterface) { - throw new \InvalidArgumentException('You must either pass a RequestContext or the matcher must implement RequestContextAwareInterface.'); - } - - $this->matcher = $matcher; - $this->context = $context ?: $matcher->getContext(); - $this->requestStack = $requestStack; - $this->logger = $logger; - $this->projectDir = $projectDir; - $this->debug = $debug; - } - - private function setCurrentRequest(Request $request = null) - { - if (null !== $request) { - try { - $this->context->fromRequest($request); - } catch (\UnexpectedValueException $e) { - throw new BadRequestHttpException($e->getMessage(), $e, $e->getCode()); - } - } - } - - /** - * After a sub-request is done, we need to reset the routing context to the parent request so that the URL generator - * operates on the correct context again. - * - * @param FinishRequestEvent $event - */ - public function onKernelFinishRequest(FinishRequestEvent $event) - { - $this->setCurrentRequest($this->requestStack->getParentRequest()); - } - - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - - $this->setCurrentRequest($request); - - if ($request->attributes->has('_controller')) { - // routing is already done - return; - } - - // add attributes based on the request (routing) - try { - // matching a request is more powerful than matching a URL path + context, so try that first - if ($this->matcher instanceof RequestMatcherInterface) { - $parameters = $this->matcher->matchRequest($request); - } else { - $parameters = $this->matcher->match($request->getPathInfo()); - } - - if (null !== $this->logger) { - $this->logger->info('Matched route "{route}".', array( - 'route' => isset($parameters['_route']) ? $parameters['_route'] : 'n/a', - 'route_parameters' => $parameters, - 'request_uri' => $request->getUri(), - 'method' => $request->getMethod(), - )); - } - - $request->attributes->add($parameters); - unset($parameters['_route'], $parameters['_controller']); - $request->attributes->set('_route_params', $parameters); - } catch (ResourceNotFoundException $e) { - if ($this->debug && $e instanceof NoConfigurationException) { - $event->setResponse($this->createWelcomeResponse()); - - return; - } - - $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo()); - - if ($referer = $request->headers->get('referer')) { - $message .= sprintf(' (from "%s")', $referer); - } - - throw new NotFoundHttpException($message, $e); - } catch (MethodNotAllowedException $e) { - $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $e->getAllowedMethods())); - - throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 32)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); - } - - private function createWelcomeResponse() - { - $version = Kernel::VERSION; - $baseDir = realpath($this->projectDir).DIRECTORY_SEPARATOR; - $docVersion = substr(Kernel::VERSION, 0, 3); - - ob_start(); - include __DIR__.'/../Resources/welcome.html.php'; - - return new Response(ob_get_clean(), Response::HTTP_NOT_FOUND); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/SaveSessionListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/SaveSessionListener.php deleted file mode 100644 index 36809b59a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/SaveSessionListener.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Saves the session, in case it is still open, before sending the response/headers. - * - * This ensures several things in case the developer did not save the session explicitly: - * - * * If a session save handler without locking is used, it ensures the data is available - * on the next request, e.g. after a redirect. PHPs auto-save at script end via - * session_register_shutdown is executed after fastcgi_finish_request. So in this case - * the data could be missing the next request because it might not be saved the moment - * the new request is processed. - * * A locking save handler (e.g. the native 'files') circumvents concurrency problems like - * the one above. But by saving the session before long-running things in the terminate event, - * we ensure the session is not blocked longer than needed. - * * When regenerating the session ID no locking is involved in PHPs session design. See - * https://bugs.php.net/bug.php?id=61470 for a discussion. So in this case, the session must - * be saved anyway before sending the headers with the new session ID. Otherwise session - * data could get lost again for concurrent requests with the new ID. One result could be - * that you get logged out after just logging in. - * - * This listener should be executed as one of the last listeners, so that previous listeners - * can still operate on the open session. This prevents the overhead of restarting it. - * Listeners after closing the session can still work with the session as usual because - * Symfonys session implementation starts the session on demand. So writing to it after - * it is saved will just restart it. - * - * @author Tobias Schultze - */ -class SaveSessionListener implements EventSubscriberInterface -{ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $session = $event->getRequest()->getSession(); - if ($session && $session->isStarted()) { - $session->save(); - } - } - - public static function getSubscribedEvents() - { - return array( - // low priority but higher than StreamedResponseListener - KernelEvents::RESPONSE => array(array('onKernelResponse', -1000)), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/SessionListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/SessionListener.php deleted file mode 100644 index 39ebfd922..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/SessionListener.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Container\ContainerInterface; - -/** - * Sets the session in the request. - * - * @author Fabien Potencier - * - * @final since version 3.3 - */ -class SessionListener extends AbstractSessionListener -{ - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - protected function getSession() - { - if (!$this->container->has('session')) { - return; - } - - return $this->container->get('session'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/StreamedResponseListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/StreamedResponseListener.php deleted file mode 100644 index 671db5d82..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/StreamedResponseListener.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * StreamedResponseListener is responsible for sending the Response - * to the client. - * - * @author Fabien Potencier - */ -class StreamedResponseListener implements EventSubscriberInterface -{ - /** - * Filters the Response. - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $response = $event->getResponse(); - - if ($response instanceof StreamedResponse) { - $response->send(); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::RESPONSE => array('onKernelResponse', -1024), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/SurrogateListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/SurrogateListener.php deleted file mode 100644 index 37d1b9d04..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/SurrogateListener.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\HttpCache\HttpCache; -use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates. - * - * @author Fabien Potencier - */ -class SurrogateListener implements EventSubscriberInterface -{ - private $surrogate; - - public function __construct(SurrogateInterface $surrogate = null) - { - $this->surrogate = $surrogate; - } - - /** - * Filters the Response. - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $kernel = $event->getKernel(); - $surrogate = $this->surrogate; - if ($kernel instanceof HttpCache) { - $surrogate = $kernel->getSurrogate(); - if (null !== $this->surrogate && $this->surrogate->getName() !== $surrogate->getName()) { - $surrogate = $this->surrogate; - } - } - - if (null === $surrogate) { - return; - } - - $surrogate->addSurrogateControl($event->getResponse()); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::RESPONSE => 'onKernelResponse', - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/TestSessionListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/TestSessionListener.php deleted file mode 100644 index 36abb422f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/TestSessionListener.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Container\ContainerInterface; - -/** - * Sets the session in the request. - * - * @author Fabien Potencier - * - * @final since version 3.3 - */ -class TestSessionListener extends AbstractTestSessionListener -{ - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - protected function getSession() - { - if (!$this->container->has('session')) { - return; - } - - return $this->container->get('session'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/TranslatorListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/TranslatorListener.php deleted file mode 100644 index 6967ad029..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/TranslatorListener.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Synchronizes the locale between the request and the translator. - * - * @author Fabien Potencier - */ -class TranslatorListener implements EventSubscriberInterface -{ - private $translator; - private $requestStack; - - public function __construct(TranslatorInterface $translator, RequestStack $requestStack) - { - $this->translator = $translator; - $this->requestStack = $requestStack; - } - - public function onKernelRequest(GetResponseEvent $event) - { - $this->setLocale($event->getRequest()); - } - - public function onKernelFinishRequest(FinishRequestEvent $event) - { - if (null === $parentRequest = $this->requestStack->getParentRequest()) { - return; - } - - $this->setLocale($parentRequest); - } - - public static function getSubscribedEvents() - { - return array( - // must be registered after the Locale listener - KernelEvents::REQUEST => array(array('onKernelRequest', 10)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); - } - - private function setLocale(Request $request) - { - try { - $this->translator->setLocale($request->getLocale()); - } catch (\InvalidArgumentException $e) { - $this->translator->setLocale($request->getDefaultLocale()); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php b/lib/silex/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php deleted file mode 100644 index a33853f72..000000000 --- a/lib/silex/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Validates Requests. - * - * @author Magnus Nordlander - */ -class ValidateRequestListener implements EventSubscriberInterface -{ - /** - * Performs the validation. - */ - public function onKernelRequest(GetResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - $request = $event->getRequest(); - - if ($request::getTrustedProxies()) { - $request->getClientIps(); - } - - $request->getHost(); - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array( - array('onKernelRequest', 256), - ), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Exception/AccessDeniedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/AccessDeniedHttpException.php deleted file mode 100644 index 394188426..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/AccessDeniedHttpException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Fabien Potencier - * @author Christophe Coevoet - */ -class AccessDeniedHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $code The internal exception code - */ - public function __construct($message = null, \Exception $previous = null, $code = 0) - { - parent::__construct(403, $message, $previous, array(), $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Exception/BadRequestHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/BadRequestHttpException.php deleted file mode 100644 index c28d83739..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/BadRequestHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class BadRequestHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/ConflictHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/ConflictHttpException.php deleted file mode 100644 index 79f24f2e5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/ConflictHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class ConflictHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/GoneHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/GoneHttpException.php deleted file mode 100644 index 84e6915df..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/GoneHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class GoneHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/HttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/HttpException.php deleted file mode 100644 index e8e376058..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/HttpException.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * HttpException. - * - * @author Kris Wallsmith - */ -class HttpException extends \RuntimeException implements HttpExceptionInterface -{ - private $statusCode; - private $headers; - - public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = array(), $code = 0) - { - $this->statusCode = $statusCode; - $this->headers = $headers; - - parent::__construct($message, $code, $previous); - } - - public function getStatusCode() - { - return $this->statusCode; - } - - public function getHeaders() - { - return $this->headers; - } - - /** - * Set response headers. - * - * @param array $headers Response headers - */ - public function setHeaders(array $headers) - { - $this->headers = $headers; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Exception/HttpExceptionInterface.php b/lib/silex/vendor/symfony/http-kernel/Exception/HttpExceptionInterface.php deleted file mode 100644 index 8aa50a9f4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/HttpExceptionInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * Interface for HTTP error exceptions. - * - * @author Kris Wallsmith - */ -interface HttpExceptionInterface -{ - /** - * Returns the status code. - * - * @return int An HTTP response status code - */ - public function getStatusCode(); - - /** - * Returns response headers. - * - * @return array Response headers - */ - public function getHeaders(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Exception/LengthRequiredHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/LengthRequiredHttpException.php deleted file mode 100644 index 645efe87d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/LengthRequiredHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class LengthRequiredHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/MethodNotAllowedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/MethodNotAllowedHttpException.php deleted file mode 100644 index e308a5fee..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/MethodNotAllowedHttpException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Kris Wallsmith - */ -class MethodNotAllowedHttpException extends HttpException -{ - /** - * @param array $allow An array of allowed methods - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $code The internal exception code - */ - public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0) - { - $headers = array('Allow' => strtoupper(implode(', ', $allow))); - - parent::__construct(405, $message, $previous, $headers, $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Exception/NotAcceptableHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/NotAcceptableHttpException.php deleted file mode 100644 index 097a13fd9..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/NotAcceptableHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class NotAcceptableHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/NotFoundHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/NotFoundHttpException.php deleted file mode 100644 index 878173cc7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/NotFoundHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Fabien Potencier - */ -class NotFoundHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $code The internal exception code - */ - public function __construct($message = null, \Exception $previous = null, $code = 0) - { - parent::__construct(404, $message, $previous, array(), $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Exception/PreconditionFailedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/PreconditionFailedHttpException.php deleted file mode 100644 index 9f13a624c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/PreconditionFailedHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class PreconditionFailedHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/PreconditionRequiredHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/PreconditionRequiredHttpException.php deleted file mode 100644 index 9d0a36d7d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/PreconditionRequiredHttpException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - * - * @see http://tools.ietf.org/html/rfc6585 - */ -class PreconditionRequiredHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/ServiceUnavailableHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/ServiceUnavailableHttpException.php deleted file mode 100644 index b2767c3fd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/ServiceUnavailableHttpException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class ServiceUnavailableHttpException extends HttpException -{ - /** - * @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 int $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/lib/silex/vendor/symfony/http-kernel/Exception/TooManyRequestsHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/TooManyRequestsHttpException.php deleted file mode 100644 index 7d8a80332..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/TooManyRequestsHttpException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - * - * @see http://tools.ietf.org/html/rfc6585 - */ -class TooManyRequestsHttpException extends HttpException -{ - /** - * @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 int $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/lib/silex/vendor/symfony/http-kernel/Exception/UnauthorizedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/UnauthorizedHttpException.php deleted file mode 100644 index 05ac875c5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/UnauthorizedHttpException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class UnauthorizedHttpException extends HttpException -{ - /** - * @param string $challenge WWW-Authenticate challenge string - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Exception/UnprocessableEntityHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/UnprocessableEntityHttpException.php deleted file mode 100644 index 01b8b8465..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/UnprocessableEntityHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Steve Hutchins - */ -class UnprocessableEntityHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $code The internal exception code - */ - public function __construct($message = null, \Exception $previous = null, $code = 0) - { - parent::__construct(422, $message, $previous, array(), $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Exception/UnsupportedMediaTypeHttpException.php b/lib/silex/vendor/symfony/http-kernel/Exception/UnsupportedMediaTypeHttpException.php deleted file mode 100644 index 6913504e8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Exception/UnsupportedMediaTypeHttpException.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * @author Ben Ramsey - */ -class UnsupportedMediaTypeHttpException extends HttpException -{ - /** - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Fragment/AbstractSurrogateFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Fragment/AbstractSurrogateFragmentRenderer.php deleted file mode 100644 index a8dca41ba..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/AbstractSurrogateFragmentRenderer.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface; -use Symfony\Component\HttpKernel\UriSigner; - -/** - * Implements Surrogate rendering strategy. - * - * @author Fabien Potencier - */ -abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRenderer -{ - private $surrogate; - private $inlineStrategy; - private $signer; - - /** - * The "fallback" strategy when surrogate is not available should always be an - * instance of InlineFragmentRenderer. - * - * @param SurrogateInterface $surrogate An Surrogate instance - * @param FragmentRendererInterface $inlineStrategy The inline strategy to use when the surrogate is not supported - * @param UriSigner $signer - */ - public function __construct(SurrogateInterface $surrogate = null, FragmentRendererInterface $inlineStrategy, UriSigner $signer = null) - { - $this->surrogate = $surrogate; - $this->inlineStrategy = $inlineStrategy; - $this->signer = $signer; - } - - /** - * {@inheritdoc} - * - * Note that if the current Request has no surrogate capability, this method - * falls back to use the inline rendering strategy. - * - * Additional available options: - * - * * alt: an alternative URI to render in case of an error - * * comment: a comment to add when returning the surrogate tag - * - * Note, that not all surrogate strategies support all options. For now - * 'alt' and 'comment' are only supported by ESI. - * - * @see Symfony\Component\HttpKernel\HttpCache\SurrogateInterface - */ - public function render($uri, Request $request, array $options = array()) - { - if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) { - if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) { - @trigger_error('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated since Symfony 3.1, and will be removed in 4.0. Use a different rendering strategy or pass scalar values.', E_USER_DEPRECATED); - } - - return $this->inlineStrategy->render($uri, $request, $options); - } - - if ($uri instanceof ControllerReference) { - $uri = $this->generateSignedFragmentUri($uri, $request); - } - - $alt = isset($options['alt']) ? $options['alt'] : null; - if ($alt instanceof ControllerReference) { - $alt = $this->generateSignedFragmentUri($alt, $request); - } - - $tag = $this->surrogate->renderIncludeTag($uri, $alt, isset($options['ignore_errors']) ? $options['ignore_errors'] : false, isset($options['comment']) ? $options['comment'] : ''); - - return new Response($tag); - } - - private function generateSignedFragmentUri($uri, Request $request) - { - if (null === $this->signer) { - throw new \LogicException('You must use a URI when using the ESI rendering strategy or set a URL signer.'); - } - - // we need to sign the absolute URI, but want to return the path only. - $fragmentUri = $this->signer->sign($this->generateFragmentUri($uri, $request, true)); - - return substr($fragmentUri, strlen($request->getSchemeAndHttpHost())); - } - - private function containsNonScalars(array $values) - { - foreach ($values as $value) { - if (is_array($value)) { - return $this->containsNonScalars($value); - } elseif (!is_scalar($value) && null !== $value) { - return true; - } - } - - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Fragment/EsiFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Fragment/EsiFragmentRenderer.php deleted file mode 100644 index a4570e3be..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/EsiFragmentRenderer.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -/** - * Implements the ESI rendering strategy. - * - * @author Fabien Potencier - */ -class EsiFragmentRenderer extends AbstractSurrogateFragmentRenderer -{ - /** - * {@inheritdoc} - */ - public function getName() - { - return 'esi'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Fragment/FragmentHandler.php b/lib/silex/vendor/symfony/http-kernel/Fragment/FragmentHandler.php deleted file mode 100644 index c9d952ffb..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/FragmentHandler.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Controller\ControllerReference; - -/** - * Renders a URI that represents a resource fragment. - * - * This class handles the rendering of resource fragments that are included into - * a main resource. The handling of the rendering is managed by specialized renderers. - * - * @author Fabien Potencier - * - * @see FragmentRendererInterface - */ -class FragmentHandler -{ - private $debug; - private $renderers = array(); - private $requestStack; - - /** - * @param RequestStack $requestStack The Request stack that controls the lifecycle of requests - * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances - * @param bool $debug Whether the debug mode is enabled or not - */ - public function __construct(RequestStack $requestStack, array $renderers = array(), $debug = false) - { - $this->requestStack = $requestStack; - foreach ($renderers as $renderer) { - $this->addRenderer($renderer); - } - $this->debug = $debug; - } - - /** - * Adds a renderer. - */ - public function addRenderer(FragmentRendererInterface $renderer) - { - $this->renderers[$renderer->getName()] = $renderer; - } - - /** - * Renders a URI and returns the Response content. - * - * Available options: - * - * * ignore_errors: true to return an empty string in case of an error - * - * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance - * @param string $renderer The renderer name - * @param array $options An array of options - * - * @return string|null The Response content or null when the Response is streamed - * - * @throws \InvalidArgumentException when the renderer does not exist - * @throws \LogicException when no master request is being handled - */ - public function render($uri, $renderer = 'inline', array $options = array()) - { - if (!isset($options['ignore_errors'])) { - $options['ignore_errors'] = !$this->debug; - } - - if (!isset($this->renderers[$renderer])) { - throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer)); - } - - if (!$request = $this->requestStack->getCurrentRequest()) { - throw new \LogicException('Rendering a fragment can only be done when handling a Request.'); - } - - return $this->deliver($this->renderers[$renderer]->render($uri, $request, $options)); - } - - /** - * Delivers the Response as a string. - * - * When the Response is a StreamedResponse, the content is streamed immediately - * instead of being returned. - * - * @return string|null The Response content or null when the Response is streamed - * - * @throws \RuntimeException when the Response is not successful - */ - protected function deliver(Response $response) - { - if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode())); - } - - if (!$response instanceof StreamedResponse) { - return $response->getContent(); - } - - $response->sendContent(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Fragment/FragmentRendererInterface.php b/lib/silex/vendor/symfony/http-kernel/Fragment/FragmentRendererInterface.php deleted file mode 100644 index b177c3ac1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/FragmentRendererInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpFoundation\Response; - -/** - * Interface implemented by all rendering strategies. - * - * @author Fabien Potencier - */ -interface FragmentRendererInterface -{ - /** - * Renders a URI and returns the Response content. - * - * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance - * @param Request $request A Request instance - * @param array $options An array of options - * - * @return Response A Response instance - */ - public function render($uri, Request $request, array $options = array()); - - /** - * Gets the name of the strategy. - * - * @return string The strategy name - */ - public function getName(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Fragment/HIncludeFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Fragment/HIncludeFragmentRenderer.php deleted file mode 100644 index 7e957d4c9..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/HIncludeFragmentRenderer.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Templating\EngineInterface; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\UriSigner; -use Twig\Environment; -use Twig\Error\LoaderError; -use Twig\Loader\ExistsLoaderInterface; - -/** - * Implements the Hinclude rendering strategy. - * - * @author Fabien Potencier - */ -class HIncludeFragmentRenderer extends RoutableFragmentRenderer -{ - private $globalDefaultTemplate; - private $signer; - private $templating; - private $charset; - - /** - * @param EngineInterface|Environment $templating An EngineInterface or a Twig instance - * @param UriSigner $signer A UriSigner instance - * @param string $globalDefaultTemplate The global default content (it can be a template name or the content) - * @param string $charset - */ - public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null, $charset = 'utf-8') - { - $this->setTemplating($templating); - $this->globalDefaultTemplate = $globalDefaultTemplate; - $this->signer = $signer; - $this->charset = $charset; - } - - /** - * Sets the templating engine to use to render the default content. - * - * @param EngineInterface|Environment|null $templating An EngineInterface or an Environment instance - * - * @throws \InvalidArgumentException - */ - public function setTemplating($templating) - { - if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof Environment) { - throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface'); - } - - $this->templating = $templating; - } - - /** - * Checks if a templating engine has been set. - * - * @return bool true if the templating engine has been set, false otherwise - */ - public function hasTemplating() - { - return null !== $this->templating; - } - - /** - * {@inheritdoc} - * - * Additional available options: - * - * * default: The default content (it can be a template name or the content) - * * id: An optional hx:include tag id attribute - * * attributes: An optional array of hx:include tag attributes - */ - public function render($uri, Request $request, array $options = array()) - { - if ($uri instanceof ControllerReference) { - if (null === $this->signer) { - throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.'); - } - - // we need to sign the absolute URI, but want to return the path only. - $uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), strlen($request->getSchemeAndHttpHost())); - } - - // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content. - $uri = str_replace('&', '&', $uri); - - $template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate; - if (null !== $this->templating && $template && $this->templateExists($template)) { - $content = $this->templating->render($template); - } else { - $content = $template; - } - - $attributes = isset($options['attributes']) && is_array($options['attributes']) ? $options['attributes'] : array(); - if (isset($options['id']) && $options['id']) { - $attributes['id'] = $options['id']; - } - $renderedAttributes = ''; - if (count($attributes) > 0) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - foreach ($attributes as $attribute => $value) { - $renderedAttributes .= sprintf( - ' %s="%s"', - htmlspecialchars($attribute, $flags, $this->charset, false), - htmlspecialchars($value, $flags, $this->charset, false) - ); - } - } - - return new Response(sprintf('%s', $uri, $renderedAttributes, $content)); - } - - /** - * @param string $template - * - * @return bool - */ - private function templateExists($template) - { - if ($this->templating instanceof EngineInterface) { - try { - return $this->templating->exists($template); - } catch (\InvalidArgumentException $e) { - return false; - } - } - - $loader = $this->templating->getLoader(); - if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) { - return $loader->exists($template); - } - - try { - if (method_exists($loader, 'getSourceContext')) { - $loader->getSourceContext($template); - } else { - $loader->getSource($template); - } - - return true; - } catch (LoaderError $e) { - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'hinclude'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php deleted file mode 100644 index 3f3a51a59..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * Implements the inline rendering strategy where the Request is rendered by the current HTTP kernel. - * - * @author Fabien Potencier - */ -class InlineFragmentRenderer extends RoutableFragmentRenderer -{ - private $kernel; - private $dispatcher; - - public function __construct(HttpKernelInterface $kernel, EventDispatcherInterface $dispatcher = null) - { - $this->kernel = $kernel; - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - * - * Additional available options: - * - * * alt: an alternative URI to render in case of an error - */ - public function render($uri, Request $request, array $options = array()) - { - $reference = null; - if ($uri instanceof ControllerReference) { - $reference = $uri; - - // Remove attributes from the generated URI because if not, the Symfony - // routing system will use them to populate the Request attributes. We don't - // want that as we want to preserve objects (so we manually set Request attributes - // below instead) - $attributes = $reference->attributes; - $reference->attributes = array(); - - // The request format and locale might have been overridden by the user - foreach (array('_format', '_locale') as $key) { - if (isset($attributes[$key])) { - $reference->attributes[$key] = $attributes[$key]; - } - } - - $uri = $this->generateFragmentUri($uri, $request, false, false); - - $reference->attributes = array_merge($attributes, $reference->attributes); - } - - $subRequest = $this->createSubRequest($uri, $request); - - // override Request attributes as they can be objects (which are not supported by the generated URI) - if (null !== $reference) { - $subRequest->attributes->add($reference->attributes); - } - - $level = ob_get_level(); - try { - return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false); - } catch (\Exception $e) { - // we dispatch the exception event to trigger the logging - // the response that comes back is simply ignored - if (isset($options['ignore_errors']) && $options['ignore_errors'] && $this->dispatcher) { - $event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::SUB_REQUEST, $e); - - $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event); - } - - // let's clean up the output buffers that were created by the sub-request - Response::closeOutputBuffers($level, false); - - if (isset($options['alt'])) { - $alt = $options['alt']; - unset($options['alt']); - - return $this->render($alt, $request, $options); - } - - if (!isset($options['ignore_errors']) || !$options['ignore_errors']) { - throw $e; - } - - return new Response(); - } - } - - protected function createSubRequest($uri, Request $request) - { - $cookies = $request->cookies->all(); - $server = $request->server->all(); - - // Override the arguments to emulate a sub-request. - // Sub-request object will point to localhost as client ip and real client ip - // will be included into trusted header for client ip - try { - if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { - $currentXForwardedFor = $request->headers->get('X_FORWARDED_FOR', ''); - - $server['HTTP_X_FORWARDED_FOR'] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp(); - } elseif (method_exists(Request::class, 'getTrustedHeaderName') && $trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP, false)) { - $currentXForwardedFor = $request->headers->get($trustedHeaderName, ''); - - $server['HTTP_'.$trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp(); - } - } catch (\InvalidArgumentException $e) { - // Do nothing - } - - $server['REMOTE_ADDR'] = '127.0.0.1'; - unset($server['HTTP_IF_MODIFIED_SINCE']); - unset($server['HTTP_IF_NONE_MATCH']); - - $subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server); - if ($request->headers->has('Surrogate-Capability')) { - $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability')); - } - - if ($session = $request->getSession()) { - $subRequest->setSession($session); - } - - return $subRequest; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'inline'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Fragment/RoutableFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Fragment/RoutableFragmentRenderer.php deleted file mode 100644 index d7eeb89a6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/RoutableFragmentRenderer.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\EventListener\FragmentListener; - -/** - * Adds the possibility to generate a fragment URI for a given Controller. - * - * @author Fabien Potencier - */ -abstract class RoutableFragmentRenderer implements FragmentRendererInterface -{ - private $fragmentPath = '/_fragment'; - - /** - * Sets the fragment path that triggers the fragment listener. - * - * @param string $path The path - * - * @see FragmentListener - */ - public function setFragmentPath($path) - { - $this->fragmentPath = $path; - } - - /** - * Generates a fragment URI for a given controller. - * - * @param ControllerReference $reference A ControllerReference instance - * @param Request $request A Request instance - * @param bool $absolute Whether to generate an absolute URL or not - * @param bool $strict Whether to allow non-scalar attributes or not - * - * @return string A fragment URI - */ - protected function generateFragmentUri(ControllerReference $reference, Request $request, $absolute = false, $strict = true) - { - if ($strict) { - $this->checkNonScalar($reference->attributes); - } - - // We need to forward the current _format and _locale values as we don't have - // a proper routing pattern to do the job for us. - // This makes things inconsistent if you switch from rendering a controller - // to rendering a route if the route pattern does not contain the special - // _format and _locale placeholders. - if (!isset($reference->attributes['_format'])) { - $reference->attributes['_format'] = $request->getRequestFormat(); - } - if (!isset($reference->attributes['_locale'])) { - $reference->attributes['_locale'] = $request->getLocale(); - } - - $reference->attributes['_controller'] = $reference->controller; - - $reference->query['_path'] = http_build_query($reference->attributes, '', '&'); - - $path = $this->fragmentPath.'?'.http_build_query($reference->query, '', '&'); - - if ($absolute) { - return $request->getUriForPath($path); - } - - return $request->getBaseUrl().$path; - } - - private function checkNonScalar($values) - { - foreach ($values as $key => $value) { - if (is_array($value)) { - $this->checkNonScalar($value); - } elseif (!is_scalar($value) && null !== $value) { - throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Fragment/SsiFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Fragment/SsiFragmentRenderer.php deleted file mode 100644 index 45e7122f0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Fragment/SsiFragmentRenderer.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -/** - * Implements the SSI rendering strategy. - * - * @author Sebastian Krebs - */ -class SsiFragmentRenderer extends AbstractSurrogateFragmentRenderer -{ - /** - * {@inheritdoc} - */ - public function getName() - { - return 'ssi'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php deleted file mode 100644 index 3b2d5f262..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * Abstract class implementing Surrogate capabilities to Request and Response instances. - * - * @author Fabien Potencier - * @author Robin Chalas - */ -abstract class AbstractSurrogate implements SurrogateInterface -{ - protected $contentTypes; - protected $phpEscapeMap = array( - array('', '', '', ''), - ); - - /** - * @param array $contentTypes An array of content-type that should be parsed for Surrogate information - * (default: text/html, text/xml, application/xhtml+xml, and application/xml) - */ - public function __construct(array $contentTypes = array('text/html', 'text/xml', 'application/xhtml+xml', 'application/xml')) - { - $this->contentTypes = $contentTypes; - } - - /** - * Returns a new cache strategy instance. - * - * @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance - */ - public function createCacheStrategy() - { - return new ResponseCacheStrategy(); - } - - /** - * {@inheritdoc} - */ - public function hasSurrogateCapability(Request $request) - { - if (null === $value = $request->headers->get('Surrogate-Capability')) { - return false; - } - - return false !== strpos($value, sprintf('%s/1.0', strtoupper($this->getName()))); - } - - /** - * {@inheritdoc} - */ - public function addSurrogateCapability(Request $request) - { - $current = $request->headers->get('Surrogate-Capability'); - $new = sprintf('symfony="%s/1.0"', strtoupper($this->getName())); - - $request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new); - } - - /** - * {@inheritdoc} - */ - public function needsParsing(Response $response) - { - if (!$control = $response->headers->get('Surrogate-Control')) { - return false; - } - - $pattern = sprintf('#content="[^"]*%s/1.0[^"]*"#', strtoupper($this->getName())); - - return (bool) preg_match($pattern, $control); - } - - /** - * {@inheritdoc} - */ - public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) - { - $subRequest = Request::create($uri, Request::METHOD_GET, array(), $cache->getRequest()->cookies->all(), array(), $cache->getRequest()->server->all()); - - try { - $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); - - if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode())); - } - - return $response->getContent(); - } catch (\Exception $e) { - if ($alt) { - return $this->handle($cache, $alt, '', $ignoreErrors); - } - - if (!$ignoreErrors) { - throw $e; - } - } - } - - /** - * Remove the Surrogate from the Surrogate-Control header. - */ - protected function removeFromControl(Response $response) - { - if (!$response->headers->has('Surrogate-Control')) { - return; - } - - $value = $response->headers->get('Surrogate-Control'); - $upperName = strtoupper($this->getName()); - - if (sprintf('content="%s/1.0"', $upperName) == $value) { - $response->headers->remove('Surrogate-Control'); - } elseif (preg_match(sprintf('#,\s*content="%s/1.0"#', $upperName), $value)) { - $response->headers->set('Surrogate-Control', preg_replace(sprintf('#,\s*content="%s/1.0"#', $upperName), '', $value)); - } elseif (preg_match(sprintf('#content="%s/1.0",\s*#', $upperName), $value)) { - $response->headers->set('Surrogate-Control', preg_replace(sprintf('#content="%s/1.0",\s*#', $upperName), '', $value)); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/Esi.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/Esi.php deleted file mode 100644 index d09907ea6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/Esi.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Esi implements the ESI capabilities to Request and Response instances. - * - * For more information, read the following W3C notes: - * - * * ESI Language Specification 1.0 (http://www.w3.org/TR/esi-lang) - * - * * Edge Architecture Specification (http://www.w3.org/TR/edge-arch) - * - * @author Fabien Potencier - */ -class Esi extends AbstractSurrogate -{ - public function getName() - { - return 'esi'; - } - - /** - * {@inheritdoc} - */ - public function addSurrogateControl(Response $response) - { - if (false !== strpos($response->getContent(), 'headers->set('Surrogate-Control', 'content="ESI/1.0"'); - } - } - - /** - * {@inheritdoc} - */ - public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '') - { - $html = sprintf('', - $uri, - $ignoreErrors ? ' onerror="continue"' : '', - $alt ? sprintf(' alt="%s"', $alt) : '' - ); - - if (!empty($comment)) { - return sprintf("\n%s", $comment, $html); - } - - return $html; - } - - /** - * {@inheritdoc} - */ - public function process(Request $request, Response $response) - { - $type = $response->headers->get('Content-Type'); - if (empty($type)) { - $type = 'text/html'; - } - - $parts = explode(';', $type); - if (!in_array($parts[0], $this->contentTypes)) { - return $response; - } - - // we don't use a proper XML parser here as we can have ESI tags in a plain text response - $content = $response->getContent(); - $content = preg_replace('#.*?#s', '', $content); - $content = preg_replace('#]+>#s', '', $content); - - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); - $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); - - $i = 1; - while (isset($chunks[$i])) { - $options = array(); - preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); - foreach ($matches as $set) { - $options[$set[1]] = $set[2]; - } - - if (!isset($options['src'])) { - throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.'); - } - - $chunks[$i] = sprintf('surrogate->handle($this, %s, %s, %s) ?>'."\n", - var_export($options['src'], true), - var_export(isset($options['alt']) ? $options['alt'] : '', true), - isset($options['onerror']) && 'continue' === $options['onerror'] ? 'true' : 'false' - ); - ++$i; - $chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]); - ++$i; - } - $content = implode('', $chunks); - - $response->setContent($content); - $response->headers->set('X-Body-Eval', 'ESI'); - - // remove ESI/1.0 from the Surrogate-Control header - $this->removeFromControl($response); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/HttpCache.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/HttpCache.php deleted file mode 100644 index 7c5a44f05..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/HttpCache.php +++ /dev/null @@ -1,714 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\TerminableInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Cache provides HTTP caching. - * - * @author Fabien Potencier - */ -class HttpCache implements HttpKernelInterface, TerminableInterface -{ - private $kernel; - private $store; - private $request; - private $surrogate; - private $surrogateCacheStrategy; - private $options = array(); - private $traces = array(); - - /** - * Constructor. - * - * The available options are: - * - * * debug: If true, the traces are added as a HTTP header to ease debugging - * - * * default_ttl The number of seconds that a cache entry should be considered - * fresh when no explicit freshness information is provided in - * a response. Explicit Cache-Control or Expires headers - * override this value. (default: 0) - * - * * private_headers Set of request headers that trigger "private" cache-control behavior - * on responses that don't explicitly state whether the response is - * public or private via a Cache-Control directive. (default: Authorization and Cookie) - * - * * allow_reload Specifies whether the client can force a cache reload by including a - * Cache-Control "no-cache" directive in the request. Set it to ``true`` - * for compliance with RFC 2616. (default: false) - * - * * allow_revalidate Specifies whether the client can force a cache revalidate by including - * a Cache-Control "max-age=0" directive in the request. Set it to ``true`` - * for compliance with RFC 2616. (default: false) - * - * * stale_while_revalidate Specifies the default number of seconds (the granularity is the second as the - * Response TTL precision is a second) during which the cache can immediately return - * a stale response while it revalidates it in the background (default: 2). - * This setting is overridden by the stale-while-revalidate HTTP Cache-Control - * extension (see RFC 5861). - * - * * stale_if_error Specifies the default number of seconds (the granularity is the second) during which - * the cache can serve a stale response when an error is encountered (default: 60). - * This setting is overridden by the stale-if-error HTTP Cache-Control extension - * (see RFC 5861). - */ - public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = array()) - { - $this->store = $store; - $this->kernel = $kernel; - $this->surrogate = $surrogate; - - // needed in case there is a fatal error because the backend is too slow to respond - register_shutdown_function(array($this->store, 'cleanup')); - - $this->options = array_merge(array( - 'debug' => false, - 'default_ttl' => 0, - 'private_headers' => array('Authorization', 'Cookie'), - 'allow_reload' => false, - 'allow_revalidate' => false, - 'stale_while_revalidate' => 2, - 'stale_if_error' => 60, - ), $options); - } - - /** - * Gets the current store. - * - * @return StoreInterface $store A StoreInterface instance - */ - public function getStore() - { - return $this->store; - } - - /** - * Returns an array of events that took place during processing of the last request. - * - * @return array An array of events - */ - public function getTraces() - { - return $this->traces; - } - - /** - * Returns a log message for the events of the last request processing. - * - * @return string A log message - */ - public function getLog() - { - $log = array(); - foreach ($this->traces as $request => $traces) { - $log[] = sprintf('%s: %s', $request, implode(', ', $traces)); - } - - return implode('; ', $log); - } - - /** - * Gets the Request instance associated with the master request. - * - * @return Request A Request instance - */ - public function getRequest() - { - return $this->request; - } - - /** - * Gets the Kernel instance. - * - * @return HttpKernelInterface An HttpKernelInterface instance - */ - public function getKernel() - { - return $this->kernel; - } - - /** - * Gets the Surrogate instance. - * - * @return SurrogateInterface A Surrogate instance - * - * @throws \LogicException - */ - public function getSurrogate() - { - return $this->surrogate; - } - - /** - * {@inheritdoc} - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism - if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->traces = array(); - $this->request = $request; - if (null !== $this->surrogate) { - $this->surrogateCacheStrategy = $this->surrogate->createCacheStrategy(); - } - } - - $this->traces[$this->getTraceKey($request)] = array(); - - if (!$request->isMethodSafe(false)) { - $response = $this->invalidate($request, $catch); - } elseif ($request->headers->has('expect') || !$request->isMethodCacheable()) { - $response = $this->pass($request, $catch); - } elseif ($this->options['allow_reload'] && $request->isNoCache()) { - /* - If allow_reload is configured and the client requests "Cache-Control: no-cache", - reload the cache by fetching a fresh response and caching it (if possible). - */ - $this->record($request, 'reload'); - $response = $this->fetch($request, $catch); - } else { - $response = $this->lookup($request, $catch); - } - - $this->restoreResponseBody($request, $response); - - if (HttpKernelInterface::MASTER_REQUEST === $type && $this->options['debug']) { - $response->headers->set('X-Symfony-Cache', $this->getLog()); - } - - if (null !== $this->surrogate) { - if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->surrogateCacheStrategy->update($response); - } else { - $this->surrogateCacheStrategy->add($response); - } - } - - $response->prepare($request); - - $response->isNotModified($request); - - return $response; - } - - /** - * {@inheritdoc} - */ - public function terminate(Request $request, Response $response) - { - if ($this->getKernel() instanceof TerminableInterface) { - $this->getKernel()->terminate($request, $response); - } - } - - /** - * Forwards the Request to the backend without storing the Response in the cache. - * - * @param Request $request A Request instance - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - */ - protected function pass(Request $request, $catch = false) - { - $this->record($request, 'pass'); - - return $this->forward($request, $catch); - } - - /** - * Invalidates non-safe methods (like POST, PUT, and DELETE). - * - * @param Request $request A Request instance - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - * - * @throws \Exception - * - * @see RFC2616 13.10 - */ - protected function invalidate(Request $request, $catch = false) - { - $response = $this->pass($request, $catch); - - // invalidate only when the response is successful - if ($response->isSuccessful() || $response->isRedirect()) { - try { - $this->store->invalidate($request); - - // As per the RFC, invalidate Location and Content-Location URLs if present - foreach (array('Location', 'Content-Location') as $header) { - if ($uri = $response->headers->get($header)) { - $subRequest = Request::create($uri, 'get', array(), array(), array(), $request->server->all()); - - $this->store->invalidate($subRequest); - } - } - - $this->record($request, 'invalidate'); - } catch (\Exception $e) { - $this->record($request, 'invalidate-failed'); - - if ($this->options['debug']) { - throw $e; - } - } - } - - return $response; - } - - /** - * Lookups a Response from the cache for the given Request. - * - * When a matching cache entry is found and is fresh, it uses it as the - * response without forwarding any request to the backend. When a matching - * cache entry is found but is stale, it attempts to "validate" the entry with - * the backend using conditional GET. When no matching cache entry is found, - * it triggers "miss" processing. - * - * @param Request $request A Request instance - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - * - * @throws \Exception - */ - protected function lookup(Request $request, $catch = false) - { - try { - $entry = $this->store->lookup($request); - } catch (\Exception $e) { - $this->record($request, 'lookup-failed'); - - if ($this->options['debug']) { - throw $e; - } - - return $this->pass($request, $catch); - } - - if (null === $entry) { - $this->record($request, 'miss'); - - return $this->fetch($request, $catch); - } - - if (!$this->isFreshEnough($request, $entry)) { - $this->record($request, 'stale'); - - return $this->validate($request, $entry, $catch); - } - - $this->record($request, 'fresh'); - - $entry->headers->set('Age', $entry->getAge()); - - return $entry; - } - - /** - * Validates that a cache entry is fresh. - * - * The original request is used as a template for a conditional - * GET request with the backend. - * - * @param Request $request A Request instance - * @param Response $entry A Response instance to validate - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - */ - protected function validate(Request $request, Response $entry, $catch = false) - { - $subRequest = clone $request; - - // send no head requests because we want content - if ('HEAD' === $request->getMethod()) { - $subRequest->setMethod('GET'); - } - - // add our cached last-modified validator - $subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified')); - - // Add our cached etag validator to the environment. - // We keep the etags from the client to handle the case when the client - // has a different private valid entry which is not cached here. - $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array(); - $requestEtags = $request->getETags(); - if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) { - $subRequest->headers->set('if_none_match', implode(', ', $etags)); - } - - $response = $this->forward($subRequest, $catch, $entry); - - if (304 == $response->getStatusCode()) { - $this->record($request, 'valid'); - - // return the response and not the cache entry if the response is valid but not cached - $etag = $response->getEtag(); - if ($etag && in_array($etag, $requestEtags) && !in_array($etag, $cachedEtags)) { - return $response; - } - - $entry = clone $entry; - $entry->headers->remove('Date'); - - foreach (array('Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified') as $name) { - if ($response->headers->has($name)) { - $entry->headers->set($name, $response->headers->get($name)); - } - } - - $response = $entry; - } else { - $this->record($request, 'invalid'); - } - - if ($response->isCacheable()) { - $this->store($request, $response); - } - - return $response; - } - - /** - * Unconditionally fetches a fresh response from the backend and - * stores it in the cache if is cacheable. - * - * @param Request $request A Request instance - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - */ - protected function fetch(Request $request, $catch = false) - { - $subRequest = clone $request; - - // send no head requests because we want content - if ('HEAD' === $request->getMethod()) { - $subRequest->setMethod('GET'); - } - - // avoid that the backend sends no content - $subRequest->headers->remove('if_modified_since'); - $subRequest->headers->remove('if_none_match'); - - $response = $this->forward($subRequest, $catch); - - if ($response->isCacheable()) { - $this->store($request, $response); - } - - return $response; - } - - /** - * Forwards the Request to the backend and returns the Response. - * - * All backend requests (cache passes, fetches, cache validations) - * run through this method. - * - * @param Request $request A Request instance - * @param bool $catch Whether to catch exceptions or not - * @param Response $entry A Response instance (the stale entry if present, null otherwise) - * - * @return Response A Response instance - */ - protected function forward(Request $request, $catch = false, Response $entry = null) - { - if ($this->surrogate) { - $this->surrogate->addSurrogateCapability($request); - } - - // modify the X-Forwarded-For header if needed - $forwardedFor = $request->headers->get('X-Forwarded-For'); - if ($forwardedFor) { - $request->headers->set('X-Forwarded-For', $forwardedFor.', '.$request->server->get('REMOTE_ADDR')); - } else { - $request->headers->set('X-Forwarded-For', $request->server->get('REMOTE_ADDR')); - } - - // fix the client IP address by setting it to 127.0.0.1 as HttpCache - // is always called from the same process as the backend. - $request->server->set('REMOTE_ADDR', '127.0.0.1'); - - // make sure HttpCache is a trusted proxy - if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { - $trustedProxies[] = '127.0.0.1'; - Request::setTrustedProxies($trustedProxies, Request::HEADER_X_FORWARDED_ALL); - } - - // always a "master" request (as the real master request can be in cache) - $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch); - // FIXME: we probably need to also catch exceptions if raw === true - - // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC - if (null !== $entry && in_array($response->getStatusCode(), array(500, 502, 503, 504))) { - if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) { - $age = $this->options['stale_if_error']; - } - - if (abs($entry->getTtl()) < $age) { - $this->record($request, 'stale-if-error'); - - return $entry; - } - } - - /* - RFC 7231 Sect. 7.1.1.2 says that a server that does not have a reasonably accurate - clock MUST NOT send a "Date" header, although it MUST send one in most other cases - except for 1xx or 5xx responses where it MAY do so. - - Anyway, a client that received a message without a "Date" header MUST add it. - */ - if (!$response->headers->has('Date')) { - $response->setDate(\DateTime::createFromFormat('U', time())); - } - - $this->processResponseBody($request, $response); - - if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { - $response->setPrivate(); - } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { - $response->setTtl($this->options['default_ttl']); - } - - return $response; - } - - /** - * Checks whether the cache entry is "fresh enough" to satisfy the Request. - * - * @return bool true if the cache entry if fresh enough, false otherwise - */ - protected function isFreshEnough(Request $request, Response $entry) - { - if (!$entry->isFresh()) { - return $this->lock($request, $entry); - } - - if ($this->options['allow_revalidate'] && null !== $maxAge = $request->headers->getCacheControlDirective('max-age')) { - return $maxAge > 0 && $maxAge >= $entry->getAge(); - } - - return true; - } - - /** - * Locks a Request during the call to the backend. - * - * @return bool true if the cache entry can be returned even if it is staled, false otherwise - */ - protected function lock(Request $request, Response $entry) - { - // try to acquire a lock to call the backend - $lock = $this->store->lock($request); - - if (true === $lock) { - // we have the lock, call the backend - return false; - } - - // there is already another process calling the backend - - // May we serve a stale response? - if ($this->mayServeStaleWhileRevalidate($entry)) { - $this->record($request, 'stale-while-revalidate'); - - return true; - } - - // wait for the lock to be released - if ($this->waitForLock($request)) { - // replace the current entry with the fresh one - $new = $this->lookup($request); - $entry->headers = $new->headers; - $entry->setContent($new->getContent()); - $entry->setStatusCode($new->getStatusCode()); - $entry->setProtocolVersion($new->getProtocolVersion()); - foreach ($new->headers->getCookies() as $cookie) { - $entry->headers->setCookie($cookie); - } - } else { - // backend is slow as hell, send a 503 response (to avoid the dog pile effect) - $entry->setStatusCode(503); - $entry->setContent('503 Service Unavailable'); - $entry->headers->set('Retry-After', 10); - } - - return true; - } - - /** - * Writes the Response to the cache. - * - * @throws \Exception - */ - protected function store(Request $request, Response $response) - { - try { - $this->store->write($request, $response); - - $this->record($request, 'store'); - - $response->headers->set('Age', $response->getAge()); - } catch (\Exception $e) { - $this->record($request, 'store-failed'); - - if ($this->options['debug']) { - throw $e; - } - } - - // now that the response is cached, release the lock - $this->store->unlock($request); - } - - /** - * Restores the Response body. - */ - private function restoreResponseBody(Request $request, Response $response) - { - if ($response->headers->has('X-Body-Eval')) { - ob_start(); - - if ($response->headers->has('X-Body-File')) { - include $response->headers->get('X-Body-File'); - } else { - eval('; ?>'.$response->getContent().'setContent(ob_get_clean()); - $response->headers->remove('X-Body-Eval'); - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); - } - } elseif ($response->headers->has('X-Body-File')) { - // Response does not include possibly dynamic content (ESI, SSI), so we need - // not handle the content for HEAD requests - if (!$request->isMethod('HEAD')) { - $response->setContent(file_get_contents($response->headers->get('X-Body-File'))); - } - } else { - return; - } - - $response->headers->remove('X-Body-File'); - } - - protected function processResponseBody(Request $request, Response $response) - { - if (null !== $this->surrogate && $this->surrogate->needsParsing($response)) { - $this->surrogate->process($request, $response); - } - } - - /** - * Checks if the Request includes authorization or other sensitive information - * that should cause the Response to be considered private by default. - * - * @return bool true if the Request is private, false otherwise - */ - private function isPrivateRequest(Request $request) - { - foreach ($this->options['private_headers'] as $key) { - $key = strtolower(str_replace('HTTP_', '', $key)); - - if ('cookie' === $key) { - if (count($request->cookies->all())) { - return true; - } - } elseif ($request->headers->has($key)) { - return true; - } - } - - return false; - } - - /** - * Records that an event took place. - * - * @param Request $request A Request instance - * @param string $event The event name - */ - private function record(Request $request, $event) - { - $this->traces[$this->getTraceKey($request)][] = $event; - } - - /** - * Calculates the key we use in the "trace" array for a given request. - * - * @param Request $request - * - * @return string - */ - private function getTraceKey(Request $request) - { - $path = $request->getPathInfo(); - if ($qs = $request->getQueryString()) { - $path .= '?'.$qs; - } - - return $request->getMethod().' '.$path; - } - - /** - * Checks whether the given (cached) response may be served as "stale" when a revalidation - * is currently in progress. - * - * @param Response $entry - * - * @return bool true when the stale response may be served, false otherwise - */ - private function mayServeStaleWhileRevalidate(Response $entry) - { - $timeout = $entry->headers->getCacheControlDirective('stale-while-revalidate'); - - if (null === $timeout) { - $timeout = $this->options['stale_while_revalidate']; - } - - return abs($entry->getTtl()) < $timeout; - } - - /** - * Waits for the store to release a locked entry. - * - * @param Request $request The request to wait for - * - * @return bool true if the lock was released before the internal timeout was hit; false if the wait timeout was exceeded - */ - private function waitForLock(Request $request) - { - $wait = 0; - while ($this->store->isLocked($request) && $wait < 100) { - usleep(50000); - ++$wait; - } - - return $wait < 100; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php deleted file mode 100644 index 027b2b176..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Response; - -/** - * ResponseCacheStrategy knows how to compute the Response cache HTTP header - * based on the different response cache headers. - * - * This implementation changes the master response TTL to the smallest TTL received - * or force validation if one of the surrogates has validation cache strategy. - * - * @author Fabien Potencier - */ -class ResponseCacheStrategy implements ResponseCacheStrategyInterface -{ - private $cacheable = true; - private $embeddedResponses = 0; - private $ttls = array(); - private $maxAges = array(); - private $isNotCacheableResponseEmbedded = false; - - /** - * {@inheritdoc} - */ - public function add(Response $response) - { - if (!$response->isFresh() || !$response->isCacheable()) { - $this->cacheable = false; - } else { - $maxAge = $response->getMaxAge(); - $this->ttls[] = $response->getTtl(); - $this->maxAges[] = $maxAge; - - if (null === $maxAge) { - $this->isNotCacheableResponseEmbedded = true; - } - } - - ++$this->embeddedResponses; - } - - /** - * {@inheritdoc} - */ - public function update(Response $response) - { - // if we have no embedded Response, do nothing - if (0 === $this->embeddedResponses) { - return; - } - - // Remove validation related headers in order to avoid browsers using - // their own cache, because some of the response content comes from - // at least one embedded response (which likely has a different caching strategy). - if ($response->isValidateable()) { - $response->setEtag(null); - $response->setLastModified(null); - } - - if (!$response->isFresh()) { - $this->cacheable = false; - } - - if (!$this->cacheable) { - $response->headers->set('Cache-Control', 'no-cache, must-revalidate'); - - return; - } - - $this->ttls[] = $response->getTtl(); - $this->maxAges[] = $response->getMaxAge(); - - if ($this->isNotCacheableResponseEmbedded) { - $response->headers->removeCacheControlDirective('s-maxage'); - } elseif (null !== $maxAge = min($this->maxAges)) { - $response->setSharedMaxAge($maxAge); - $response->headers->set('Age', $maxAge - min($this->ttls)); - } - $response->setMaxAge(0); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategyInterface.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategyInterface.php deleted file mode 100644 index e282299ae..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategyInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Response; - -/** - * ResponseCacheStrategyInterface implementations know how to compute the - * Response cache HTTP header based on the different response cache headers. - * - * @author Fabien Potencier - */ -interface ResponseCacheStrategyInterface -{ - /** - * Adds a Response. - */ - public function add(Response $response); - - /** - * Updates the Response HTTP headers based on the embedded Responses. - */ - public function update(Response $response); -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/Ssi.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/Ssi.php deleted file mode 100644 index 3178c3351..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/Ssi.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Ssi implements the SSI capabilities to Request and Response instances. - * - * @author Sebastian Krebs - */ -class Ssi extends AbstractSurrogate -{ - /** - * {@inheritdoc} - */ - public function getName() - { - return 'ssi'; - } - - /** - * {@inheritdoc} - */ - public function addSurrogateControl(Response $response) - { - if (false !== strpos($response->getContent(), '', $uri); - } - - /** - * {@inheritdoc} - */ - public function process(Request $request, Response $response) - { - $type = $response->headers->get('Content-Type'); - if (empty($type)) { - $type = 'text/html'; - } - - $parts = explode(';', $type); - if (!in_array($parts[0], $this->contentTypes)) { - return $response; - } - - // we don't use a proper XML parser here as we can have SSI tags in a plain text response - $content = $response->getContent(); - - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); - $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); - - $i = 1; - while (isset($chunks[$i])) { - $options = array(); - preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); - foreach ($matches as $set) { - $options[$set[1]] = $set[2]; - } - - if (!isset($options['virtual'])) { - throw new \RuntimeException('Unable to process an SSI tag without a "virtual" attribute.'); - } - - $chunks[$i] = sprintf('surrogate->handle($this, %s, \'\', false) ?>'."\n", - var_export($options['virtual'], true) - ); - ++$i; - $chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]); - ++$i; - } - $content = implode('', $chunks); - - $response->setContent($content); - $response->headers->set('X-Body-Eval', 'SSI'); - - // remove SSI/1.0 from the Surrogate-Control header - $this->removeFromControl($response); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/Store.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/Store.php deleted file mode 100644 index fa0d4a867..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/Store.php +++ /dev/null @@ -1,485 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Store implements all the logic for storing cache metadata (Request and Response headers). - * - * @author Fabien Potencier - */ -class Store implements StoreInterface -{ - protected $root; - private $keyCache; - private $locks; - - /** - * @param string $root The path to the cache directory - * - * @throws \RuntimeException - */ - public function __construct($root) - { - $this->root = $root; - if (!file_exists($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) { - throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); - } - $this->keyCache = new \SplObjectStorage(); - $this->locks = array(); - } - - /** - * Cleanups storage. - */ - public function cleanup() - { - // unlock everything - foreach ($this->locks as $lock) { - flock($lock, LOCK_UN); - fclose($lock); - } - - $this->locks = array(); - } - - /** - * Tries to lock the cache for a given Request, without blocking. - * - * @return bool|string true if the lock is acquired, the path to the current lock otherwise - */ - public function lock(Request $request) - { - $key = $this->getCacheKey($request); - - if (!isset($this->locks[$key])) { - $path = $this->getPath($key); - if (!file_exists(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) { - return $path; - } - $h = fopen($path, 'cb'); - if (!flock($h, LOCK_EX | LOCK_NB)) { - fclose($h); - - return $path; - } - - $this->locks[$key] = $h; - } - - return true; - } - - /** - * Releases the lock for the given Request. - * - * @return bool False if the lock file does not exist or cannot be unlocked, true otherwise - */ - public function unlock(Request $request) - { - $key = $this->getCacheKey($request); - - if (isset($this->locks[$key])) { - flock($this->locks[$key], LOCK_UN); - fclose($this->locks[$key]); - unset($this->locks[$key]); - - return true; - } - - return false; - } - - public function isLocked(Request $request) - { - $key = $this->getCacheKey($request); - - if (isset($this->locks[$key])) { - return true; // shortcut if lock held by this process - } - - if (!file_exists($path = $this->getPath($key))) { - return false; - } - - $h = fopen($path, 'rb'); - flock($h, LOCK_EX | LOCK_NB, $wouldBlock); - flock($h, LOCK_UN); // release the lock we just acquired - fclose($h); - - return (bool) $wouldBlock; - } - - /** - * Locates a cached Response for the Request provided. - * - * @return Response|null A Response instance, or null if no cache entry was found - */ - public function lookup(Request $request) - { - $key = $this->getCacheKey($request); - - if (!$entries = $this->getMetadata($key)) { - return; - } - - // find a cached entry that matches the request. - $match = null; - foreach ($entries as $entry) { - if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? implode(', ', $entry[1]['vary']) : '', $request->headers->all(), $entry[0])) { - $match = $entry; - - break; - } - } - - if (null === $match) { - return; - } - - $headers = $match[1]; - if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) { - return $this->restoreResponse($headers, $body); - } - - // TODO the metaStore referenced an entity that doesn't exist in - // the entityStore. We definitely want to return nil but we should - // also purge the entry from the meta-store when this is detected. - } - - /** - * Writes a cache entry to the store for the given Request and Response. - * - * Existing entries are read and any that match the response are removed. This - * method calls write with the new list of cache entries. - * - * @return string The key under which the response is stored - * - * @throws \RuntimeException - */ - public function write(Request $request, Response $response) - { - $key = $this->getCacheKey($request); - $storedEnv = $this->persistRequest($request); - - // write the response body to the entity store if this is the original response - if (!$response->headers->has('X-Content-Digest')) { - $digest = $this->generateContentDigest($response); - - if (false === $this->save($digest, $response->getContent())) { - throw new \RuntimeException('Unable to store the entity.'); - } - - $response->headers->set('X-Content-Digest', $digest); - - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); - } - } - - // read existing cache entries, remove non-varying, and add this one to the list - $entries = array(); - $vary = $response->headers->get('vary'); - foreach ($this->getMetadata($key) as $entry) { - if (!isset($entry[1]['vary'][0])) { - $entry[1]['vary'] = array(''); - } - - if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { - $entries[] = $entry; - } - } - - $headers = $this->persistResponse($response); - unset($headers['age']); - - array_unshift($entries, array($storedEnv, $headers)); - - if (false === $this->save($key, serialize($entries))) { - throw new \RuntimeException('Unable to store the metadata.'); - } - - return $key; - } - - /** - * Returns content digest for $response. - * - * @return string - */ - protected function generateContentDigest(Response $response) - { - return 'en'.hash('sha256', $response->getContent()); - } - - /** - * Invalidates all cache entries that match the request. - * - * @throws \RuntimeException - */ - public function invalidate(Request $request) - { - $modified = false; - $key = $this->getCacheKey($request); - - $entries = array(); - foreach ($this->getMetadata($key) as $entry) { - $response = $this->restoreResponse($entry[1]); - if ($response->isFresh()) { - $response->expire(); - $modified = true; - $entries[] = array($entry[0], $this->persistResponse($response)); - } else { - $entries[] = $entry; - } - } - - if ($modified && false === $this->save($key, serialize($entries))) { - throw new \RuntimeException('Unable to store the metadata.'); - } - } - - /** - * Determines whether two Request HTTP header sets are non-varying based on - * the vary response header value provided. - * - * @param string $vary A Response vary header - * @param array $env1 A Request HTTP header array - * @param array $env2 A Request HTTP header array - * - * @return bool true if the two environments match, false otherwise - */ - private function requestsMatch($vary, $env1, $env2) - { - if (empty($vary)) { - return true; - } - - foreach (preg_split('/[\s,]+/', $vary) as $header) { - $key = str_replace('_', '-', strtolower($header)); - $v1 = isset($env1[$key]) ? $env1[$key] : null; - $v2 = isset($env2[$key]) ? $env2[$key] : null; - if ($v1 !== $v2) { - return false; - } - } - - return true; - } - - /** - * Gets all data associated with the given key. - * - * Use this method only if you know what you are doing. - * - * @param string $key The store key - * - * @return array An array of data associated with the key - */ - private function getMetadata($key) - { - if (!$entries = $this->load($key)) { - return array(); - } - - return unserialize($entries); - } - - /** - * Purges data for the given URL. - * - * This method purges both the HTTP and the HTTPS version of the cache entry. - * - * @param string $url A URL - * - * @return bool true if the URL exists with either HTTP or HTTPS scheme and has been purged, false otherwise - */ - public function purge($url) - { - $http = preg_replace('#^https:#', 'http:', $url); - $https = preg_replace('#^http:#', 'https:', $url); - - $purgedHttp = $this->doPurge($http); - $purgedHttps = $this->doPurge($https); - - return $purgedHttp || $purgedHttps; - } - - /** - * Purges data for the given URL. - * - * @param string $url A URL - * - * @return bool true if the URL exists and has been purged, false otherwise - */ - private function doPurge($url) - { - $key = $this->getCacheKey(Request::create($url)); - if (isset($this->locks[$key])) { - flock($this->locks[$key], LOCK_UN); - fclose($this->locks[$key]); - unset($this->locks[$key]); - } - - if (file_exists($path = $this->getPath($key))) { - unlink($path); - - return true; - } - - return false; - } - - /** - * Loads data for the given key. - * - * @param string $key The store key - * - * @return string The data associated with the key - */ - private function load($key) - { - $path = $this->getPath($key); - - return file_exists($path) ? file_get_contents($path) : false; - } - - /** - * Save data for the given key. - * - * @param string $key The store key - * @param string $data The data to store - * - * @return bool - */ - private function save($key, $data) - { - $path = $this->getPath($key); - - if (isset($this->locks[$key])) { - $fp = $this->locks[$key]; - @ftruncate($fp, 0); - @fseek($fp, 0); - $len = @fwrite($fp, $data); - if (strlen($data) !== $len) { - @ftruncate($fp, 0); - - return false; - } - } else { - if (!file_exists(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) { - return false; - } - - $tmpFile = tempnam(dirname($path), basename($path)); - if (false === $fp = @fopen($tmpFile, 'wb')) { - return false; - } - @fwrite($fp, $data); - @fclose($fp); - - if ($data != file_get_contents($tmpFile)) { - return false; - } - - if (false === @rename($tmpFile, $path)) { - return false; - } - } - - @chmod($path, 0666 & ~umask()); - } - - public function getPath($key) - { - return $this->root.DIRECTORY_SEPARATOR.substr($key, 0, 2).DIRECTORY_SEPARATOR.substr($key, 2, 2).DIRECTORY_SEPARATOR.substr($key, 4, 2).DIRECTORY_SEPARATOR.substr($key, 6); - } - - /** - * Generates a cache key for the given Request. - * - * This method should return a key that must only depend on a - * normalized version of the request URI. - * - * If the same URI can have more than one representation, based on some - * headers, use a Vary header to indicate them, and each representation will - * be stored independently under the same cache key. - * - * @return string A key for the given Request - */ - protected function generateCacheKey(Request $request) - { - return 'md'.hash('sha256', $request->getUri()); - } - - /** - * Returns a cache key for the given Request. - * - * @return string A key for the given Request - */ - private function getCacheKey(Request $request) - { - if (isset($this->keyCache[$request])) { - return $this->keyCache[$request]; - } - - return $this->keyCache[$request] = $this->generateCacheKey($request); - } - - /** - * Persists the Request HTTP headers. - * - * @return array An array of HTTP headers - */ - private function persistRequest(Request $request) - { - return $request->headers->all(); - } - - /** - * Persists the Response HTTP headers. - * - * @return array An array of HTTP headers - */ - private function persistResponse(Response $response) - { - $headers = $response->headers->all(); - $headers['X-Status'] = array($response->getStatusCode()); - - return $headers; - } - - /** - * Restores a Response from the HTTP headers and body. - * - * @param array $headers An array of HTTP headers for the Response - * @param string $body The Response body - * - * @return Response - */ - private function restoreResponse($headers, $body = null) - { - $status = $headers['X-Status'][0]; - unset($headers['X-Status']); - - if (null !== $body) { - $headers['X-Body-File'] = array($body); - } - - return new Response($body, $status, $headers); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/StoreInterface.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/StoreInterface.php deleted file mode 100644 index 8f1cf4409..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/StoreInterface.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Interface implemented by HTTP cache stores. - * - * @author Fabien Potencier - */ -interface StoreInterface -{ - /** - * Locates a cached Response for the Request provided. - * - * @return Response|null A Response instance, or null if no cache entry was found - */ - public function lookup(Request $request); - - /** - * Writes a cache entry to the store for the given Request and Response. - * - * Existing entries are read and any that match the response are removed. This - * method calls write with the new list of cache entries. - * - * @return string The key under which the response is stored - */ - public function write(Request $request, Response $response); - - /** - * Invalidates all cache entries that match the request. - */ - public function invalidate(Request $request); - - /** - * Locks the cache for a given Request. - * - * @return bool|string true if the lock is acquired, the path to the current lock otherwise - */ - public function lock(Request $request); - - /** - * Releases the lock for the given Request. - * - * @return bool 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. - * - * @return bool true if lock exists, false otherwise - */ - public function isLocked(Request $request); - - /** - * Purges data for the given URL. - * - * @param string $url A URL - * - * @return bool true if the URL exists and has been purged, false otherwise - */ - public function purge($url); - - /** - * Cleanups storage. - */ - public function cleanup(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpCache/SurrogateInterface.php b/lib/silex/vendor/symfony/http-kernel/HttpCache/SurrogateInterface.php deleted file mode 100644 index 85391f8f3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpCache/SurrogateInterface.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -interface SurrogateInterface -{ - /** - * Returns surrogate name. - * - * @return string - */ - public function getName(); - - /** - * Returns a new cache strategy instance. - * - * @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance - */ - public function createCacheStrategy(); - - /** - * Checks that at least one surrogate has Surrogate capability. - * - * @return bool true if one surrogate has Surrogate capability, false otherwise - */ - public function hasSurrogateCapability(Request $request); - - /** - * Adds Surrogate-capability to the given Request. - */ - public function addSurrogateCapability(Request $request); - - /** - * Adds HTTP headers to specify that the Response needs to be parsed for Surrogate. - * - * This method only adds an Surrogate HTTP header if the Response has some Surrogate tags. - */ - public function addSurrogateControl(Response $response); - - /** - * Checks that the Response needs to be parsed for Surrogate tags. - * - * @return bool true if the Response needs to be parsed, false otherwise - */ - public function needsParsing(Response $response); - - /** - * Renders a Surrogate tag. - * - * @param string $uri A URI - * @param string $alt An alternate URI - * @param bool $ignoreErrors Whether to ignore errors or not - * @param string $comment A comment to add as an esi:include tag - * - * @return string - */ - public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = ''); - - /** - * Replaces a Response Surrogate tags with the included resource content. - * - * @return Response - */ - public function process(Request $request, Response $response); - - /** - * Handles a Surrogate from the cache. - * - * @param HttpCache $cache An HttpCache instance - * @param string $uri The main URI - * @param string $alt An alternative URI - * @param bool $ignoreErrors Whether to ignore errors or not - * - * @return string - * - * @throws \RuntimeException - * @throws \Exception - */ - public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors); -} diff --git a/lib/silex/vendor/symfony/http-kernel/HttpKernel.php b/lib/silex/vendor/symfony/http-kernel/HttpKernel.php deleted file mode 100644 index 41f8913be..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpKernel.php +++ /dev/null @@ -1,299 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpKernel\Controller\ArgumentResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * HttpKernel notifies events to convert a Request object to a Response one. - * - * @author Fabien Potencier - */ -class HttpKernel implements HttpKernelInterface, TerminableInterface -{ - protected $dispatcher; - protected $resolver; - protected $requestStack; - private $argumentResolver; - - public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, RequestStack $requestStack = null, ArgumentResolverInterface $argumentResolver = null) - { - $this->dispatcher = $dispatcher; - $this->resolver = $resolver; - $this->requestStack = $requestStack ?: new RequestStack(); - $this->argumentResolver = $argumentResolver; - - if (null === $this->argumentResolver) { - @trigger_error(sprintf('As of 3.1 an %s is used to resolve arguments. In 4.0 the $argumentResolver becomes the %s if no other is provided instead of using the $resolver argument.', ArgumentResolverInterface::class, ArgumentResolver::class), E_USER_DEPRECATED); - // fallback in case of deprecations - $this->argumentResolver = $resolver; - } - } - - /** - * {@inheritdoc} - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - $request->headers->set('X-Php-Ob-Level', ob_get_level()); - - try { - return $this->handleRaw($request, $type); - } catch (\Exception $e) { - if ($e instanceof RequestExceptionInterface) { - $e = new BadRequestHttpException($e->getMessage(), $e); - } - if (false === $catch) { - $this->finishRequest($request, $type); - - throw $e; - } - - return $this->handleException($e, $request, $type); - } - } - - /** - * {@inheritdoc} - */ - public function terminate(Request $request, Response $response) - { - $this->dispatcher->dispatch(KernelEvents::TERMINATE, new PostResponseEvent($this, $request, $response)); - } - - /** - * @internal - */ - public function terminateWithException(\Exception $exception, Request $request = null) - { - if (!$request = $request ?: $this->requestStack->getMasterRequest()) { - throw $exception; - } - - $response = $this->handleException($exception, $request, self::MASTER_REQUEST); - - $response->sendHeaders(); - $response->sendContent(); - - $this->terminate($request, $response); - } - - /** - * Handles a request to convert it to a response. - * - * Exceptions are not caught. - * - * @param Request $request A Request instance - * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * - * @return Response A Response instance - * - * @throws \LogicException If one of the listener does not behave as expected - * @throws NotFoundHttpException When controller cannot be found - */ - private function handleRaw(Request $request, $type = self::MASTER_REQUEST) - { - $this->requestStack->push($request); - - // request - $event = new GetResponseEvent($this, $request, $type); - $this->dispatcher->dispatch(KernelEvents::REQUEST, $event); - - if ($event->hasResponse()) { - return $this->filterResponse($event->getResponse(), $request, $type); - } - - // load controller - if (false === $controller = $this->resolver->getController($request)) { - throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); - } - - $event = new FilterControllerEvent($this, $controller, $request, $type); - $this->dispatcher->dispatch(KernelEvents::CONTROLLER, $event); - $controller = $event->getController(); - - // controller arguments - $arguments = $this->argumentResolver->getArguments($request, $controller); - - $event = new FilterControllerArgumentsEvent($this, $controller, $arguments, $request, $type); - $this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS, $event); - $controller = $event->getController(); - $arguments = $event->getArguments(); - - // call controller - $response = \call_user_func_array($controller, $arguments); - - // view - if (!$response instanceof Response) { - $event = new GetResponseForControllerResultEvent($this, $request, $type, $response); - $this->dispatcher->dispatch(KernelEvents::VIEW, $event); - - if ($event->hasResponse()) { - $response = $event->getResponse(); - } - - if (!$response instanceof Response) { - $msg = sprintf('The controller must return a response (%s given).', $this->varToString($response)); - - // the user may have forgotten to return something - if (null === $response) { - $msg .= ' Did you forget to add a return statement somewhere in your controller?'; - } - throw new \LogicException($msg); - } - } - - return $this->filterResponse($response, $request, $type); - } - - /** - * Filters a response object. - * - * @param Response $response A Response instance - * @param Request $request An error message in case the response is not a Response object - * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * - * @return Response The filtered Response instance - * - * @throws \RuntimeException if the passed object is not a Response instance - */ - private function filterResponse(Response $response, Request $request, $type) - { - $event = new FilterResponseEvent($this, $request, $type, $response); - - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->finishRequest($request, $type); - - return $event->getResponse(); - } - - /** - * Publishes the finish request event, then pop the request from the stack. - * - * Note that the order of the operations is important here, otherwise - * operations such as {@link RequestStack::getParentRequest()} can lead to - * weird results. - * - * @param Request $request - * @param int $type - */ - private function finishRequest(Request $request, $type) - { - $this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this, $request, $type)); - $this->requestStack->pop(); - } - - /** - * Handles an exception by trying to convert it to a Response. - * - * @param \Exception $e An \Exception instance - * @param Request $request A Request instance - * @param int $type The type of the request - * - * @return Response A Response instance - * - * @throws \Exception - */ - private function handleException(\Exception $e, $request, $type) - { - $event = new GetResponseForExceptionEvent($this, $request, $type, $e); - $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event); - - // a listener might have replaced the exception - $e = $event->getException(); - - if (!$event->hasResponse()) { - $this->finishRequest($request, $type); - - throw $e; - } - - $response = $event->getResponse(); - - // the developer asked for a specific status code - if ($response->headers->has('X-Status-Code')) { - @trigger_error(sprintf('Using the X-Status-Code header is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s::allowCustomResponseCode() instead.', GetResponseForExceptionEvent::class), E_USER_DEPRECATED); - - $response->setStatusCode($response->headers->get('X-Status-Code')); - - $response->headers->remove('X-Status-Code'); - } elseif (!$event->isAllowingCustomResponseCode() && !$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) { - // ensure that we actually have an error response - if ($e instanceof HttpExceptionInterface) { - // keep the HTTP status code and headers - $response->setStatusCode($e->getStatusCode()); - $response->headers->add($e->getHeaders()); - } else { - $response->setStatusCode(500); - } - } - - try { - return $this->filterResponse($response, $request, $type); - } catch (\Exception $e) { - return $response; - } - } - - private 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/lib/silex/vendor/symfony/http-kernel/HttpKernelInterface.php b/lib/silex/vendor/symfony/http-kernel/HttpKernelInterface.php deleted file mode 100644 index 5050bfcfb..000000000 --- a/lib/silex/vendor/symfony/http-kernel/HttpKernelInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * HttpKernelInterface handles a Request to convert it to a Response. - * - * @author Fabien Potencier - */ -interface HttpKernelInterface -{ - const MASTER_REQUEST = 1; - const SUB_REQUEST = 2; - - /** - * Handles a Request to convert it to a Response. - * - * When $catch is true, the implementation must catch all exceptions - * and do its best to convert them to a Response instance. - * - * @param Request $request A Request instance - * @param int $type The type of the request - * (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * @param bool $catch Whether to catch exceptions or not - * - * @return Response A Response instance - * - * @throws \Exception When an Exception occurs during processing - */ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Kernel.php b/lib/silex/vendor/symfony/http-kernel/Kernel.php deleted file mode 100644 index eb2364e46..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Kernel.php +++ /dev/null @@ -1,969 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; -use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Compiler\PassConfig; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\Loader\IniFileLoader; -use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -use Symfony\Component\DependencyInjection\Loader\DirectoryLoader; -use Symfony\Component\DependencyInjection\Loader\ClosureLoader; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\HttpKernel\Config\EnvParametersResource; -use Symfony\Component\HttpKernel\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; -use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; -use Symfony\Component\Config\Loader\GlobFileLoader; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\Config\Loader\DelegatingLoader; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\ClassLoader\ClassCollectionLoader; - -/** - * The Kernel is the heart of the Symfony system. - * - * It manages an environment made of bundles. - * - * @author Fabien Potencier - */ -abstract class Kernel implements KernelInterface, RebootableInterface, TerminableInterface -{ - /** - * @var BundleInterface[] - */ - protected $bundles = array(); - - protected $bundleMap; - protected $container; - protected $rootDir; - protected $environment; - protected $debug; - protected $booted = false; - protected $name; - protected $startTime; - protected $loadClassCache; - - private $projectDir; - private $warmupDir; - private $requestStackSize = 0; - private $resetServices = false; - - const VERSION = '3.4.4'; - const VERSION_ID = 30404; - const MAJOR_VERSION = 3; - const MINOR_VERSION = 4; - const RELEASE_VERSION = 4; - const EXTRA_VERSION = ''; - - const END_OF_MAINTENANCE = '11/2020'; - const END_OF_LIFE = '11/2021'; - - /** - * @param string $environment The environment - * @param bool $debug Whether to enable debugging or not - */ - public function __construct($environment, $debug) - { - $this->environment = $environment; - $this->debug = (bool) $debug; - $this->rootDir = $this->getRootDir(); - $this->name = $this->getName(); - - if ($this->debug) { - $this->startTime = microtime(true); - } - } - - public function __clone() - { - if ($this->debug) { - $this->startTime = microtime(true); - } - - $this->booted = false; - $this->container = null; - $this->requestStackSize = 0; - $this->resetServices = false; - } - - /** - * Boots the current kernel. - */ - public function boot() - { - if (true === $this->booted) { - if (!$this->requestStackSize && $this->resetServices) { - if ($this->container->has('services_resetter')) { - $this->container->get('services_resetter')->reset(); - } - $this->resetServices = false; - } - - return; - } - if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) { - putenv('SHELL_VERBOSITY=3'); - $_ENV['SHELL_VERBOSITY'] = 3; - $_SERVER['SHELL_VERBOSITY'] = 3; - } - - if ($this->loadClassCache) { - $this->doLoadClassCache($this->loadClassCache[0], $this->loadClassCache[1]); - } - - // init bundles - $this->initializeBundles(); - - // init container - $this->initializeContainer(); - - foreach ($this->getBundles() as $bundle) { - $bundle->setContainer($this->container); - $bundle->boot(); - } - - $this->booted = true; - } - - /** - * {@inheritdoc} - */ - public function reboot($warmupDir) - { - $this->shutdown(); - $this->warmupDir = $warmupDir; - $this->boot(); - } - - /** - * {@inheritdoc} - */ - public function terminate(Request $request, Response $response) - { - if (false === $this->booted) { - return; - } - - if ($this->getHttpKernel() instanceof TerminableInterface) { - $this->getHttpKernel()->terminate($request, $response); - } - } - - /** - * {@inheritdoc} - */ - public function shutdown() - { - if (false === $this->booted) { - return; - } - - $this->booted = false; - - foreach ($this->getBundles() as $bundle) { - $bundle->shutdown(); - $bundle->setContainer(null); - } - - $this->container = null; - $this->requestStackSize = 0; - $this->resetServices = false; - } - - /** - * {@inheritdoc} - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - $this->boot(); - ++$this->requestStackSize; - $this->resetServices = true; - - try { - return $this->getHttpKernel()->handle($request, $type, $catch); - } finally { - --$this->requestStackSize; - } - } - - /** - * Gets a HTTP kernel from the container. - * - * @return HttpKernel - */ - protected function getHttpKernel() - { - return $this->container->get('http_kernel'); - } - - /** - * {@inheritdoc} - */ - public function getBundles() - { - return $this->bundles; - } - - /** - * {@inheritdoc} - */ - public function getBundle($name, $first = true/*, $noDeprecation = false */) - { - $noDeprecation = false; - if (func_num_args() >= 3) { - $noDeprecation = func_get_arg(2); - } - - if (!$first && !$noDeprecation) { - @trigger_error(sprintf('Passing "false" as the second argument to %s() is deprecated as of 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); - } - - 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() method of your %s.php file?', $name, get_class($this))); - } - - if (true === $first) { - return $this->bundleMap[$name][0]; - } - - return $this->bundleMap[$name]; - } - - /** - * {@inheritdoc} - * - * @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle - */ - public function locateResource($name, $dir = null, $first = true) - { - if ('@' !== $name[0]) { - throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name)); - } - - if (false !== strpos($name, '..')) { - throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name)); - } - - $bundleName = substr($name, 1); - $path = ''; - if (false !== strpos($bundleName, '/')) { - list($bundleName, $path) = explode('/', $bundleName, 2); - } - - $isResource = 0 === strpos($path, 'Resources') && null !== $dir; - $overridePath = substr($path, 9); - $resourceBundle = null; - $bundles = $this->getBundle($bundleName, false, true); - $files = array(); - - foreach ($bundles as $bundle) { - if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) { - if (null !== $resourceBundle) { - throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', - $file, - $resourceBundle, - $dir.'/'.$bundles[0]->getName().$overridePath - )); - } - - if ($first) { - return $file; - } - $files[] = $file; - } - - if (file_exists($file = $bundle->getPath().'/'.$path)) { - if ($first && !$isResource) { - return $file; - } - $files[] = $file; - $resourceBundle = $bundle->getName(); - } - } - - if (count($files) > 0) { - return $first && $isResource ? $files[0] : $files; - } - - throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name)); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - if (null === $this->name) { - $this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir)); - if (ctype_digit($this->name[0])) { - $this->name = '_'.$this->name; - } - } - - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getEnvironment() - { - return $this->environment; - } - - /** - * {@inheritdoc} - */ - public function isDebug() - { - return $this->debug; - } - - /** - * {@inheritdoc} - */ - public function getRootDir() - { - if (null === $this->rootDir) { - $r = new \ReflectionObject($this); - $this->rootDir = dirname($r->getFileName()); - } - - return $this->rootDir; - } - - /** - * Gets the application root dir (path of the project's composer file). - * - * @return string The project root dir - */ - public function getProjectDir() - { - if (null === $this->projectDir) { - $r = new \ReflectionObject($this); - $dir = $rootDir = dirname($r->getFileName()); - while (!file_exists($dir.'/composer.json')) { - if ($dir === dirname($dir)) { - return $this->projectDir = $rootDir; - } - $dir = dirname($dir); - } - $this->projectDir = $dir; - } - - return $this->projectDir; - } - - /** - * {@inheritdoc} - */ - public function getContainer() - { - return $this->container; - } - - /** - * Loads the PHP class cache. - * - * This methods only registers the fact that you want to load the cache classes. - * The cache will actually only be loaded when the Kernel is booted. - * - * That optimization is mainly useful when using the HttpCache class in which - * case the class cache is not loaded if the Response is in the cache. - * - * @param string $name The cache name prefix - * @param string $extension File extension of the resulting file - * - * @deprecated since version 3.3, to be removed in 4.0. The class cache is not needed anymore when using PHP 7.0. - */ - public function loadClassCache($name = 'classes', $extension = '.php') - { - if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); - } - - $this->loadClassCache = array($name, $extension); - } - - /** - * @internal - * - * @deprecated since version 3.3, to be removed in 4.0. - */ - public function setClassCache(array $classes) - { - if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); - } - - file_put_contents(($this->warmupDir ?: $this->getCacheDir()).'/classes.map', sprintf('warmupDir ?: $this->getCacheDir()).'/annotations.map', sprintf('debug ? $this->startTime : -INF; - } - - /** - * {@inheritdoc} - */ - public function getCacheDir() - { - return $this->rootDir.'/cache/'.$this->environment; - } - - /** - * {@inheritdoc} - */ - public function getLogDir() - { - return $this->rootDir.'/logs'; - } - - /** - * {@inheritdoc} - */ - public function getCharset() - { - return 'UTF-8'; - } - - /** - * @deprecated since version 3.3, to be removed in 4.0. - */ - protected function doLoadClassCache($name, $extension) - { - if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); - } - $cacheDir = $this->warmupDir ?: $this->getCacheDir(); - - if (!$this->booted && is_file($cacheDir.'/classes.map')) { - ClassCollectionLoader::load(include($cacheDir.'/classes.map'), $cacheDir, $name, $this->debug, false, $extension); - } - } - - /** - * Initializes the data structures related to the bundle management. - * - * - the bundles property maps a bundle name to the bundle instance, - * - the bundleMap property maps a bundle name to the bundle inheritance hierarchy (most derived bundle first). - * - * @throws \LogicException if two bundles share a common name - * @throws \LogicException if a bundle tries to extend a non-registered bundle - * @throws \LogicException if a bundle tries to extend itself - * @throws \LogicException if two bundles extend the same ancestor - */ - protected function initializeBundles() - { - // init bundles - $this->bundles = array(); - $topMostBundles = array(); - $directChildren = array(); - - foreach ($this->registerBundles() as $bundle) { - $name = $bundle->getName(); - if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name)); - } - $this->bundles[$name] = $bundle; - - if ($parentName = $bundle->getParent()) { - @trigger_error('Bundle inheritance is deprecated as of 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); - - if (isset($directChildren[$parentName])) { - throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName])); - } - if ($parentName == $name) { - throw new \LogicException(sprintf('Bundle "%s" can not extend itself.', $name)); - } - $directChildren[$parentName] = $name; - } else { - $topMostBundles[$name] = $bundle; - } - } - - // look for orphans - if (!empty($directChildren) && count($diff = array_diff_key($directChildren, $this->bundles))) { - $diff = array_keys($diff); - - throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0])); - } - - // inheritance - $this->bundleMap = array(); - foreach ($topMostBundles as $name => $bundle) { - $bundleMap = array($bundle); - $hierarchy = array($name); - - while (isset($directChildren[$name])) { - $name = $directChildren[$name]; - array_unshift($bundleMap, $this->bundles[$name]); - $hierarchy[] = $name; - } - - foreach ($hierarchy as $hierarchyBundle) { - $this->bundleMap[$hierarchyBundle] = $bundleMap; - array_pop($bundleMap); - } - } - } - - /** - * The extension point similar to the Bundle::build() method. - * - * Use this method to register compiler passes and manipulate the container during the building process. - */ - protected function build(ContainerBuilder $container) - { - } - - /** - * Gets the container class. - * - * @return string The container class - */ - protected function getContainerClass() - { - return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer'; - } - - /** - * Gets the container's base class. - * - * All names except Container must be fully qualified. - * - * @return string - */ - protected function getContainerBaseClass() - { - return 'Container'; - } - - /** - * Initializes the service container. - * - * The cached version of the service container is used when fresh, otherwise the - * container is built. - */ - protected function initializeContainer() - { - $class = $this->getContainerClass(); - $cacheDir = $this->warmupDir ?: $this->getCacheDir(); - $cache = new ConfigCache($cacheDir.'/'.$class.'.php', $this->debug); - $oldContainer = null; - if ($fresh = $cache->isFresh()) { - // Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors - $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); - $fresh = $oldContainer = false; - try { - if (\is_object($this->container = include $cache->getPath())) { - $this->container->set('kernel', $this); - $oldContainer = $this->container; - $fresh = true; - } - } catch (\Throwable $e) { - } catch (\Exception $e) { - } finally { - error_reporting($errorLevel); - } - } - - if ($fresh) { - return; - } - - if ($this->debug) { - $collectedLogs = array(); - $previousHandler = defined('PHPUNIT_COMPOSER_INSTALL'); - $previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) { - if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { - return $previousHandler ? $previousHandler($type, $message, $file, $line) : false; - } - - if (isset($collectedLogs[$message])) { - ++$collectedLogs[$message]['count']; - - return; - } - - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); - // Clean the trace by removing first frames added by the error handler itself. - for ($i = 0; isset($backtrace[$i]); ++$i) { - if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { - $backtrace = array_slice($backtrace, 1 + $i); - break; - } - } - - $collectedLogs[$message] = array( - 'type' => $type, - 'message' => $message, - 'file' => $file, - 'line' => $line, - 'trace' => $backtrace, - 'count' => 1, - ); - }); - } - - try { - $container = null; - $container = $this->buildContainer(); - $container->compile(); - } finally { - if ($this->debug && true !== $previousHandler) { - restore_error_handler(); - - file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs))); - file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : ''); - } - } - - if (null === $oldContainer) { - $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); - try { - $oldContainer = include $cache->getPath(); - } catch (\Throwable $e) { - } catch (\Exception $e) { - } finally { - error_reporting($errorLevel); - } - } - $oldContainer = is_object($oldContainer) ? new \ReflectionClass($oldContainer) : false; - - $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - $this->container = require $cache->getPath(); - $this->container->set('kernel', $this); - - if ($oldContainer && get_class($this->container) !== $oldContainer->name) { - // Because concurrent requests might still be using them, - // old container files are not removed immediately, - // but on a next dump of the container. - $oldContainerDir = dirname($oldContainer->getFileName()); - foreach (glob(dirname($oldContainerDir).'/*.legacy') as $legacyContainer) { - if ($oldContainerDir.'.legacy' !== $legacyContainer && @unlink($legacyContainer)) { - (new Filesystem())->remove(substr($legacyContainer, 0, -7)); - } - } - - touch($oldContainerDir.'.legacy'); - } - - if ($this->container->has('cache_warmer')) { - $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); - } - } - - /** - * Returns the kernel parameters. - * - * @return array An array of kernel parameters - */ - protected function getKernelParameters() - { - $bundles = array(); - $bundlesMetadata = array(); - - foreach ($this->bundles as $name => $bundle) { - $bundles[$name] = get_class($bundle); - $bundlesMetadata[$name] = array( - 'parent' => $bundle->getParent(), - 'path' => $bundle->getPath(), - 'namespace' => $bundle->getNamespace(), - ); - } - - return array_merge( - array( - 'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir, - 'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(), - 'kernel.environment' => $this->environment, - 'kernel.debug' => $this->debug, - 'kernel.name' => $this->name, - 'kernel.cache_dir' => realpath($cacheDir = $this->warmupDir ?: $this->getCacheDir()) ?: $cacheDir, - 'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(), - 'kernel.bundles' => $bundles, - 'kernel.bundles_metadata' => $bundlesMetadata, - 'kernel.charset' => $this->getCharset(), - 'kernel.container_class' => $this->getContainerClass(), - ), - $this->getEnvParameters(false) - ); - } - - /** - * Gets the environment parameters. - * - * Only the parameters starting with "SYMFONY__" are considered. - * - * @return array An array of parameters - * - * @deprecated since version 3.3, to be removed in 4.0 - */ - protected function getEnvParameters() - { - if (0 === func_num_args() || func_get_arg(0)) { - @trigger_error(sprintf('The %s() method is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax to get the value of any environment variable from configuration files instead.', __METHOD__), E_USER_DEPRECATED); - } - - $parameters = array(); - foreach ($_SERVER as $key => $value) { - if (0 === strpos($key, 'SYMFONY__')) { - @trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax instead to get the value of environment variables in configuration files.', $key), E_USER_DEPRECATED); - $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; - } - } - - return $parameters; - } - - /** - * Builds the service container. - * - * @return ContainerBuilder The compiled service container - * - * @throws \RuntimeException - */ - protected function buildContainer() - { - foreach (array('cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) { - if (!is_dir($dir)) { - if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir)); - } - } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir)); - } - } - - $container = $this->getContainerBuilder(); - $container->addObjectResource($this); - $this->prepareContainer($container); - - if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) { - $container->merge($cont); - } - - $container->addCompilerPass(new AddAnnotatedClassesToCachePass($this)); - $container->addResource(new EnvParametersResource('SYMFONY__')); - - return $container; - } - - /** - * Prepares the ContainerBuilder before it is compiled. - */ - protected function prepareContainer(ContainerBuilder $container) - { - $extensions = array(); - foreach ($this->bundles as $bundle) { - if ($extension = $bundle->getContainerExtension()) { - $container->registerExtension($extension); - $extensions[] = $extension->getAlias(); - } - - if ($this->debug) { - $container->addObjectResource($bundle); - } - } - - foreach ($this->bundles as $bundle) { - $bundle->build($container); - } - - $this->build($container); - - // ensure these extensions are implicitly loaded - $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions)); - } - - /** - * Gets a new ContainerBuilder instance used to build the service container. - * - * @return ContainerBuilder - */ - protected function getContainerBuilder() - { - $container = new ContainerBuilder(); - $container->getParameterBag()->add($this->getKernelParameters()); - - if ($this instanceof CompilerPassInterface) { - $container->addCompilerPass($this, PassConfig::TYPE_BEFORE_OPTIMIZATION, -10000); - } - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) { - $container->setProxyInstantiator(new RuntimeInstantiator()); - } - - return $container; - } - - /** - * Dumps the service container to PHP code in the cache. - * - * @param ConfigCache $cache The config cache - * @param ContainerBuilder $container The service container - * @param string $class The name of the class to generate - * @param string $baseClass The name of the container's base class - */ - protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass) - { - // cache the container - $dumper = new PhpDumper($container); - - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) { - $dumper->setProxyDumper(new ProxyDumper(substr(hash('sha256', $cache->getPath()), 0, 7))); - } - - $content = $dumper->dump(array( - 'class' => $class, - 'base_class' => $baseClass, - 'file' => $cache->getPath(), - 'as_files' => true, - 'debug' => $this->debug, - 'inline_class_loader_parameter' => \PHP_VERSION_ID >= 70000 && !$this->loadClassCache && !class_exists(ClassCollectionLoader::class, false) ? 'container.dumper.inline_class_loader' : null, - )); - - $rootCode = array_pop($content); - $dir = dirname($cache->getPath()).'/'; - $fs = new Filesystem(); - - foreach ($content as $file => $code) { - $fs->dumpFile($dir.$file, $code); - @chmod($dir.$file, 0666 & ~umask()); - } - @unlink(dirname($dir.$file).'.legacy'); - - $cache->write($rootCode, $container->getResources()); - } - - /** - * Returns a loader for the container. - * - * @return DelegatingLoader The loader - */ - protected function getContainerLoader(ContainerInterface $container) - { - $locator = new FileLocator($this); - $resolver = new LoaderResolver(array( - new XmlFileLoader($container, $locator), - new YamlFileLoader($container, $locator), - new IniFileLoader($container, $locator), - new PhpFileLoader($container, $locator), - new GlobFileLoader($locator), - new DirectoryLoader($container, $locator), - new ClosureLoader($container), - )); - - return new DelegatingLoader($resolver); - } - - /** - * 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 - */ - public static function stripComments($source) - { - if (!function_exists('token_get_all')) { - return $source; - } - - $rawChunk = ''; - $output = ''; - $tokens = token_get_all($source); - $ignoreSpace = false; - for ($i = 0; isset($tokens[$i]); ++$i) { - $token = $tokens[$i]; - if (!isset($token[1]) || 'b"' === $token) { - $rawChunk .= $token; - } elseif (T_START_HEREDOC === $token[0]) { - $output .= $rawChunk.$token[1]; - do { - $token = $tokens[++$i]; - $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; - } while (T_END_HEREDOC !== $token[0]); - $rawChunk = ''; - } elseif (T_WHITESPACE === $token[0]) { - if ($ignoreSpace) { - $ignoreSpace = false; - - continue; - } - - // replace multiple new lines with a single newline - $rawChunk .= preg_replace(array('/\n{2,}/S'), "\n", $token[1]); - } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { - $ignoreSpace = true; - } else { - $rawChunk .= $token[1]; - - // The PHP-open tag already has a new-line - if (T_OPEN_TAG === $token[0]) { - $ignoreSpace = true; - } - } - } - - $output .= $rawChunk; - - if (\PHP_VERSION_ID >= 70000) { - // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 - unset($tokens, $rawChunk); - gc_mem_caches(); - } - - return $output; - } - - public function serialize() - { - return serialize(array($this->environment, $this->debug)); - } - - public function unserialize($data) - { - if (\PHP_VERSION_ID >= 70000) { - list($environment, $debug) = unserialize($data, array('allowed_classes' => false)); - } else { - list($environment, $debug) = unserialize($data); - } - - $this->__construct($environment, $debug); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/KernelEvents.php b/lib/silex/vendor/symfony/http-kernel/KernelEvents.php deleted file mode 100644 index 674376325..000000000 --- a/lib/silex/vendor/symfony/http-kernel/KernelEvents.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -/** - * Contains all events thrown in the HttpKernel component. - * - * @author Bernhard Schussek - */ -final class KernelEvents -{ - /** - * The REQUEST event occurs at the very beginning of request - * dispatching. - * - * This event allows you to create a response for a request before any - * other code in the framework is executed. - * - * @Event("Symfony\Component\HttpKernel\Event\GetResponseEvent") - */ - const REQUEST = 'kernel.request'; - - /** - * The EXCEPTION event occurs when an uncaught exception appears. - * - * This event allows you to create a response for a thrown exception or - * to modify the thrown exception. - * - * @Event("Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent") - */ - const EXCEPTION = 'kernel.exception'; - - /** - * The VIEW event occurs when the return value of a controller - * is not a Response instance. - * - * This event allows you to create a response for the return value of the - * controller. - * - * @Event("Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent") - */ - const VIEW = 'kernel.view'; - - /** - * The CONTROLLER event occurs once a controller was found for - * handling a request. - * - * This event allows you to change the controller that will handle the - * request. - * - * @Event("Symfony\Component\HttpKernel\Event\FilterControllerEvent") - */ - const CONTROLLER = 'kernel.controller'; - - /** - * The CONTROLLER_ARGUMENTS event occurs once controller arguments have been resolved. - * - * This event allows you to change the arguments that will be passed to - * the controller. - * - * @Event("Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent") - */ - const CONTROLLER_ARGUMENTS = 'kernel.controller_arguments'; - - /** - * The RESPONSE event occurs once a response was created for - * replying to a request. - * - * This event allows you to modify or replace the response that will be - * replied. - * - * @Event("Symfony\Component\HttpKernel\Event\FilterResponseEvent") - */ - const RESPONSE = 'kernel.response'; - - /** - * The TERMINATE event occurs once a response was sent. - * - * This event allows you to run expensive post-response jobs. - * - * @Event("Symfony\Component\HttpKernel\Event\PostResponseEvent") - */ - const TERMINATE = 'kernel.terminate'; - - /** - * The FINISH_REQUEST event occurs when a response was generated for a request. - * - * This event allows you to reset the global and environmental state of - * the application, when it was changed during the request. - * - * @Event("Symfony\Component\HttpKernel\Event\FinishRequestEvent") - */ - const FINISH_REQUEST = 'kernel.finish_request'; -} diff --git a/lib/silex/vendor/symfony/http-kernel/KernelInterface.php b/lib/silex/vendor/symfony/http-kernel/KernelInterface.php deleted file mode 100644 index b341e3e9f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/KernelInterface.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\Config\Loader\LoaderInterface; - -/** - * The Kernel is the heart of the Symfony system. - * - * It manages an environment made of bundles. - * - * @author Fabien Potencier - */ -interface KernelInterface extends HttpKernelInterface, \Serializable -{ - /** - * Returns an array of bundles to register. - * - * @return BundleInterface[] An array of bundle instances - */ - public function registerBundles(); - - /** - * Loads the container configuration. - */ - public function registerContainerConfiguration(LoaderInterface $loader); - - /** - * Boots the current kernel. - */ - public function boot(); - - /** - * Shutdowns the kernel. - * - * This method is mainly useful when doing functional testing. - */ - public function shutdown(); - - /** - * Gets the registered bundle instances. - * - * @return BundleInterface[] An array of registered bundle instances - */ - public function getBundles(); - - /** - * Returns a bundle and optionally its descendants by its name. - * - * The second argument is deprecated as of 3.4 and will be removed in 4.0. This method - * will always return an instance of BundleInterface in 4.0. - * - * @param string $name Bundle name - * @param bool $first Whether to return the first bundle only or together with its descendants - * - * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false - * - * @throws \InvalidArgumentException when the bundle is not enabled - */ - public function getBundle($name, $first = true); - - /** - * Returns the file path for a given resource. - * - * A Resource can be a file or a directory. - * - * The resource name must follow the following pattern: - * - * "@BundleName/path/to/a/file.something" - * - * where BundleName is the name of the bundle - * and the remaining part is the relative path in the bundle. - * - * If $dir is passed, and the first segment of the path is "Resources", - * this method will look for a file named: - * - * $dir//path/without/Resources - * - * before looking in the bundle resource folder. - * - * @param string $name A resource name to locate - * @param string $dir A directory where to look for the resource first - * @param bool $first Whether to return the first path or paths for all matching bundles - * - * @return string|array The absolute path of the resource or an array if $first is false - * - * @throws \InvalidArgumentException if the file cannot be found or the name is not valid - * @throws \RuntimeException if the name contains invalid/unsafe characters - */ - public function locateResource($name, $dir = null, $first = true); - - /** - * Gets the name of the kernel. - * - * @return string The kernel name - */ - public function getName(); - - /** - * Gets the environment. - * - * @return string The current environment - */ - public function getEnvironment(); - - /** - * Checks if debug mode is enabled. - * - * @return bool true if debug mode is enabled, false otherwise - */ - public function isDebug(); - - /** - * Gets the application root dir (path of the project's Kernel class). - * - * @return string The Kernel root dir - */ - public function getRootDir(); - - /** - * Gets the current container. - * - * @return ContainerInterface A ContainerInterface instance - */ - public function getContainer(); - - /** - * Gets the request start time (not available if debug is disabled). - * - * @return int The request start timestamp - */ - public function getStartTime(); - - /** - * Gets the cache directory. - * - * @return string The cache directory - */ - public function getCacheDir(); - - /** - * Gets the log directory. - * - * @return string The log directory - */ - public function getLogDir(); - - /** - * Gets the charset of the application. - * - * @return string The charset - */ - public function getCharset(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/LICENSE b/lib/silex/vendor/symfony/http-kernel/LICENSE deleted file mode 100644 index 21d7fb9e2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2018 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/http-kernel/Log/DebugLoggerInterface.php b/lib/silex/vendor/symfony/http-kernel/Log/DebugLoggerInterface.php deleted file mode 100644 index f0606d3b0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Log/DebugLoggerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Log; - -/** - * DebugLoggerInterface. - * - * @author Fabien Potencier - * - * @method clear() Removes all log records. - */ -interface DebugLoggerInterface -{ - /** - * Returns an array of logs. - * - * A log is an array with the following mandatory keys: - * timestamp, message, priority, and priorityName. - * It can also have an optional context key containing an array. - * - * @return array An array of logs - */ - public function getLogs(); - - /** - * Returns the number of errors. - * - * @return int The number of errors - */ - public function countErrors(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Log/Logger.php b/lib/silex/vendor/symfony/http-kernel/Log/Logger.php deleted file mode 100644 index 617efcf13..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Log/Logger.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Log; - -use Psr\Log\AbstractLogger; -use Psr\Log\InvalidArgumentException; -use Psr\Log\LogLevel; - -/** - * Minimalist PSR-3 logger designed to write in stderr or any other stream. - * - * @author Kévin Dunglas - */ -class Logger extends AbstractLogger -{ - private static $levels = array( - LogLevel::DEBUG => 0, - LogLevel::INFO => 1, - LogLevel::NOTICE => 2, - LogLevel::WARNING => 3, - LogLevel::ERROR => 4, - LogLevel::CRITICAL => 5, - LogLevel::ALERT => 6, - LogLevel::EMERGENCY => 7, - ); - - private $minLevelIndex; - private $formatter; - private $handle; - - public function __construct($minLevel = null, $output = 'php://stderr', callable $formatter = null) - { - if (null === $minLevel) { - $minLevel = LogLevel::WARNING; - - if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { - switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { - case -1: $minLevel = LogLevel::ERROR; break; - case 1: $minLevel = LogLevel::NOTICE; break; - case 2: $minLevel = LogLevel::INFO; break; - case 3: $minLevel = LogLevel::DEBUG; break; - } - } - } - - if (!isset(self::$levels[$minLevel])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $minLevel)); - } - - $this->minLevelIndex = self::$levels[$minLevel]; - $this->formatter = $formatter ?: array($this, 'format'); - if (false === $this->handle = is_resource($output) ? $output : @fopen($output, 'a')) { - throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); - } - } - - /** - * {@inheritdoc} - */ - public function log($level, $message, array $context = array()) - { - if (!isset(self::$levels[$level])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); - } - - if (self::$levels[$level] < $this->minLevelIndex) { - return; - } - - $formatter = $this->formatter; - fwrite($this->handle, $formatter($level, $message, $context)); - } - - /** - * @param string $level - * @param string $message - * @param array $context - * - * @return string - */ - private function format($level, $message, array $context) - { - if (false !== strpos($message, '{')) { - $replacements = array(); - foreach ($context as $key => $val) { - if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { - $replacements["{{$key}}"] = $val; - } elseif ($val instanceof \DateTimeInterface) { - $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339); - } elseif (\is_object($val)) { - $replacements["{{$key}}"] = '[object '.\get_class($val).']'; - } else { - $replacements["{{$key}}"] = '['.\gettype($val).']'; - } - } - - $message = strtr($message, $replacements); - } - - return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).\PHP_EOL; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php deleted file mode 100644 index e24b2e018..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php +++ /dev/null @@ -1,292 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * Storage for profiler using files. - * - * @author Alexandre Salomé - */ -class FileProfilerStorage implements ProfilerStorageInterface -{ - /** - * Folder where profiler data are stored. - * - * @var string - */ - private $folder; - - /** - * Constructs the file storage using a "dsn-like" path. - * - * Example : "file:/path/to/the/storage/folder" - * - * @param string $dsn The DSN - * - * @throws \RuntimeException - */ - 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".', $dsn)); - } - $this->folder = substr($dsn, 5); - - if (!is_dir($this->folder) && false === @mkdir($this->folder, 0777, true) && !is_dir($this->folder)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $this->folder)); - } - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null) - { - $file = $this->getIndexFilename(); - - if (!file_exists($file)) { - return array(); - } - - $file = fopen($file, 'r'); - fseek($file, 0, SEEK_END); - - $result = array(); - while (count($result) < $limit && $line = $this->readLineFromFile($file)) { - $values = str_getcsv($line); - list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode) = $values; - $csvTime = (int) $csvTime; - - if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method) || $statusCode && false === strpos($csvStatusCode, $statusCode)) { - continue; - } - - if (!empty($start) && $csvTime < $start) { - continue; - } - - if (!empty($end) && $csvTime > $end) { - continue; - } - - $result[$csvToken] = array( - 'token' => $csvToken, - 'ip' => $csvIp, - 'method' => $csvMethod, - 'url' => $csvUrl, - 'time' => $csvTime, - 'parent' => $csvParent, - 'status_code' => $csvStatusCode, - ); - } - - fclose($file); - - return array_values($result); - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $flags = \FilesystemIterator::SKIP_DOTS; - $iterator = new \RecursiveDirectoryIterator($this->folder, $flags); - $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST); - - foreach ($iterator as $file) { - if (is_file($file)) { - unlink($file); - } else { - rmdir($file); - } - } - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (!$token || !file_exists($file = $this->getFilename($token))) { - return; - } - - return $this->createProfileFromData($token, unserialize(file_get_contents($file))); - } - - /** - * {@inheritdoc} - * - * @throws \RuntimeException - */ - public function write(Profile $profile) - { - $file = $this->getFilename($profile->getToken()); - - $profileIndexed = is_file($file); - if (!$profileIndexed) { - // Create directory - $dir = dirname($file); - if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir)); - } - } - - $profileToken = $profile->getToken(); - // when there are errors in sub-requests, the parent and/or children tokens - // may equal the profile token, resulting in infinite loops - $parentToken = $profile->getParentToken() !== $profileToken ? $profile->getParentToken() : null; - $childrenToken = array_filter(array_map(function ($p) use ($profileToken) { - return $profileToken !== $p->getToken() ? $p->getToken() : null; - }, $profile->getChildren())); - - // Store profile - $data = array( - 'token' => $profileToken, - 'parent' => $parentToken, - 'children' => $childrenToken, - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - 'status_code' => $profile->getStatusCode(), - ); - - if (false === file_put_contents($file, serialize($data))) { - return false; - } - - if (!$profileIndexed) { - // Add to index - if (false === $file = fopen($this->getIndexFilename(), 'a')) { - return false; - } - - fputcsv($file, array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - $profile->getStatusCode(), - )); - fclose($file); - } - - return true; - } - - /** - * Gets filename to store data, associated to the token. - * - * @param string $token - * - * @return string The profile filename - */ - protected function getFilename($token) - { - // Uses 4 last characters, because first are mostly the same. - $folderA = substr($token, -2, 2); - $folderB = substr($token, -4, 2); - - return $this->folder.'/'.$folderA.'/'.$folderB.'/'.$token; - } - - /** - * Gets the index filename. - * - * @return string The index filename - */ - protected function getIndexFilename() - { - return $this->folder.'/index.csv'; - } - - /** - * Reads a line in the file, backward. - * - * This function automatically skips the empty lines and do not include the line return in result value. - * - * @param resource $file The file resource, with the pointer placed at the end of the line to read - * - * @return mixed A string representing the line or null if beginning of file is reached - */ - protected function readLineFromFile($file) - { - $line = ''; - $position = ftell($file); - - if (0 === $position) { - return; - } - - while (true) { - $chunkSize = min($position, 1024); - $position -= $chunkSize; - fseek($file, $position); - - if (0 === $chunkSize) { - // bof reached - break; - } - - $buffer = fread($file, $chunkSize); - - if (false === ($upTo = strrpos($buffer, "\n"))) { - $line = $buffer.$line; - continue; - } - - $position += $upTo; - $line = substr($buffer, $upTo + 1).$line; - fseek($file, max(0, $position), SEEK_SET); - - if ('' !== $line) { - break; - } - } - - return '' === $line ? null : $line; - } - - protected function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setStatusCode($data['status_code']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token || !file_exists($file = $this->getFilename($token))) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile)); - } - - return $profile; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Profiler/Profile.php b/lib/silex/vendor/symfony/http-kernel/Profiler/Profile.php deleted file mode 100644 index c21c9d38a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Profiler/Profile.php +++ /dev/null @@ -1,287 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; - -/** - * Profile. - * - * @author Fabien Potencier - */ -class Profile -{ - private $token; - - /** - * @var DataCollectorInterface[] - */ - private $collectors = array(); - - private $ip; - private $method; - private $url; - private $time; - private $statusCode; - - /** - * @var Profile - */ - private $parent; - - /** - * @var Profile[] - */ - private $children = array(); - - /** - * @param string $token The token - */ - public function __construct($token) - { - $this->token = $token; - } - - /** - * Sets the token. - * - * @param string $token The token - */ - public function setToken($token) - { - $this->token = $token; - } - - /** - * Gets the token. - * - * @return string The token - */ - public function getToken() - { - return $this->token; - } - - /** - * Sets the parent token. - */ - public function setParent(Profile $parent) - { - $this->parent = $parent; - } - - /** - * Returns the parent profile. - * - * @return self - */ - public function getParent() - { - return $this->parent; - } - - /** - * Returns the parent token. - * - * @return null|string The parent token - */ - public function getParentToken() - { - return $this->parent ? $this->parent->getToken() : null; - } - - /** - * Returns the IP. - * - * @return string The IP - */ - public function getIp() - { - return $this->ip; - } - - /** - * Sets the IP. - * - * @param string $ip - */ - public function setIp($ip) - { - $this->ip = $ip; - } - - /** - * Returns the request method. - * - * @return string The request method - */ - public function getMethod() - { - return $this->method; - } - - public function setMethod($method) - { - $this->method = $method; - } - - /** - * Returns the URL. - * - * @return string The URL - */ - public function getUrl() - { - return $this->url; - } - - public function setUrl($url) - { - $this->url = $url; - } - - /** - * Returns the time. - * - * @return int The time - */ - public function getTime() - { - if (null === $this->time) { - return 0; - } - - return $this->time; - } - - /** - * @param int $time The time - */ - public function setTime($time) - { - $this->time = $time; - } - - /** - * @param int $statusCode - */ - public function setStatusCode($statusCode) - { - $this->statusCode = $statusCode; - } - - /** - * @return int - */ - public function getStatusCode() - { - return $this->statusCode; - } - - /** - * Finds children profilers. - * - * @return self[] - */ - public function getChildren() - { - return $this->children; - } - - /** - * Sets children profiler. - * - * @param Profile[] $children - */ - public function setChildren(array $children) - { - $this->children = array(); - foreach ($children as $child) { - $this->addChild($child); - } - } - - /** - * Adds the child token. - */ - public function addChild(Profile $child) - { - $this->children[] = $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])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $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(); - foreach ($collectors as $collector) { - $this->addCollector($collector); - } - } - - /** - * Adds a Collector. - */ - 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 bool - */ - public function hasCollector($name) - { - return isset($this->collectors[$name]); - } - - public function __sleep() - { - return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Profiler/Profiler.php b/lib/silex/vendor/symfony/http-kernel/Profiler/Profiler.php deleted file mode 100644 index 15bfbc5a0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Profiler/Profiler.php +++ /dev/null @@ -1,265 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; -use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; -use Psr\Log\LoggerInterface; - -/** - * Profiler. - * - * @author Fabien Potencier - */ -class Profiler -{ - private $storage; - - /** - * @var DataCollectorInterface[] - */ - private $collectors = array(); - - private $logger; - private $initiallyEnabled = true; - private $enabled = true; - - /** - * @param bool $enable The initial enabled state - */ - public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, $enable = true) - { - $this->storage = $storage; - $this->logger = $logger; - $this->initiallyEnabled = $this->enabled = (bool) $enable; - } - - /** - * Disables the profiler. - */ - public function disable() - { - $this->enabled = false; - } - - /** - * Enables the profiler. - */ - public function enable() - { - $this->enabled = true; - } - - /** - * Loads the Profile for the given Response. - * - * @return Profile|false A Profile instance - */ - public function loadProfileFromResponse(Response $response) - { - if (!$token = $response->headers->get('X-Debug-Token')) { - return false; - } - - return $this->loadProfile($token); - } - - /** - * Loads the Profile for the given token. - * - * @param string $token A token - * - * @return Profile A Profile instance - */ - public function loadProfile($token) - { - return $this->storage->read($token); - } - - /** - * Saves a Profile. - * - * @return bool - */ - public function saveProfile(Profile $profile) - { - // late collect - foreach ($profile->getCollectors() as $collector) { - if ($collector instanceof LateDataCollectorInterface) { - $collector->lateCollect(); - } - } - - if (!($ret = $this->storage->write($profile)) && null !== $this->logger) { - $this->logger->warning('Unable to store the profiler information.', array('configured_storage' => get_class($this->storage))); - } - - return $ret; - } - - /** - * Purges all data from the storage. - */ - public function purge() - { - $this->storage->purge(); - } - - /** - * 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 - * @param string $start The start date to search from - * @param string $end The end date to search to - * @param string $statusCode The request status code - * - * @return array An array of tokens - * - * @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats - */ - public function find($ip, $url, $limit, $method, $start, $end, $statusCode = null) - { - return $this->storage->find($ip, $url, $limit, $method, $this->getTimestamp($start), $this->getTimestamp($end), $statusCode); - } - - /** - * Collects data for the given Response. - * - * @return Profile|null A Profile instance or null if the profiler is disabled - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if (false === $this->enabled) { - return; - } - - $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6)); - $profile->setTime(time()); - $profile->setUrl($request->getUri()); - $profile->setMethod($request->getMethod()); - $profile->setStatusCode($response->getStatusCode()); - try { - $profile->setIp($request->getClientIp()); - } catch (ConflictingHeadersException $e) { - $profile->setIp('Unknown'); - } - - $response->headers->set('X-Debug-Token', $profile->getToken()); - - foreach ($this->collectors as $collector) { - $collector->collect($request, $response, $exception); - - // we need to clone for sub-requests - $profile->addCollector(clone $collector); - } - - return $profile; - } - - public function reset() - { - foreach ($this->collectors as $collector) { - if (!method_exists($collector, 'reset')) { - continue; - } - - $collector->reset(); - } - $this->enabled = $this->initiallyEnabled; - } - - /** - * Gets the Collectors associated with this profiler. - * - * @return array An array of collectors - */ - public function all() - { - return $this->collectors; - } - - /** - * Sets the Collectors associated with this profiler. - * - * @param DataCollectorInterface[] $collectors An array of collectors - */ - public function set(array $collectors = array()) - { - $this->collectors = array(); - foreach ($collectors as $collector) { - $this->add($collector); - } - } - - /** - * Adds a Collector. - */ - public function add(DataCollectorInterface $collector) - { - if (!method_exists($collector, 'reset')) { - @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', DataCollectorInterface::class, \get_class($collector)), E_USER_DEPRECATED); - } - - $this->collectors[$collector->getName()] = $collector; - } - - /** - * Returns true if a Collector for the given name exists. - * - * @param string $name A collector name - * - * @return bool - */ - public function has($name) - { - return isset($this->collectors[$name]); - } - - /** - * 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 get($name) - { - if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); - } - - return $this->collectors[$name]; - } - - private function getTimestamp($value) - { - if (null === $value || '' == $value) { - return; - } - - try { - $value = new \DateTime(is_numeric($value) ? '@'.$value : $value); - } catch (\Exception $e) { - return; - } - - return $value->getTimestamp(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Profiler/ProfilerStorageInterface.php b/lib/silex/vendor/symfony/http-kernel/Profiler/ProfilerStorageInterface.php deleted file mode 100644 index 544fb1fef..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Profiler/ProfilerStorageInterface.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * ProfilerStorageInterface. - * - * @author Fabien Potencier - */ -interface ProfilerStorageInterface -{ - /** - * 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 - * @param int|null $start The start date to search from - * @param int|null $end The end date to search to - * - * @return array An array of tokens - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null); - - /** - * Reads data associated with the given token. - * - * The method returns false if the token does not exist in the storage. - * - * @param string $token A token - * - * @return Profile The profile associated with token - */ - public function read($token); - - /** - * Saves a Profile. - * - * @return bool Write operation successful - */ - public function write(Profile $profile); - - /** - * Purges all data from the database. - */ - public function purge(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/README.md b/lib/silex/vendor/symfony/http-kernel/README.md deleted file mode 100644 index cc5e74b6b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/README.md +++ /dev/null @@ -1,16 +0,0 @@ -HttpKernel Component -==================== - -The HttpKernel component provides a structured process for converting a Request -into a Response by making use of the EventDispatcher component. It's flexible -enough to create a full-stack framework (Symfony), a micro-framework (Silex) or -an advanced CMS system (Drupal). - -Resources ---------- - - * [Documentation](https://symfony.com/doc/current/components/http_kernel/index.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/lib/silex/vendor/symfony/http-kernel/RebootableInterface.php b/lib/silex/vendor/symfony/http-kernel/RebootableInterface.php deleted file mode 100644 index 58d9ef59e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/RebootableInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -/** - * Allows the Kernel to be rebooted using a temporary cache directory. - * - * @author Nicolas Grekas - */ -interface RebootableInterface -{ - /** - * Reboots a kernel. - * - * The getCacheDir() method of a rebootable kernel should not be called - * while building the container. Use the %kernel.cache_dir% parameter instead. - * - * @param string|null $warmupDir pass null to reboot in the regular cache directory - */ - public function reboot($warmupDir); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Resources/welcome.html.php b/lib/silex/vendor/symfony/http-kernel/Resources/welcome.html.php deleted file mode 100644 index d8c37beb5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Resources/welcome.html.php +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Welcome! - - - -
-
-
-

Welcome to Symfony

-
- -
-

- - - Your application is now ready. You can start working on it at:
- -

-
- - -
-
-

- You're seeing this message because you have debug mode enabled and you haven't configured any URLs. -

-
-
- - diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore deleted file mode 100644 index 94a6a2528..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vendor/ -composer.lock -phpunit.xml -Tests/Fixtures/cache/ -Tests/Fixtures/logs/ diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php deleted file mode 100644 index c58f0f03b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ /dev/null @@ -1,215 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Bundle; - -use Symfony\Component\DependencyInjection\ContainerAware; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\Console\Application; -use Symfony\Component\Finder\Finder; -use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; - -/** - * An implementation of BundleInterface that adds a few conventions - * for DependencyInjection extensions and Console commands. - * - * @author Fabien Potencier - * - * @api - */ -abstract class Bundle extends ContainerAware implements BundleInterface -{ - protected $name; - protected $extension; - protected $path; - - /** - * Boots the Bundle. - */ - public function boot() - { - } - - /** - * Shutdowns the Bundle. - */ - public function shutdown() - { - } - - /** - * Builds the bundle. - * - * It is only ever called once when the cache is empty. - * - * This method can be overridden to register compilation passes, - * other extensions, ... - * - * @param ContainerBuilder $container A ContainerBuilder instance - */ - public function build(ContainerBuilder $container) - { - } - - /** - * Returns the bundle's container extension. - * - * @return ExtensionInterface|null The container extension - * - * @throws \LogicException - * - * @api - */ - public function getContainerExtension() - { - if (null === $this->extension) { - $class = $this->getContainerExtensionClass(); - if (class_exists($class)) { - $extension = new $class(); - - if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', $class)); - } - - // check naming convention - $basename = preg_replace('/Bundle$/', '', $this->getName()); - $expectedAlias = Container::underscore($basename); - if ($expectedAlias != $extension->getAlias()) { - throw new \LogicException(sprintf( - 'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', - $expectedAlias, $extension->getAlias() - )); - } - - $this->extension = $extension; - } else { - $this->extension = false; - } - } - - if ($this->extension) { - return $this->extension; - } - } - - /** - * Gets the Bundle namespace. - * - * @return string The Bundle namespace - * - * @api - */ - public function getNamespace() - { - $class = get_class($this); - - return substr($class, 0, strrpos($class, '\\')); - } - - /** - * Gets the Bundle directory path. - * - * @return string The Bundle absolute path - * - * @api - */ - public function getPath() - { - if (null === $this->path) { - $reflected = new \ReflectionObject($this); - $this->path = dirname($reflected->getFileName()); - } - - return $this->path; - } - - /** - * Returns the bundle parent name. - * - * @return string The Bundle parent name it overrides or null if no parent - * - * @api - */ - public function getParent() - { - } - - /** - * Returns the bundle name (the class short name). - * - * @return string The Bundle name - * - * @api - */ - final public function getName() - { - if (null !== $this->name) { - return $this->name; - } - - $name = get_class($this); - $pos = strrpos($name, '\\'); - - return $this->name = false === $pos ? $name : substr($name, $pos + 1); - } - - /** - * Finds and registers Commands. - * - * Override this method if your bundle commands do not follow the conventions: - * - * * Commands are in the 'Command' sub-directory - * * Commands extend Symfony\Component\Console\Command\Command - * - * @param Application $application An Application instance - */ - public function registerCommands(Application $application) - { - if (!is_dir($dir = $this->getPath().'/Command')) { - return; - } - - $finder = new Finder(); - $finder->files()->name('*Command.php')->in($dir); - - $prefix = $this->getNamespace().'\\Command'; - foreach ($finder as $file) { - $ns = $prefix; - if ($relativePath = $file->getRelativePath()) { - $ns .= '\\'.strtr($relativePath, '/', '\\'); - } - $class = $ns.'\\'.$file->getBasename('.php'); - if ($this->container) { - $alias = 'console.command.'.strtolower(str_replace('\\', '_', $class)); - if ($this->container->has($alias)) { - continue; - } - } - $r = new \ReflectionClass($class); - if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) { - $application->add($r->newInstance()); - } - } - } - - /** - * Returns the bundle's container extension class. - * - * @return string - */ - protected function getContainerExtensionClass() - { - $basename = preg_replace('/Bundle$/', '', $this->getName()); - - return $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/BundleInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/BundleInterface.php deleted file mode 100644 index 3203d84a2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/BundleInterface.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Bundle; - -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; - -/** - * BundleInterface. - * - * @author Fabien Potencier - * - * @api - */ -interface BundleInterface extends ContainerAwareInterface -{ - /** - * Boots the Bundle. - * - * @api - */ - public function boot(); - - /** - * Shutdowns the Bundle. - * - * @api - */ - public function shutdown(); - - /** - * Builds the bundle. - * - * It is only ever called once when the cache is empty. - * - * @param ContainerBuilder $container A ContainerBuilder instance - * - * @api - */ - public function build(ContainerBuilder $container); - - /** - * Returns the container extension that should be implicitly loaded. - * - * @return ExtensionInterface|null The default extension or null if there is none - * - * @api - */ - public function getContainerExtension(); - - /** - * Returns the bundle name that this bundle overrides. - * - * Despite its name, this method does not imply any parent/child relationship - * between the bundles, just a way to extend and override an existing - * bundle. - * - * @return string The Bundle name it overrides or null if no parent - * - * @api - */ - public function getParent(); - - /** - * Returns the bundle name (the class short name). - * - * @return string The Bundle name - * - * @api - */ - public function getName(); - - /** - * Gets the Bundle namespace. - * - * @return string The Bundle namespace - * - * @api - */ - public function getNamespace(); - - /** - * Gets the Bundle directory path. - * - * The path should always be returned as a Unix path (with /). - * - * @return string The Bundle absolute path - * - * @api - */ - public function getPath(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md deleted file mode 100644 index 39d35f3c6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md +++ /dev/null @@ -1,68 +0,0 @@ -CHANGELOG -========= - -2.6.0 ------ - - * deprecated `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener`, use `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` instead - * deprecated unused method `Symfony\Component\HttpKernel\Kernel::isClassInActiveBundle` and `Symfony\Component\HttpKernel\KernelInterface::isClassInActiveBundle` - -2.5.0 ------ - - * deprecated `Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass`, use `Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass` instead - -2.4.0 ------ - - * added event listeners for the session - * added the KernelEvents::FINISH_REQUEST event - -2.3.0 ------ - - * [BC BREAK] renamed `Symfony\Component\HttpKernel\EventListener\DeprecationLoggerListener` to `Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener` and changed its constructor - * deprecated `Symfony\Component\HttpKernel\Debug\ErrorHandler`, `Symfony\Component\HttpKernel\Debug\ExceptionHandler`, - `Symfony\Component\HttpKernel\Exception\FatalErrorException` and `Symfony\Component\HttpKernel\Exception\FlattenException` - * deprecated `Symfony\Component\HttpKernel\Kernel::init()`` - * added the possibility to specify an id an extra attributes to hinclude tags - * added the collect of data if a controller is a Closure in the Request collector - * pass exceptions from the ExceptionListener to the logger using the logging context to allow for more - detailed messages - -2.2.0 ------ - - * [BC BREAK] the path info for sub-request is now always _fragment (or whatever you configured instead of the default) - * added Symfony\Component\HttpKernel\EventListener\FragmentListener - * added Symfony\Component\HttpKernel\UriSigner - * added Symfony\Component\HttpKernel\FragmentRenderer and rendering strategies (in Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface) - * added Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel - * added ControllerReference to create reference of Controllers (used in the FragmentRenderer class) - * [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 ------ - - * [BC BREAK] the charset is now configured via the Kernel::getCharset() method - * [BC BREAK] the current locale for the user is not stored anymore in the session - * added the HTTP method to the profiler storage - * updated all listeners to implement EventSubscriberInterface - * added TimeDataCollector - * added ContainerAwareTraceableEventDispatcher - * moved TraceableEventDispatcherInterface to the EventDispatcher component - * added RouterListener, LocaleListener, and StreamedResponseListener - * added CacheClearerInterface (and ChainCacheClearer) - * added a kernel.terminate event (via TerminableInterface and PostResponseEvent) - * added a Stopwatch class - * added WarmableInterface - * improved extensibility between bundles - * added profiler storages for Memcache(d), File-based, MongoDB, Redis - * moved Filesystem class to its own component diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php deleted file mode 100644 index d4a2db376..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheClearer; - -/** - * CacheClearerInterface. - * - * @author Dustin Dobervich - */ -interface CacheClearerInterface -{ - /** - * Clears any caches necessary. - * - * @param string $cacheDir The cache directory. - */ - public function clear($cacheDir); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php deleted file mode 100644 index 81c43b602..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheClearer; - -/** - * ChainCacheClearer. - * - * @author Dustin Dobervich - */ -class ChainCacheClearer implements CacheClearerInterface -{ - /** - * @var array - */ - protected $clearers; - - /** - * Constructs a new instance of ChainCacheClearer. - * - * @param array $clearers The initial clearers. - */ - public function __construct(array $clearers = array()) - { - $this->clearers = $clearers; - } - - /** - * {@inheritdoc} - */ - public function clear($cacheDir) - { - foreach ($this->clearers as $clearer) { - $clearer->clear($cacheDir); - } - } - - /** - * Adds a cache clearer to the aggregate. - * - * @param CacheClearerInterface $clearer - */ - public function add(CacheClearerInterface $clearer) - { - $this->clearers[] = $clearer; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php deleted file mode 100644 index 948b3ffd1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Abstract cache warmer that knows how to write a file to the cache. - * - * @author Fabien Potencier - */ -abstract class CacheWarmer implements CacheWarmerInterface -{ - protected function writeCacheFile($file, $content) - { - $tmpFile = tempnam(dirname($file), basename($file)); - if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { - @chmod($file, 0666 & ~umask()); - - return; - } - - throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php deleted file mode 100644 index e5f4e4fa4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Aggregates several cache warmers into a single one. - * - * @author Fabien Potencier - */ -class CacheWarmerAggregate implements CacheWarmerInterface -{ - protected $warmers = array(); - protected $optionalsEnabled = false; - - public function __construct(array $warmers = array()) - { - foreach ($warmers as $warmer) { - $this->add($warmer); - } - } - - public function enableOptionalWarmers() - { - $this->optionalsEnabled = true; - } - - /** - * Warms up the cache. - * - * @param string $cacheDir The cache directory - */ - public function warmUp($cacheDir) - { - foreach ($this->warmers as $warmer) { - if (!$this->optionalsEnabled && $warmer->isOptional()) { - continue; - } - - $warmer->warmUp($cacheDir); - } - } - - /** - * Checks whether this warmer is optional or not. - * - * @return bool always false - */ - public function isOptional() - { - return false; - } - - public function setWarmers(array $warmers) - { - $this->warmers = array(); - foreach ($warmers as $warmer) { - $this->add($warmer); - } - } - - public function add(CacheWarmerInterface $warmer) - { - $this->warmers[] = $warmer; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php deleted file mode 100644 index 8fece5e95..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Interface for classes able to warm up the cache. - * - * @author Fabien Potencier - */ -interface CacheWarmerInterface extends WarmableInterface -{ - /** - * Checks whether this warmer is optional or not. - * - * Optional warmers can be ignored on certain conditions. - * - * A warmer should return true if the cache can be - * generated incrementally and on-demand. - * - * @return bool true if the warmer is optional, false otherwise - */ - public function isOptional(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php deleted file mode 100644 index 25d8ee8f6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\CacheWarmer; - -/** - * Interface for classes that support warming their cache. - * - * @author Fabien Potencier - */ -interface WarmableInterface -{ - /** - * Warms up the cache. - * - * @param string $cacheDir The cache directory - */ - public function warmUp($cacheDir); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php deleted file mode 100644 index 50895e713..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php +++ /dev/null @@ -1,228 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\BrowserKit\Client as BaseClient; -use Symfony\Component\BrowserKit\Request as DomRequest; -use Symfony\Component\BrowserKit\Response as DomResponse; -use Symfony\Component\BrowserKit\Cookie as DomCookie; -use Symfony\Component\BrowserKit\History; -use Symfony\Component\BrowserKit\CookieJar; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Client simulates a browser and makes requests to a Kernel object. - * - * @author Fabien Potencier - * - * @api - */ -class Client extends BaseClient -{ - protected $kernel; - - /** - * Constructor. - * - * @param HttpKernelInterface $kernel An HttpKernel instance - * @param array $server The server parameters (equivalent of $_SERVER) - * @param History $history A History instance to store the browser history - * @param CookieJar $cookieJar A CookieJar instance to store the cookies - */ - public function __construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null) - { - // These class properties must be set before calling the parent constructor, as it may depend on it. - $this->kernel = $kernel; - $this->followRedirects = false; - - parent::__construct($server, $history, $cookieJar); - } - - /** - * {@inheritdoc} - * - * @return Request|null A Request instance - */ - public function getRequest() - { - return parent::getRequest(); - } - - /** - * {@inheritdoc} - * - * @return Response|null A Response instance - */ - public function getResponse() - { - return parent::getResponse(); - } - - /** - * Makes a request. - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - protected function doRequest($request) - { - $response = $this->kernel->handle($request); - - if ($this->kernel instanceof TerminableInterface) { - $this->kernel->terminate($request, $response); - } - - return $response; - } - - /** - * Returns the script to execute when the request must be insulated. - * - * @param Request $request A Request instance - * - * @return string - */ - protected function getScript($request) - { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); - - $r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader'); - $requirePath = str_replace("'", "\\'", $r->getFileName()); - $symfonyPath = str_replace("'", "\\'", dirname(dirname(dirname(__DIR__)))); - $errorReporting = error_reporting(); - - $code = <<addPrefix('Symfony', '$symfonyPath'); -\$loader->register(); - -\$kernel = unserialize('$kernel'); -\$request = unserialize('$request'); -EOF; - - return $code.$this->getHandleScript(); - } - - protected function getHandleScript() - { - return <<<'EOF' -$response = $kernel->handle($request); - -if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) { - $kernel->terminate($request, $response); -} - -echo serialize($response); -EOF; - } - - /** - * Converts the BrowserKit request to a HttpKernel request. - * - * @param DomRequest $request A DomRequest instance - * - * @return Request A Request instance - */ - protected function filterRequest(DomRequest $request) - { - $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent()); - - foreach ($this->filterFiles($httpRequest->files->all()) as $key => $value) { - $httpRequest->files->set($key, $value); - } - - return $httpRequest; - } - - /** - * Filters an array of files. - * - * This method created test instances of UploadedFile so that the move() - * method can be called on those instances. - * - * If the size of a file is greater than the allowed size (from php.ini) then - * an invalid UploadedFile is returned with an error set to UPLOAD_ERR_INI_SIZE. - * - * @see UploadedFile - * - * @param array $files An array of files - * - * @return array An array with all uploaded files marked as already moved - */ - protected function filterFiles(array $files) - { - $filtered = array(); - foreach ($files as $key => $value) { - if (is_array($value)) { - $filtered[$key] = $this->filterFiles($value); - } elseif ($value instanceof UploadedFile) { - if ($value->isValid() && $value->getSize() > UploadedFile::getMaxFilesize()) { - $filtered[$key] = new UploadedFile( - '', - $value->getClientOriginalName(), - $value->getClientMimeType(), - 0, - UPLOAD_ERR_INI_SIZE, - true - ); - } else { - $filtered[$key] = new UploadedFile( - $value->getPathname(), - $value->getClientOriginalName(), - $value->getClientMimeType(), - $value->getClientSize(), - $value->getError(), - true - ); - } - } - } - - return $filtered; - } - - /** - * Converts the HttpKernel response to a BrowserKit response. - * - * @param Response $response A Response instance - * - * @return DomResponse A DomResponse instance - */ - protected function filterResponse($response) - { - $headers = $response->headers->all(); - if ($response->headers->getCookies()) { - $cookies = array(); - foreach ($response->headers->getCookies() as $cookie) { - $cookies[] = new DomCookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - $headers['Set-Cookie'] = $cookies; - } - - // this is needed to support StreamedResponse - ob_start(); - $response->sendContent(); - $content = ob_get_clean(); - - return new DomResponse($content, $response->getStatusCode(), $headers); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/EnvParametersResource.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/EnvParametersResource.php deleted file mode 100644 index 5f5445013..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/EnvParametersResource.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Config; - -use Symfony\Component\Config\Resource\ResourceInterface; - -/** - * EnvParametersResource represents resources stored in prefixed environment variables. - * - * @author Chris Wilkinson - */ -class EnvParametersResource implements ResourceInterface, \Serializable -{ - /** - * @var string - */ - private $prefix; - - /** - * @var string - */ - private $variables; - - /** - * Constructor. - * - * @param string $prefix - */ - public function __construct($prefix) - { - $this->prefix = $prefix; - $this->variables = $this->findVariables(); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return serialize($this->getResource()); - } - - /** - * {@inheritdoc} - */ - public function getResource() - { - return array('prefix' => $this->prefix, 'variables' => $this->variables); - } - - /** - * {@inheritdoc} - */ - public function isFresh($timestamp) - { - return $this->findVariables() === $this->variables; - } - - public function serialize() - { - return serialize(array('prefix' => $this->prefix, 'variables' => $this->variables)); - } - - public function unserialize($serialized) - { - $unserialized = unserialize($serialized); - - $this->prefix = $unserialized['prefix']; - $this->variables = $unserialized['variables']; - } - - private function findVariables() - { - $variables = array(); - - foreach ($_SERVER as $key => $value) { - if (0 === strpos($key, $this->prefix)) { - $variables[$key] = $value; - } - } - - ksort($variables); - - return $variables; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php deleted file mode 100644 index 169c9ad6e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Config; - -use Symfony\Component\Config\FileLocator as BaseFileLocator; -use Symfony\Component\HttpKernel\KernelInterface; - -/** - * FileLocator uses the KernelInterface to locate resources in bundles. - * - * @author Fabien Potencier - */ -class FileLocator extends BaseFileLocator -{ - private $kernel; - private $path; - - /** - * Constructor. - * - * @param KernelInterface $kernel A KernelInterface instance - * @param null|string $path The path the global resource directory - * @param array $paths An array of paths where to look for resources - */ - public function __construct(KernelInterface $kernel, $path = null, array $paths = array()) - { - $this->kernel = $kernel; - if (null !== $path) { - $this->path = $path; - $paths[] = $path; - } - - parent::__construct($paths); - } - - /** - * {@inheritdoc} - */ - public function locate($file, $currentPath = null, $first = true) - { - if (isset($file[0]) && '@' === $file[0]) { - return $this->kernel->locateResource($file, $this->path, $first); - } - - return parent::locate($file, $currentPath, $first); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerReference.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerReference.php deleted file mode 100644 index 3d1592e83..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerReference.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * 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\HttpKernel\Fragment\FragmentRendererInterface; - -/** - * Acts as a marker and a data holder for a Controller. - * - * Some methods in Symfony accept both a URI (as a string) or a controller as - * an argument. In the latter case, instead of passing an array representing - * the controller, you can use an instance of this class. - * - * @author Fabien Potencier - * - * @see FragmentRendererInterface - */ -class ControllerReference -{ - public $controller; - public $attributes = array(); - public $query = array(); - - /** - * Constructor. - * - * @param string $controller The controller name - * @param array $attributes An array of parameters to add to the Request attributes - * @param array $query An array of parameters to add to the Request query string - */ - public function __construct($controller, array $attributes = array(), array $query = array()) - { - $this->controller = $controller; - $this->attributes = $attributes; - $this->query = $query; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php deleted file mode 100644 index b9bac023b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * 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 Psr\Log\LoggerInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * ControllerResolver. - * - * This implementation uses the '_controller' request attribute to determine - * the controller to execute and uses the request attributes to determine - * the controller method arguments. - * - * @author Fabien Potencier - * - * @api - */ -class ControllerResolver implements ControllerResolverInterface -{ - private $logger; - - /** - * Constructor. - * - * @param LoggerInterface $logger A LoggerInterface instance - */ - public function __construct(LoggerInterface $logger = null) - { - $this->logger = $logger; - } - - /** - * {@inheritdoc} - * - * This method looks for a '_controller' request attribute that represents - * the controller name (a string like ClassName::MethodName). - * - * @api - */ - public function getController(Request $request) - { - if (!$controller = $request->attributes->get('_controller')) { - if (null !== $this->logger) { - $this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing'); - } - - return false; - } - - if (is_array($controller)) { - return $controller; - } - - if (is_object($controller)) { - if (method_exists($controller, '__invoke')) { - return $controller; - } - - throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', get_class($controller), $request->getPathInfo())); - } - - if (false === strpos($controller, ':')) { - if (method_exists($controller, '__invoke')) { - return $this->instantiateController($controller); - } elseif (function_exists($controller)) { - return $controller; - } - } - - $callable = $this->createController($controller); - - if (!is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request->getPathInfo())); - } - - return $callable; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getArguments(Request $request, $controller) - { - if (is_array($controller)) { - $r = new \ReflectionMethod($controller[0], $controller[1]); - } elseif (is_object($controller) && !$controller instanceof \Closure) { - $r = new \ReflectionObject($controller); - $r = $r->getMethod('__invoke'); - } else { - $r = new \ReflectionFunction($controller); - } - - return $this->doGetArguments($request, $controller, $r->getParameters()); - } - - protected function doGetArguments(Request $request, $controller, array $parameters) - { - $attributes = $request->attributes->all(); - $arguments = array(); - foreach ($parameters as $param) { - if (array_key_exists($param->name, $attributes)) { - $arguments[] = $attributes[$param->name]; - } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { - $arguments[] = $request; - } elseif ($param->isDefaultValueAvailable()) { - $arguments[] = $param->getDefaultValue(); - } else { - if (is_array($controller)) { - $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); - } elseif (is_object($controller)) { - $repr = get_class($controller); - } else { - $repr = $controller; - } - - throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->name)); - } - } - - return $arguments; - } - - /** - * Returns a callable for the given controller. - * - * @param string $controller A Controller string - * - * @return mixed A PHP callable - * - * @throws \InvalidArgumentException - */ - protected function createController($controller) - { - if (false === strpos($controller, '::')) { - throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller)); - } - - list($class, $method) = explode('::', $controller, 2); - - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); - } - - return array($this->instantiateController($class), $method); - } - - /** - * Returns an instantiated controller - * - * @param string $class A class name - * - * @return object - */ - protected function instantiateController($class) - { - return new $class(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php deleted file mode 100644 index 6f805ed2d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * 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\HttpFoundation\Request; - -/** - * A ControllerResolverInterface implementation knows how to determine the - * controller to execute based on a Request object. - * - * It can also determine the arguments to pass to the Controller. - * - * A Controller can be any valid PHP callable. - * - * @author Fabien Potencier - * - * @api - */ -interface ControllerResolverInterface -{ - /** - * Returns the Controller instance associated with a Request. - * - * As several resolvers can exist for a single application, a resolver must - * return false when it is not able to determine the controller. - * - * The resolver must only throw an exception when it should be able to load - * controller but cannot because of some errors made by the developer. - * - * @param Request $request A Request instance - * - * @return callable|false A PHP callable representing the Controller, - * or false if this resolver is not able to determine the controller - * - * @throws \LogicException If the controller can't be found - * - * @api - */ - public function getController(Request $request); - - /** - * Returns the arguments to pass to the controller. - * - * @param Request $request A Request instance - * @param callable $controller A PHP callable - * - * @return array An array of arguments to pass to the controller - * - * @throws \RuntimeException When value for argument given is not provided - * - * @api - */ - public function getArguments(Request $request, $controller); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php deleted file mode 100644 index f8de31cf0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * 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 - */ -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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php deleted file mode 100644 index f58027e21..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ /dev/null @@ -1,245 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * ConfigDataCollector. - * - * @author Fabien Potencier - */ -class ConfigDataCollector extends DataCollector -{ - private $kernel; - private $name; - private $version; - - /** - * Constructor. - * - * @param string $name The name of the application using the web profiler - * @param string $version The version of the application using the web profiler - */ - public function __construct($name = null, $version = null) - { - $this->name = $name; - $this->version = $version; - } - - /** - * Sets the Kernel associated with this Request. - * - * @param KernelInterface $kernel A KernelInterface instance - */ - public function setKernel(KernelInterface $kernel = null) - { - $this->kernel = $kernel; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $this->data = array( - 'app_name' => $this->name, - 'app_version' => $this->version, - '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'), - 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), - 'bundles' => array(), - 'sapi_name' => php_sapi_name(), - ); - - if (isset($this->kernel)) { - foreach ($this->kernel->getBundles() as $name => $bundle) { - $this->data['bundles'][$name] = $bundle->getPath(); - } - } - } - - public function getApplicationName() - { - return $this->data['app_name']; - } - - public function getApplicationVersion() - { - return $this->data['app_version']; - } - - /** - * Gets the token. - * - * @return string The token - */ - public function getToken() - { - return $this->data['token']; - } - - /** - * Gets the Symfony version. - * - * @return string The Symfony version - */ - public function getSymfonyVersion() - { - return $this->data['symfony_version']; - } - - /** - * Gets the PHP version. - * - * @return string The PHP version - */ - public function getPhpVersion() - { - return $this->data['php_version']; - } - - /** - * Gets the application name. - * - * @return string The application name - */ - public function getAppName() - { - return $this->data['name']; - } - - /** - * Gets the environment. - * - * @return string The environment - */ - public function getEnv() - { - return $this->data['env']; - } - - /** - * Returns true if the debug is enabled. - * - * @return bool true if debug is enabled, false otherwise - */ - public function isDebug() - { - return $this->data['debug']; - } - - /** - * Returns true if the XDebug is enabled. - * - * @return bool true if XDebug is enabled, false otherwise - */ - public function hasXDebug() - { - return $this->data['xdebug_enabled']; - } - - /** - * Returns true if EAccelerator is enabled. - * - * @return bool true if EAccelerator is enabled, false otherwise - */ - public function hasEAccelerator() - { - return $this->data['eaccel_enabled']; - } - - /** - * Returns true if APC is enabled. - * - * @return bool true if APC is enabled, false otherwise - */ - public function hasApc() - { - return $this->data['apc_enabled']; - } - - /** - * Returns true if Zend OPcache is enabled. - * - * @return bool true if Zend OPcache is enabled, false otherwise - */ - public function hasZendOpcache() - { - return $this->data['zend_opcache_enabled']; - } - - /** - * Returns true if XCache is enabled. - * - * @return bool true if XCache is enabled, false otherwise - */ - public function hasXCache() - { - return $this->data['xcache_enabled']; - } - - /** - * Returns true if WinCache is enabled. - * - * @return bool true if WinCache is enabled, false otherwise - */ - public function hasWinCache() - { - return $this->data['wincache_enabled']; - } - - /** - * Returns true if any accelerator is enabled. - * - * @return bool true if any accelerator is enabled, false otherwise - */ - public function hasAccelerator() - { - return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache(); - } - - public function getBundles() - { - return $this->data['bundles']; - } - - /** - * Gets the PHP SAPI name. - * - * @return string The environment - */ - public function getSapiName() - { - return $this->data['sapi_name']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'config'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php deleted file mode 100644 index 5dca65298..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; - -/** - * DataCollector. - * - * Children of this class must store the collected data in the data property. - * - * @author Fabien Potencier - * @author Bernhard Schussek - */ -abstract class DataCollector implements DataCollectorInterface, \Serializable -{ - protected $data = array(); - - /** - * @var ValueExporter - */ - private $valueExporter; - - public function serialize() - { - return serialize($this->data); - } - - 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 (null === $this->valueExporter) { - $this->valueExporter = new ValueExporter(); - } - - return $this->valueExporter->exportValue($var); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php deleted file mode 100644 index cf4cdfd77..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * DataCollectorInterface. - * - * @author Fabien Potencier - * - * @api - */ -interface DataCollectorInterface -{ - /** - * Collects data for the given Request and Response. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * @param \Exception $exception An Exception instance - * - * @api - */ - public function collect(Request $request, Response $response, \Exception $exception = null); - - /** - * Returns the name of the collector. - * - * @return string The collector name - * - * @api - */ - public function getName(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php deleted file mode 100644 index c2e89a1c3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ /dev/null @@ -1,298 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; -use Symfony\Component\VarDumper\Dumper\HtmlDumper; -use Symfony\Component\VarDumper\Dumper\DataDumperInterface; - -/** - * @author Nicolas Grekas - */ -class DumpDataCollector extends DataCollector implements DataDumperInterface -{ - private $stopwatch; - private $fileLinkFormat; - private $dataCount = 0; - private $isCollected = true; - private $clonesCount = 0; - private $clonesIndex = 0; - private $rootRefs; - private $charset; - private $dumper; - private $dumperIsInjected; - - public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $charset = null, RequestStack $requestStack = null, DataDumperInterface $dumper = null) - { - $this->stopwatch = $stopwatch; - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - $this->charset = $charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8'; - $this->requestStack = $requestStack; - $this->dumper = $dumper; - $this->dumperIsInjected = null !== $dumper; - - // All clones share these properties by reference: - $this->rootRefs = array( - &$this->data, - &$this->dataCount, - &$this->isCollected, - &$this->clonesCount, - ); - } - - public function __clone() - { - $this->clonesIndex = ++$this->clonesCount; - } - - public function dump(Data $data) - { - if ($this->stopwatch) { - $this->stopwatch->start('dump'); - } - if ($this->isCollected) { - $this->isCollected = false; - } - - $trace = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS : true; - if (PHP_VERSION_ID >= 50400) { - $trace = debug_backtrace($trace, 7); - } else { - $trace = debug_backtrace($trace); - } - - $file = $trace[0]['file']; - $line = $trace[0]['line']; - $name = false; - $fileExcerpt = false; - - for ($i = 1; $i < 7; ++$i) { - if (isset($trace[$i]['class'], $trace[$i]['function']) - && 'dump' === $trace[$i]['function'] - && 'Symfony\Component\VarDumper\VarDumper' === $trace[$i]['class'] - ) { - $file = $trace[$i]['file']; - $line = $trace[$i]['line']; - - while (++$i < 7) { - if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && 0 !== strpos($trace[$i]['function'], 'call_user_func')) { - $file = $trace[$i]['file']; - $line = $trace[$i]['line']; - - break; - } elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof \Twig_Template) { - $info = $trace[$i]['object']; - $name = $info->getTemplateName(); - $src = $info->getEnvironment()->getLoader()->getSource($name); - $info = $info->getDebugInfo(); - if (isset($info[$trace[$i - 1]['line']])) { - $file = false; - $line = $info[$trace[$i - 1]['line']]; - $src = explode("\n", $src); - $fileExcerpt = array(); - - for ($i = max($line - 3, 1), $max = min($line + 3, count($src)); $i <= $max; ++$i) { - $fileExcerpt[] = ''.$this->htmlEncode($src[$i - 1]).''; - } - - $fileExcerpt = '
    '.implode("\n", $fileExcerpt).'
'; - } - break; - } - } - break; - } - } - - if (false === $name) { - $name = strtr($file, '\\', '/'); - $name = substr($name, strrpos($name, '/') + 1); - } - - if ($this->dumper) { - $this->doDump($data, $name, $file, $line); - } - - $this->data[] = compact('data', 'name', 'file', 'line', 'fileExcerpt'); - ++$this->dataCount; - - if ($this->stopwatch) { - $this->stopwatch->stop('dump'); - } - } - - public function collect(Request $request, Response $response, \Exception $exception = null) - { - // Sub-requests and programmatic calls stay in the collected profile. - if ($this->dumper || ($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) { - return; - } - - // In all other conditions that remove the web debug toolbar, dumps are written on the output. - if (!$this->requestStack - || !$response->headers->has('X-Debug-Token') - || $response->isRedirection() - || ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html')) - || 'html' !== $request->getRequestFormat() - || false === strripos($response->getContent(), '') - ) { - if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) { - $this->dumper = new HtmlDumper('php://output', $this->charset); - } else { - $this->dumper = new CliDumper('php://output', $this->charset); - } - - foreach ($this->data as $dump) { - $this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']); - } - } - } - - public function serialize() - { - if ($this->clonesCount !== $this->clonesIndex) { - return 'a:0:{}'; - } - - $ser = serialize($this->data); - $this->data = array(); - $this->dataCount = 0; - $this->isCollected = true; - if (!$this->dumperIsInjected) { - $this->dumper = null; - } - - return $ser; - } - - public function unserialize($data) - { - parent::unserialize($data); - $this->dataCount = count($this->data); - self::__construct($this->stopwatch); - } - - public function getDumpsCount() - { - return $this->dataCount; - } - - public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) - { - $data = fopen('php://memory', 'r+b'); - - if ('html' === $format) { - $dumper = new HtmlDumper($data, $this->charset); - } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format)); - } - $dumps = array(); - - foreach ($this->data as $dump) { - $dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth)); - rewind($data); - $dump['data'] = stream_get_contents($data); - ftruncate($data, 0); - rewind($data); - $dumps[] = $dump; - } - - return $dumps; - } - - public function getName() - { - return 'dump'; - } - - public function __destruct() - { - if (0 === $this->clonesCount-- && !$this->isCollected && $this->data) { - $this->clonesCount = 0; - $this->isCollected = true; - - $h = headers_list(); - $i = count($h); - array_unshift($h, 'Content-Type: '.ini_get('default_mimetype')); - while (0 !== stripos($h[$i], 'Content-Type:')) { - --$i; - } - - if ('cli' !== PHP_SAPI && stripos($h[$i], 'html')) { - $this->dumper = new HtmlDumper('php://output', $this->charset); - } else { - $this->dumper = new CliDumper('php://output', $this->charset); - } - - foreach ($this->data as $i => $dump) { - $this->data[$i] = null; - $this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']); - } - - $this->data = array(); - $this->dataCount = 0; - } - } - - private function doDump($data, $name, $file, $line) - { - if (PHP_VERSION_ID >= 50400 && $this->dumper instanceof CliDumper) { - $contextDumper = function ($name, $file, $line, $fileLinkFormat) { - if ($this instanceof HtmlDumper) { - if ('' !== $file) { - $s = $this->style('meta', '%s'); - $name = strip_tags($this->style('', $name)); - $file = strip_tags($this->style('', $file)); - if ($fileLinkFormat) { - $link = strtr(strip_tags($this->style('', $fileLinkFormat)), array('%f' => $file, '%l' => (int) $line)); - $name = sprintf(''.$s.'', $link, $file, $name); - } else { - $name = sprintf(''.$s.'', $file, $name); - } - } else { - $name = $this->style('meta', $name); - } - $this->line = $name.' on line '.$this->style('meta', $line).':'; - } else { - $this->line = $this->style('meta', $name).' on line '.$this->style('meta', $line).':'; - } - $this->dumpLine(0); - }; - $contextDumper = $contextDumper->bindTo($this->dumper, $this->dumper); - $contextDumper($name, $file, $line, $this->fileLinkFormat); - } else { - $cloner = new VarCloner(); - $this->dumper->dump($cloner->cloneVar($name.' on line '.$line.':')); - } - $this->dumper->dump($data); - } - - private function htmlEncode($s) - { - $html = ''; - - $dumper = new HtmlDumper(function ($line) use (&$html) {$html .= $line;}, $this->charset); - $dumper->setDumpHeader(''); - $dumper->setDumpBoundaries('', ''); - - $cloner = new VarCloner(); - $dumper->dump($cloner->cloneVar($s)); - - return substr(strip_tags($html), 1, -1); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php deleted file mode 100644 index 0a87bc389..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; - -/** - * EventDataCollector. - * - * @author Fabien Potencier - */ -class EventDataCollector extends DataCollector implements LateDataCollectorInterface -{ - protected $dispatcher; - - public function __construct(EventDispatcherInterface $dispatcher = null) - { - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $this->data = array( - 'called_listeners' => array(), - 'not_called_listeners' => array(), - ); - } - - public function lateCollect() - { - if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { - $this->setCalledListeners($this->dispatcher->getCalledListeners()); - $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners()); - } - } - - /** - * 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. - * - * @return array An array of called listeners - * - * @see TraceableEventDispatcherInterface - */ - 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. - * - * @return array An array of not called listeners - * - * @see TraceableEventDispatcherInterface - */ - public function getNotCalledListeners() - { - return $this->data['not_called_listeners']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'events'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php deleted file mode 100644 index 9fe826446..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * ExceptionDataCollector. - * - * @author Fabien Potencier - */ -class ExceptionDataCollector extends DataCollector -{ - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if (null !== $exception) { - $this->data = array( - 'exception' => FlattenException::create($exception), - ); - } - } - - /** - * Checks if the exception is not null. - * - * @return bool true if the exception is not null, false otherwise - */ - public function hasException() - { - return isset($this->data['exception']); - } - - /** - * Gets the exception. - * - * @return \Exception The exception - */ - public function getException() - { - return $this->data['exception']; - } - - /** - * Gets the exception message. - * - * @return string The exception message - */ - public function getMessage() - { - return $this->data['exception']->getMessage(); - } - - /** - * Gets the exception code. - * - * @return int The exception code - */ - public function getCode() - { - return $this->data['exception']->getCode(); - } - - /** - * Gets the status code. - * - * @return int The status code - */ - public function getStatusCode() - { - return $this->data['exception']->getStatusCode(); - } - - /** - * Gets the exception trace. - * - * @return array The exception trace - */ - public function getTrace() - { - return $this->data['exception']->getTrace(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'exception'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php deleted file mode 100644 index 012332de4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -/** - * LateDataCollectorInterface. - * - * @author Fabien Potencier - */ -interface LateDataCollectorInterface -{ - /** - * Collects data as late as possible. - */ - public function lateCollect(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php deleted file mode 100644 index 0d1decda3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ /dev/null @@ -1,164 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; - -/** - * LogDataCollector. - * - * @author Fabien Potencier - */ -class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface -{ - private $logger; - - public function __construct($logger = null) - { - if (null !== $logger && $logger instanceof DebugLoggerInterface) { - $this->logger = $logger; - } - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - // everything is done as late as possible - } - - /** - * {@inheritdoc} - */ - public function lateCollect() - { - if (null !== $this->logger) { - $this->data = $this->computeErrorsCount(); - $this->data['logs'] = $this->sanitizeLogs($this->logger->getLogs()); - } - } - - /** - * Gets the called events. - * - * @return array An array of called events - * - * @see TraceableEventDispatcherInterface - */ - public function countErrors() - { - return isset($this->data['error_count']) ? $this->data['error_count'] : 0; - } - - /** - * Gets the logs. - * - * @return array An array of logs - */ - public function getLogs() - { - return isset($this->data['logs']) ? $this->data['logs'] : array(); - } - - public function getPriorities() - { - return isset($this->data['priorities']) ? $this->data['priorities'] : array(); - } - - public function countDeprecations() - { - return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0; - } - - public function countScreams() - { - return isset($this->data['scream_count']) ? $this->data['scream_count'] : 0; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'logger'; - } - - private function sanitizeLogs($logs) - { - foreach ($logs as $i => $log) { - $context = $this->sanitizeContext($log['context']); - if (isset($context['type'], $context['level']) && !($context['type'] & $context['level'])) { - $context['scream'] = true; - } - $logs[$i]['context'] = $context; - } - - return $logs; - } - - private function sanitizeContext($context) - { - if (is_array($context)) { - foreach ($context as $key => $value) { - $context[$key] = $this->sanitizeContext($value); - } - - return $context; - } - - if (is_resource($context)) { - return sprintf('Resource(%s)', get_resource_type($context)); - } - - if (is_object($context)) { - return sprintf('Object(%s)', get_class($context)); - } - - return $context; - } - - private function computeErrorsCount() - { - $count = array( - 'error_count' => $this->logger->countErrors(), - 'deprecation_count' => 0, - 'scream_count' => 0, - 'priorities' => array(), - ); - - foreach ($this->logger->getLogs() as $log) { - if (isset($count['priorities'][$log['priority']])) { - ++$count['priorities'][$log['priority']]['count']; - } else { - $count['priorities'][$log['priority']] = array( - 'count' => 1, - 'name' => $log['priorityName'], - ); - } - - if (isset($log['context']['type'], $log['context']['level'])) { - if (E_DEPRECATED === $log['context']['type'] || E_USER_DEPRECATED === $log['context']['type']) { - ++$count['deprecation_count']; - } elseif (!($log['context']['type'] & $log['context']['level'])) { - ++$count['scream_count']; - } - } - } - - ksort($count['priorities']); - - return $count; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php deleted file mode 100644 index 938501084..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * MemoryDataCollector. - * - * @author Fabien Potencier - */ -class MemoryDataCollector extends DataCollector implements LateDataCollectorInterface -{ - public function __construct() - { - $this->data = array( - 'memory' => 0, - 'memory_limit' => $this->convertToBytes(ini_get('memory_limit')), - ); - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $this->updateMemoryUsage(); - } - - /** - * {@inheritdoc} - */ - public function lateCollect() - { - $this->updateMemoryUsage(); - } - - /** - * Gets the memory. - * - * @return int The memory - */ - public function getMemory() - { - return $this->data['memory']; - } - - /** - * Gets the PHP memory limit. - * - * @return int The memory limit - */ - public function getMemoryLimit() - { - return $this->data['memory_limit']; - } - - /** - * Updates the memory usage data. - */ - public function updateMemoryUsage() - { - $this->data['memory'] = memory_get_peak_usage(true); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'memory'; - } - - private function convertToBytes($memoryLimit) - { - if ('-1' === $memoryLimit) { - return -1; - } - - $memoryLimit = strtolower($memoryLimit); - $max = strtolower(ltrim($memoryLimit, '+')); - if (0 === strpos($max, '0x')) { - $max = intval($max, 16); - } elseif (0 === strpos($max, '0')) { - $max = intval($max, 8); - } else { - $max = (int) $max; - } - - switch (substr($memoryLimit, -1)) { - case 't': $max *= 1024; - case 'g': $max *= 1024; - case 'm': $max *= 1024; - case 'k': $max *= 1024; - } - - return $max; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php deleted file mode 100644 index 8e4e7c7dd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ /dev/null @@ -1,338 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\HttpFoundation\HeaderBag; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\ResponseHeaderBag; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * RequestDataCollector. - * - * @author Fabien Potencier - */ -class RequestDataCollector extends DataCollector implements EventSubscriberInterface -{ - protected $controllers; - - public function __construct() - { - $this->controllers = new \SplObjectStorage(); - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $responseHeaders = $response->headers->all(); - $cookies = array(); - foreach ($response->headers->getCookies() as $cookie) { - $cookies[] = $this->getCookieHeader($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); - } - if (count($cookies) > 0) { - $responseHeaders['Set-Cookie'] = $cookies; - } - - // attributes are serialized and as they can be anything, they need to be converted to strings. - $attributes = array(); - foreach ($request->attributes->all() as $key => $value) { - if ('_route' === $key && is_object($value)) { - $attributes[$key] = $this->varToString($value->getPath()); - } elseif ('_route_params' === $key) { - // we need to keep route params as an array (see getRouteParams()) - foreach ($value as $k => $v) { - $value[$k] = $this->varToString($v); - } - $attributes[$key] = $value; - } else { - $attributes[$key] = $this->varToString($value); - } - } - - $content = null; - try { - $content = $request->getContent(); - } catch (\LogicException $e) { - // the user already got the request content as a resource - $content = false; - } - - $sessionMetadata = array(); - $sessionAttributes = array(); - $flashes = array(); - if ($request->hasSession()) { - $session = $request->getSession(); - if ($session->isStarted()) { - $sessionMetadata['Created'] = date(DATE_RFC822, $session->getMetadataBag()->getCreated()); - $sessionMetadata['Last used'] = date(DATE_RFC822, $session->getMetadataBag()->getLastUsed()); - $sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime(); - $sessionAttributes = $session->all(); - $flashes = $session->getFlashBag()->peekAll(); - } - } - - $statusCode = $response->getStatusCode(); - - $this->data = array( - 'format' => $request->getRequestFormat(), - 'content' => $content, - 'content_type' => $response->headers->get('Content-Type', 'text/html'), - 'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '', - 'status_code' => $statusCode, - 'request_query' => $request->query->all(), - 'request_request' => $request->request->all(), - 'request_headers' => $request->headers->all(), - 'request_server' => $request->server->all(), - 'request_cookies' => $request->cookies->all(), - 'request_attributes' => $attributes, - 'response_headers' => $responseHeaders, - 'session_metadata' => $sessionMetadata, - 'session_attributes' => $sessionAttributes, - 'flashes' => $flashes, - 'path_info' => $request->getPathInfo(), - 'controller' => 'n/a', - 'locale' => $request->getLocale(), - ); - - if (isset($this->data['request_headers']['php-auth-pw'])) { - $this->data['request_headers']['php-auth-pw'] = '******'; - } - - if (isset($this->data['request_server']['PHP_AUTH_PW'])) { - $this->data['request_server']['PHP_AUTH_PW'] = '******'; - } - - if (isset($this->controllers[$request])) { - $controller = $this->controllers[$request]; - if (is_array($controller)) { - 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 $e) { - 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) { - $r = new \ReflectionFunction($controller); - $this->data['controller'] = array( - 'class' => $r->getName(), - 'method' => null, - 'file' => $r->getFileName(), - 'line' => $r->getStartLine(), - ); - } elseif (is_object($controller)) { - $r = new \ReflectionClass($controller); - $this->data['controller'] = array( - 'class' => $r->getName(), - 'method' => null, - 'file' => $r->getFileName(), - 'line' => $r->getStartLine(), - ); - } else { - $this->data['controller'] = (string) $controller ?: 'n/a'; - } - unset($this->controllers[$request]); - } - } - - public function getPathInfo() - { - return $this->data['path_info']; - } - - public function getRequestRequest() - { - return new ParameterBag($this->data['request_request']); - } - - public function getRequestQuery() - { - return new ParameterBag($this->data['request_query']); - } - - public function getRequestHeaders() - { - return new HeaderBag($this->data['request_headers']); - } - - public function getRequestServer() - { - return new ParameterBag($this->data['request_server']); - } - - public function getRequestCookies() - { - return new ParameterBag($this->data['request_cookies']); - } - - public function getRequestAttributes() - { - return new ParameterBag($this->data['request_attributes']); - } - - public function getResponseHeaders() - { - return new ResponseHeaderBag($this->data['response_headers']); - } - - public function getSessionMetadata() - { - return $this->data['session_metadata']; - } - - public function getSessionAttributes() - { - return $this->data['session_attributes']; - } - - public function getFlashes() - { - return $this->data['flashes']; - } - - public function getContent() - { - return $this->data['content']; - } - - public function getContentType() - { - return $this->data['content_type']; - } - - public function getStatusText() - { - return $this->data['status_text']; - } - - public function getStatusCode() - { - return $this->data['status_code']; - } - - public function getFormat() - { - return $this->data['format']; - } - - public function getLocale() - { - return $this->data['locale']; - } - - /** - * Gets the route name. - * - * The _route request attributes is automatically set by the Router Matcher. - * - * @return string The route - */ - public function getRoute() - { - return isset($this->data['request_attributes']['_route']) ? $this->data['request_attributes']['_route'] : ''; - } - - /** - * Gets the route parameters. - * - * The _route_params request attributes is automatically set by the RouterListener. - * - * @return array The parameters - */ - public function getRouteParams() - { - return isset($this->data['request_attributes']['_route_params']) ? $this->data['request_attributes']['_route_params'] : array(); - } - - /** - * Gets the controller. - * - * @return string The controller as a string - */ - public function getController() - { - return $this->data['controller']; - } - - public function onKernelController(FilterControllerEvent $event) - { - $this->controllers[$event->getRequest()] = $event->getController(); - } - - public static function getSubscribedEvents() - { - return array(KernelEvents::CONTROLLER => 'onKernelController'); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'request'; - } - - private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly) - { - $cookie = sprintf('%s=%s', $name, urlencode($value)); - - if (0 !== $expires) { - if (is_numeric($expires)) { - $expires = (int) $expires; - } elseif ($expires instanceof \DateTime) { - $expires = $expires->getTimestamp(); - } else { - $tmp = strtotime($expires); - if (false === $tmp || -1 == $tmp) { - throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid (%s).', $expires)); - } - $expires = $tmp; - } - - $cookie .= '; expires='.str_replace('+0000', '', \DateTime::createFromFormat('U', $expires, new \DateTimeZone('GMT'))->format('D, d-M-Y H:i:s T')); - } - - if ($domain) { - $cookie .= '; domain='.$domain; - } - - $cookie .= '; path='.$path; - - if ($secure) { - $cookie .= '; secure'; - } - - if ($httponly) { - $cookie .= '; httponly'; - } - - return $cookie; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php deleted file mode 100644 index 76d962346..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; - -/** - * RouterDataCollector. - * - * @author Fabien Potencier - */ -class RouterDataCollector extends DataCollector -{ - protected $controllers; - - public function __construct() - { - $this->controllers = new \SplObjectStorage(); - - $this->data = array( - 'redirect' => false, - 'url' => null, - 'route' => null, - ); - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if ($response instanceof RedirectResponse) { - $this->data['redirect'] = true; - $this->data['url'] = $response->getTargetUrl(); - - if ($this->controllers->contains($request)) { - $this->data['route'] = $this->guessRoute($request, $this->controllers[$request]); - } - } - - unset($this->controllers[$request]); - } - - protected function guessRoute(Request $request, $controller) - { - return 'n/a'; - } - - /** - * Remembers the controller associated to each request. - * - * @param FilterControllerEvent $event The filter controller event - */ - public function onKernelController(FilterControllerEvent $event) - { - $this->controllers[$event->getRequest()] = $event->getController(); - } - - /** - * @return bool Whether this request will result in a redirect - */ - public function getRedirect() - { - return $this->data['redirect']; - } - - /** - * @return string|null The target URL - */ - public function getTargetUrl() - { - return $this->data['url']; - } - - /** - * @return string|null The target route - */ - public function getTargetRoute() - { - return $this->data['route']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'router'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php deleted file mode 100644 index 4ccaafa31..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\KernelInterface; - -/** - * TimeDataCollector. - * - * @author Fabien Potencier - */ -class TimeDataCollector extends DataCollector implements LateDataCollectorInterface -{ - protected $kernel; - protected $stopwatch; - - public function __construct(KernelInterface $kernel = null, $stopwatch = null) - { - $this->kernel = $kernel; - $this->stopwatch = $stopwatch; - } - - /** - * {@inheritdoc} - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if (null !== $this->kernel) { - $startTime = $this->kernel->getStartTime(); - } else { - $startTime = $request->server->get('REQUEST_TIME_FLOAT', $request->server->get('REQUEST_TIME')); - } - - $this->data = array( - 'token' => $response->headers->get('X-Debug-Token'), - 'start_time' => $startTime * 1000, - 'events' => array(), - ); - } - - /** - * {@inheritdoc} - */ - public function lateCollect() - { - if (null !== $this->stopwatch && isset($this->data['token'])) { - $this->setEvents($this->stopwatch->getSectionEvents($this->data['token'])); - } - unset($this->data['token']); - } - - /** - * Sets the request events. - * - * @param array $events The request events - */ - public function setEvents(array $events) - { - foreach ($events as $event) { - $event->ensureStopped(); - } - - $this->data['events'] = $events; - } - - /** - * Gets the request events. - * - * @return array The request events - */ - public function getEvents() - { - return $this->data['events']; - } - - /** - * Gets the request elapsed time. - * - * @return float The elapsed time - */ - public function getDuration() - { - if (!isset($this->data['events']['__section__'])) { - return 0; - } - - $lastEvent = $this->data['events']['__section__']; - - return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime(); - } - - /** - * Gets the initialization time. - * - * This is the time spent until the beginning of the request handling. - * - * @return float The elapsed time - */ - public function getInitTime() - { - if (!isset($this->data['events']['__section__'])) { - return 0; - } - - return $this->data['events']['__section__']->getOrigin() - $this->getStartTime(); - } - - /** - * Gets the request time. - * - * @return int The time - */ - public function getStartTime() - { - return $this->data['start_time']; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'time'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php deleted file mode 100644 index 20d607489..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DataCollector\Util; - -/** - * @author Bernhard Schussek - */ -class ValueExporter -{ - /** - * Converts a PHP value to a string. - * - * @param mixed $value The PHP value - * @param int $depth only for internal usage - * @param bool $deep only for internal usage - * - * @return string The string representation of the given value - */ - public function exportValue($value, $depth = 1, $deep = false) - { - if (is_object($value)) { - if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) { - return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ISO8601)); - } - - return sprintf('Object(%s)', get_class($value)); - } - - if (is_array($value)) { - if (empty($value)) { - return '[]'; - } - - $indent = str_repeat(' ', $depth); - - $a = array(); - foreach ($value as $k => $v) { - if (is_array($v)) { - $deep = true; - } - $a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep)); - } - - if ($deep) { - return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), str_repeat(' ', $depth - 1)); - } - - return sprintf("[%s]", implode(', ', $a)); - } - - if (is_resource($value)) { - return sprintf('Resource(%s#%d)', get_resource_type($value), $value); - } - - if (null === $value) { - return 'null'; - } - - if (false === $value) { - return 'false'; - } - - if (true === $value) { - return 'true'; - } - - return (string) $value; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php deleted file mode 100644 index 2718f891d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * 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\Debug\ErrorHandler as DebugErrorHandler; - -/** - * ErrorHandler. - * - * @author Fabien Potencier - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class ErrorHandler extends DebugErrorHandler -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php deleted file mode 100644 index 581e29cd8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * 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\Debug\ExceptionHandler as DebugExceptionHandler; - -/** - * ExceptionHandler converts an exception to a Response object. - * - * @author Fabien Potencier - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class ExceptionHandler extends DebugExceptionHandler -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php deleted file mode 100644 index 02df5242b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * 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\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\Event; - -/** - * Collects some data about event listeners. - * - * This event dispatcher delegates the dispatching to another one. - * - * @author Fabien Potencier - */ -class TraceableEventDispatcher extends BaseTraceableEventDispatcher -{ - /** - * Sets the profiler. - * - * The traceable event dispatcher does not use the profiler anymore. - * The job is now done directly by the Profiler listener and the - * data collectors themselves. - * - * @param Profiler|null $profiler A Profiler instance - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function setProfiler(Profiler $profiler = null) - { - } - - /** - * {@inheritdoc} - */ - protected function preDispatch($eventName, Event $event) - { - switch ($eventName) { - case KernelEvents::REQUEST: - $this->stopwatch->openSection(); - break; - case KernelEvents::VIEW: - case KernelEvents::RESPONSE: - // stop only if a controller has been executed - if ($this->stopwatch->isStarted('controller')) { - $this->stopwatch->stop('controller'); - } - break; - case KernelEvents::TERMINATE: - $token = $event->getResponse()->headers->get('X-Debug-Token'); - // There is a very special case when using built-in AppCache class as kernel wrapper, in the case - // of an ESI request leading to a `stale` response [B] inside a `fresh` cached response [A]. - // In this case, `$token` contains the [B] debug token, but the open `stopwatch` section ID - // is equal to the [A] debug token. Trying to reopen section with the [B] token throws an exception - // which must be caught. - try { - $this->stopwatch->openSection($token); - } catch (\LogicException $e) { - } - break; - } - } - - /** - * {@inheritdoc} - */ - protected function postDispatch($eventName, Event $event) - { - switch ($eventName) { - case KernelEvents::CONTROLLER: - $this->stopwatch->start('controller', 'section'); - break; - case KernelEvents::RESPONSE: - $token = $event->getResponse()->headers->get('X-Debug-Token'); - $this->stopwatch->stopSection($token); - break; - case KernelEvents::TERMINATE: - // In the special case described in the `preDispatch` method above, the `$token` section - // does not exist, then closing it throws an exception which must be caught. - $token = $event->getResponse()->headers->get('X-Debug-Token'); - try { - $this->stopwatch->stopSection($token); - } catch (\LogicException $e) { - } - break; - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php deleted file mode 100644 index 09af6bd25..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\HttpKernel\Kernel; - -/** - * Sets the classes to compile in the cache for the container. - * - * @author Fabien Potencier - */ -class AddClassesToCachePass implements CompilerPassInterface -{ - private $kernel; - - public function __construct(Kernel $kernel) - { - $this->kernel = $kernel; - } - - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) - { - $classes = array(); - foreach ($container->getExtensions() as $extension) { - if ($extension instanceof Extension) { - $classes = array_merge($classes, $extension->getClassesToCompile()); - } - } - - $this->kernel->setClassCache(array_unique($container->getParameterBag()->resolveValue($classes))); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php deleted file mode 100644 index 3ec454bbc..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * This extension sub-class provides first-class integration with the - * Config/Definition Component. - * - * You can use this as base class if you - * - * a) use the Config/Definition component for configuration - * b) your configuration class is named "Configuration" and - * c) the configuration class resides in the DependencyInjection sub-folder - * - * @author Johannes M. Schmitt - */ -abstract class ConfigurableExtension extends Extension -{ - /** - * {@inheritdoc} - */ - final public function load(array $configs, ContainerBuilder $container) - { - $this->loadInternal($this->processConfiguration($this->getConfiguration($configs, $container), $configs), $container); - } - - /** - * Configures the passed container according to the merged configuration. - * - * @param array $mergedConfig - * @param ContainerBuilder $container - */ - abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php deleted file mode 100644 index 69e7937d1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Scope; - -/** - * Adds a managed request scope. - * - * @author Fabien Potencier - * @author Johannes M. Schmitt - */ -class ContainerAwareHttpKernel extends HttpKernel -{ - protected $container; - - /** - * Constructor. - * - * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance - * @param ContainerInterface $container A ContainerInterface instance - * @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance - * @param RequestStack $requestStack A stack for master/sub requests - */ - public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver, RequestStack $requestStack = null) - { - parent::__construct($dispatcher, $controllerResolver, $requestStack); - - $this->container = $container; - - // the request scope might have been created before (see FrameworkBundle) - if (!$container->hasScope('request')) { - $container->addScope(new Scope('request')); - } - } - - /** - * {@inheritdoc} - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - $request->headers->set('X-Php-Ob-Level', ob_get_level()); - - $this->container->enterScope('request'); - $this->container->set('request', $request, 'request'); - - try { - $response = parent::handle($request, $type, $catch); - } catch (\Exception $e) { - $this->container->set('request', null, 'request'); - $this->container->leaveScope('request'); - - throw $e; - } - - $this->container->set('request', null, 'request'); - $this->container->leaveScope('request'); - - return $response; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php deleted file mode 100644 index 2ca0f1328..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Extension\Extension as BaseExtension; - -/** - * Allow adding classes to the class cache. - * - * @author Fabien Potencier - */ -abstract class Extension extends BaseExtension -{ - private $classes = array(); - - /** - * Gets the classes to cache. - * - * @return array An array of classes - */ - public function getClassesToCompile() - { - return $this->classes; - } - - /** - * Adds classes to the class cache. - * - * @param array $classes An array of classes - */ - public function addClassesToCompile(array $classes) - { - $this->classes = array_merge($this->classes, $classes); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php deleted file mode 100644 index dcd73828d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass as BaseMergeExtensionConfigurationPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Ensures certain extensions are always loaded. - * - * @author Kris Wallsmith - */ -class MergeExtensionConfigurationPass extends BaseMergeExtensionConfigurationPass -{ - private $extensions; - - public function __construct(array $extensions) - { - $this->extensions = $extensions; - } - - public function process(ContainerBuilder $container) - { - foreach ($this->extensions as $extension) { - if (!count($container->getExtensionConfig($extension))) { - $container->loadFromExtension($extension, array()); - } - } - - parent::process($container); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php deleted file mode 100644 index 0e14e9165..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\DependencyInjection; - -use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass as BaseRegisterListenersPass; - -/** - * Compiler pass to register tagged services for an event dispatcher. - * - * @deprecated Deprecated in 2.5, to be removed in 3.0. Use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass instead. - */ -class RegisterListenersPass extends BaseRegisterListenersPass -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php deleted file mode 100644 index e33a01175..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows filtering of a controller callable. - * - * You can call getController() to retrieve the current controller. With - * setController() you can set a new controller that is used in the processing - * of the request. - * - * Controllers should be callables. - * - * @author Bernhard Schussek - * - * @api - */ -class FilterControllerEvent extends KernelEvent -{ - /** - * The current controller. - * - * @var callable - */ - private $controller; - - public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType) - { - parent::__construct($kernel, $request, $requestType); - - $this->setController($controller); - } - - /** - * Returns the current controller. - * - * @return callable - * - * @api - */ - public function getController() - { - return $this->controller; - } - - /** - * Sets a new controller. - * - * @param callable $controller - * - * @throws \LogicException - * - * @api - */ - public function setController($controller) - { - // controller must be a callable - if (!is_callable($controller)) { - throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this->varToString($controller))); - } - - $this->controller = $controller; - } - - private 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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php deleted file mode 100644 index fd88f8773..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to filter a Response object. - * - * You can call getResponse() to retrieve the current response. With - * setResponse() you can set a new response that will be returned to the - * browser. - * - * @author Bernhard Schussek - * - * @api - */ -class FilterResponseEvent extends KernelEvent -{ - /** - * The current response object. - * - * @var Response - */ - private $response; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, Response $response) - { - parent::__construct($kernel, $request, $requestType); - - $this->setResponse($response); - } - - /** - * Returns the current response object. - * - * @return Response - * - * @api - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a new response object. - * - * @param Response $response - * - * @api - */ - public function setResponse(Response $response) - { - $this->response = $response; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php deleted file mode 100644 index ee724843c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -/** - * Triggered whenever a request is fully processed. - * - * @author Benjamin Eberlei - */ -class FinishRequestEvent extends KernelEvent -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php deleted file mode 100644 index b9310faef..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to create a response for a request. - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * @author Bernhard Schussek - * - * @api - */ -class GetResponseEvent extends KernelEvent -{ - /** - * The response object. - * - * @var Response - */ - private $response; - - /** - * Returns the response object. - * - * @return Response - * - * @api - */ - public function getResponse() - { - return $this->response; - } - - /** - * Sets a response and stops event propagation. - * - * @param Response $response - * - * @api - */ - public function setResponse(Response $response) - { - $this->response = $response; - - $this->stopPropagation(); - } - - /** - * Returns whether a response was set. - * - * @return bool Whether a response was set - * - * @api - */ - public function hasResponse() - { - return null !== $this->response; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php deleted file mode 100644 index afb1c4505..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows to create a response for the return value of a controller. - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * @author Bernhard Schussek - * - * @api - */ -class GetResponseForControllerResultEvent extends GetResponseEvent -{ - /** - * The return value of the controller. - * - * @var mixed - */ - private $controllerResult; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, $controllerResult) - { - parent::__construct($kernel, $request, $requestType); - - $this->controllerResult = $controllerResult; - } - - /** - * Returns the return value of the controller. - * - * @return mixed The controller return value - * - * @api - */ - public function getControllerResult() - { - return $this->controllerResult; - } - - /** - * Assigns the return value of the controller. - * - * @param mixed $controllerResult The controller return value - * - * @api - */ - public function setControllerResult($controllerResult) - { - $this->controllerResult = $controllerResult; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php deleted file mode 100644 index 3b5957efd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Allows to create a response for a thrown exception. - * - * Call setResponse() to set the response that will be returned for the - * current request. The propagation of this event is stopped as soon as a - * response is set. - * - * You can also call setException() to replace the thrown exception. This - * exception will be thrown if no response is set during processing of this - * event. - * - * @author Bernhard Schussek - * - * @api - */ -class GetResponseForExceptionEvent extends GetResponseEvent -{ - /** - * The exception object. - * - * @var \Exception - */ - private $exception; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, \Exception $e) - { - parent::__construct($kernel, $request, $requestType); - - $this->setException($e); - } - - /** - * Returns the thrown exception. - * - * @return \Exception The thrown exception - * - * @api - */ - public function getException() - { - return $this->exception; - } - - /** - * Replaces the thrown exception. - * - * This exception will be thrown if no response is set in the event. - * - * @param \Exception $exception The thrown exception - * - * @api - */ - public function setException(\Exception $exception) - { - $this->exception = $exception; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php deleted file mode 100644 index 1d97ead4d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\Event; - -/** - * Base class for events thrown in the HttpKernel component. - * - * @author Bernhard Schussek - * - * @api - */ -class KernelEvent extends Event -{ - /** - * The kernel in which this event was thrown. - * - * @var HttpKernelInterface - */ - private $kernel; - - /** - * The request the kernel is currently processing. - * - * @var Request - */ - private $request; - - /** - * The request type the kernel is currently processing. One of - * HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST. - * - * @var int - */ - private $requestType; - - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType) - { - $this->kernel = $kernel; - $this->request = $request; - $this->requestType = $requestType; - } - - /** - * Returns the kernel in which this event was thrown. - * - * @return HttpKernelInterface - * - * @api - */ - public function getKernel() - { - return $this->kernel; - } - - /** - * Returns the request the kernel is currently processing. - * - * @return Request - * - * @api - */ - public function getRequest() - { - return $this->request; - } - - /** - * Returns the request type the kernel is currently processing. - * - * @return int One of HttpKernelInterface::MASTER_REQUEST and - * HttpKernelInterface::SUB_REQUEST - * - * @api - */ - public function getRequestType() - { - return $this->requestType; - } - - /** - * Checks if this is a master request. - * - * @return bool True if the request is a master request - * - * @api - */ - public function isMasterRequest() - { - return HttpKernelInterface::MASTER_REQUEST === $this->requestType; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/PostResponseEvent.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/PostResponseEvent.php deleted file mode 100644 index 5d4450b35..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Event/PostResponseEvent.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Event; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Allows to execute logic after a response was sent. - * - * @author Jordi Boggiano - */ -class PostResponseEvent extends Event -{ - /** - * The kernel in which this event was thrown. - * - * @var HttpKernelInterface - */ - private $kernel; - - private $request; - - private $response; - - public function __construct(HttpKernelInterface $kernel, Request $request, Response $response) - { - $this->kernel = $kernel; - $this->request = $request; - $this->response = $response; - } - - /** - * Returns the kernel in which this event was thrown. - * - * @return HttpKernelInterface - */ - public function getKernel() - { - return $this->kernel; - } - - /** - * Returns the request for which this event was thrown. - * - * @return Request - */ - public function getRequest() - { - return $this->request; - } - - /** - * Returns the response for which this event was thrown. - * - * @return Response - */ - public function getResponse() - { - return $this->response; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php deleted file mode 100644 index c37a53700..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/AddRequestFormatsListener.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; - -/** - * Adds configured formats to each request - * - * @author Gildas Quemener - */ -class AddRequestFormatsListener implements EventSubscriberInterface -{ - /** - * @var array - */ - protected $formats; - - /** - * @param array $formats - */ - public function __construct(array $formats) - { - $this->formats = $formats; - } - - /** - * Adds request formats - * - * @param GetResponseEvent $event - */ - public function onKernelRequest(GetResponseEvent $event) - { - foreach ($this->formats as $format => $mimeTypes) { - $event->getRequest()->setFormat($format, $mimeTypes); - } - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return array(KernelEvents::REQUEST => 'onKernelRequest'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php deleted file mode 100644 index f50e4d6c3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\KernelEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\Console\Event\ConsoleEvent; -use Symfony\Component\Console\Output\ConsoleOutputInterface; - -/** - * Configures errors and exceptions handlers. - * - * @author Nicolas Grekas - */ -class DebugHandlersListener implements EventSubscriberInterface -{ - private $exceptionHandler; - private $logger; - private $levels; - private $throwAt; - private $scream; - private $fileLinkFormat; - private $firstCall = true; - - /** - * @param callable|null $exceptionHandler A handler that will be called on Exception - * @param LoggerInterface|null $logger A PSR-3 logger - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants - * @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value - * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged - * @param string $fileLinkFormat The format for links to source files - */ - public function __construct($exceptionHandler, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null) - { - $this->exceptionHandler = $exceptionHandler; - $this->logger = $logger; - $this->levels = $levels; - $this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? -1 : null)); - $this->scream = (bool) $scream; - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - } - - /** - * Configures the error handler. - * - * @param Event|null $event The triggering event - */ - public function configure(Event $event = null) - { - if (!$this->firstCall) { - return; - } - $this->firstCall = false; - if ($this->logger || null !== $this->throwAt) { - $handler = set_error_handler('var_dump', 0); - $handler = is_array($handler) ? $handler[0] : null; - restore_error_handler(); - if ($handler instanceof ErrorHandler) { - if ($this->logger) { - $handler->setDefaultLogger($this->logger, $this->levels); - if (is_array($this->levels)) { - $scream = 0; - foreach ($this->levels as $type => $log) { - $scream |= $type; - } - } else { - $scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels; - } - if ($this->scream) { - $handler->screamAt($scream); - } - $this->logger = $this->levels = null; - } - if (null !== $this->throwAt) { - $handler->throwAt($this->throwAt, true); - } - } - } - if (!$this->exceptionHandler) { - if ($event instanceof KernelEvent) { - $this->exceptionHandler = array($event->getKernel(), 'terminateWithException'); - } elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) { - $output = $event->getOutput(); - if ($output instanceof ConsoleOutputInterface) { - $output = $output->getErrorOutput(); - } - $this->exceptionHandler = function ($e) use ($app, $output) { - $app->renderException($e, $output); - }; - } - } - if ($this->exceptionHandler) { - $handler = set_exception_handler('var_dump'); - $handler = is_array($handler) ? $handler[0] : null; - restore_exception_handler(); - if ($handler instanceof ErrorHandler) { - $h = $handler->setExceptionHandler('var_dump') ?: $this->exceptionHandler; - $handler->setExceptionHandler($h); - $handler = is_array($h) ? $h[0] : null; - } - if ($handler instanceof ExceptionHandler) { - $handler->setHandler($this->exceptionHandler); - if (null !== $this->fileLinkFormat) { - $handler->setFileLinkFormat($this->fileLinkFormat); - } - } - $this->exceptionHandler = null; - } - } - - public static function getSubscribedEvents() - { - $events = array(KernelEvents::REQUEST => array('configure', 2048)); - - if (defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) { - $events[ConsoleEvents::COMMAND] = array('configure', 2048); - } - - return $events; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DumpListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DumpListener.php deleted file mode 100644 index bccde8eb9..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/DumpListener.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\VarDumper\Cloner\ClonerInterface; -use Symfony\Component\VarDumper\Dumper\DataDumperInterface; -use Symfony\Component\VarDumper\VarDumper; - -/** - * Configures dump() handler. - * - * @author Nicolas Grekas - */ -class DumpListener implements EventSubscriberInterface -{ - private $cloner; - private $dumper; - - /** - * @param ClonerInterface $cloner Cloner service. - * @param DataDumperInterface $dumper Dumper service. - */ - public function __construct(ClonerInterface $cloner, DataDumperInterface $dumper) - { - $this->cloner = $cloner; - $this->dumper = $dumper; - } - - public function configure() - { - $cloner = $this->cloner; - $dumper = $this->dumper; - - VarDumper::setHandler(function ($var) use ($cloner, $dumper) { - $dumper->dump($cloner->cloneVar($var)); - }); - } - - public static function getSubscribedEvents() - { - // Register early to have a working dump() as early as possible - return array(KernelEvents::REQUEST => array('configure', 1024)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php deleted file mode 100644 index d5400b7d6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Injects the logger into the ErrorHandler, so that it can log various errors. - * - * @author Colin Frei - * @author Konstantin Myakshin - * - * @deprecated since 2.6, to be removed in 3.0. Use DebugHandlersListener instead. - */ -class ErrorsLoggerListener implements EventSubscriberInterface -{ - private $channel; - - private $logger; - - public function __construct($channel, LoggerInterface $logger = null) - { - $this->channel = $channel; - $this->logger = $logger; - } - - public function injectLogger() - { - if (null !== $this->logger) { - ErrorHandler::setLogger($this->logger, $this->channel); - $this->logger = null; - } - } - - public static function getSubscribedEvents() - { - return array(KernelEvents::REQUEST => array('injectLogger', 2048)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php deleted file mode 100644 index 638016901..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -/** - * EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI. - * - * @author Fabien Potencier - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use SurrogateListener instead - */ -class EsiListener extends SurrogateListener -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php deleted file mode 100644 index b7ded63e4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * ExceptionListener. - * - * @author Fabien Potencier - */ -class ExceptionListener implements EventSubscriberInterface -{ - protected $controller; - protected $logger; - - public function __construct($controller, LoggerInterface $logger = null) - { - $this->controller = $controller; - $this->logger = $logger; - } - - public function onKernelException(GetResponseForExceptionEvent $event) - { - $exception = $event->getException(); - $request = $event->getRequest(); - - $this->logException($exception, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); - - $request = $this->duplicateRequest($exception, $request); - - try { - $response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false); - } catch (\Exception $e) { - $this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), false); - - $wrapper = $e; - - while ($prev = $wrapper->getPrevious()) { - if ($exception === $wrapper = $prev) { - throw $e; - } - } - - $prev = new \ReflectionProperty('Exception', 'previous'); - $prev->setAccessible(true); - $prev->setValue($wrapper, $exception); - - throw $e; - } - - $event->setResponse($response); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::EXCEPTION => array('onKernelException', -128), - ); - } - - /** - * Logs an exception. - * - * @param \Exception $exception The \Exception instance - * @param string $message The error message to log - * @param bool $original False when the handling of the exception thrown another exception - */ - protected function logException(\Exception $exception, $message, $original = true) - { - $isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500; - $context = array('exception' => $exception); - if (null !== $this->logger) { - if ($isCritical) { - $this->logger->critical($message, $context); - } else { - $this->logger->error($message, $context); - } - } elseif (!$original || $isCritical) { - error_log($message); - } - } - - /** - * Clones the request for the exception. - * - * @param \Exception $exception The thrown exception. - * @param Request $request The original request. - * - * @return Request $request The cloned request. - */ - protected function duplicateRequest(\Exception $exception, Request $request) - { - $attributes = array( - '_controller' => $this->controller, - 'exception' => FlattenException::create($exception), - 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, - // keep for BC -- as $format can be an argument of the controller callable - // see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php - // @deprecated in 2.4, to be removed in 3.0 - 'format' => $request->getRequestFormat(), - ); - $request = $request->duplicate(null, null, $attributes); - $request->setMethod('GET'); - - return $request; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php deleted file mode 100644 index b95078a25..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\HttpKernel\UriSigner; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Handles content fragments represented by special URIs. - * - * All URL paths starting with /_fragment are handled as - * content fragments by this listener. - * - * If throws an AccessDeniedHttpException exception if the request - * is not signed or if it is not an internal sub-request. - * - * @author Fabien Potencier - */ -class FragmentListener implements EventSubscriberInterface -{ - private $signer; - private $fragmentPath; - - /** - * Constructor. - * - * @param UriSigner $signer A UriSigner instance - * @param string $fragmentPath The path that triggers this listener - */ - public function __construct(UriSigner $signer, $fragmentPath = '/_fragment') - { - $this->signer = $signer; - $this->fragmentPath = $fragmentPath; - } - - /** - * Fixes request attributes when the path is '/_fragment'. - * - * @param GetResponseEvent $event A GetResponseEvent instance - * - * @throws AccessDeniedHttpException if the request does not come from a trusted IP. - */ - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - - if ($request->attributes->has('_controller') || $this->fragmentPath !== rawurldecode($request->getPathInfo())) { - return; - } - - if ($event->isMasterRequest()) { - $this->validateRequest($request); - } - - parse_str($request->query->get('_path', ''), $attributes); - $request->attributes->add($attributes); - $request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes)); - $request->query->remove('_path'); - } - - protected function validateRequest(Request $request) - { - // is the Request safe? - if (!$request->isMethodSafe()) { - throw new AccessDeniedHttpException(); - } - - // is the Request signed? - // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering) - if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) { - return; - } - - throw new AccessDeniedHttpException(); - } - - /** - * @deprecated Deprecated since 2.3.19, to be removed in 3.0. - * - * @return string[] - */ - protected function getLocalIpAddresses() - { - return array('127.0.0.1', 'fe80::1', '::1'); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 48)), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php deleted file mode 100644 index bdcf4c764..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Initializes the locale based on the current request. - * - * This listener works in 2 modes: - * - * * 2.3 compatibility mode where you must call setRequest whenever the Request changes. - * * 2.4+ mode where you must pass a RequestStack instance in the constructor. - * - * @author Fabien Potencier - */ -class LocaleListener implements EventSubscriberInterface -{ - private $router; - private $defaultLocale; - private $requestStack; - - /** - * RequestStack will become required in 3.0. - */ - public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null, RequestStack $requestStack = null) - { - $this->defaultLocale = $defaultLocale; - $this->requestStack = $requestStack; - $this->router = $router; - } - - /** - * Sets the current Request. - * - * This method was used to synchronize the Request, but as the HttpKernel - * is doing that automatically now, you should never call it directly. - * It is kept public for BC with the 2.3 version. - * - * @param Request|null $request A Request instance - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function setRequest(Request $request = null) - { - if (null === $request) { - return; - } - - $this->setLocale($request); - $this->setRouterContext($request); - } - - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - $request->setDefaultLocale($this->defaultLocale); - - $this->setLocale($request); - $this->setRouterContext($request); - } - - public function onKernelFinishRequest(FinishRequestEvent $event) - { - if (null === $this->requestStack) { - return; // removed when requestStack is required - } - - if (null !== $parentRequest = $this->requestStack->getParentRequest()) { - $this->setRouterContext($parentRequest); - } - } - - private function setLocale(Request $request) - { - if ($locale = $request->attributes->get('_locale')) { - $request->setLocale($locale); - } - } - - private function setRouterContext(Request $request) - { - if (null !== $this->router) { - $this->router->getContext()->setParameter('_locale', $request->getLocale()); - } - } - - public static function getSubscribedEvents() - { - return array( - // must be registered after the Router to have access to the _locale - KernelEvents::REQUEST => array(array('onKernelRequest', 16)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php deleted file mode 100644 index 43d8d03a7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\RequestMatcherInterface; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * ProfilerListener collects data for the current request by listening to the onKernelResponse event. - * - * @author Fabien Potencier - */ -class ProfilerListener implements EventSubscriberInterface -{ - protected $profiler; - protected $matcher; - protected $onlyException; - protected $onlyMasterRequests; - protected $exception; - protected $requests = array(); - protected $profiles; - protected $requestStack; - protected $parents; - - /** - * Constructor. - * - * @param Profiler $profiler A Profiler instance - * @param RequestMatcherInterface|null $matcher A RequestMatcher instance - * @param bool $onlyException true if the profiler only collects data when an exception occurs, false otherwise - * @param bool $onlyMasterRequests true if the profiler only collects data when the request is a master request, false otherwise - * @param RequestStack|null $requestStack A RequestStack instance - */ - public function __construct(Profiler $profiler, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false, RequestStack $requestStack = null) - { - $this->profiler = $profiler; - $this->matcher = $matcher; - $this->onlyException = (bool) $onlyException; - $this->onlyMasterRequests = (bool) $onlyMasterRequests; - $this->profiles = new \SplObjectStorage(); - $this->parents = new \SplObjectStorage(); - $this->requestStack = $requestStack; - } - - /** - * Handles the onKernelException event. - * - * @param GetResponseForExceptionEvent $event A GetResponseForExceptionEvent instance - */ - public function onKernelException(GetResponseForExceptionEvent $event) - { - if ($this->onlyMasterRequests && !$event->isMasterRequest()) { - return; - } - - $this->exception = $event->getException(); - } - - /** - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function onKernelRequest(GetResponseEvent $event) - { - if (null === $this->requestStack) { - $this->requests[] = $event->getRequest(); - } - } - - /** - * Handles the onKernelResponse event. - * - * @param FilterResponseEvent $event A FilterResponseEvent instance - */ - public function onKernelResponse(FilterResponseEvent $event) - { - $master = $event->isMasterRequest(); - if ($this->onlyMasterRequests && !$master) { - return; - } - - if ($this->onlyException && null === $this->exception) { - return; - } - - $request = $event->getRequest(); - $exception = $this->exception; - $this->exception = null; - - if (null !== $this->matcher && !$this->matcher->matches($request)) { - return; - } - - if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) { - return; - } - - $this->profiles[$request] = $profile; - - if (null !== $this->requestStack) { - $this->parents[$request] = $this->requestStack->getParentRequest(); - } elseif (!$master) { - // to be removed when requestStack is required - array_pop($this->requests); - - $this->parents[$request] = end($this->requests); - } - } - - public function onKernelTerminate(PostResponseEvent $event) - { - // attach children to parents - foreach ($this->profiles as $request) { - // isset call should be removed when requestStack is required - if (isset($this->parents[$request]) && null !== $parentRequest = $this->parents[$request]) { - if (isset($this->profiles[$parentRequest])) { - $this->profiles[$parentRequest]->addChild($this->profiles[$request]); - } - } - } - - // save profiles - foreach ($this->profiles as $request) { - $this->profiler->saveProfile($this->profiles[$request]); - } - - $this->profiles = new \SplObjectStorage(); - $this->parents = new \SplObjectStorage(); - $this->requests = array(); - } - - public static function getSubscribedEvents() - { - return array( - // kernel.request must be registered as early as possible to not break - // when an exception is thrown in any other kernel.request listener - KernelEvents::REQUEST => array('onKernelRequest', 1024), - KernelEvents::RESPONSE => array('onKernelResponse', -100), - KernelEvents::EXCEPTION => 'onKernelException', - KernelEvents::TERMINATE => array('onKernelTerminate', -1024), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php deleted file mode 100644 index eeb2b0fcb..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * ResponseListener fixes the Response headers based on the Request. - * - * @author Fabien Potencier - */ -class ResponseListener implements EventSubscriberInterface -{ - private $charset; - - public function __construct($charset) - { - $this->charset = $charset; - } - - /** - * Filters the Response. - * - * @param FilterResponseEvent $event A FilterResponseEvent instance - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $response = $event->getResponse(); - - if (null === $response->getCharset()) { - $response->setCharset($this->charset); - } - - $response->prepare($event->getRequest()); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::RESPONSE => 'onKernelResponse', - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php deleted file mode 100644 index db05fcac1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; -use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * Initializes the context from the request and sets request attributes based on a matching route. - * - * This listener works in 2 modes: - * - * * 2.3 compatibility mode where you must call setRequest whenever the Request changes. - * * 2.4+ mode where you must pass a RequestStack instance in the constructor. - * - * @author Fabien Potencier - */ -class RouterListener implements EventSubscriberInterface -{ - private $matcher; - private $context; - private $logger; - private $request; - private $requestStack; - - /** - * Constructor. - * - * RequestStack will become required in 3.0. - * - * @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher - * @param RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface) - * @param LoggerInterface|null $logger The logger - * @param RequestStack|null $requestStack A RequestStack instance - * - * @throws \InvalidArgumentException - */ - public function __construct($matcher, RequestContext $context = null, LoggerInterface $logger = null, RequestStack $requestStack = null) - { - if (!$matcher instanceof UrlMatcherInterface && !$matcher instanceof RequestMatcherInterface) { - throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.'); - } - - if (null === $context && !$matcher instanceof RequestContextAwareInterface) { - throw new \InvalidArgumentException('You must either pass a RequestContext or the matcher must implement RequestContextAwareInterface.'); - } - - $this->matcher = $matcher; - $this->context = $context ?: $matcher->getContext(); - $this->requestStack = $requestStack; - $this->logger = $logger; - } - - /** - * Sets the current Request. - * - * This method was used to synchronize the Request, but as the HttpKernel - * is doing that automatically now, you should never call it directly. - * It is kept public for BC with the 2.3 version. - * - * @param Request|null $request A Request instance - * - * @deprecated Deprecated since version 2.4, to be moved to a private function in 3.0. - */ - public function setRequest(Request $request = null) - { - if (null !== $request && $this->request !== $request) { - $this->context->fromRequest($request); - } - $this->request = $request; - } - - public function onKernelFinishRequest(FinishRequestEvent $event) - { - if (null === $this->requestStack) { - return; // removed when requestStack is required - } - - $this->setRequest($this->requestStack->getParentRequest()); - } - - public function onKernelRequest(GetResponseEvent $event) - { - $request = $event->getRequest(); - - // initialize the context that is also used by the generator (assuming matcher and generator share the same context instance) - // we call setRequest even if most of the time, it has already been done to keep compatibility - // with frameworks which do not use the Symfony service container - // when we have a RequestStack, no need to do it - if (null !== $this->requestStack) { - $this->setRequest($request); - } - - if ($request->attributes->has('_controller')) { - // routing is already done - return; - } - - // add attributes based on the request (routing) - try { - // matching a request is more powerful than matching a URL path + context, so try that first - if ($this->matcher instanceof RequestMatcherInterface) { - $parameters = $this->matcher->matchRequest($request); - } else { - $parameters = $this->matcher->match($request->getPathInfo()); - } - - if (null !== $this->logger) { - $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters))); - } - - $request->attributes->add($parameters); - unset($parameters['_route'], $parameters['_controller']); - $request->attributes->set('_route_params', $parameters); - } catch (ResourceNotFoundException $e) { - $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo()); - - if ($referer = $request->headers->get('referer')) { - $message .= sprintf(' (from "%s")', $referer); - } - - throw new NotFoundHttpException($message, $e); - } catch (MethodNotAllowedException $e) { - $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $e->getAllowedMethods())); - - throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); - } - } - - private function parametersToString(array $parameters) - { - $pieces = array(); - foreach ($parameters as $key => $val) { - $pieces[] = sprintf('"%s": "%s"', $key, (is_string($val) ? $val : json_encode($val))); - } - - return implode(', ', $pieces); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 32)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php deleted file mode 100644 index 36809b59a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Saves the session, in case it is still open, before sending the response/headers. - * - * This ensures several things in case the developer did not save the session explicitly: - * - * * If a session save handler without locking is used, it ensures the data is available - * on the next request, e.g. after a redirect. PHPs auto-save at script end via - * session_register_shutdown is executed after fastcgi_finish_request. So in this case - * the data could be missing the next request because it might not be saved the moment - * the new request is processed. - * * A locking save handler (e.g. the native 'files') circumvents concurrency problems like - * the one above. But by saving the session before long-running things in the terminate event, - * we ensure the session is not blocked longer than needed. - * * When regenerating the session ID no locking is involved in PHPs session design. See - * https://bugs.php.net/bug.php?id=61470 for a discussion. So in this case, the session must - * be saved anyway before sending the headers with the new session ID. Otherwise session - * data could get lost again for concurrent requests with the new ID. One result could be - * that you get logged out after just logging in. - * - * This listener should be executed as one of the last listeners, so that previous listeners - * can still operate on the open session. This prevents the overhead of restarting it. - * Listeners after closing the session can still work with the session as usual because - * Symfonys session implementation starts the session on demand. So writing to it after - * it is saved will just restart it. - * - * @author Tobias Schultze - */ -class SaveSessionListener implements EventSubscriberInterface -{ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $session = $event->getRequest()->getSession(); - if ($session && $session->isStarted()) { - $session->save(); - } - } - - public static function getSubscribedEvents() - { - return array( - // low priority but higher than StreamedResponseListener - KernelEvents::RESPONSE => array(array('onKernelResponse', -1000)), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php deleted file mode 100644 index ecf065f0e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Sets the session in the request. - * - * @author Johannes M. Schmitt - */ -abstract class SessionListener implements EventSubscriberInterface -{ - public function onKernelRequest(GetResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $request = $event->getRequest(); - $session = $this->getSession(); - if (null === $session || $request->hasSession()) { - return; - } - - $request->setSession($session); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 128), - ); - } - - /** - * Gets the session object. - * - * @return SessionInterface|null A SessionInterface instance or null if no session is available - */ - abstract protected function getSession(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php deleted file mode 100644 index 571cd74e3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * StreamedResponseListener is responsible for sending the Response - * to the client. - * - * @author Fabien Potencier - */ -class StreamedResponseListener implements EventSubscriberInterface -{ - /** - * Filters the Response. - * - * @param FilterResponseEvent $event A FilterResponseEvent instance - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $response = $event->getResponse(); - - if ($response instanceof StreamedResponse) { - $response->send(); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::RESPONSE => array('onKernelResponse', -1024), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php deleted file mode 100644 index 00f4fbf24..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SurrogateListener.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates - * - * @author Fabien Potencier - */ -class SurrogateListener implements EventSubscriberInterface -{ - private $surrogate; - - /** - * Constructor. - * - * @param SurrogateInterface $surrogate An SurrogateInterface instance - */ - public function __construct(SurrogateInterface $surrogate = null) - { - $this->surrogate = $surrogate; - } - - /** - * Filters the Response. - * - * @param FilterResponseEvent $event A FilterResponseEvent instance - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest() || null === $this->surrogate) { - return; - } - - $this->surrogate->addSurrogateControl($event->getResponse()); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::RESPONSE => 'onKernelResponse', - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php deleted file mode 100644 index 42a0f20bd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * TestSessionListener. - * - * Saves session in test environment. - * - * @author Bulat Shakirzyanov - * @author Fabien Potencier - */ -abstract class TestSessionListener implements EventSubscriberInterface -{ - public function onKernelRequest(GetResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - // bootstrap the session - $session = $this->getSession(); - if (!$session) { - return; - } - - $cookies = $event->getRequest()->cookies; - - if ($cookies->has($session->getName())) { - $session->setId($cookies->get($session->getName())); - } - } - - /** - * Checks if session was initialized and saves if current request is master - * Runs on 'kernel.response' in test environment - * - * @param FilterResponseEvent $event - */ - public function onKernelResponse(FilterResponseEvent $event) - { - if (!$event->isMasterRequest()) { - return; - } - - $session = $event->getRequest()->getSession(); - if ($session && $session->isStarted()) { - $session->save(); - $params = session_get_cookie_params(); - $event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'])); - } - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 192), - KernelEvents::RESPONSE => array('onKernelResponse', -128), - ); - } - - /** - * Gets the session object. - * - * @return SessionInterface|null A SessionInterface instance or null if no session is available - */ - abstract protected function getSession(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TranslatorListener.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TranslatorListener.php deleted file mode 100644 index 6967ad029..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TranslatorListener.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Synchronizes the locale between the request and the translator. - * - * @author Fabien Potencier - */ -class TranslatorListener implements EventSubscriberInterface -{ - private $translator; - private $requestStack; - - public function __construct(TranslatorInterface $translator, RequestStack $requestStack) - { - $this->translator = $translator; - $this->requestStack = $requestStack; - } - - public function onKernelRequest(GetResponseEvent $event) - { - $this->setLocale($event->getRequest()); - } - - public function onKernelFinishRequest(FinishRequestEvent $event) - { - if (null === $parentRequest = $this->requestStack->getParentRequest()) { - return; - } - - $this->setLocale($parentRequest); - } - - public static function getSubscribedEvents() - { - return array( - // must be registered after the Locale listener - KernelEvents::REQUEST => array(array('onKernelRequest', 10)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); - } - - private function setLocale(Request $request) - { - try { - $this->translator->setLocale($request->getLocale()); - } catch (\InvalidArgumentException $e) { - $this->translator->setLocale($request->getDefaultLocale()); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php deleted file mode 100644 index 79d8639a5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * AccessDeniedHttpException. - * - * @author Fabien Potencier - * @author Christophe Coevoet - */ -class AccessDeniedHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $code The internal exception code - */ - public function __construct($message = null, \Exception $previous = null, $code = 0) - { - parent::__construct(403, $message, $previous, array(), $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php deleted file mode 100644 index 5f68172a8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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 - */ -class BadRequestHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php deleted file mode 100644 index 34d738ed1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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 - */ -class ConflictHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php deleted file mode 100644 index 7a1cd2338..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/* - * Fatal Error Exception. - * - * @author Konstanton Myakshin - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class_exists('Symfony\Component\Debug\Exception\FatalErrorException'); diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php deleted file mode 100644 index ebe45b458..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/* - * FlattenException wraps a PHP Exception to be able to serialize it. - * - * Basically, this class removes all objects from the trace. - * - * @author Fabien Potencier - * - * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead. - */ -class_exists('Symfony\Component\Debug\Exception\FlattenException'); diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php deleted file mode 100644 index 16ea223fa..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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 - */ -class GoneHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpException.php deleted file mode 100644 index 4e1b52632..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpException.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * HttpException. - * - * @author Kris Wallsmith - */ -class HttpException extends \RuntimeException implements HttpExceptionInterface -{ - private $statusCode; - private $headers; - - public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = array(), $code = 0) - { - $this->statusCode = $statusCode; - $this->headers = $headers; - - parent::__construct($message, $code, $previous); - } - - public function getStatusCode() - { - return $this->statusCode; - } - - public function getHeaders() - { - return $this->headers; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php deleted file mode 100644 index 8aa50a9f4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * Interface for HTTP error exceptions. - * - * @author Kris Wallsmith - */ -interface HttpExceptionInterface -{ - /** - * Returns the status code. - * - * @return int An HTTP response status code - */ - public function getStatusCode(); - - /** - * Returns response headers. - * - * @return array Response headers - */ - public function getHeaders(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php deleted file mode 100644 index 0c4b9431f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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 - */ -class LengthRequiredHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php deleted file mode 100644 index 78dd26bf0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * MethodNotAllowedHttpException. - * - * @author Kris Wallsmith - */ -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 int $code The internal exception code - */ - public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0) - { - $headers = array('Allow' => strtoupper(implode(', ', $allow))); - - parent::__construct(405, $message, $previous, $headers, $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php deleted file mode 100644 index cc6be4ba4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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 - */ -class NotAcceptableHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php deleted file mode 100644 index 4639e379b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * NotFoundHttpException. - * - * @author Fabien Potencier - */ -class NotFoundHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $code The internal exception code - */ - public function __construct($message = null, \Exception $previous = null, $code = 0) - { - parent::__construct(404, $message, $previous, array(), $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php deleted file mode 100644 index 9df0e7b49..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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 - */ -class PreconditionFailedHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php deleted file mode 100644 index 08ebca224..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * 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 - * - * @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 int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php deleted file mode 100644 index 32b9e2d26..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * 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 - */ -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 int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php deleted file mode 100644 index ab86e0920..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * 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 - * - * @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 int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php deleted file mode 100644 index 0dfe42db9..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * 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 - */ -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 int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php deleted file mode 100644 index eb13f563f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Exception; - -/** - * UnprocessableEntityHttpException. - * - * @author Steve Hutchins - */ -class UnprocessableEntityHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $code The internal exception code - */ - public function __construct($message = null, \Exception $previous = null, $code = 0) - { - parent::__construct(422, $message, $previous, array(), $code); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php deleted file mode 100644 index a9d8fa086..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * 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 - */ -class UnsupportedMediaTypeHttpException extends HttpException -{ - /** - * Constructor. - * - * @param string $message The internal exception message - * @param \Exception $previous The previous exception - * @param int $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php deleted file mode 100644 index 1968001a8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface; -use Symfony\Component\HttpKernel\UriSigner; - -/** - * Implements Surrogate rendering strategy. - * - * @author Fabien Potencier - */ -abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRenderer -{ - private $surrogate; - private $inlineStrategy; - private $signer; - - /** - * Constructor. - * - * The "fallback" strategy when surrogate is not available should always be an - * instance of InlineFragmentRenderer. - * - * @param SurrogateInterface $surrogate An Surrogate instance - * @param FragmentRendererInterface $inlineStrategy The inline strategy to use when the surrogate is not supported - * @param UriSigner $signer - */ - public function __construct(SurrogateInterface $surrogate = null, FragmentRendererInterface $inlineStrategy, UriSigner $signer = null) - { - $this->surrogate = $surrogate; - $this->inlineStrategy = $inlineStrategy; - $this->signer = $signer; - } - - /** - * {@inheritdoc} - * - * Note that if the current Request has no surrogate capability, this method - * falls back to use the inline rendering strategy. - * - * Additional available options: - * - * * alt: an alternative URI to render in case of an error - * * comment: a comment to add when returning the surrogate tag - * - * Note, that not all surrogate strategies support all options. For now - * 'alt' and 'comment' are only supported by ESI. - * - * @see Symfony\Component\HttpKernel\HttpCache\SurrogateInterface - */ - public function render($uri, Request $request, array $options = array()) - { - if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) { - return $this->inlineStrategy->render($uri, $request, $options); - } - - if ($uri instanceof ControllerReference) { - $uri = $this->generateSignedFragmentUri($uri, $request); - } - - $alt = isset($options['alt']) ? $options['alt'] : null; - if ($alt instanceof ControllerReference) { - $alt = $this->generateSignedFragmentUri($alt, $request); - } - - $tag = $this->surrogate->renderIncludeTag($uri, $alt, isset($options['ignore_errors']) ? $options['ignore_errors'] : false, isset($options['comment']) ? $options['comment'] : ''); - - return new Response($tag); - } - - private function generateSignedFragmentUri($uri, Request $request) - { - if (null === $this->signer) { - throw new \LogicException('You must use a URI when using the ESI rendering strategy or set a URL signer.'); - } - - // we need to sign the absolute URI, but want to return the path only. - $fragmentUri = $this->signer->sign($this->generateFragmentUri($uri, $request, true)); - - return substr($fragmentUri, strlen($request->getSchemeAndHttpHost())); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php deleted file mode 100644 index a4570e3be..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -/** - * Implements the ESI rendering strategy. - * - * @author Fabien Potencier - */ -class EsiFragmentRenderer extends AbstractSurrogateFragmentRenderer -{ - /** - * {@inheritdoc} - */ - public function getName() - { - return 'esi'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php deleted file mode 100644 index 27fa7eabe..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Controller\ControllerReference; - -/** - * Renders a URI that represents a resource fragment. - * - * This class handles the rendering of resource fragments that are included into - * a main resource. The handling of the rendering is managed by specialized renderers. - * - * This listener works in 2 modes: - * - * * 2.3 compatibility mode where you must call setRequest whenever the Request changes. - * * 2.4+ mode where you must pass a RequestStack instance in the constructor. - * - * @author Fabien Potencier - * - * @see FragmentRendererInterface - */ -class FragmentHandler -{ - private $debug; - private $renderers = array(); - private $request; - private $requestStack; - - /** - * Constructor. - * - * RequestStack will become required in 3.0. - * - * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances - * @param bool $debug Whether the debug mode is enabled or not - * @param RequestStack|null $requestStack The Request stack that controls the lifecycle of requests - */ - public function __construct(array $renderers = array(), $debug = false, RequestStack $requestStack = null) - { - $this->requestStack = $requestStack; - foreach ($renderers as $renderer) { - $this->addRenderer($renderer); - } - $this->debug = $debug; - } - - /** - * Adds a renderer. - * - * @param FragmentRendererInterface $renderer A FragmentRendererInterface instance - */ - public function addRenderer(FragmentRendererInterface $renderer) - { - $this->renderers[$renderer->getName()] = $renderer; - } - - /** - * Sets the current Request. - * - * This method was used to synchronize the Request, but as the HttpKernel - * is doing that automatically now, you should never call it directly. - * It is kept public for BC with the 2.3 version. - * - * @param Request|null $request A Request instance - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function setRequest(Request $request = null) - { - $this->request = $request; - } - - /** - * Renders a URI and returns the Response content. - * - * Available options: - * - * * ignore_errors: true to return an empty string in case of an error - * - * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance - * @param string $renderer The renderer name - * @param array $options An array of options - * - * @return string|null The Response content or null when the Response is streamed - * - * @throws \InvalidArgumentException when the renderer does not exist - * @throws \LogicException when no master request is being handled - */ - public function render($uri, $renderer = 'inline', array $options = array()) - { - if (!isset($options['ignore_errors'])) { - $options['ignore_errors'] = !$this->debug; - } - - if (!isset($this->renderers[$renderer])) { - throw new \InvalidArgumentException(sprintf('The "%s" renderer does not exist.', $renderer)); - } - - if (!$request = $this->getRequest()) { - throw new \LogicException('Rendering a fragment can only be done when handling a Request.'); - } - - return $this->deliver($this->renderers[$renderer]->render($uri, $request, $options)); - } - - /** - * Delivers the Response as a string. - * - * When the Response is a StreamedResponse, the content is streamed immediately - * instead of being returned. - * - * @param Response $response A Response instance - * - * @return string|null The Response content or null when the Response is streamed - * - * @throws \RuntimeException when the Response is not successful - */ - protected function deliver(Response $response) - { - if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->getRequest()->getUri(), $response->getStatusCode())); - } - - if (!$response instanceof StreamedResponse) { - return $response->getContent(); - } - - $response->sendContent(); - } - - private function getRequest() - { - return $this->requestStack ? $this->requestStack->getCurrentRequest() : $this->request; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php deleted file mode 100644 index b177c3ac1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpFoundation\Response; - -/** - * Interface implemented by all rendering strategies. - * - * @author Fabien Potencier - */ -interface FragmentRendererInterface -{ - /** - * Renders a URI and returns the Response content. - * - * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance - * @param Request $request A Request instance - * @param array $options An array of options - * - * @return Response A Response instance - */ - public function render($uri, Request $request, array $options = array()); - - /** - * Gets the name of the strategy. - * - * @return string The strategy name - */ - public function getName(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php deleted file mode 100644 index 56c96b3ce..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ /dev/null @@ -1,164 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Templating\EngineInterface; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\UriSigner; - -/** - * Implements the Hinclude rendering strategy. - * - * @author Fabien Potencier - */ -class HIncludeFragmentRenderer extends RoutableFragmentRenderer -{ - private $globalDefaultTemplate; - private $signer; - private $templating; - private $charset; - - /** - * Constructor. - * - * @param EngineInterface|\Twig_Environment $templating An EngineInterface or a \Twig_Environment instance - * @param UriSigner $signer A UriSigner instance - * @param string $globalDefaultTemplate The global default content (it can be a template name or the content) - * @param string $charset - */ - public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null, $charset = 'utf-8') - { - $this->setTemplating($templating); - $this->globalDefaultTemplate = $globalDefaultTemplate; - $this->signer = $signer; - $this->charset = $charset; - } - - /** - * Sets the templating engine to use to render the default content. - * - * @param EngineInterface|\Twig_Environment|null $templating An EngineInterface or a \Twig_Environment instance - * - * @throws \InvalidArgumentException - */ - public function setTemplating($templating) - { - if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) { - throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of \Twig_Environment or Symfony\Component\Templating\EngineInterface'); - } - - $this->templating = $templating; - } - - /** - * Checks if a templating engine has been set. - * - * @return bool true if the templating engine has been set, false otherwise - */ - public function hasTemplating() - { - return null !== $this->templating; - } - - /** - * {@inheritdoc} - * - * Additional available options: - * - * * default: The default content (it can be a template name or the content) - * * id: An optional hx:include tag id attribute - * * attributes: An optional array of hx:include tag attributes - */ - public function render($uri, Request $request, array $options = array()) - { - if ($uri instanceof ControllerReference) { - if (null === $this->signer) { - throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.'); - } - - // we need to sign the absolute URI, but want to return the path only. - $uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), strlen($request->getSchemeAndHttpHost())); - } - - // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content. - $uri = str_replace('&', '&', $uri); - - $template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate; - if (null !== $this->templating && $template && $this->templateExists($template)) { - $content = $this->templating->render($template); - } else { - $content = $template; - } - - $attributes = isset($options['attributes']) && is_array($options['attributes']) ? $options['attributes'] : array(); - if (isset($options['id']) && $options['id']) { - $attributes['id'] = $options['id']; - } - $renderedAttributes = ''; - if (count($attributes) > 0) { - if (PHP_VERSION_ID >= 50400) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - } else { - $flags = ENT_QUOTES; - } - foreach ($attributes as $attribute => $value) { - $renderedAttributes .= sprintf( - ' %s="%s"', - htmlspecialchars($attribute, $flags, $this->charset, false), - htmlspecialchars($value, $flags, $this->charset, false) - ); - } - } - - return new Response(sprintf('%s', $uri, $renderedAttributes, $content)); - } - - /** - * @param string $template - * - * @return bool - */ - private function templateExists($template) - { - if ($this->templating instanceof EngineInterface) { - try { - return $this->templating->exists($template); - } catch (\InvalidArgumentException $e) { - return false; - } - } - - $loader = $this->templating->getLoader(); - if ($loader instanceof \Twig_ExistsLoaderInterface) { - return $loader->exists($template); - } - - try { - $loader->getSource($template); - - return true; - } catch (\Twig_Error_Loader $e) { - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'hinclude'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php deleted file mode 100644 index a6ab82ea2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * Implements the inline rendering strategy where the Request is rendered by the current HTTP kernel. - * - * @author Fabien Potencier - */ -class InlineFragmentRenderer extends RoutableFragmentRenderer -{ - private $kernel; - private $dispatcher; - - /** - * Constructor. - * - * @param HttpKernelInterface $kernel A HttpKernelInterface instance - * @param EventDispatcherInterface $dispatcher A EventDispatcherInterface instance - */ - public function __construct(HttpKernelInterface $kernel, EventDispatcherInterface $dispatcher = null) - { - $this->kernel = $kernel; - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - * - * Additional available options: - * - * * alt: an alternative URI to render in case of an error - */ - public function render($uri, Request $request, array $options = array()) - { - $reference = null; - if ($uri instanceof ControllerReference) { - $reference = $uri; - - // Remove attributes from the generated URI because if not, the Symfony - // routing system will use them to populate the Request attributes. We don't - // want that as we want to preserve objects (so we manually set Request attributes - // below instead) - $attributes = $reference->attributes; - $reference->attributes = array(); - - // The request format and locale might have been overridden by the user - foreach (array('_format', '_locale') as $key) { - if (isset($attributes[$key])) { - $reference->attributes[$key] = $attributes[$key]; - } - } - - $uri = $this->generateFragmentUri($uri, $request, false, false); - - $reference->attributes = array_merge($attributes, $reference->attributes); - } - - $subRequest = $this->createSubRequest($uri, $request); - - // override Request attributes as they can be objects (which are not supported by the generated URI) - if (null !== $reference) { - $subRequest->attributes->add($reference->attributes); - } - - $level = ob_get_level(); - try { - return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false); - } catch (\Exception $e) { - // we dispatch the exception event to trigger the logging - // the response that comes back is simply ignored - if (isset($options['ignore_errors']) && $options['ignore_errors'] && $this->dispatcher) { - $event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::SUB_REQUEST, $e); - - $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event); - } - - // let's clean up the output buffers that were created by the sub-request - Response::closeOutputBuffers($level, false); - - if (isset($options['alt'])) { - $alt = $options['alt']; - unset($options['alt']); - - return $this->render($alt, $request, $options); - } - - if (!isset($options['ignore_errors']) || !$options['ignore_errors']) { - throw $e; - } - - return new Response(); - } - } - - protected function createSubRequest($uri, Request $request) - { - $cookies = $request->cookies->all(); - $server = $request->server->all(); - - // Override the arguments to emulate a sub-request. - // Sub-request object will point to localhost as client ip and real client ip - // will be included into trusted header for client ip - try { - if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { - $currentXForwardedFor = $request->headers->get($trustedHeaderName, ''); - - $server['HTTP_'.$trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp(); - } - } catch (\InvalidArgumentException $e) { - // Do nothing - } - - $server['REMOTE_ADDR'] = '127.0.0.1'; - - $subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server); - if ($request->headers->has('Surrogate-Capability')) { - $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability')); - } - - if ($session = $request->getSession()) { - $subRequest->setSession($session); - } - - return $subRequest; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'inline'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php deleted file mode 100644 index d7eeb89a6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\EventListener\FragmentListener; - -/** - * Adds the possibility to generate a fragment URI for a given Controller. - * - * @author Fabien Potencier - */ -abstract class RoutableFragmentRenderer implements FragmentRendererInterface -{ - private $fragmentPath = '/_fragment'; - - /** - * Sets the fragment path that triggers the fragment listener. - * - * @param string $path The path - * - * @see FragmentListener - */ - public function setFragmentPath($path) - { - $this->fragmentPath = $path; - } - - /** - * Generates a fragment URI for a given controller. - * - * @param ControllerReference $reference A ControllerReference instance - * @param Request $request A Request instance - * @param bool $absolute Whether to generate an absolute URL or not - * @param bool $strict Whether to allow non-scalar attributes or not - * - * @return string A fragment URI - */ - protected function generateFragmentUri(ControllerReference $reference, Request $request, $absolute = false, $strict = true) - { - if ($strict) { - $this->checkNonScalar($reference->attributes); - } - - // We need to forward the current _format and _locale values as we don't have - // a proper routing pattern to do the job for us. - // This makes things inconsistent if you switch from rendering a controller - // to rendering a route if the route pattern does not contain the special - // _format and _locale placeholders. - if (!isset($reference->attributes['_format'])) { - $reference->attributes['_format'] = $request->getRequestFormat(); - } - if (!isset($reference->attributes['_locale'])) { - $reference->attributes['_locale'] = $request->getLocale(); - } - - $reference->attributes['_controller'] = $reference->controller; - - $reference->query['_path'] = http_build_query($reference->attributes, '', '&'); - - $path = $this->fragmentPath.'?'.http_build_query($reference->query, '', '&'); - - if ($absolute) { - return $request->getUriForPath($path); - } - - return $request->getBaseUrl().$path; - } - - private function checkNonScalar($values) - { - foreach ($values as $key => $value) { - if (is_array($value)) { - $this->checkNonScalar($value); - } elseif (!is_scalar($value) && null !== $value) { - throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/SsiFragmentRenderer.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/SsiFragmentRenderer.php deleted file mode 100644 index 45e7122f0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/SsiFragmentRenderer.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Fragment; - -/** - * Implements the SSI rendering strategy. - * - * @author Sebastian Krebs - */ -class SsiFragmentRenderer extends AbstractSurrogateFragmentRenderer -{ - /** - * {@inheritdoc} - */ - public function getName() - { - return 'ssi'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php deleted file mode 100644 index ed99613d4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php +++ /dev/null @@ -1,290 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * Esi implements the ESI capabilities to Request and Response instances. - * - * For more information, read the following W3C notes: - * - * * ESI Language Specification 1.0 (http://www.w3.org/TR/esi-lang) - * - * * Edge Architecture Specification (http://www.w3.org/TR/edge-arch) - * - * @author Fabien Potencier - */ -class Esi implements SurrogateInterface -{ - private $contentTypes; - private $phpEscapeMap = array( - array('', '', '', ''), - ); - - /** - * Constructor. - * - * @param array $contentTypes An array of content-type that should be parsed for ESI information. - * (default: text/html, text/xml, application/xhtml+xml, and application/xml) - */ - public function __construct(array $contentTypes = array('text/html', 'text/xml', 'application/xhtml+xml', 'application/xml')) - { - $this->contentTypes = $contentTypes; - } - - public function getName() - { - return 'esi'; - } - - /** - * Returns a new cache strategy instance. - * - * @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance - */ - public function createCacheStrategy() - { - return new EsiResponseCacheStrategy(); - } - - /** - * Checks that at least one surrogate has ESI/1.0 capability. - * - * @param Request $request A Request instance - * - * @return bool true if one surrogate has ESI/1.0 capability, false otherwise - */ - public function hasSurrogateCapability(Request $request) - { - return $this->hasSurrogateEsiCapability($request); - } - - /** - * Checks that at least one surrogate has ESI/1.0 capability. - * - * @param Request $request A Request instance - * - * @return bool true if one surrogate has ESI/1.0 capability, false otherwise - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use hasSurrogateCapability() instead - */ - public function hasSurrogateEsiCapability(Request $request) - { - if (null === $value = $request->headers->get('Surrogate-Capability')) { - return false; - } - - return false !== strpos($value, 'ESI/1.0'); - } - - /** - * Adds ESI/1.0 capability to the given Request. - * - * @param Request $request A Request instance - */ - public function addSurrogateCapability(Request $request) - { - $this->addSurrogateEsiCapability($request); - } - - /** - * Adds ESI/1.0 capability to the given Request. - * - * @param Request $request A Request instance - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use addSurrogateCapability() instead - */ - public function addSurrogateEsiCapability(Request $request) - { - $current = $request->headers->get('Surrogate-Capability'); - $new = 'symfony2="ESI/1.0"'; - - $request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new); - } - - /** - * Adds HTTP headers to specify that the Response needs to be parsed for ESI. - * - * This method only adds an ESI HTTP header if the Response has some ESI tags. - * - * @param Response $response A Response instance - */ - public function addSurrogateControl(Response $response) - { - if (false !== strpos($response->getContent(), 'headers->set('Surrogate-Control', 'content="ESI/1.0"'); - } - } - - /** - * Checks that the Response needs to be parsed for ESI tags. - * - * @param Response $response A Response instance - * - * @return bool true if the Response needs to be parsed, false otherwise - */ - public function needsParsing(Response $response) - { - return $this->needsEsiParsing($response); - } - - /** - * Checks that the Response needs to be parsed for ESI tags. - * - * @param Response $response A Response instance - * - * @return bool true if the Response needs to be parsed, false otherwise - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use needsParsing() instead - */ - public function needsEsiParsing(Response $response) - { - if (!$control = $response->headers->get('Surrogate-Control')) { - return false; - } - - return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control); - } - - /** - * Renders an ESI tag. - * - * @param string $uri A URI - * @param string $alt An alternate URI - * @param bool $ignoreErrors Whether to ignore errors or not - * @param string $comment A comment to add as an esi:include tag - * - * @return string - */ - public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '') - { - $html = sprintf('', - $uri, - $ignoreErrors ? ' onerror="continue"' : '', - $alt ? sprintf(' alt="%s"', $alt) : '' - ); - - if (!empty($comment)) { - return sprintf("\n%s", $comment, $html); - } - - return $html; - } - - /** - * Replaces a Response ESI tags with the included resource content. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @return Response - */ - public function process(Request $request, Response $response) - { - $this->request = $request; - $type = $response->headers->get('Content-Type'); - if (empty($type)) { - $type = 'text/html'; - } - - $parts = explode(';', $type); - if (!in_array($parts[0], $this->contentTypes)) { - return $response; - } - - // we don't use a proper XML parser here as we can have ESI tags in a plain text response - $content = $response->getContent(); - $content = preg_replace('#.*?#', '', $content); - $content = preg_replace('#]*(?:/|#', '', $content); - - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); - $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); - - $i = 1; - while (isset($chunks[$i])) { - $options = array(); - preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); - foreach ($matches as $set) { - $options[$set[1]] = $set[2]; - } - - if (!isset($options['src'])) { - throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.'); - } - - $chunks[$i] = sprintf('surrogate->handle($this, %s, %s, %s) ?>'."\n", - var_export($options['src'], true), - var_export(isset($options['alt']) ? $options['alt'] : '', true), - isset($options['onerror']) && 'continue' === $options['onerror'] ? 'true' : 'false' - ); - ++$i; - $chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]); - ++$i; - } - $content = implode('', $chunks); - - $response->setContent($content); - $response->headers->set('X-Body-Eval', 'ESI'); - - // remove ESI/1.0 from the Surrogate-Control header - if ($response->headers->has('Surrogate-Control')) { - $value = $response->headers->get('Surrogate-Control'); - if ('content="ESI/1.0"' == $value) { - $response->headers->remove('Surrogate-Control'); - } elseif (preg_match('#,\s*content="ESI/1.0"#', $value)) { - $response->headers->set('Surrogate-Control', preg_replace('#,\s*content="ESI/1.0"#', '', $value)); - } elseif (preg_match('#content="ESI/1.0",\s*#', $value)) { - $response->headers->set('Surrogate-Control', preg_replace('#content="ESI/1.0",\s*#', '', $value)); - } - } - } - - /** - * Handles an ESI from the cache. - * - * @param HttpCache $cache An HttpCache instance - * @param string $uri The main URI - * @param string $alt An alternative URI - * @param bool $ignoreErrors Whether to ignore errors or not - * - * @return string - * - * @throws \RuntimeException - * @throws \Exception - */ - public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) - { - $subRequest = Request::create($uri, 'get', array(), $cache->getRequest()->cookies->all(), array(), $cache->getRequest()->server->all()); - - try { - $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); - - if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode())); - } - - return $response->getContent(); - } catch (\Exception $e) { - if ($alt) { - return $this->handle($cache, $alt, '', $ignoreErrors); - } - - if (!$ignoreErrors) { - throw $e; - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php deleted file mode 100644 index 1bef14759..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -/** - * EsiResponseCacheStrategy knows how to compute the Response cache HTTP header - * based on the different ESI response cache headers. - * - * This implementation changes the master response TTL to the smallest TTL received - * or force validation if one of the ESI has validation cache strategy. - * - * @author Fabien Potencier - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategy instead - */ -class EsiResponseCacheStrategy extends ResponseCacheStrategy implements EsiResponseCacheStrategyInterface -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php deleted file mode 100644 index 03df0575a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -/** - * ResponseCacheStrategyInterface implementations know how to compute the - * Response cache HTTP header based on the different response cache headers. - * - * @author Fabien Potencier - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use ResponseCacheStrategyInterface instead - */ -interface EsiResponseCacheStrategyInterface extends ResponseCacheStrategyInterface -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php deleted file mode 100644 index 68ee7ea82..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ /dev/null @@ -1,709 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\TerminableInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Cache provides HTTP caching. - * - * @author Fabien Potencier - * - * @api - */ -class HttpCache implements HttpKernelInterface, TerminableInterface -{ - private $kernel; - private $store; - private $request; - private $surrogate; - private $surrogateCacheStrategy; - private $options = array(); - private $traces = array(); - - /** - * Constructor. - * - * The available options are: - * - * * debug: If true, the traces are added as a HTTP header to ease debugging - * - * * default_ttl The number of seconds that a cache entry should be considered - * fresh when no explicit freshness information is provided in - * a response. Explicit Cache-Control or Expires headers - * override this value. (default: 0) - * - * * private_headers Set of request headers that trigger "private" cache-control behavior - * on responses that don't explicitly state whether the response is - * public or private via a Cache-Control directive. (default: Authorization and Cookie) - * - * * allow_reload Specifies whether the client can force a cache reload by including a - * Cache-Control "no-cache" directive in the request. Set it to ``true`` - * for compliance with RFC 2616. (default: false) - * - * * allow_revalidate Specifies whether the client can force a cache revalidate by including - * a Cache-Control "max-age=0" directive in the request. Set it to ``true`` - * for compliance with RFC 2616. (default: false) - * - * * stale_while_revalidate Specifies the default number of seconds (the granularity is the second as the - * Response TTL precision is a second) during which the cache can immediately return - * a stale response while it revalidates it in the background (default: 2). - * This setting is overridden by the stale-while-revalidate HTTP Cache-Control - * extension (see RFC 5861). - * - * * stale_if_error Specifies the default number of seconds (the granularity is the second) during which - * the cache can serve a stale response when an error is encountered (default: 60). - * This setting is overridden by the stale-if-error HTTP Cache-Control extension - * (see RFC 5861). - * - * @param HttpKernelInterface $kernel An HttpKernelInterface instance - * @param StoreInterface $store A Store instance - * @param SurrogateInterface $surrogate A SurrogateInterface instance - * @param array $options An array of options - */ - public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = array()) - { - $this->store = $store; - $this->kernel = $kernel; - $this->surrogate = $surrogate; - - // needed in case there is a fatal error because the backend is too slow to respond - register_shutdown_function(array($this->store, 'cleanup')); - - $this->options = array_merge(array( - 'debug' => false, - 'default_ttl' => 0, - 'private_headers' => array('Authorization', 'Cookie'), - 'allow_reload' => false, - 'allow_revalidate' => false, - 'stale_while_revalidate' => 2, - 'stale_if_error' => 60, - ), $options); - } - - /** - * Gets the current store. - * - * @return StoreInterface $store A StoreInterface instance - */ - public function getStore() - { - return $this->store; - } - - /** - * Returns an array of events that took place during processing of the last request. - * - * @return array An array of events - */ - public function getTraces() - { - return $this->traces; - } - - /** - * Returns a log message for the events of the last request processing. - * - * @return string A log message - */ - public function getLog() - { - $log = array(); - foreach ($this->traces as $request => $traces) { - $log[] = sprintf('%s: %s', $request, implode(', ', $traces)); - } - - return implode('; ', $log); - } - - /** - * Gets the Request instance associated with the master request. - * - * @return Request A Request instance - */ - public function getRequest() - { - return $this->request; - } - - /** - * Gets the Kernel instance. - * - * @return HttpKernelInterface An HttpKernelInterface instance - */ - public function getKernel() - { - return $this->kernel; - } - - /** - * Gets the Surrogate instance. - * - * @throws \LogicException - * @return SurrogateInterface A Surrogate instance - */ - public function getSurrogate() - { - return $this->getEsi(); - } - - /** - * Gets the Esi instance. - * - * @throws \LogicException - * - * @return Esi An Esi instance - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. Use getSurrogate() instead - */ - public function getEsi() - { - if (!$this->surrogate instanceof Esi) { - throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate'); - } - - return $this->surrogate; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism - if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->traces = array(); - $this->request = $request; - if (null !== $this->surrogate) { - $this->surrogateCacheStrategy = $this->surrogate->createCacheStrategy(); - } - } - - $path = $request->getPathInfo(); - if ($qs = $request->getQueryString()) { - $path .= '?'.$qs; - } - $this->traces[$request->getMethod().' '.$path] = array(); - - if (!$request->isMethodSafe()) { - $response = $this->invalidate($request, $catch); - } elseif ($request->headers->has('expect')) { - $response = $this->pass($request, $catch); - } else { - $response = $this->lookup($request, $catch); - } - - $this->restoreResponseBody($request, $response); - - $response->setDate(new \DateTime(null, new \DateTimeZone('UTC'))); - - if (HttpKernelInterface::MASTER_REQUEST === $type && $this->options['debug']) { - $response->headers->set('X-Symfony-Cache', $this->getLog()); - } - - if (null !== $this->surrogate) { - if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->surrogateCacheStrategy->update($response); - } else { - $this->surrogateCacheStrategy->add($response); - } - } - - $response->prepare($request); - - $response->isNotModified($request); - - return $response; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function terminate(Request $request, Response $response) - { - if ($this->getKernel() instanceof TerminableInterface) { - $this->getKernel()->terminate($request, $response); - } - } - - /** - * Forwards the Request to the backend without storing the Response in the cache. - * - * @param Request $request A Request instance - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - */ - protected function pass(Request $request, $catch = false) - { - $this->record($request, 'pass'); - - return $this->forward($request, $catch); - } - - /** - * Invalidates non-safe methods (like POST, PUT, and DELETE). - * - * @param Request $request A Request instance - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - * - * @throws \Exception - * - * @see RFC2616 13.10 - */ - protected function invalidate(Request $request, $catch = false) - { - $response = $this->pass($request, $catch); - - // invalidate only when the response is successful - if ($response->isSuccessful() || $response->isRedirect()) { - try { - $this->store->invalidate($request, $catch); - - // As per the RFC, invalidate Location and Content-Location URLs if present - foreach (array('Location', 'Content-Location') as $header) { - if ($uri = $response->headers->get($header)) { - $subRequest = Request::create($uri, 'get', array(), array(), array(), $request->server->all()); - - $this->store->invalidate($subRequest); - } - } - - $this->record($request, 'invalidate'); - } catch (\Exception $e) { - $this->record($request, 'invalidate-failed'); - - if ($this->options['debug']) { - throw $e; - } - } - } - - return $response; - } - - /** - * Lookups a Response from the cache for the given Request. - * - * When a matching cache entry is found and is fresh, it uses it as the - * response without forwarding any request to the backend. When a matching - * cache entry is found but is stale, it attempts to "validate" the entry with - * the backend using conditional GET. When no matching cache entry is found, - * it triggers "miss" processing. - * - * @param Request $request A Request instance - * @param bool $catch whether to process exceptions - * - * @return Response A Response instance - * - * @throws \Exception - */ - protected function lookup(Request $request, $catch = false) - { - // if allow_reload and no-cache Cache-Control, allow a cache reload - if ($this->options['allow_reload'] && $request->isNoCache()) { - $this->record($request, 'reload'); - - return $this->fetch($request, $catch); - } - - try { - $entry = $this->store->lookup($request); - } catch (\Exception $e) { - $this->record($request, 'lookup-failed'); - - if ($this->options['debug']) { - throw $e; - } - - return $this->pass($request, $catch); - } - - if (null === $entry) { - $this->record($request, 'miss'); - - return $this->fetch($request, $catch); - } - - if (!$this->isFreshEnough($request, $entry)) { - $this->record($request, 'stale'); - - return $this->validate($request, $entry, $catch); - } - - $this->record($request, 'fresh'); - - $entry->headers->set('Age', $entry->getAge()); - - return $entry; - } - - /** - * Validates that a cache entry is fresh. - * - * The original request is used as a template for a conditional - * GET request with the backend. - * - * @param Request $request A Request instance - * @param Response $entry A Response instance to validate - * @param bool $catch Whether to process exceptions - * - * @return Response A Response instance - */ - protected function validate(Request $request, Response $entry, $catch = false) - { - $subRequest = clone $request; - - // send no head requests because we want content - $subRequest->setMethod('GET'); - - // add our cached last-modified validator - $subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified')); - - // Add our cached etag validator to the environment. - // We keep the etags from the client to handle the case when the client - // has a different private valid entry which is not cached here. - $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array(); - $requestEtags = $request->getETags(); - if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) { - $subRequest->headers->set('if_none_match', implode(', ', $etags)); - } - - $response = $this->forward($subRequest, $catch, $entry); - - if (304 == $response->getStatusCode()) { - $this->record($request, 'valid'); - - // return the response and not the cache entry if the response is valid but not cached - $etag = $response->getEtag(); - if ($etag && in_array($etag, $requestEtags) && !in_array($etag, $cachedEtags)) { - return $response; - } - - $entry = clone $entry; - $entry->headers->remove('Date'); - - foreach (array('Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified') as $name) { - if ($response->headers->has($name)) { - $entry->headers->set($name, $response->headers->get($name)); - } - } - - $response = $entry; - } else { - $this->record($request, 'invalid'); - } - - if ($response->isCacheable()) { - $this->store($request, $response); - } - - return $response; - } - - /** - * Forwards the Request to the backend and determines whether the response should be stored. - * - * This methods is triggered when the cache missed or a reload is required. - * - * @param Request $request A Request instance - * @param bool $catch whether to process exceptions - * - * @return Response A Response instance - */ - protected function fetch(Request $request, $catch = false) - { - $subRequest = clone $request; - - // send no head requests because we want content - $subRequest->setMethod('GET'); - - // avoid that the backend sends no content - $subRequest->headers->remove('if_modified_since'); - $subRequest->headers->remove('if_none_match'); - - $response = $this->forward($subRequest, $catch); - - if ($response->isCacheable()) { - $this->store($request, $response); - } - - return $response; - } - - /** - * Forwards the Request to the backend and returns the Response. - * - * @param Request $request A Request instance - * @param bool $catch Whether to catch exceptions or not - * @param Response $entry A Response instance (the stale entry if present, null otherwise) - * - * @return Response A Response instance - */ - protected function forward(Request $request, $catch = false, Response $entry = null) - { - if ($this->surrogate) { - $this->surrogate->addSurrogateCapability($request); - } - - // modify the X-Forwarded-For header if needed - $forwardedFor = $request->headers->get('X-Forwarded-For'); - if ($forwardedFor) { - $request->headers->set('X-Forwarded-For', $forwardedFor.', '.$request->server->get('REMOTE_ADDR')); - } else { - $request->headers->set('X-Forwarded-For', $request->server->get('REMOTE_ADDR')); - } - - // fix the client IP address by setting it to 127.0.0.1 as HttpCache - // is always called from the same process as the backend. - $request->server->set('REMOTE_ADDR', '127.0.0.1'); - - // make sure HttpCache is a trusted proxy - if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { - $trustedProxies[] = '127.0.0.1'; - Request::setTrustedProxies($trustedProxies); - } - - // always a "master" request (as the real master request can be in cache) - $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch); - // FIXME: we probably need to also catch exceptions if raw === true - - // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC - if (null !== $entry && in_array($response->getStatusCode(), array(500, 502, 503, 504))) { - if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) { - $age = $this->options['stale_if_error']; - } - - if (abs($entry->getTtl()) < $age) { - $this->record($request, 'stale-if-error'); - - return $entry; - } - } - - $this->processResponseBody($request, $response); - - if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { - $response->setPrivate(true); - } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { - $response->setTtl($this->options['default_ttl']); - } - - return $response; - } - - /** - * Checks whether the cache entry is "fresh enough" to satisfy the Request. - * - * @param Request $request A Request instance - * @param Response $entry A Response instance - * - * @return bool true if the cache entry if fresh enough, false otherwise - */ - protected function isFreshEnough(Request $request, Response $entry) - { - if (!$entry->isFresh()) { - return $this->lock($request, $entry); - } - - if ($this->options['allow_revalidate'] && null !== $maxAge = $request->headers->getCacheControlDirective('max-age')) { - return $maxAge > 0 && $maxAge >= $entry->getAge(); - } - - return true; - } - - /** - * Locks a Request during the call to the backend. - * - * @param Request $request A Request instance - * @param Response $entry A Response instance - * - * @return bool true if the cache entry can be returned even if it is staled, false otherwise - */ - protected function lock(Request $request, Response $entry) - { - // try to acquire a lock to call the backend - $lock = $this->store->lock($request); - - // there is already another process calling the backend - if (true !== $lock) { - // check if we can serve the stale entry - if (null === $age = $entry->headers->getCacheControlDirective('stale-while-revalidate')) { - $age = $this->options['stale_while_revalidate']; - } - - if (abs($entry->getTtl()) < $age) { - $this->record($request, 'stale-while-revalidate'); - - // server the stale response while there is a revalidation - return true; - } - - // wait for the lock to be released - $wait = 0; - while ($this->store->isLocked($request) && $wait < 5000000) { - usleep(50000); - $wait += 50000; - } - - if ($wait < 2000000) { - // replace the current entry with the fresh one - $new = $this->lookup($request); - $entry->headers = $new->headers; - $entry->setContent($new->getContent()); - $entry->setStatusCode($new->getStatusCode()); - $entry->setProtocolVersion($new->getProtocolVersion()); - foreach ($new->headers->getCookies() as $cookie) { - $entry->headers->setCookie($cookie); - } - } else { - // backend is slow as hell, send a 503 response (to avoid the dog pile effect) - $entry->setStatusCode(503); - $entry->setContent('503 Service Unavailable'); - $entry->headers->set('Retry-After', 10); - } - - return true; - } - - // we have the lock, call the backend - return false; - } - - /** - * Writes the Response to the cache. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @throws \Exception - */ - protected function store(Request $request, Response $response) - { - try { - $this->store->write($request, $response); - - $this->record($request, 'store'); - - $response->headers->set('Age', $response->getAge()); - } catch (\Exception $e) { - $this->record($request, 'store-failed'); - - if ($this->options['debug']) { - throw $e; - } - } - - // now that the response is cached, release the lock - $this->store->unlock($request); - } - - /** - * Restores the Response body. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - */ - private function restoreResponseBody(Request $request, Response $response) - { - if ($request->isMethod('HEAD') || 304 === $response->getStatusCode()) { - $response->setContent(null); - $response->headers->remove('X-Body-Eval'); - $response->headers->remove('X-Body-File'); - - return; - } - - if ($response->headers->has('X-Body-Eval')) { - ob_start(); - - if ($response->headers->has('X-Body-File')) { - include $response->headers->get('X-Body-File'); - } else { - eval('; ?>'.$response->getContent().'setContent(ob_get_clean()); - $response->headers->remove('X-Body-Eval'); - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); - } - } elseif ($response->headers->has('X-Body-File')) { - $response->setContent(file_get_contents($response->headers->get('X-Body-File'))); - } else { - return; - } - - $response->headers->remove('X-Body-File'); - } - - protected function processResponseBody(Request $request, Response $response) - { - if (null !== $this->surrogate && $this->surrogate->needsParsing($response)) { - $this->surrogate->process($request, $response); - } - } - - /** - * Checks if the Request includes authorization or other sensitive information - * that should cause the Response to be considered private by default. - * - * @param Request $request A Request instance - * - * @return bool true if the Request is private, false otherwise - */ - private function isPrivateRequest(Request $request) - { - foreach ($this->options['private_headers'] as $key) { - $key = strtolower(str_replace('HTTP_', '', $key)); - - if ('cookie' === $key) { - if (count($request->cookies->all())) { - return true; - } - } elseif ($request->headers->has($key)) { - return true; - } - } - - return false; - } - - /** - * Records that an event took place. - * - * @param Request $request A Request instance - * @param string $event The event name - */ - private function record(Request $request, $event) - { - $path = $request->getPathInfo(); - if ($qs = $request->getQueryString()) { - $path .= '?'.$qs; - } - $this->traces[$request->getMethod().' '.$path][] = $event; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php deleted file mode 100644 index d22dff1e5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Response; - -/** - * ResponseCacheStrategy knows how to compute the Response cache HTTP header - * based on the different response cache headers. - * - * This implementation changes the master response TTL to the smallest TTL received - * or force validation if one of the surrogates has validation cache strategy. - * - * @author Fabien Potencier - */ -class ResponseCacheStrategy implements ResponseCacheStrategyInterface -{ - private $cacheable = true; - private $embeddedResponses = 0; - private $ttls = array(); - private $maxAges = array(); - - /** - * {@inheritdoc} - */ - public function add(Response $response) - { - if ($response->isValidateable()) { - $this->cacheable = false; - } else { - $this->ttls[] = $response->getTtl(); - $this->maxAges[] = $response->getMaxAge(); - } - - $this->embeddedResponses++; - } - - /** - * {@inheritdoc} - */ - public function update(Response $response) - { - // if we have no embedded Response, do nothing - if (0 === $this->embeddedResponses) { - return; - } - - // Remove validation related headers in order to avoid browsers using - // their own cache, because some of the response content comes from - // at least one embedded response (which likely has a different caching strategy). - if ($response->isValidateable()) { - $response->setEtag(null); - $response->setLastModified(null); - $this->cacheable = false; - } - - if (!$this->cacheable) { - $response->headers->set('Cache-Control', 'no-cache, must-revalidate'); - - return; - } - - $this->ttls[] = $response->getTtl(); - $this->maxAges[] = $response->getMaxAge(); - - if (null !== $maxAge = min($this->maxAges)) { - $response->setSharedMaxAge($maxAge); - $response->headers->set('Age', $maxAge - min($this->ttls)); - } - $response->setMaxAge(0); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategyInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategyInterface.php deleted file mode 100644 index d70c2e06e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategyInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Response; - -/** - * ResponseCacheStrategyInterface implementations know how to compute the - * Response cache HTTP header based on the different response cache headers. - * - * @author Fabien Potencier - */ -interface ResponseCacheStrategyInterface -{ - /** - * Adds a Response. - * - * @param Response $response - */ - public function add(Response $response); - - /** - * Updates the Response HTTP headers based on the embedded Responses. - * - * @param Response $response - */ - public function update(Response $response); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Ssi.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Ssi.php deleted file mode 100644 index 7bb54cff6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Ssi.php +++ /dev/null @@ -1,195 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * Ssi implements the SSI capabilities to Request and Response instances. - * - * @author Sebastian Krebs - */ -class Ssi implements SurrogateInterface -{ - private $contentTypes; - private $phpEscapeMap = array( - array('', '', '', ''), - ); - - /** - * Constructor. - * - * @param array $contentTypes An array of content-type that should be parsed for SSI information. - * (default: text/html, text/xml, application/xhtml+xml, and application/xml) - */ - public function __construct(array $contentTypes = array('text/html', 'text/xml', 'application/xhtml+xml', 'application/xml')) - { - $this->contentTypes = $contentTypes; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'ssi'; - } - - /** - * {@inheritdoc} - */ - public function createCacheStrategy() - { - return new ResponseCacheStrategy(); - } - - /** - * {@inheritdoc} - */ - public function hasSurrogateCapability(Request $request) - { - if (null === $value = $request->headers->get('Surrogate-Capability')) { - return false; - } - - return false !== strpos($value, 'SSI/1.0'); - } - - /** - * {@inheritdoc} - */ - public function addSurrogateCapability(Request $request) - { - $current = $request->headers->get('Surrogate-Capability'); - $new = 'symfony2="SSI/1.0"'; - - $request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new); - } - - /** - * {@inheritdoc} - */ - public function addSurrogateControl(Response $response) - { - if (false !== strpos($response->getContent(), '', $uri); - } - - /** - * {@inheritdoc} - */ - public function process(Request $request, Response $response) - { - $this->request = $request; - $type = $response->headers->get('Content-Type'); - if (empty($type)) { - $type = 'text/html'; - } - - $parts = explode(';', $type); - if (!in_array($parts[0], $this->contentTypes)) { - return $response; - } - - // we don't use a proper XML parser here as we can have SSI tags in a plain text response - $content = $response->getContent(); - - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); - $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); - - $i = 1; - while (isset($chunks[$i])) { - $options = array(); - preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); - foreach ($matches as $set) { - $options[$set[1]] = $set[2]; - } - - if (!isset($options['virtual'])) { - throw new \RuntimeException('Unable to process an SSI tag without a "virtual" attribute.'); - } - - $chunks[$i] = sprintf('surrogate->handle($this, %s, \'\', false) ?>'."\n", - var_export($options['virtual'], true) - ); - ++$i; - $chunks[$i] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[$i]); - ++$i; - } - $content = implode('', $chunks); - - $response->setContent($content); - $response->headers->set('X-Body-Eval', 'SSI'); - - // remove SSI/1.0 from the Surrogate-Control header - if ($response->headers->has('Surrogate-Control')) { - $value = $response->headers->get('Surrogate-Control'); - if ('content="SSI/1.0"' == $value) { - $response->headers->remove('Surrogate-Control'); - } elseif (preg_match('#,\s*content="SSI/1.0"#', $value)) { - $response->headers->set('Surrogate-Control', preg_replace('#,\s*content="SSI/1.0"#', '', $value)); - } elseif (preg_match('#content="SSI/1.0",\s*#', $value)) { - $response->headers->set('Surrogate-Control', preg_replace('#content="SSI/1.0",\s*#', '', $value)); - } - } - } - - /** - * {@inheritdoc} - */ - public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) - { - $subRequest = Request::create($uri, 'get', array(), $cache->getRequest()->cookies->all(), array(), $cache->getRequest()->server->all()); - - try { - $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); - - if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode())); - } - - return $response->getContent(); - } catch (\Exception $e) { - if ($alt) { - return $this->handle($cache, $alt, '', $ignoreErrors); - } - - if (!$ignoreErrors) { - throw $e; - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php deleted file mode 100644 index 044d14e0c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php +++ /dev/null @@ -1,449 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Store implements all the logic for storing cache metadata (Request and Response headers). - * - * @author Fabien Potencier - */ -class Store implements StoreInterface -{ - protected $root; - private $keyCache; - private $locks; - - /** - * Constructor. - * - * @param string $root The path to the cache directory - */ - public function __construct($root) - { - $this->root = $root; - if (!is_dir($this->root)) { - mkdir($this->root, 0777, true); - } - $this->keyCache = new \SplObjectStorage(); - $this->locks = array(); - } - - /** - * Cleanups storage. - */ - public function cleanup() - { - // unlock everything - foreach ($this->locks as $lock) { - if (file_exists($lock)) { - @unlink($lock); - } - } - - $error = error_get_last(); - if (1 === $error['type'] && false === headers_sent()) { - // send a 503 - header('HTTP/1.0 503 Service Unavailable'); - header('Retry-After: 10'); - echo '503 Service Unavailable'; - } - } - - /** - * Locks the cache for a given Request. - * - * @param Request $request A Request instance - * - * @return bool|string true if the lock is acquired, the path to the current lock otherwise - */ - public function lock(Request $request) - { - $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 !file_exists($path) ?: $path; - } - - /** - * Releases the lock for the given Request. - * - * @param Request $request A Request instance - * - * @return bool False if the lock file does not exist or cannot be unlocked, true otherwise - */ - public function unlock(Request $request) - { - $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')); - } - - /** - * Locates a cached Response for the Request provided. - * - * @param Request $request A Request instance - * - * @return Response|null A Response instance, or null if no cache entry was found - */ - public function lookup(Request $request) - { - $key = $this->getCacheKey($request); - - if (!$entries = $this->getMetadata($key)) { - return; - } - - // find a cached entry that matches the request. - $match = null; - foreach ($entries as $entry) { - if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? implode(', ', $entry[1]['vary']) : '', $request->headers->all(), $entry[0])) { - $match = $entry; - - break; - } - } - - if (null === $match) { - return; - } - - list($req, $headers) = $match; - if (is_file($body = $this->getPath($headers['x-content-digest'][0]))) { - return $this->restoreResponse($headers, $body); - } - - // TODO the metaStore referenced an entity that doesn't exist in - // the entityStore. We definitely want to return nil but we should - // also purge the entry from the meta-store when this is detected. - } - - /** - * Writes a cache entry to the store for the given Request and Response. - * - * Existing entries are read and any that match the response are removed. This - * method calls write with the new list of cache entries. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @return string The key under which the response is stored - * - * @throws \RuntimeException - */ - public function write(Request $request, Response $response) - { - $key = $this->getCacheKey($request); - $storedEnv = $this->persistRequest($request); - - // write the response body to the entity store if this is the original response - if (!$response->headers->has('X-Content-Digest')) { - $digest = $this->generateContentDigest($response); - - if (false === $this->save($digest, $response->getContent())) { - throw new \RuntimeException('Unable to store the entity.'); - } - - $response->headers->set('X-Content-Digest', $digest); - - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); - } - } - - // read existing cache entries, remove non-varying, and add this one to the list - $entries = array(); - $vary = $response->headers->get('vary'); - foreach ($this->getMetadata($key) as $entry) { - if (!isset($entry[1]['vary'][0])) { - $entry[1]['vary'] = array(''); - } - - if ($vary != $entry[1]['vary'][0] || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { - $entries[] = $entry; - } - } - - $headers = $this->persistResponse($response); - unset($headers['age']); - - array_unshift($entries, array($storedEnv, $headers)); - - if (false === $this->save($key, serialize($entries))) { - throw new \RuntimeException('Unable to store the metadata.'); - } - - return $key; - } - - /** - * Returns content digest for $response. - * - * @param Response $response - * - * @return string - */ - protected function generateContentDigest(Response $response) - { - return 'en'.hash('sha256', $response->getContent()); - } - - /** - * Invalidates all cache entries that match the request. - * - * @param Request $request A Request instance - * - * @throws \RuntimeException - */ - public function invalidate(Request $request) - { - $modified = false; - $key = $this->getCacheKey($request); - - $entries = array(); - foreach ($this->getMetadata($key) as $entry) { - $response = $this->restoreResponse($entry[1]); - if ($response->isFresh()) { - $response->expire(); - $modified = true; - $entries[] = array($entry[0], $this->persistResponse($response)); - } else { - $entries[] = $entry; - } - } - - if ($modified) { - if (false === $this->save($key, serialize($entries))) { - throw new \RuntimeException('Unable to store the metadata.'); - } - } - } - - /** - * Determines whether two Request HTTP header sets are non-varying based on - * the vary response header value provided. - * - * @param string $vary A Response vary header - * @param array $env1 A Request HTTP header array - * @param array $env2 A Request HTTP header array - * - * @return bool true if the two environments match, false otherwise - */ - private function requestsMatch($vary, $env1, $env2) - { - if (empty($vary)) { - return true; - } - - foreach (preg_split('/[\s,]+/', $vary) as $header) { - $key = strtr(strtolower($header), '_', '-'); - $v1 = isset($env1[$key]) ? $env1[$key] : null; - $v2 = isset($env2[$key]) ? $env2[$key] : null; - if ($v1 !== $v2) { - return false; - } - } - - return true; - } - - /** - * Gets all data associated with the given key. - * - * Use this method only if you know what you are doing. - * - * @param string $key The store key - * - * @return array An array of data associated with the key - */ - private function getMetadata($key) - { - if (false === $entries = $this->load($key)) { - return array(); - } - - return unserialize($entries); - } - - /** - * Purges data for the given URL. - * - * @param string $url A URL - * - * @return bool true if the URL exists and has been purged, false otherwise - */ - public function purge($url) - { - if (is_file($path = $this->getPath($this->getCacheKey(Request::create($url))))) { - unlink($path); - - return true; - } - - return false; - } - - /** - * Loads data for the given key. - * - * @param string $key The store key - * - * @return string The data associated with the key - */ - private function load($key) - { - $path = $this->getPath($key); - - return is_file($path) ? file_get_contents($path) : false; - } - - /** - * Save data for the given key. - * - * @param string $key The store key - * @param string $data The data to store - * - * @return bool - */ - private function save($key, $data) - { - $path = $this->getPath($key); - if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) { - return false; - } - - $tmpFile = tempnam(dirname($path), basename($path)); - if (false === $fp = @fopen($tmpFile, 'wb')) { - return false; - } - @fwrite($fp, $data); - @fclose($fp); - - if ($data != file_get_contents($tmpFile)) { - return false; - } - - if (false === @rename($tmpFile, $path)) { - return false; - } - - @chmod($path, 0666 & ~umask()); - } - - public function getPath($key) - { - return $this->root.DIRECTORY_SEPARATOR.substr($key, 0, 2).DIRECTORY_SEPARATOR.substr($key, 2, 2).DIRECTORY_SEPARATOR.substr($key, 4, 2).DIRECTORY_SEPARATOR.substr($key, 6); - } - - /** - * Generates a cache key for the given Request. - * - * This method should return a key that must only depend on a - * normalized version of the request URI. - * - * If the same URI can have more than one representation, based on some - * headers, use a Vary header to indicate them, and each representation will - * be stored independently under the same cache key. - * - * @param Request $request A Request instance - * - * @return string A key for the given Request - */ - protected function generateCacheKey(Request $request) - { - return 'md'.hash('sha256', $request->getUri()); - } - - /** - * Returns a cache key for the given Request. - * - * @param Request $request A Request instance - * - * @return string A key for the given Request - */ - private function getCacheKey(Request $request) - { - if (isset($this->keyCache[$request])) { - return $this->keyCache[$request]; - } - - return $this->keyCache[$request] = $this->generateCacheKey($request); - } - - /** - * Persists the Request HTTP headers. - * - * @param Request $request A Request instance - * - * @return array An array of HTTP headers - */ - private function persistRequest(Request $request) - { - return $request->headers->all(); - } - - /** - * Persists the Response HTTP headers. - * - * @param Response $response A Response instance - * - * @return array An array of HTTP headers - */ - private function persistResponse(Response $response) - { - $headers = $response->headers->all(); - $headers['X-Status'] = array($response->getStatusCode()); - - return $headers; - } - - /** - * Restores a Response from the HTTP headers and body. - * - * @param array $headers An array of HTTP headers for the Response - * @param string $body The Response body - * - * @return Response - */ - private function restoreResponse($headers, $body = null) - { - $status = $headers['X-Status'][0]; - unset($headers['X-Status']); - - if (null !== $body) { - $headers['X-Body-File'] = array($body); - } - - return new Response($body, $status, $headers); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php deleted file mode 100644 index ddc0c04ee..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Interface implemented by HTTP cache stores. - * - * @author Fabien Potencier - */ -interface StoreInterface -{ - /** - * Locates a cached Response for the Request provided. - * - * @param Request $request A Request instance - * - * @return Response|null A Response instance, or null if no cache entry was found - */ - public function lookup(Request $request); - - /** - * Writes a cache entry to the store for the given Request and Response. - * - * Existing entries are read and any that match the response are removed. This - * method calls write with the new list of cache entries. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @return string The key under which the response is stored - */ - public function write(Request $request, Response $response); - - /** - * Invalidates all cache entries that match the request. - * - * @param Request $request A Request instance - */ - public function invalidate(Request $request); - - /** - * Locks the cache for a given Request. - * - * @param Request $request A Request instance - * - * @return bool|string true if the lock is acquired, the path to the current lock otherwise - */ - public function lock(Request $request); - - /** - * Releases the lock for the given Request. - * - * @param Request $request A Request instance - * - * @return bool 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 bool true if lock exists, false otherwise - */ - public function isLocked(Request $request); - - /** - * Purges data for the given URL. - * - * @param string $url A URL - * - * @return bool true if the URL exists and has been purged, false otherwise - */ - public function purge($url); - - /** - * Cleanups storage. - */ - public function cleanup(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php deleted file mode 100644 index 46b788d53..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/SurrogateInterface.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -interface SurrogateInterface -{ - /** - * Returns surrogate name - * - * @return string - */ - public function getName(); - - /** - * Returns a new cache strategy instance. - * - * @return ResponseCacheStrategyInterface A ResponseCacheStrategyInterface instance - */ - public function createCacheStrategy(); - - /** - * Checks that at least one surrogate has Surrogate capability. - * - * @param Request $request A Request instance - * - * @return bool true if one surrogate has Surrogate capability, false otherwise - */ - public function hasSurrogateCapability(Request $request); - - /** - * Adds Surrogate-capability to the given Request. - * - * @param Request $request A Request instance - */ - public function addSurrogateCapability(Request $request); - - /** - * Adds HTTP headers to specify that the Response needs to be parsed for Surrogate. - * - * This method only adds an Surrogate HTTP header if the Response has some Surrogate tags. - * - * @param Response $response A Response instance - */ - public function addSurrogateControl(Response $response); - - /** - * Checks that the Response needs to be parsed for Surrogate tags. - * - * @param Response $response A Response instance - * - * @return bool true if the Response needs to be parsed, false otherwise - */ - public function needsParsing(Response $response); - - /** - * Renders a Surrogate tag. - * - * @param string $uri A URI - * @param string $alt An alternate URI - * @param bool $ignoreErrors Whether to ignore errors or not - * @param string $comment A comment to add as an esi:include tag - * - * @return string - */ - public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = ''); - - /** - * Replaces a Response Surrogate tags with the included resource content. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @return Response - */ - public function process(Request $request, Response $response); - - /** - * Handles a Surrogate from the cache. - * - * @param HttpCache $cache An HttpCache instance - * @param string $uri The main URI - * @param string $alt An alternative URI - * @param bool $ignoreErrors Whether to ignore errors or not - * - * @return string - * - * @throws \RuntimeException - * @throws \Exception - */ - public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php deleted file mode 100644 index c69b75a79..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php +++ /dev/null @@ -1,291 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * HttpKernel notifies events to convert a Request object to a Response one. - * - * @author Fabien Potencier - * - * @api - */ -class HttpKernel implements HttpKernelInterface, TerminableInterface -{ - protected $dispatcher; - protected $resolver; - protected $requestStack; - - /** - * Constructor. - * - * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance - * @param ControllerResolverInterface $resolver A ControllerResolverInterface instance - * @param RequestStack $requestStack A stack for master/sub requests - * - * @api - */ - public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, RequestStack $requestStack = null) - { - $this->dispatcher = $dispatcher; - $this->resolver = $resolver; - $this->requestStack = $requestStack ?: new RequestStack(); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - try { - return $this->handleRaw($request, $type); - } catch (\Exception $e) { - if (false === $catch) { - $this->finishRequest($request, $type); - - throw $e; - } - - return $this->handleException($e, $request, $type); - } - } - - /** - * {@inheritdoc} - * - * @api - */ - public function terminate(Request $request, Response $response) - { - $this->dispatcher->dispatch(KernelEvents::TERMINATE, new PostResponseEvent($this, $request, $response)); - } - - /** - * @throws \LogicException If the request stack is empty - * - * @internal - */ - public function terminateWithException(\Exception $exception) - { - if (!$request = $this->requestStack->getMasterRequest()) { - throw new \LogicException('Request stack is empty', 0, $exception); - } - - $response = $this->handleException($exception, $request, self::MASTER_REQUEST); - - $response->sendHeaders(); - $response->sendContent(); - - $this->terminate($request, $response); - } - - /** - * Handles a request to convert it to a response. - * - * Exceptions are not caught. - * - * @param Request $request A Request instance - * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * - * @return Response A Response instance - * - * @throws \LogicException If one of the listener does not behave as expected - * @throws NotFoundHttpException When controller cannot be found - */ - private function handleRaw(Request $request, $type = self::MASTER_REQUEST) - { - $this->requestStack->push($request); - - // request - $event = new GetResponseEvent($this, $request, $type); - $this->dispatcher->dispatch(KernelEvents::REQUEST, $event); - - if ($event->hasResponse()) { - return $this->filterResponse($event->getResponse(), $request, $type); - } - - // load controller - if (false === $controller = $this->resolver->getController($request)) { - throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo())); - } - - $event = new FilterControllerEvent($this, $controller, $request, $type); - $this->dispatcher->dispatch(KernelEvents::CONTROLLER, $event); - $controller = $event->getController(); - - // controller arguments - $arguments = $this->resolver->getArguments($request, $controller); - - // call controller - $response = call_user_func_array($controller, $arguments); - - // view - if (!$response instanceof Response) { - $event = new GetResponseForControllerResultEvent($this, $request, $type, $response); - $this->dispatcher->dispatch(KernelEvents::VIEW, $event); - - if ($event->hasResponse()) { - $response = $event->getResponse(); - } - - if (!$response instanceof Response) { - $msg = sprintf('The controller must return a response (%s given).', $this->varToString($response)); - - // the user may have forgotten to return something - if (null === $response) { - $msg .= ' Did you forget to add a return statement somewhere in your controller?'; - } - throw new \LogicException($msg); - } - } - - return $this->filterResponse($response, $request, $type); - } - - /** - * Filters a response object. - * - * @param Response $response A Response instance - * @param Request $request An error message in case the response is not a Response object - * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * - * @return Response The filtered Response instance - * - * @throws \RuntimeException if the passed object is not a Response instance - */ - private function filterResponse(Response $response, Request $request, $type) - { - $event = new FilterResponseEvent($this, $request, $type, $response); - - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->finishRequest($request, $type); - - return $event->getResponse(); - } - - /** - * Publishes the finish request event, then pop the request from the stack. - * - * Note that the order of the operations is important here, otherwise - * operations such as {@link RequestStack::getParentRequest()} can lead to - * weird results. - * - * @param Request $request - * @param int $type - */ - private function finishRequest(Request $request, $type) - { - $this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this, $request, $type)); - $this->requestStack->pop(); - } - - /** - * Handles an exception by trying to convert it to a Response. - * - * @param \Exception $e An \Exception instance - * @param Request $request A Request instance - * @param int $type The type of the request - * - * @return Response A Response instance - * - * @throws \Exception - */ - private function handleException(\Exception $e, $request, $type) - { - $event = new GetResponseForExceptionEvent($this, $request, $type, $e); - $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event); - - // a listener might have replaced the exception - $e = $event->getException(); - - if (!$event->hasResponse()) { - $this->finishRequest($request, $type); - - throw $e; - } - - $response = $event->getResponse(); - - // the developer asked for a specific status code - if ($response->headers->has('X-Status-Code')) { - $response->setStatusCode($response->headers->get('X-Status-Code')); - - $response->headers->remove('X-Status-Code'); - } elseif (!$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) { - // ensure that we actually have an error response - if ($e instanceof HttpExceptionInterface) { - // keep the HTTP status code and headers - $response->setStatusCode($e->getStatusCode()); - $response->headers->add($e->getHeaders()); - } else { - $response->setStatusCode(500); - } - } - - try { - return $this->filterResponse($response, $request, $type); - } catch (\Exception $e) { - return $response; - } - } - - private 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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php deleted file mode 100644 index d09da6bee..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * HttpKernelInterface handles a Request to convert it to a Response. - * - * @author Fabien Potencier - * - * @api - */ -interface HttpKernelInterface -{ - const MASTER_REQUEST = 1; - const SUB_REQUEST = 2; - - /** - * Handles a Request to convert it to a Response. - * - * When $catch is true, the implementation must catch all exceptions - * and do its best to convert them to a Response instance. - * - * @param Request $request A Request instance - * @param int $type The type of the request - * (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) - * @param bool $catch Whether to catch exceptions or not - * - * @return Response A Response instance - * - * @throws \Exception When an Exception occurs during processing - * - * @api - */ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php deleted file mode 100644 index 52a89dd28..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php +++ /dev/null @@ -1,785 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; -use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\Loader\IniFileLoader; -use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -use Symfony\Component\DependencyInjection\Loader\ClosureLoader; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\HttpKernel\Config\EnvParametersResource; -use Symfony\Component\HttpKernel\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; -use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\Config\Loader\DelegatingLoader; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\ClassLoader\ClassCollectionLoader; - -/** - * The Kernel is the heart of the Symfony system. - * - * It manages an environment made of bundles. - * - * @author Fabien Potencier - * - * @api - */ -abstract class Kernel implements KernelInterface, TerminableInterface -{ - /** - * @var BundleInterface[] - */ - protected $bundles = array(); - - protected $bundleMap; - protected $container; - protected $rootDir; - protected $environment; - protected $debug; - protected $booted = false; - protected $name; - protected $startTime; - protected $loadClassCache; - - const VERSION = '2.6.12'; - const VERSION_ID = '20612'; - const MAJOR_VERSION = '2'; - const MINOR_VERSION = '6'; - const RELEASE_VERSION = '12'; - const EXTRA_VERSION = ''; - - /** - * Constructor. - * - * @param string $environment The environment - * @param bool $debug Whether to enable debugging or not - * - * @api - */ - public function __construct($environment, $debug) - { - $this->environment = $environment; - $this->debug = (bool) $debug; - $this->rootDir = $this->getRootDir(); - $this->name = $this->getName(); - - if ($this->debug) { - $this->startTime = microtime(true); - } - - $this->init(); - } - - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Move your logic in the constructor instead. - */ - public function init() - { - } - - public function __clone() - { - if ($this->debug) { - $this->startTime = microtime(true); - } - - $this->booted = false; - $this->container = null; - } - - /** - * Boots the current kernel. - * - * @api - */ - public function boot() - { - if (true === $this->booted) { - return; - } - - if ($this->loadClassCache) { - $this->doLoadClassCache($this->loadClassCache[0], $this->loadClassCache[1]); - } - - // init bundles - $this->initializeBundles(); - - // init container - $this->initializeContainer(); - - foreach ($this->getBundles() as $bundle) { - $bundle->setContainer($this->container); - $bundle->boot(); - } - - $this->booted = true; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function terminate(Request $request, Response $response) - { - if (false === $this->booted) { - return; - } - - if ($this->getHttpKernel() instanceof TerminableInterface) { - $this->getHttpKernel()->terminate($request, $response); - } - } - - /** - * {@inheritdoc} - * - * @api - */ - public function shutdown() - { - if (false === $this->booted) { - return; - } - - $this->booted = false; - - foreach ($this->getBundles() as $bundle) { - $bundle->shutdown(); - $bundle->setContainer(null); - } - - $this->container = null; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) - { - if (false === $this->booted) { - $this->boot(); - } - - return $this->getHttpKernel()->handle($request, $type, $catch); - } - - /** - * Gets a HTTP kernel from the container. - * - * @return HttpKernel - */ - protected function getHttpKernel() - { - return $this->container->get('http_kernel'); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getBundles() - { - return $this->bundles; - } - - /** - * {@inheritdoc} - * - * @api - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. - */ - public function isClassInActiveBundle($class) - { - foreach ($this->getBundles() as $bundle) { - if (0 === strpos($class, $bundle->getNamespace())) { - return true; - } - } - - return false; - } - - /** - * {@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() method of your %s.php file?', $name, get_class($this))); - } - - if (true === $first) { - return $this->bundleMap[$name][0]; - } - - return $this->bundleMap[$name]; - } - - /** - * {@inheritdoc} - * - * @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle - */ - public function locateResource($name, $dir = null, $first = true) - { - if ('@' !== $name[0]) { - throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name)); - } - - if (false !== strpos($name, '..')) { - throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name)); - } - - $bundleName = substr($name, 1); - $path = ''; - if (false !== strpos($bundleName, '/')) { - list($bundleName, $path) = explode('/', $bundleName, 2); - } - - $isResource = 0 === strpos($path, 'Resources') && null !== $dir; - $overridePath = substr($path, 9); - $resourceBundle = null; - $bundles = $this->getBundle($bundleName, false); - $files = array(); - - foreach ($bundles as $bundle) { - if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) { - if (null !== $resourceBundle) { - throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', - $file, - $resourceBundle, - $dir.'/'.$bundles[0]->getName().$overridePath - )); - } - - if ($first) { - return $file; - } - $files[] = $file; - } - - if (file_exists($file = $bundle->getPath().'/'.$path)) { - if ($first && !$isResource) { - return $file; - } - $files[] = $file; - $resourceBundle = $bundle->getName(); - } - } - - if (count($files) > 0) { - return $first && $isResource ? $files[0] : $files; - } - - throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name)); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getName() - { - if (null === $this->name) { - $this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir)); - } - - return $this->name; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getEnvironment() - { - return $this->environment; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function isDebug() - { - return $this->debug; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getRootDir() - { - if (null === $this->rootDir) { - $r = new \ReflectionObject($this); - $this->rootDir = str_replace('\\', '/', dirname($r->getFileName())); - } - - return $this->rootDir; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getContainer() - { - return $this->container; - } - - /** - * Loads the PHP class cache. - * - * This methods only registers the fact that you want to load the cache classes. - * The cache will actually only be loaded when the Kernel is booted. - * - * That optimization is mainly useful when using the HttpCache class in which - * case the class cache is not loaded if the Response is in the cache. - * - * @param string $name The cache name prefix - * @param string $extension File extension of the resulting file - */ - public function loadClassCache($name = 'classes', $extension = '.php') - { - $this->loadClassCache = array($name, $extension); - } - - /** - * Used internally. - */ - public function setClassCache(array $classes) - { - file_put_contents($this->getCacheDir().'/classes.map', sprintf('debug ? $this->startTime : -INF; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getCacheDir() - { - return $this->rootDir.'/cache/'.$this->environment; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getLogDir() - { - return $this->rootDir.'/logs'; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function getCharset() - { - return 'UTF-8'; - } - - protected function doLoadClassCache($name, $extension) - { - if (!$this->booted && is_file($this->getCacheDir().'/classes.map')) { - ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, false, $extension); - } - } - - /** - * Initializes the data structures related to the bundle management. - * - * - the bundles property maps a bundle name to the bundle instance, - * - the bundleMap property maps a bundle name to the bundle inheritance hierarchy (most derived bundle first). - * - * @throws \LogicException if two bundles share a common name - * @throws \LogicException if a bundle tries to extend a non-registered bundle - * @throws \LogicException if a bundle tries to extend itself - * @throws \LogicException if two bundles extend the same ancestor - */ - protected function initializeBundles() - { - // init bundles - $this->bundles = array(); - $topMostBundles = array(); - $directChildren = array(); - - foreach ($this->registerBundles() as $bundle) { - $name = $bundle->getName(); - if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name)); - } - $this->bundles[$name] = $bundle; - - if ($parentName = $bundle->getParent()) { - if (isset($directChildren[$parentName])) { - throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName])); - } - if ($parentName == $name) { - throw new \LogicException(sprintf('Bundle "%s" can not extend itself.', $name)); - } - $directChildren[$parentName] = $name; - } else { - $topMostBundles[$name] = $bundle; - } - } - - // look for orphans - if (!empty($directChildren) && count($diff = array_diff_key($directChildren, $this->bundles))) { - $diff = array_keys($diff); - - throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0])); - } - - // inheritance - $this->bundleMap = array(); - foreach ($topMostBundles as $name => $bundle) { - $bundleMap = array($bundle); - $hierarchy = array($name); - - while (isset($directChildren[$name])) { - $name = $directChildren[$name]; - array_unshift($bundleMap, $this->bundles[$name]); - $hierarchy[] = $name; - } - - foreach ($hierarchy as $bundle) { - $this->bundleMap[$bundle] = $bundleMap; - array_pop($bundleMap); - } - } - } - - /** - * Gets the container class. - * - * @return string The container class - */ - protected function getContainerClass() - { - return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer'; - } - - /** - * Gets the container's base class. - * - * All names except Container must be fully qualified. - * - * @return string - */ - protected function getContainerBaseClass() - { - return 'Container'; - } - - /** - * Initializes the service container. - * - * The cached version of the service container is used when fresh, otherwise the - * container is built. - */ - protected function initializeContainer() - { - $class = $this->getContainerClass(); - $cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug); - $fresh = true; - if (!$cache->isFresh()) { - $container = $this->buildContainer(); - $container->compile(); - $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - - $fresh = false; - } - - require_once $cache; - - $this->container = new $class(); - $this->container->set('kernel', $this); - - if (!$fresh && $this->container->has('cache_warmer')) { - $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); - } - } - - /** - * Returns the kernel parameters. - * - * @return array An array of kernel parameters - */ - protected function getKernelParameters() - { - $bundles = array(); - foreach ($this->bundles as $name => $bundle) { - $bundles[$name] = get_class($bundle); - } - - return array_merge( - array( - 'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir, - 'kernel.environment' => $this->environment, - 'kernel.debug' => $this->debug, - 'kernel.name' => $this->name, - 'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(), - 'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(), - 'kernel.bundles' => $bundles, - 'kernel.charset' => $this->getCharset(), - 'kernel.container_class' => $this->getContainerClass(), - ), - $this->getEnvParameters() - ); - } - - /** - * Gets the environment parameters. - * - * Only the parameters starting with "SYMFONY__" are considered. - * - * @return array An array of parameters - */ - protected function getEnvParameters() - { - $parameters = array(); - foreach ($_SERVER as $key => $value) { - if (0 === strpos($key, 'SYMFONY__')) { - $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; - } - } - - return $parameters; - } - - /** - * Builds the service container. - * - * @return ContainerBuilder The compiled service container - * - * @throws \RuntimeException - */ - protected function buildContainer() - { - foreach (array('cache' => $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) { - if (!is_dir($dir)) { - if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir)); - } - } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir)); - } - } - - $container = $this->getContainerBuilder(); - $container->addObjectResource($this); - $this->prepareContainer($container); - - if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) { - $container->merge($cont); - } - - $container->addCompilerPass(new AddClassesToCachePass($this)); - $container->addResource(new EnvParametersResource('SYMFONY__')); - - return $container; - } - - /** - * Prepares the ContainerBuilder before it is compiled. - * - * @param ContainerBuilder $container A ContainerBuilder instance - */ - protected function prepareContainer(ContainerBuilder $container) - { - $extensions = array(); - foreach ($this->bundles as $bundle) { - if ($extension = $bundle->getContainerExtension()) { - $container->registerExtension($extension); - $extensions[] = $extension->getAlias(); - } - - if ($this->debug) { - $container->addObjectResource($bundle); - } - } - foreach ($this->bundles as $bundle) { - $bundle->build($container); - } - - // ensure these extensions are implicitly loaded - $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions)); - } - - /** - * Gets a new ContainerBuilder instance used to build the service container. - * - * @return ContainerBuilder - */ - protected function getContainerBuilder() - { - $container = new ContainerBuilder(new ParameterBag($this->getKernelParameters())); - - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) { - $container->setProxyInstantiator(new RuntimeInstantiator()); - } - - return $container; - } - - /** - * Dumps the service container to PHP code in the cache. - * - * @param ConfigCache $cache The config cache - * @param ContainerBuilder $container The service container - * @param string $class The name of the class to generate - * @param string $baseClass The name of the container's base class - */ - protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass) - { - // cache the container - $dumper = new PhpDumper($container); - - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) { - $dumper->setProxyDumper(new ProxyDumper(md5((string) $cache))); - } - - $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache)); - if (!$this->debug) { - $content = static::stripComments($content); - } - - $cache->write($content, $container->getResources()); - } - - /** - * Returns a loader for the container. - * - * @param ContainerInterface $container The service container - * - * @return DelegatingLoader The loader - */ - protected function getContainerLoader(ContainerInterface $container) - { - $locator = new FileLocator($this); - $resolver = new LoaderResolver(array( - new XmlFileLoader($container, $locator), - new YamlFileLoader($container, $locator), - new IniFileLoader($container, $locator), - new PhpFileLoader($container, $locator), - new ClosureLoader($container), - )); - - return new DelegatingLoader($resolver); - } - - /** - * 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 - */ - public static function stripComments($source) - { - if (!function_exists('token_get_all')) { - return $source; - } - - $rawChunk = ''; - $output = ''; - $tokens = token_get_all($source); - $ignoreSpace = false; - for (reset($tokens); false !== $token = current($tokens); next($tokens)) { - if (is_string($token)) { - $rawChunk .= $token; - } elseif (T_START_HEREDOC === $token[0]) { - $output .= $rawChunk.$token[1]; - do { - $token = next($tokens); - $output .= $token[1]; - } while ($token[0] !== T_END_HEREDOC); - $rawChunk = ''; - } elseif (T_WHITESPACE === $token[0]) { - if ($ignoreSpace) { - $ignoreSpace = false; - - continue; - } - - // replace multiple new lines with a single newline - $rawChunk .= preg_replace(array('/\n{2,}/S'), "\n", $token[1]); - } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { - $ignoreSpace = true; - } else { - $rawChunk .= $token[1]; - - // The PHP-open tag already has a new-line - if (T_OPEN_TAG === $token[0]) { - $ignoreSpace = true; - } - } - } - - $output .= $rawChunk; - - return $output; - } - - public function serialize() - { - return serialize(array($this->environment, $this->debug)); - } - - public function unserialize($data) - { - list($environment, $debug) = unserialize($data); - - $this->__construct($environment, $debug); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php deleted file mode 100644 index e259af5bd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php +++ /dev/null @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -/** - * Contains all events thrown in the HttpKernel component. - * - * @author Bernhard Schussek - * - * @api - */ -final class KernelEvents -{ - /** - * The REQUEST event occurs at the very beginning of request - * dispatching. - * - * This event allows you to create a response for a request before any - * other code in the framework is executed. The event listener method - * receives a Symfony\Component\HttpKernel\Event\GetResponseEvent - * instance. - * - * @Event - * - * @var string - * - * @api - */ - const REQUEST = 'kernel.request'; - - /** - * The EXCEPTION event occurs when an uncaught exception appears. - * - * This event allows you to create a response for a thrown exception or - * to modify the thrown exception. The event listener method receives - * a Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent - * instance. - * - * @Event - * - * @var string - * - * @api - */ - const EXCEPTION = 'kernel.exception'; - - /** - * The VIEW event occurs when the return value of a controller - * is not a Response instance. - * - * This event allows you to create a response for the return value of the - * controller. The event listener method receives a - * Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent - * instance. - * - * @Event - * - * @var string - * - * @api - */ - const VIEW = 'kernel.view'; - - /** - * The CONTROLLER event occurs once a controller was found for - * handling a request. - * - * This event allows you to change the controller that will handle the - * request. The event listener method receives a - * Symfony\Component\HttpKernel\Event\FilterControllerEvent instance. - * - * @Event - * - * @var string - * - * @api - */ - const CONTROLLER = 'kernel.controller'; - - /** - * The RESPONSE event occurs once a response was created for - * replying to a request. - * - * This event allows you to modify or replace the response that will be - * replied. The event listener method receives a - * Symfony\Component\HttpKernel\Event\FilterResponseEvent instance. - * - * @Event - * - * @var string - * - * @api - */ - const RESPONSE = 'kernel.response'; - - /** - * The TERMINATE event occurs once a response was sent. - * - * This event allows you to run expensive post-response jobs. - * The event listener method receives a - * Symfony\Component\HttpKernel\Event\PostResponseEvent instance. - * - * @Event - * - * @var string - */ - const TERMINATE = 'kernel.terminate'; - - /** - * The FINISH_REQUEST event occurs when a response was generated for a request. - * - * This event allows you to reset the global and environmental state of - * the application, when it was changed during the request. - * - * @var string - */ - const FINISH_REQUEST = 'kernel.finish_request'; -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php deleted file mode 100644 index 1ab35a503..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php +++ /dev/null @@ -1,211 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\Config\Loader\LoaderInterface; - -/** - * The Kernel is the heart of the Symfony system. - * - * It manages an environment made of bundles. - * - * @author Fabien Potencier - * - * @api - */ -interface KernelInterface extends HttpKernelInterface, \Serializable -{ - /** - * Returns an array of bundles to register. - * - * @return BundleInterface[] An array of bundle instances. - * - * @api - */ - public function registerBundles(); - - /** - * Loads the container configuration. - * - * @param LoaderInterface $loader A LoaderInterface instance - * - * @api - */ - public function registerContainerConfiguration(LoaderInterface $loader); - - /** - * Boots the current kernel. - * - * @api - */ - public function boot(); - - /** - * Shutdowns the kernel. - * - * This method is mainly useful when doing functional testing. - * - * @api - */ - public function shutdown(); - - /** - * Gets the registered bundle instances. - * - * @return BundleInterface[] An array of registered bundle instances - * - * @api - */ - public function getBundles(); - - /** - * Checks if a given class name belongs to an active bundle. - * - * @param string $class A class name - * - * @return bool true if the class belongs to an active bundle, false otherwise - * - * @api - * - * @deprecated Deprecated since version 2.6, to be removed in 3.0. - */ - public function isClassInActiveBundle($class); - - /** - * Returns a bundle and optionally its descendants by its name. - * - * @param string $name Bundle name - * @param bool $first Whether to return the first bundle only or together with its descendants - * - * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false - * - * @throws \InvalidArgumentException when the bundle is not enabled - * - * @api - */ - public function getBundle($name, $first = true); - - /** - * Returns the file path for a given resource. - * - * A Resource can be a file or a directory. - * - * The resource name must follow the following pattern: - * - * "@BundleName/path/to/a/file.something" - * - * where BundleName is the name of the bundle - * and the remaining part is the relative path in the bundle. - * - * If $dir is passed, and the first segment of the path is "Resources", - * this method will look for a file named: - * - * $dir//path/without/Resources - * - * before looking in the bundle resource folder. - * - * @param string $name A resource name to locate - * @param string $dir A directory where to look for the resource first - * @param bool $first Whether to return the first path or paths for all matching bundles - * - * @return string|array The absolute path of the resource or an array if $first is false - * - * @throws \InvalidArgumentException if the file cannot be found or the name is not valid - * @throws \RuntimeException if the name contains invalid/unsafe characters - * - * @api - */ - public function locateResource($name, $dir = null, $first = true); - - /** - * Gets the name of the kernel. - * - * @return string The kernel name - * - * @api - */ - public function getName(); - - /** - * Gets the environment. - * - * @return string The current environment - * - * @api - */ - public function getEnvironment(); - - /** - * Checks if debug mode is enabled. - * - * @return bool true if debug mode is enabled, false otherwise - * - * @api - */ - public function isDebug(); - - /** - * Gets the application root dir. - * - * @return string The application root dir - * - * @api - */ - public function getRootDir(); - - /** - * Gets the current container. - * - * @return ContainerInterface A ContainerInterface instance - * - * @api - */ - public function getContainer(); - - /** - * Gets the request start time (not available if debug is disabled). - * - * @return int The request start timestamp - * - * @api - */ - public function getStartTime(); - - /** - * Gets the cache directory. - * - * @return string The cache directory - * - * @api - */ - public function getCacheDir(); - - /** - * Gets the log directory. - * - * @return string The log directory - * - * @api - */ - public function getLogDir(); - - /** - * Gets the charset of the application. - * - * @return string The charset - * - * @api - */ - public function getCharset(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE deleted file mode 100644 index 43028bc60..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php deleted file mode 100644 index 5635a2184..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Log; - -/** - * DebugLoggerInterface. - * - * @author Fabien Potencier - */ -interface DebugLoggerInterface -{ - /** - * Returns an array of logs. - * - * A log is an array with the following mandatory keys: - * timestamp, message, priority, and priorityName. - * It can also have an optional context key containing an array. - * - * @return array An array of logs - */ - public function getLogs(); - - /** - * Returns the number of errors. - * - * @return int The number of errors - */ - public function countErrors(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/LoggerInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/LoggerInterface.php deleted file mode 100644 index 856c26a18..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/LoggerInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Log; - -use Psr\Log\LoggerInterface as PsrLogger; - -/** - * LoggerInterface. - * - * @author Fabien Potencier - * - * @deprecated since 2.2, to be removed in 3.0. Type-hint \Psr\Log\LoggerInterface instead. - * - * @api - */ -interface LoggerInterface extends PsrLogger -{ - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible. - */ - public function emerg($message, array $context = array()); - - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible. - */ - public function crit($message, array $context = array()); - - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible. - */ - public function err($message, array $context = array()); - - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible. - */ - public function warn($message, array $context = array()); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/NullLogger.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/NullLogger.php deleted file mode 100644 index 0948e0d88..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Log/NullLogger.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Log; - -use Psr\Log\NullLogger as PsrNullLogger; - -/** - * NullLogger. - * - * @author Fabien Potencier - * - * @api - */ -class NullLogger extends PsrNullLogger implements LoggerInterface -{ - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible. - */ - public function emerg($message, array $context = array()) - { - } - - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible. - */ - public function crit($message, array $context = array()) - { - } - - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible. - */ - public function err($message, array $context = array()) - { - } - - /** - * @api - * - * @deprecated since 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible. - */ - public function warn($message, array $context = array()) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php deleted file mode 100644 index f50b83e5d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php +++ /dev/null @@ -1,306 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * Base Memcache storage for profiling information in a Memcache. - * - * @author Andrej Hudec - */ -abstract class BaseMemcacheProfilerStorage implements ProfilerStorageInterface -{ - const TOKEN_PREFIX = 'sf_profiler_'; - - protected $dsn; - protected $lifetime; - - /** - * Constructor. - * - * @param string $dsn A data source name - * @param string $username - * @param string $password - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName); - if (!$indexContent) { - return array(); - } - - $profileList = explode("\n", $indexContent); - $result = array(); - - foreach ($profileList as $item) { - if ($limit === 0) { - break; - } - - if ($item == '') { - continue; - } - - list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = explode("\t", $item, 6); - - $itemTime = (int) $itemTime; - - if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) { - continue; - } - - if (!empty($start) && $itemTime < $start) { - continue; - } - - if (!empty($end) && $itemTime > $end) { - continue; - } - - $result[$itemToken] = array( - 'token' => $itemToken, - 'ip' => $itemIp, - 'method' => $itemMethod, - 'url' => $itemUrl, - 'time' => $itemTime, - 'parent' => $itemParent, - ); - --$limit; - } - - usort($result, function ($a, $b) { - if ($a['time'] === $b['time']) { - return 0; - } - - return $a['time'] > $b['time'] ? -1 : 1; - }); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - // delete only items from index - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName); - - if (!$indexContent) { - return false; - } - - $profileList = explode("\n", $indexContent); - - foreach ($profileList as $item) { - if ($item == '') { - continue; - } - - if (false !== $pos = strpos($item, "\t")) { - $this->delete($this->getItemName(substr($item, 0, $pos))); - } - } - - return $this->delete($indexName); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (empty($token)) { - return false; - } - - $profile = $this->getValue($this->getItemName($token)); - - if (false !== $profile) { - $profile = $this->createProfileFromData($token, $profile); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $data = array( - 'token' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()), - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); - - if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) { - if (!$profileIndexed) { - // Add to index - $indexName = $this->getIndexName(); - - $indexRow = implode("\t", array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - ))."\n"; - - return $this->appendValue($indexName, $indexRow, $this->lifetime); - } - - return true; - } - - return false; - } - - /** - * Retrieve item from the memcache server. - * - * @param string $key - * - * @return mixed - */ - abstract protected function getValue($key); - - /** - * Store an item on the memcache server under the specified key. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * - * @return bool - */ - abstract protected function setValue($key, $value, $expiration = 0); - - /** - * Delete item from the memcache server. - * - * @param string $key - * - * @return bool - */ - abstract protected function delete($key); - - /** - * Append data to an existing item on the memcache server. - * - * @param string $key - * @param string $value - * @param int $expiration - * - * @return bool - */ - abstract protected function appendValue($key, $value, $expiration = 0); - - private function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token) { - continue; - } - - if (!$childProfileData = $this->getValue($this->getItemName($token))) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, $childProfileData, $profile)); - } - - return $profile; - } - - /** - * Get item name. - * - * @param string $token - * - * @return string - */ - private function getItemName($token) - { - $name = self::TOKEN_PREFIX.$token; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - /** - * Get name of index. - * - * @return string - */ - private function getIndexName() - { - $name = self::TOKEN_PREFIX.'index'; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - private function isItemNameValid($name) - { - $length = strlen($name); - - if ($length > 250) { - throw new \RuntimeException(sprintf('The memcache item key "%s" is too long (%s bytes). Allowed maximum size is 250 bytes.', $name, $length)); - } - - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php deleted file mode 100644 index bda87e80e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ /dev/null @@ -1,278 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * Storage for profiler using files. - * - * @author Alexandre Salomé - */ -class FileProfilerStorage implements ProfilerStorageInterface -{ - /** - * Folder where profiler data are stored. - * - * @var string - */ - private $folder; - - /** - * Constructs the file storage using a "dsn-like" path. - * - * Example : "file:/path/to/the/storage/folder" - * - * @param string $dsn The DSN - * - * @throws \RuntimeException - */ - 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".', $dsn)); - } - $this->folder = substr($dsn, 5); - - if (!is_dir($this->folder)) { - mkdir($this->folder, 0777, true); - } - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - $file = $this->getIndexFilename(); - - if (!file_exists($file)) { - return array(); - } - - $file = fopen($file, 'r'); - fseek($file, 0, SEEK_END); - - $result = array(); - while (count($result) < $limit && $line = $this->readLineFromFile($file)) { - list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = str_getcsv($line); - - $csvTime = (int) $csvTime; - - if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) { - continue; - } - - if (!empty($start) && $csvTime < $start) { - continue; - } - - if (!empty($end) && $csvTime > $end) { - continue; - } - - $result[$csvToken] = array( - 'token' => $csvToken, - 'ip' => $csvIp, - 'method' => $csvMethod, - 'url' => $csvUrl, - 'time' => $csvTime, - 'parent' => $csvParent, - ); - } - - fclose($file); - - return array_values($result); - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $flags = \FilesystemIterator::SKIP_DOTS; - $iterator = new \RecursiveDirectoryIterator($this->folder, $flags); - $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST); - - foreach ($iterator as $file) { - if (is_file($file)) { - unlink($file); - } else { - rmdir($file); - } - } - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (!$token || !file_exists($file = $this->getFilename($token))) { - return; - } - - return $this->createProfileFromData($token, unserialize(file_get_contents($file))); - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $file = $this->getFilename($profile->getToken()); - - $profileIndexed = is_file($file); - if (!$profileIndexed) { - // Create directory - $dir = dirname($file); - if (!is_dir($dir)) { - mkdir($dir, 0777, true); - } - } - - // Store profile - $data = array( - 'token' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()), - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - if (false === file_put_contents($file, serialize($data))) { - return false; - } - - if (!$profileIndexed) { - // Add to index - if (false === $file = fopen($this->getIndexFilename(), 'a')) { - return false; - } - - fputcsv($file, array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - )); - fclose($file); - } - - return true; - } - - /** - * Gets filename to store data, associated to the token. - * - * @param string $token - * - * @return string The profile filename - */ - protected function getFilename($token) - { - // Uses 4 last characters, because first are mostly the same. - $folderA = substr($token, -2, 2); - $folderB = substr($token, -4, 2); - - return $this->folder.'/'.$folderA.'/'.$folderB.'/'.$token; - } - - /** - * Gets the index filename. - * - * @return string The index filename - */ - protected function getIndexFilename() - { - return $this->folder.'/index.csv'; - } - - /** - * Reads a line in the file, backward. - * - * This function automatically skips the empty lines and do not include the line return in result value. - * - * @param resource $file The file resource, with the pointer placed at the end of the line to read - * - * @return mixed A string representing the line or null if beginning of file is reached - */ - protected function readLineFromFile($file) - { - $line = ''; - $position = ftell($file); - - if (0 === $position) { - return; - } - - while (true) { - $chunkSize = min($position, 1024); - $position -= $chunkSize; - fseek($file, $position); - - if (0 === $chunkSize) { - // bof reached - break; - } - - $buffer = fread($file, $chunkSize); - - if (false === ($upTo = strrpos($buffer, "\n"))) { - $line = $buffer.$line; - continue; - } - - $position += $upTo; - $line = substr($buffer, $upTo + 1).$line; - fseek($file, max(0, $position), SEEK_SET); - - if ('' !== $line) { - break; - } - } - - return '' === $line ? null : $line; - } - - protected function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token || !file_exists($file = $this->getFilename($token))) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile)); - } - - return $profile; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php deleted file mode 100644 index 2727405cb..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * Memcache Profiler Storage. - * - * @author Andrej Hudec - */ -class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage -{ - /** - * @var \Memcache - */ - private $memcache; - - /** - * Internal convenience method that returns the instance of the Memcache. - * - * @return \Memcache - * - * @throws \RuntimeException - */ - protected function getMemcache() - { - if (null === $this->memcache) { - if (!preg_match('#^memcache://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcache with an invalid dsn "%s". The expected format is "memcache://[host]:port".', $this->dsn)); - } - - $host = $matches[1] ?: $matches[2]; - $port = $matches[3]; - - $memcache = new \Memcache(); - $memcache->addserver($host, $port); - - $this->memcache = $memcache; - } - - return $this->memcache; - } - - /** - * Set instance of the Memcache. - * - * @param \Memcache $memcache - */ - public function setMemcache($memcache) - { - $this->memcache = $memcache; - } - - /** - * {@inheritdoc} - */ - protected function getValue($key) - { - return $this->getMemcache()->get($key); - } - - /** - * {@inheritdoc} - */ - protected function setValue($key, $value, $expiration = 0) - { - return $this->getMemcache()->set($key, $value, false, time() + $expiration); - } - - /** - * {@inheritdoc} - */ - protected function delete($key) - { - return $this->getMemcache()->delete($key); - } - - /** - * {@inheritdoc} - */ - protected function appendValue($key, $value, $expiration = 0) - { - $memcache = $this->getMemcache(); - - if (method_exists($memcache, 'append')) { - // Memcache v3.0 - if (!$result = $memcache->append($key, $value, false, $expiration)) { - return $memcache->set($key, $value, false, $expiration); - } - - return $result; - } - - // simulate append in Memcache <3.0 - $content = $memcache->get($key); - - return $memcache->set($key, $content.$value, false, $expiration); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php deleted file mode 100644 index 0c57373ae..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * Memcached Profiler Storage. - * - * @author Andrej Hudec - */ -class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage -{ - /** - * @var \Memcached - */ - private $memcached; - - /** - * Internal convenience method that returns the instance of the Memcached. - * - * @return \Memcached - * - * @throws \RuntimeException - */ - protected function getMemcached() - { - if (null === $this->memcached) { - if (!preg_match('#^memcached://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcached with an invalid dsn "%s". The expected format is "memcached://[host]:port".', $this->dsn)); - } - - $host = $matches[1] ?: $matches[2]; - $port = $matches[3]; - - $memcached = new \Memcached(); - - // disable compression to allow appending - $memcached->setOption(\Memcached::OPT_COMPRESSION, false); - - $memcached->addServer($host, $port); - - $this->memcached = $memcached; - } - - return $this->memcached; - } - - /** - * Set instance of the Memcached. - * - * @param \Memcached $memcached - */ - public function setMemcached($memcached) - { - $this->memcached = $memcached; - } - - /** - * {@inheritdoc} - */ - protected function getValue($key) - { - return $this->getMemcached()->get($key); - } - - /** - * {@inheritdoc} - */ - protected function setValue($key, $value, $expiration = 0) - { - return $this->getMemcached()->set($key, $value, time() + $expiration); - } - - /** - * {@inheritdoc} - */ - protected function delete($key) - { - return $this->getMemcached()->delete($key); - } - - /** - * {@inheritdoc} - */ - protected function appendValue($key, $value, $expiration = 0) - { - $memcached = $this->getMemcached(); - - if (!$result = $memcached->append($key, $value)) { - return $memcached->set($key, $value, $expiration); - } - - return $result; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php deleted file mode 100644 index 23224b4a6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -class MongoDbProfilerStorage implements ProfilerStorageInterface -{ - protected $dsn; - protected $lifetime; - private $mongo; - - /** - * Constructor. - * - * @param string $dsn A data source name - * @param string $username Not used - * @param string $password Not used - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - $cursor = $this->getMongo()->find($this->buildQuery($ip, $url, $method, $start, $end), array('_id', 'parent', 'ip', 'method', 'url', 'time'))->sort(array('time' => -1))->limit($limit); - - $tokens = array(); - foreach ($cursor as $profile) { - $tokens[] = $this->getData($profile); - } - - return $tokens; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $this->getMongo()->remove(array()); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - $profile = $this->getMongo()->findOne(array('_id' => $token, 'data' => array('$exists' => true))); - - if (null !== $profile) { - $profile = $this->createProfileFromData($this->getData($profile)); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $this->cleanup(); - - $record = array( - '_id' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'data' => base64_encode(serialize($profile->getCollectors())), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - $result = $this->getMongo()->update(array('_id' => $profile->getToken()), array_filter($record, function ($v) { return !empty($v); }), array('upsert' => true)); - - return (bool) (isset($result['ok']) ? $result['ok'] : $result); - } - - /** - * Internal convenience method that returns the instance of the MongoDB Collection. - * - * @return \MongoCollection - * - * @throws \RuntimeException - */ - protected function getMongo() - { - if (null !== $this->mongo) { - return $this->mongo; - } - - if (!$parsedDsn = $this->parseDsn($this->dsn)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://[user:pass@]host/database/collection"', $this->dsn)); - } - - list($server, $database, $collection) = $parsedDsn; - $mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? '\Mongo' : '\MongoClient'; - $mongo = new $mongoClass($server); - - return $this->mongo = $mongo->selectCollection($database, $collection); - } - - /** - * @param array $data - * - * @return Profile - */ - protected function createProfileFromData(array $data) - { - $profile = $this->getProfile($data); - - if ($data['parent']) { - $parent = $this->getMongo()->findOne(array('_id' => $data['parent'], 'data' => array('$exists' => true))); - if ($parent) { - $profile->setParent($this->getProfile($this->getData($parent))); - } - } - - $profile->setChildren($this->readChildren($data['token'])); - - return $profile; - } - - /** - * @param string $token - * - * @return Profile[] An array of Profile instances - */ - protected function readChildren($token) - { - $profiles = array(); - - $cursor = $this->getMongo()->find(array('parent' => $token, 'data' => array('$exists' => true))); - foreach ($cursor as $d) { - $profiles[] = $this->getProfile($this->getData($d)); - } - - return $profiles; - } - - protected function cleanup() - { - $this->getMongo()->remove(array('time' => array('$lt' => time() - $this->lifetime))); - } - - /** - * @param string $ip - * @param string $url - * @param string $method - * @param int $start - * @param int $end - * - * @return array - */ - private function buildQuery($ip, $url, $method, $start, $end) - { - $query = array(); - - if (!empty($ip)) { - $query['ip'] = $ip; - } - - if (!empty($url)) { - $query['url'] = $url; - } - - if (!empty($method)) { - $query['method'] = $method; - } - - if (!empty($start) || !empty($end)) { - $query['time'] = array(); - } - - if (!empty($start)) { - $query['time']['$gte'] = $start; - } - - if (!empty($end)) { - $query['time']['$lte'] = $end; - } - - return $query; - } - - /** - * @param array $data - * - * @return array - */ - private function getData(array $data) - { - return array( - 'token' => $data['_id'], - 'parent' => isset($data['parent']) ? $data['parent'] : null, - 'ip' => isset($data['ip']) ? $data['ip'] : null, - 'method' => isset($data['method']) ? $data['method'] : null, - 'url' => isset($data['url']) ? $data['url'] : null, - 'time' => isset($data['time']) ? $data['time'] : null, - 'data' => isset($data['data']) ? $data['data'] : null, - ); - } - - /** - * @param array $data - * - * @return Profile - */ - private function getProfile(array $data) - { - $profile = new Profile($data['token']); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors(unserialize(base64_decode($data['data']))); - - return $profile; - } - - /** - * @param string $dsn - * - * @return null|array Array($server, $database, $collection) - */ - private function parseDsn($dsn) - { - if (!preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $dsn, $matches)) { - return; - } - - $server = $matches[1]; - $database = $matches[2]; - $collection = $matches[3]; - preg_match('#^mongodb://(([^:]+):?(.*)(?=@))?@?([^/]*)(.*)$#', $server, $matchesServer); - - if ('' == $matchesServer[5] && '' != $matches[2]) { - $server .= '/'.$matches[2]; - } - - return array($server, $database, $collection); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php deleted file mode 100644 index 69a865f9b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * A ProfilerStorage for Mysql. - * - * @author Jan Schumann - */ -class MysqlProfilerStorage extends PdoProfilerStorage -{ - /** - * {@inheritdoc} - */ - protected function initDb() - { - if (null === $this->db) { - if (0 !== strpos($this->dsn, 'mysql')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Mysql with an invalid dsn "%s". The expected format is "mysql:dbname=database_name;host=host_name".', $this->dsn)); - } - - if (!class_exists('PDO') || !in_array('mysql', \PDO::getAvailableDrivers(), true)) { - throw new \RuntimeException('You need to enable PDO_Mysql extension for the profiler to run properly.'); - } - - $db = new \PDO($this->dsn, $this->username, $this->password); - $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token VARCHAR(255) PRIMARY KEY, data LONGTEXT, ip VARCHAR(64), method VARCHAR(6), url VARCHAR(255), time INTEGER UNSIGNED, parent VARCHAR(255), created_at INTEGER UNSIGNED, KEY (created_at), KEY (ip), KEY (method), KEY (url), KEY (parent))'); - - $this->db = $db; - } - - return $this->db; - } - - /** - * {@inheritdoc} - */ - protected function buildCriteria($ip, $url, $start, $end, $limit, $method) - { - $criteria = array(); - $args = array(); - - if ($ip = preg_replace('/[^\d\.]/', '', $ip)) { - $criteria[] = 'ip LIKE :ip'; - $args[':ip'] = '%'.$ip.'%'; - } - - if ($url) { - $criteria[] = 'url LIKE :url'; - $args[':url'] = '%'.addcslashes($url, '%_\\').'%'; - } - - if ($method) { - $criteria[] = 'method = :method'; - $args[':method'] = $method; - } - - if (!empty($start)) { - $criteria[] = 'time >= :start'; - $args[':start'] = $start; - } - - if (!empty($end)) { - $criteria[] = 'time <= :end'; - $args[':end'] = $end; - } - - return array($criteria, $args); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php deleted file mode 100644 index a545e6b44..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php +++ /dev/null @@ -1,262 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * Base PDO storage for profiling information in a PDO database. - * - * @author Fabien Potencier - * @author Jan Schumann - */ -abstract class PdoProfilerStorage implements ProfilerStorageInterface -{ - protected $dsn; - protected $username; - protected $password; - protected $lifetime; - protected $db; - - /** - * Constructor. - * - * @param string $dsn A data source name - * @param string $username The username for the database - * @param string $password The password for the database - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->username = $username; - $this->password = $password; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - if (null === $start) { - $start = 0; - } - - if (null === $end) { - $end = time(); - } - - list($criteria, $args) = $this->buildCriteria($ip, $url, $start, $end, $limit, $method); - - $criteria = $criteria ? 'WHERE '.implode(' AND ', $criteria) : ''; - - $db = $this->initDb(); - $tokens = $this->fetch($db, 'SELECT token, ip, method, url, time, parent FROM sf_profiler_data '.$criteria.' ORDER BY time DESC LIMIT '.((int) $limit), $args); - $this->close($db); - - return $tokens; - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - $db = $this->initDb(); - $args = array(':token' => $token); - $data = $this->fetch($db, 'SELECT data, parent, ip, method, url, time FROM sf_profiler_data WHERE token = :token LIMIT 1', $args); - $this->close($db); - if (isset($data[0]['data'])) { - return $this->createProfileFromData($token, $data[0]); - } - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $db = $this->initDb(); - $args = array( - ':token' => $profile->getToken(), - ':parent' => $profile->getParentToken(), - ':data' => base64_encode(serialize($profile->getCollectors())), - ':ip' => $profile->getIp(), - ':method' => $profile->getMethod(), - ':url' => $profile->getUrl(), - ':time' => $profile->getTime(), - ':created_at' => time(), - ); - - try { - if ($this->has($profile->getToken())) { - $this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at WHERE token = :token', $args); - } else { - $this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at)', $args); - } - $this->cleanup(); - $status = true; - } catch (\Exception $e) { - $status = false; - } - - $this->close($db); - - return $status; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - $db = $this->initDb(); - $this->exec($db, 'DELETE FROM sf_profiler_data'); - $this->close($db); - } - - /** - * Build SQL criteria to fetch records by ip and url. - * - * @param string $ip The IP - * @param string $url The URL - * @param string $start The start period to search from - * @param string $end The end period to search to - * @param string $limit The maximum number of tokens to return - * @param string $method The request method - * - * @return array An array with (criteria, args) - */ - abstract protected function buildCriteria($ip, $url, $start, $end, $limit, $method); - - /** - * Initializes the database. - * - * @throws \RuntimeException When the requested database driver is not installed - */ - abstract protected function initDb(); - - protected function cleanup() - { - $db = $this->initDb(); - $this->exec($db, 'DELETE FROM sf_profiler_data WHERE created_at < :time', array(':time' => time() - $this->lifetime)); - $this->close($db); - } - - protected function exec($db, $query, array $args = array()) - { - $stmt = $this->prepareStatement($db, $query); - - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); - } - $success = $stmt->execute(); - if (!$success) { - throw new \RuntimeException(sprintf('Error executing query "%s"', $query)); - } - } - - protected function prepareStatement($db, $query) - { - try { - $stmt = $db->prepare($query); - } catch (\Exception $e) { - $stmt = false; - } - - if (false === $stmt) { - throw new \RuntimeException('The database cannot successfully prepare the statement'); - } - - return $stmt; - } - - protected function fetch($db, $query, array $args = array()) - { - $stmt = $this->prepareStatement($db, $query); - - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); - } - $stmt->execute(); - $return = $stmt->fetchAll(\PDO::FETCH_ASSOC); - - return $return; - } - - protected function close($db) - { - } - - protected function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors(unserialize(base64_decode($data['data']))); - - if (!$parent && !empty($data['parent'])) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - $profile->setChildren($this->readChildren($token, $profile)); - - return $profile; - } - - /** - * Reads the child profiles for the given token. - * - * @param string $token The parent token - * @param string $parent The parent instance - * - * @return Profile[] An array of Profile instance - */ - protected function readChildren($token, $parent) - { - $db = $this->initDb(); - $data = $this->fetch($db, 'SELECT token, data, ip, method, url, time FROM sf_profiler_data WHERE parent = :token', array(':token' => $token)); - $this->close($db); - - if (!$data) { - return array(); - } - - $profiles = array(); - foreach ($data as $d) { - $profiles[] = $this->createProfileFromData($d['token'], $d, $parent); - } - - return $profiles; - } - - /** - * Returns whether data for the given token already exists in storage. - * - * @param string $token The profile token - * - * @return string - */ - protected function has($token) - { - $db = $this->initDb(); - $tokenExists = $this->fetch($db, 'SELECT 1 FROM sf_profiler_data WHERE token = :token LIMIT 1', array(':token' => $token)); - $this->close($db); - - return !empty($tokenExists); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php deleted file mode 100644 index 85284bf29..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php +++ /dev/null @@ -1,275 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; - -/** - * Profile. - * - * @author Fabien Potencier - */ -class Profile -{ - private $token; - - /** - * @var DataCollectorInterface[] - */ - private $collectors = array(); - - private $ip; - private $method; - private $url; - private $time; - - /** - * @var Profile - */ - private $parent; - - /** - * @var Profile[] - */ - private $children = array(); - - /** - * Constructor. - * - * @param string $token The token - */ - public function __construct($token) - { - $this->token = $token; - } - - /** - * Sets the token. - * - * @param string $token The token - */ - public function setToken($token) - { - $this->token = $token; - } - - /** - * Gets the token. - * - * @return string The token - */ - public function getToken() - { - return $this->token; - } - - /** - * Sets the parent token. - * - * @param Profile $parent The parent Profile - */ - public function setParent(Profile $parent) - { - $this->parent = $parent; - } - - /** - * Returns the parent profile. - * - * @return Profile The parent profile - */ - public function getParent() - { - return $this->parent; - } - - /** - * Returns the parent token. - * - * @return null|string The parent token - */ - public function getParentToken() - { - return $this->parent ? $this->parent->getToken() : null; - } - - /** - * Returns the IP. - * - * @return string The IP - */ - public function getIp() - { - return $this->ip; - } - - /** - * Sets the IP. - * - * @param string $ip - */ - public function setIp($ip) - { - $this->ip = $ip; - } - - /** - * Returns the request method. - * - * @return string The request method - */ - public function getMethod() - { - return $this->method; - } - - public function setMethod($method) - { - $this->method = $method; - } - - /** - * Returns the URL. - * - * @return string The URL - */ - public function getUrl() - { - return $this->url; - } - - public function setUrl($url) - { - $this->url = $url; - } - - /** - * Returns the time. - * - * @return string The time - */ - public function getTime() - { - if (null === $this->time) { - return 0; - } - - return $this->time; - } - - public function setTime($time) - { - $this->time = $time; - } - - /** - * Finds children profilers. - * - * @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(); - foreach ($children as $child) { - $this->addChild($child); - } - } - - /** - * Adds the child token. - * - * @param Profile $child The child Profile - */ - public function addChild(Profile $child) - { - $this->children[] = $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])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $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(); - foreach ($collectors as $collector) { - $this->addCollector($collector); - } - } - - /** - * 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 bool - */ - public function hasCollector($name) - { - return isset($this->collectors[$name]); - } - - public function __sleep() - { - return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php deleted file mode 100644 index 62f5cd78b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ /dev/null @@ -1,295 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; -use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; -use Psr\Log\LoggerInterface; - -/** - * Profiler. - * - * @author Fabien Potencier - */ -class Profiler -{ - /** - * @var ProfilerStorageInterface - */ - private $storage; - - /** - * @var DataCollectorInterface[] - */ - private $collectors = array(); - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var bool - */ - private $enabled = true; - - /** - * Constructor. - * - * @param ProfilerStorageInterface $storage A ProfilerStorageInterface instance - * @param LoggerInterface $logger A LoggerInterface instance - */ - public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null) - { - $this->storage = $storage; - $this->logger = $logger; - } - - /** - * Disables the profiler. - */ - public function disable() - { - $this->enabled = false; - } - - /** - * Enables the profiler. - */ - public function enable() - { - $this->enabled = true; - } - - /** - * Loads the Profile for the given Response. - * - * @param Response $response A Response instance - * - * @return Profile A Profile instance - */ - public function loadProfileFromResponse(Response $response) - { - if (!$token = $response->headers->get('X-Debug-Token')) { - return false; - } - - return $this->loadProfile($token); - } - - /** - * Loads the Profile for the given token. - * - * @param string $token A token - * - * @return Profile A Profile instance - */ - public function loadProfile($token) - { - return $this->storage->read($token); - } - - /** - * Saves a Profile. - * - * @param Profile $profile A Profile instance - * - * @return bool - */ - public function saveProfile(Profile $profile) - { - // late collect - foreach ($profile->getCollectors() as $collector) { - if ($collector instanceof LateDataCollectorInterface) { - $collector->lateCollect(); - } - } - - if (!($ret = $this->storage->write($profile)) && null !== $this->logger) { - $this->logger->warning('Unable to store the profiler information.'); - } - - return $ret; - } - - /** - * Purges all data from the storage. - */ - public function purge() - { - $this->storage->purge(); - } - - /** - * Exports the current profiler data. - * - * @param Profile $profile A Profile instance - * - * @return string The exported data - */ - public function export(Profile $profile) - { - return base64_encode(serialize($profile)); - } - - /** - * Imports data into the profiler storage. - * - * @param string $data A data string as exported by the export() method - * - * @return Profile A Profile instance - */ - public function import($data) - { - $profile = unserialize(base64_decode($data)); - - if ($this->storage->read($profile->getToken())) { - return false; - } - - $this->saveProfile($profile); - - return $profile; - } - - /** - * 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 - * @param string $start The start date to search from - * @param string $end The end date to search to - * - * @return array An array of tokens - * - * @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats - */ - public function find($ip, $url, $limit, $method, $start, $end) - { - return $this->storage->find($ip, $url, $limit, $method, $this->getTimestamp($start), $this->getTimestamp($end)); - } - - /** - * Collects data for the given Response. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * @param \Exception $exception An exception instance if the request threw one - * - * @return Profile|null A Profile instance or null if the profiler is disabled - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - if (false === $this->enabled) { - return; - } - - $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6)); - $profile->setTime(time()); - $profile->setUrl($request->getUri()); - $profile->setIp($request->getClientIp()); - $profile->setMethod($request->getMethod()); - - $response->headers->set('X-Debug-Token', $profile->getToken()); - - foreach ($this->collectors as $collector) { - $collector->collect($request, $response, $exception); - - // we need to clone for sub-requests - $profile->addCollector(clone $collector); - } - - return $profile; - } - - /** - * Gets the Collectors associated with this profiler. - * - * @return array An array of collectors - */ - public function all() - { - return $this->collectors; - } - - /** - * Sets the Collectors associated with this profiler. - * - * @param DataCollectorInterface[] $collectors An array of collectors - */ - public function set(array $collectors = array()) - { - $this->collectors = array(); - foreach ($collectors as $collector) { - $this->add($collector); - } - } - - /** - * Adds a Collector. - * - * @param DataCollectorInterface $collector A DataCollectorInterface instance - */ - public function add(DataCollectorInterface $collector) - { - $this->collectors[$collector->getName()] = $collector; - } - - /** - * Returns true if a Collector for the given name exists. - * - * @param string $name A collector name - * - * @return bool - */ - public function has($name) - { - return isset($this->collectors[$name]); - } - - /** - * 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 get($name) - { - if (!isset($this->collectors[$name])) { - throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); - } - - return $this->collectors[$name]; - } - - private function getTimestamp($value) - { - if (null === $value || '' == $value) { - return; - } - - try { - $value = new \DateTime(is_numeric($value) ? '@'.$value : $value); - } catch (\Exception $e) { - return; - } - - return $value->getTimestamp(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php deleted file mode 100644 index ea72af231..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * ProfilerStorageInterface. - * - * @author Fabien Potencier - */ -interface ProfilerStorageInterface -{ - /** - * 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 - * @param int|null $start The start date to search from - * @param int|null $end The end date to search to - * - * @return array An array of tokens - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null); - - /** - * Reads data associated with the given token. - * - * The method returns false if the token does not exist in the storage. - * - * @param string $token A token - * - * @return Profile The profile associated with token - */ - public function read($token); - - /** - * Saves a Profile. - * - * @param Profile $profile A Profile instance - * - * @return bool Write operation successful - */ - public function write(Profile $profile); - - /** - * Purges all data from the database. - */ - public function purge(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php deleted file mode 100644 index b05adcc72..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php +++ /dev/null @@ -1,390 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * RedisProfilerStorage stores profiling information in Redis. - * - * @author Andrej Hudec - * @author Stephane PY - */ -class RedisProfilerStorage implements ProfilerStorageInterface -{ - const TOKEN_PREFIX = 'sf_profiler_'; - - const REDIS_OPT_SERIALIZER = 1; - const REDIS_OPT_PREFIX = 2; - const REDIS_SERIALIZER_NONE = 0; - const REDIS_SERIALIZER_PHP = 1; - - protected $dsn; - protected $lifetime; - - /** - * @var \Redis - */ - private $redis; - - /** - * Constructor. - * - * @param string $dsn A data source name - * @param string $username Not used - * @param string $password Not used - * @param int $lifetime The lifetime to use for the purge - */ - public function __construct($dsn, $username = '', $password = '', $lifetime = 86400) - { - $this->dsn = $dsn; - $this->lifetime = (int) $lifetime; - } - - /** - * {@inheritdoc} - */ - public function find($ip, $url, $limit, $method, $start = null, $end = null) - { - $indexName = $this->getIndexName(); - - if (!$indexContent = $this->getValue($indexName, self::REDIS_SERIALIZER_NONE)) { - return array(); - } - - $profileList = array_reverse(explode("\n", $indexContent)); - $result = array(); - - foreach ($profileList as $item) { - if ($limit === 0) { - break; - } - - if ($item == '') { - continue; - } - - list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = explode("\t", $item, 6); - - $itemTime = (int) $itemTime; - - if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) { - continue; - } - - if (!empty($start) && $itemTime < $start) { - continue; - } - - if (!empty($end) && $itemTime > $end) { - continue; - } - - $result[] = array( - 'token' => $itemToken, - 'ip' => $itemIp, - 'method' => $itemMethod, - 'url' => $itemUrl, - 'time' => $itemTime, - 'parent' => $itemParent, - ); - --$limit; - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function purge() - { - // delete only items from index - $indexName = $this->getIndexName(); - - $indexContent = $this->getValue($indexName, self::REDIS_SERIALIZER_NONE); - - if (!$indexContent) { - return false; - } - - $profileList = explode("\n", $indexContent); - - $result = array(); - - foreach ($profileList as $item) { - if ($item == '') { - continue; - } - - if (false !== $pos = strpos($item, "\t")) { - $result[] = $this->getItemName(substr($item, 0, $pos)); - } - } - - $result[] = $indexName; - - return $this->delete($result); - } - - /** - * {@inheritdoc} - */ - public function read($token) - { - if (empty($token)) { - return false; - } - - $profile = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP); - - if (false !== $profile) { - $profile = $this->createProfileFromData($token, $profile); - } - - return $profile; - } - - /** - * {@inheritdoc} - */ - public function write(Profile $profile) - { - $data = array( - 'token' => $profile->getToken(), - 'parent' => $profile->getParentToken(), - 'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()), - 'data' => $profile->getCollectors(), - 'ip' => $profile->getIp(), - 'method' => $profile->getMethod(), - 'url' => $profile->getUrl(), - 'time' => $profile->getTime(), - ); - - $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); - - if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, self::REDIS_SERIALIZER_PHP)) { - if (!$profileIndexed) { - // Add to index - $indexName = $this->getIndexName(); - - $indexRow = implode("\t", array( - $profile->getToken(), - $profile->getIp(), - $profile->getMethod(), - $profile->getUrl(), - $profile->getTime(), - $profile->getParentToken(), - ))."\n"; - - return $this->appendValue($indexName, $indexRow, $this->lifetime); - } - - return true; - } - - return false; - } - - /** - * Internal convenience method that returns the instance of Redis. - * - * @return \Redis - * - * @throws \RuntimeException - */ - protected function getRedis() - { - if (null === $this->redis) { - $data = parse_url($this->dsn); - - if (false === $data || !isset($data['scheme']) || $data['scheme'] !== 'redis' || !isset($data['host']) || !isset($data['port'])) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn)); - } - - if (!extension_loaded('redis')) { - throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.'); - } - - $redis = new \Redis(); - $redis->connect($data['host'], $data['port']); - - if (isset($data['path'])) { - $redis->select(substr($data['path'], 1)); - } - - if (isset($data['pass'])) { - $redis->auth($data['pass']); - } - - $redis->setOption(self::REDIS_OPT_PREFIX, self::TOKEN_PREFIX); - - $this->redis = $redis; - } - - return $this->redis; - } - - /** - * Set instance of the Redis. - * - * @param \Redis $redis - */ - public function setRedis($redis) - { - $this->redis = $redis; - } - - private function createProfileFromData($token, $data, $parent = null) - { - $profile = new Profile($token); - $profile->setIp($data['ip']); - $profile->setMethod($data['method']); - $profile->setUrl($data['url']); - $profile->setTime($data['time']); - $profile->setCollectors($data['data']); - - if (!$parent && $data['parent']) { - $parent = $this->read($data['parent']); - } - - if ($parent) { - $profile->setParent($parent); - } - - foreach ($data['children'] as $token) { - if (!$token) { - continue; - } - - if (!$childProfileData = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP)) { - continue; - } - - $profile->addChild($this->createProfileFromData($token, $childProfileData, $profile)); - } - - return $profile; - } - - /** - * Gets the item name. - * - * @param string $token - * - * @return string - */ - private function getItemName($token) - { - $name = $token; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - /** - * Gets the name of the index. - * - * @return string - */ - private function getIndexName() - { - $name = 'index'; - - if ($this->isItemNameValid($name)) { - return $name; - } - - return false; - } - - private function isItemNameValid($name) - { - $length = strlen($name); - - if ($length > 2147483648) { - throw new \RuntimeException(sprintf('The Redis item key "%s" is too long (%s bytes). Allowed maximum size is 2^31 bytes.', $name, $length)); - } - - return true; - } - - /** - * Retrieves an item from the Redis server. - * - * @param string $key - * @param int $serializer - * - * @return mixed - */ - private function getValue($key, $serializer = self::REDIS_SERIALIZER_NONE) - { - $redis = $this->getRedis(); - $redis->setOption(self::REDIS_OPT_SERIALIZER, $serializer); - - return $redis->get($key); - } - - /** - * Stores an item on the Redis server under the specified key. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * @param int $serializer - * - * @return bool - */ - private function setValue($key, $value, $expiration = 0, $serializer = self::REDIS_SERIALIZER_NONE) - { - $redis = $this->getRedis(); - $redis->setOption(self::REDIS_OPT_SERIALIZER, $serializer); - - return $redis->setex($key, $expiration, $value); - } - - /** - * Appends data to an existing item on the Redis server. - * - * @param string $key - * @param string $value - * @param int $expiration - * - * @return bool - */ - private function appendValue($key, $value, $expiration = 0) - { - $redis = $this->getRedis(); - $redis->setOption(self::REDIS_OPT_SERIALIZER, self::REDIS_SERIALIZER_NONE); - - if ($redis->exists($key)) { - $redis->append($key, $value); - - return $redis->setTimeout($key, $expiration); - } - - return $redis->setex($key, $expiration, $value); - } - - /** - * Removes the specified keys. - * - * @param array $keys - * - * @return bool - */ - private function delete(array $keys) - { - return (bool) $this->getRedis()->delete($keys); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php deleted file mode 100644 index 0c25bc950..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Profiler; - -/** - * SqliteProfilerStorage stores profiling information in a SQLite database. - * - * @author Fabien Potencier - */ -class SqliteProfilerStorage extends PdoProfilerStorage -{ - /** - * @throws \RuntimeException When neither of SQLite3 or PDO_SQLite extension is enabled - */ - protected function initDb() - { - if (null === $this->db || $this->db instanceof \SQLite3) { - if (0 !== strpos($this->dsn, 'sqlite')) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Sqlite with an invalid dsn "%s". The expected format is "sqlite:/path/to/the/db/file".', $this->dsn)); - } - if (class_exists('SQLite3')) { - $db = new \SQLite3(substr($this->dsn, 7, strlen($this->dsn)), \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE); - if (method_exists($db, 'busyTimeout')) { - // busyTimeout only exists for PHP >= 5.3.3 - $db->busyTimeout(1000); - } - } elseif (class_exists('PDO') && in_array('sqlite', \PDO::getAvailableDrivers(), true)) { - $db = new \PDO($this->dsn); - } else { - throw new \RuntimeException('You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.'); - } - - $db->exec('PRAGMA temp_store=MEMORY; PRAGMA journal_mode=MEMORY;'); - $db->exec('CREATE TABLE IF NOT EXISTS sf_profiler_data (token STRING, data STRING, ip STRING, method STRING, url STRING, time INTEGER, parent STRING, created_at INTEGER)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_created_at ON sf_profiler_data (created_at)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_ip ON sf_profiler_data (ip)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_method ON sf_profiler_data (method)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_url ON sf_profiler_data (url)'); - $db->exec('CREATE INDEX IF NOT EXISTS data_parent ON sf_profiler_data (parent)'); - $db->exec('CREATE UNIQUE INDEX IF NOT EXISTS data_token ON sf_profiler_data (token)'); - - $this->db = $db; - } - - return $this->db; - } - - protected function exec($db, $query, array $args = array()) - { - if ($db instanceof \SQLite3) { - $stmt = $this->prepareStatement($db, $query); - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); - } - - $res = $stmt->execute(); - if (false === $res) { - throw new \RuntimeException(sprintf('Error executing SQLite query "%s"', $query)); - } - $res->finalize(); - } else { - parent::exec($db, $query, $args); - } - } - - protected function fetch($db, $query, array $args = array()) - { - $return = array(); - - if ($db instanceof \SQLite3) { - $stmt = $this->prepareStatement($db, $query, true); - foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); - } - $res = $stmt->execute(); - while ($row = $res->fetchArray(\SQLITE3_ASSOC)) { - $return[] = $row; - } - $res->finalize(); - $stmt->close(); - } else { - $return = parent::fetch($db, $query, $args); - } - - return $return; - } - - /** - * {@inheritdoc} - */ - protected function buildCriteria($ip, $url, $start, $end, $limit, $method) - { - $criteria = array(); - $args = array(); - - if ($ip = preg_replace('/[^\d\.]/', '', $ip)) { - $criteria[] = 'ip LIKE :ip'; - $args[':ip'] = '%'.$ip.'%'; - } - - if ($url) { - $criteria[] = 'url LIKE :url ESCAPE "\"'; - $args[':url'] = '%'.addcslashes($url, '%_\\').'%'; - } - - if ($method) { - $criteria[] = 'method = :method'; - $args[':method'] = $method; - } - - if (!empty($start)) { - $criteria[] = 'time >= :start'; - $args[':start'] = $start; - } - - if (!empty($end)) { - $criteria[] = 'time <= :end'; - $args[':end'] = $end; - } - - return array($criteria, $args); - } - - protected function close($db) - { - if ($db instanceof \SQLite3) { - $db->close(); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md deleted file mode 100644 index 9ec8c0427..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md +++ /dev/null @@ -1,99 +0,0 @@ -HttpKernel Component -==================== - -HttpKernel provides the building blocks to create flexible and fast HTTP-based -frameworks. - -``HttpKernelInterface`` is the core interface of the Symfony full-stack -framework: - -```php -interface HttpKernelInterface -{ - /** - * Handles a Request to convert it to a Response. - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); -} -``` - -It takes a ``Request`` as an input and should return a ``Response`` as an -output. Using this interface makes your code compatible with all frameworks -using the Symfony components. And this will give you many cool features for -free. - -Creating a framework based on the Symfony components is really easy. Here is -a very simple, but fully-featured framework based on the Symfony components: - -```php -$routes = new RouteCollection(); -$routes->add('hello', new Route('/hello', array('_controller' => - function (Request $request) { - return new Response(sprintf("Hello %s", $request->get('name'))); - } -))); - -$request = Request::createFromGlobals(); - -$context = new RequestContext(); -$context->fromRequest($request); - -$matcher = new UrlMatcher($routes, $context); - -$dispatcher = new EventDispatcher(); -$dispatcher->addSubscriber(new RouterListener($matcher)); - -$resolver = new ControllerResolver(); - -$kernel = new HttpKernel($dispatcher, $resolver); - -$kernel->handle($request)->send(); -``` - -This is all you need to create a flexible framework with the Symfony -components. - -Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side -Includes? - -```php -$kernel = new HttpKernel($dispatcher, $resolver); - -$kernel = new HttpCache($kernel, new Store(__DIR__.'/cache')); -``` - -Want to functional test this small framework? - -```php -$client = new Client($kernel); -$crawler = $client->request('GET', '/hello/Fabien'); - -$this->assertEquals('Fabien', $crawler->filter('p > span')->text()); -``` - -Want nice error pages instead of ugly PHP exceptions? - -```php -$dispatcher->addSubscriber(new ExceptionListener(function (Request $request) { - $msg = 'Something went wrong! ('.$request->get('exception')->getMessage().')'; - - return new Response($msg, 500); -})); -``` - -And that's why the simple looking ``HttpKernelInterface`` is so powerful. It -gives you access to a lot of cool features, ready to be used out of the box, -with no efforts. - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/HttpKernel/ - $ composer install - $ phpunit diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php deleted file mode 100644 index fc0e580df..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Terminable extends the Kernel request/response cycle with dispatching a post - * response event after sending the response and before shutting down the kernel. - * - * @author Jordi Boggiano - * @author Pierre Minnieur - * - * @api - */ -interface TerminableInterface -{ - /** - * Terminates a request/response cycle. - * - * Should be called after sending the response and before shutting down the kernel. - * - * @param Request $request A Request instance - * @param Response $response A Response instance - * - * @api - */ - public function terminate(Request $request, Response $response); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php deleted file mode 100644 index c9059a74a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Bundle; - -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\ExtensionNotValidBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand; - -class BundleTest extends \PHPUnit_Framework_TestCase -{ - public function testRegisterCommands() - { - $cmd = new FooCommand(); - $app = $this->getMock('Symfony\Component\Console\Application'); - $app->expects($this->once())->method('add')->with($this->equalTo($cmd)); - - $bundle = new ExtensionPresentBundle(); - $bundle->registerCommands($app); - - $bundle2 = new ExtensionAbsentBundle(); - - $this->assertNull($bundle2->registerCommands($app)); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface - */ - public function testGetContainerExtensionWithInvalidClass() - { - $bundle = new ExtensionNotValidBundle(); - $bundle->getContainerExtension(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php deleted file mode 100644 index b54d169a5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheClearer/ChainCacheClearerTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\CacheClearer; - -use Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer; - -class ChainCacheClearerTest extends \PHPUnit_Framework_TestCase -{ - protected static $cacheDir; - - public static function setUpBeforeClass() - { - self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_clearer_dir'); - } - - public static function tearDownAfterClass() - { - @unlink(self::$cacheDir); - } - - public function testInjectClearersInConstructor() - { - $clearer = $this->getMockClearer(); - $clearer - ->expects($this->once()) - ->method('clear'); - - $chainClearer = new ChainCacheClearer(array($clearer)); - $chainClearer->clear(self::$cacheDir); - } - - public function testInjectClearerUsingAdd() - { - $clearer = $this->getMockClearer(); - $clearer - ->expects($this->once()) - ->method('clear'); - - $chainClearer = new ChainCacheClearer(); - $chainClearer->add($clearer); - $chainClearer->clear(self::$cacheDir); - } - - protected function getMockClearer() - { - return $this->getMock('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php deleted file mode 100644 index e78c8d14c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\CacheWarmer; - -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate; - -class CacheWarmerAggregateTest extends \PHPUnit_Framework_TestCase -{ - protected static $cacheDir; - - public static function setUpBeforeClass() - { - self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_warmer_dir'); - } - - public static function tearDownAfterClass() - { - @unlink(self::$cacheDir); - } - - public function testInjectWarmersUsingConstructor() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(array($warmer)); - $aggregate->warmUp(self::$cacheDir); - } - - public function testInjectWarmersUsingAdd() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(); - $aggregate->add($warmer); - $aggregate->warmUp(self::$cacheDir); - } - - public function testInjectWarmersUsingSetWarmers() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(); - $aggregate->setWarmers(array($warmer)); - $aggregate->warmUp(self::$cacheDir); - } - - public function testWarmupDoesCallWarmupOnOptionalWarmersWhenEnableOptionalWarmersIsEnabled() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->never()) - ->method('isOptional'); - $warmer - ->expects($this->once()) - ->method('warmUp'); - - $aggregate = new CacheWarmerAggregate(array($warmer)); - $aggregate->enableOptionalWarmers(); - $aggregate->warmUp(self::$cacheDir); - } - - public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWarmersIsNotEnabled() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('isOptional') - ->will($this->returnValue(true)); - $warmer - ->expects($this->never()) - ->method('warmUp'); - - $aggregate = new CacheWarmerAggregate(array($warmer)); - $aggregate->warmUp(self::$cacheDir); - } - - protected function getCacheWarmerMock() - { - $warmer = $this->getMockBuilder('Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface') - ->disableOriginalConstructor() - ->getMock(); - - return $warmer; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php deleted file mode 100644 index f0ab05d62..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\CacheWarmer; - -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer; - -class CacheWarmerTest extends \PHPUnit_Framework_TestCase -{ - protected static $cacheFile; - - public static function setUpBeforeClass() - { - self::$cacheFile = tempnam(sys_get_temp_dir(), 'sf2_cache_warmer_dir'); - } - - public static function tearDownAfterClass() - { - @unlink(self::$cacheFile); - } - - public function testWriteCacheFileCreatesTheFile() - { - $warmer = new TestCacheWarmer(self::$cacheFile); - $warmer->warmUp(dirname(self::$cacheFile)); - - $this->assertTrue(file_exists(self::$cacheFile)); - } - - /** - * @expectedException \RuntimeException - */ - public function testWriteNonWritableCacheFileThrowsARuntimeException() - { - $nonWritableFile = '/this/file/is/very/probably/not/writable'; - $warmer = new TestCacheWarmer($nonWritableFile); - $warmer->warmUp(dirname($nonWritableFile)); - } -} - -class TestCacheWarmer extends CacheWarmer -{ - protected $file; - - public function __construct($file) - { - $this->file = $file; - } - - public function warmUp($cacheDir) - { - $this->writeCacheFile($this->file, 'content'); - } - - public function isOptional() - { - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php deleted file mode 100644 index b5d2c9ced..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ /dev/null @@ -1,179 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\HttpKernel\Client; -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; - -class ClientTest extends \PHPUnit_Framework_TestCase -{ - public function testDoRequest() - { - $client = new Client(new TestHttpKernel()); - - $client->request('GET', '/'); - $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Request', $client->getRequest()); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $client->getResponse()); - - $client->request('GET', 'http://www.example.com/'); - $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); - $this->assertEquals('www.example.com', $client->getRequest()->getHost(), '->doRequest() uses the request handler to make the request'); - - $client->request('GET', 'http://www.example.com/?parameter=http://google.com'); - $this->assertEquals('http://www.example.com/?parameter='.urlencode('http://google.com'), $client->getRequest()->getUri(), '->doRequest() uses the request handler to make the request'); - } - - public function testGetScript() - { - $client = new TestClient(new TestHttpKernel()); - $client->insulate(); - $client->request('GET', '/'); - - $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->getScript() returns a script that uses the request handler to make the request'); - } - - public function testFilterResponseConvertsCookies() - { - $client = new Client(new TestHttpKernel()); - - $r = new \ReflectionObject($client); - $m = $r->getMethod('filterResponse'); - $m->setAccessible(true); - - $expected = array( - 'foo=bar; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', - 'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', - ); - - $response = new Response(); - $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); - $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); - - $response = new Response(); - $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); - $response->headers->setCookie(new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); - $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); - $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'); - $target = sys_get_temp_dir().'/sf.moved.file'; - @unlink($target); - - $kernel = new TestHttpKernel(); - $client = new Client($kernel); - - $files = array( - array('tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => 123, 'error' => UPLOAD_ERR_OK), - new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true), - ); - - $file = null; - foreach ($files as $file) { - $client->request('POST', '/', array(), array('foo' => $file)); - - $files = $client->getRequest()->files->all(); - - $this->assertCount(1, $files); - - $file = $files['foo']; - - $this->assertEquals('original', $file->getClientOriginalName()); - $this->assertEquals('mime/original', $file->getClientMimeType()); - $this->assertEquals('123', $file->getClientSize()); - $this->assertTrue($file->isValid()); - } - - $file->move(dirname($target), basename($target)); - - $this->assertFileExists($target); - unlink($target); - } - - public function testUploadedFileWhenNoFileSelected() - { - $kernel = new TestHttpKernel(); - $client = new Client($kernel); - - $file = array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE); - - $client->request('POST', '/', array(), array('foo' => $file)); - - $files = $client->getRequest()->files->all(); - - $this->assertCount(1, $files); - $this->assertNull($files['foo']); - } - - public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() - { - $source = tempnam(sys_get_temp_dir(), 'source'); - - $kernel = new TestHttpKernel(); - $client = new Client($kernel); - - $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true)) - ->setMethods(array('getSize')) - ->getMock() - ; - - $file->expects($this->once()) - ->method('getSize') - ->will($this->returnValue(INF)) - ; - - $client->request('POST', '/', array(), array($file)); - - $files = $client->getRequest()->files->all(); - - $this->assertCount(1, $files); - - $file = $files[0]; - - $this->assertFalse($file->isValid()); - $this->assertEquals(UPLOAD_ERR_INI_SIZE, $file->getError()); - $this->assertEquals('mime/original', $file->getClientMimeType()); - $this->assertEquals('original', $file->getClientOriginalName()); - $this->assertEquals(0, $file->getClientSize()); - - unlink($source); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php deleted file mode 100644 index ee5ecce3c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Config; - -use Symfony\Component\HttpKernel\Config\EnvParametersResource; - -class EnvParametersResourceTest extends \PHPUnit_Framework_TestCase -{ - protected $prefix = '__DUMMY_'; - protected $initialEnv; - protected $resource; - - protected function setUp() - { - $this->initialEnv = array( - $this->prefix.'1' => 'foo', - $this->prefix.'2' => 'bar', - ); - - foreach ($this->initialEnv as $key => $value) { - $_SERVER[$key] = $value; - } - - $this->resource = new EnvParametersResource($this->prefix); - } - - protected function tearDown() - { - foreach ($_SERVER as $key => $value) { - if (0 === strpos($key, $this->prefix)) { - unset($_SERVER[$key]); - } - } - } - - public function testGetResource() - { - $this->assertSame( - array('prefix' => $this->prefix, 'variables' => $this->initialEnv), - $this->resource->getResource(), - '->getResource() returns the resource' - ); - } - - public function testToString() - { - $this->assertSame( - serialize(array('prefix' => $this->prefix, 'variables' => $this->initialEnv)), - (string) $this->resource - ); - } - - public function testIsFreshNotChanged() - { - $this->assertTrue( - $this->resource->isFresh(time()), - '->isFresh() returns true if the variables have not changed' - ); - } - - public function testIsFreshValueChanged() - { - reset($this->initialEnv); - $_SERVER[key($this->initialEnv)] = 'baz'; - - $this->assertFalse( - $this->resource->isFresh(time()), - '->isFresh() returns false if a variable has been changed' - ); - } - - public function testIsFreshValueRemoved() - { - reset($this->initialEnv); - unset($_SERVER[key($this->initialEnv)]); - - $this->assertFalse( - $this->resource->isFresh(time()), - '->isFresh() returns false if a variable has been removed' - ); - } - - public function testIsFreshValueAdded() - { - $_SERVER[$this->prefix.'3'] = 'foo'; - - $this->assertFalse( - $this->resource->isFresh(time()), - '->isFresh() returns false if a variable has been added' - ); - } - - public function testSerializeUnserialize() - { - $this->assertEquals($this->resource, unserialize(serialize($this->resource))); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php deleted file mode 100644 index be5948626..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Config; - -use Symfony\Component\HttpKernel\Config\FileLocator; - -class FileLocatorTest extends \PHPUnit_Framework_TestCase -{ - public function testLocate() - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); - $kernel - ->expects($this->atLeastOnce()) - ->method('locateResource') - ->with('@BundleName/some/path', null, true) - ->will($this->returnValue('/bundle-name/some/path')); - $locator = new FileLocator($kernel); - $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path')); - - $kernel - ->expects($this->never()) - ->method('locateResource'); - $this->setExpectedException('LogicException'); - $locator->locate('/some/path'); - } - - public function testLocateWithGlobalResourcePath() - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); - $kernel - ->expects($this->atLeastOnce()) - ->method('locateResource') - ->with('@BundleName/some/path', '/global/resource/path', false); - - $locator = new FileLocator($kernel, '/global/resource/path'); - $locator->locate('@BundleName/some/path', null, false); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php deleted file mode 100644 index fe70ae5d5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ /dev/null @@ -1,242 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Controller; - -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Controller\ControllerResolver; -use Symfony\Component\HttpFoundation\Request; - -class ControllerResolverTest extends \PHPUnit_Framework_TestCase -{ - public function testGetControllerWithoutControllerParameter() - { - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing'); - $resolver = $this->createControllerResolver($logger); - - $request = Request::create('/'); - $this->assertFalse($resolver->getController($request), '->getController() returns false when the request has no _controller attribute'); - } - - public function testGetControllerWithLambda() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', $lambda = function () {}); - $controller = $resolver->getController($request); - $this->assertSame($lambda, $controller); - } - - public function testGetControllerWithObjectAndInvokeMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', $this); - $controller = $resolver->getController($request); - $this->assertSame($this, $controller); - } - - public function testGetControllerWithObjectAndMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', array($this, 'controllerMethod1')); - $controller = $resolver->getController($request); - $this->assertSame(array($this, 'controllerMethod1'), $controller); - } - - public function testGetControllerWithClassAndMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4')); - $controller = $resolver->getController($request); - $this->assertSame(array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4'), $controller); - } - - public function testGetControllerWithObjectAndMethodAsString() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::controllerMethod1'); - $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller[0], '->getController() returns a PHP callable'); - } - - public function testGetControllerWithClassAndInvokeMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest'); - $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetControllerOnObjectWithoutInvokeMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', new \stdClass()); - $resolver->getController($request); - } - - public function testGetControllerWithFunction() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'); - $controller = $resolver->getController($request); - $this->assertSame('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function', $controller); - } - - /** - * @dataProvider getUndefinedControllers - * @expectedException \InvalidArgumentException - */ - public function testGetControllerOnNonUndefinedFunction($controller) - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', $controller); - $resolver->getController($request); - } - - public function getUndefinedControllers() - { - return array( - array('foo'), - array('foo::bar'), - array('stdClass'), - array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar'), - ); - } - - public function testGetArguments() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $controller = array(new self(), 'testGetArguments'); - $this->assertEquals(array(), $resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments'); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerMethod1'); - $this->assertEquals(array('foo'), $resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method'); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerMethod2'); - $this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller), '->getArguments() uses default values if present'); - - $request->attributes->set('bar', 'bar'); - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes'); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = function ($foo) {}; - $this->assertEquals(array('foo'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = function ($foo, $bar = 'bar') {}; - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = new self(); - $this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller)); - $request->attributes->set('bar', 'bar'); - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('foobar', 'foobar'); - $controller = 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'; - $this->assertEquals(array('foo', 'foobar'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('foobar', 'foobar'); - $controller = array(new self(), 'controllerMethod3'); - - if (PHP_VERSION_ID === 50316) { - $this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system'); - } else { - try { - $resolver->getArguments($request, $controller); - $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } - } - - $request = Request::create('/'); - $controller = array(new self(), 'controllerMethod5'); - $this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request'); - } - - public function testCreateControllerCanReturnAnyCallable() - { - $mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController')); - $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function')); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'foobar'); - $mock->getController($request); - } - - protected function createControllerResolver(LoggerInterface $logger = null) - { - return new ControllerResolver($logger); - } - - public function __invoke($foo, $bar = null) - { - } - - public function controllerMethod1($foo) - { - } - - protected function controllerMethod2($foo, $bar = null) - { - } - - protected function controllerMethod3($foo, $bar = null, $foobar) - { - } - - protected static function controllerMethod4() - { - } - - protected function controllerMethod5(Request $request) - { - } -} - -function some_controller_function($foo, $foobar) -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php deleted file mode 100644 index fea95b4e2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * 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\ConfigDataCollector; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class ConfigDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - public function testCollect() - { - $kernel = new KernelForTest('test', true); - $c = new ConfigDataCollector(); - $c->setKernel($kernel); - $c->collect(new Request(), new Response()); - - $this->assertSame('test', $c->getEnv()); - $this->assertTrue($c->isDebug()); - $this->assertSame('config', $c->getName()); - $this->assertSame('testkernel', $c->getAppName()); - $this->assertSame(PHP_VERSION, $c->getPhpVersion()); - $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); - $this->assertNull($c->getToken()); - - // if else clause because we don't know it - if (extension_loaded('xdebug')) { - $this->assertTrue($c->hasXDebug()); - } else { - $this->assertFalse($c->hasXDebug()); - } - - // if else clause because we don't know it - if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) - || - (extension_loaded('apc') && ini_get('apc.enabled')) - || - (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) - || - (extension_loaded('xcache') && ini_get('xcache.cacher')) - || - (extension_loaded('wincache') && ini_get('wincache.ocenabled')))) { - $this->assertTrue($c->hasAccelerator()); - } else { - $this->assertFalse($c->hasAccelerator()); - } - } -} - -class KernelForTest extends Kernel -{ - public function getName() - { - return 'testkernel'; - } - - public function registerBundles() - { - } - - public function getBundles() - { - return array(); - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php deleted file mode 100644 index e9b8433c4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * 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\DumpDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\VarDumper\Cloner\Data; - -/** - * @author Nicolas Grekas - */ -class DumpDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - public function testDump() - { - $data = new Data(array(array(123))); - - $collector = new DumpDataCollector(); - - $this->assertSame('dump', $collector->getName()); - - $collector->dump($data); - $line = __LINE__ - 1; - $this->assertSame(1, $collector->getDumpsCount()); - - $dump = $collector->getDumps('html'); - $this->assertTrue(isset($dump[0]['data'])); - $dump[0]['data'] = preg_replace('/^.*?
 "
123\n
\n", - 'name' => 'DumpDataCollectorTest.php', - 'file' => __FILE__, - 'line' => $line, - 'fileExcerpt' => false, - ), - ); - $this->assertSame($xDump, $dump); - - $this->assertStringMatchesFormat( - 'a:1:{i:0;a:5:{s:4:"data";O:39:"Symfony\Component\VarDumper\Cloner\Data":4:{s:45:"Symfony\Component\VarDumper\Cloner\Datadata";a:1:{i:0;a:1:{i:0;i:123;}}s:49:"Symfony\Component\VarDumper\Cloner\DatamaxDepth";i:%i;s:57:"Symfony\Component\VarDumper\Cloner\DatamaxItemsPerDepth";i:%i;s:54:"Symfony\Component\VarDumper\Cloner\DatauseRefHandles";i:%i;}s:4:"name";s:25:"DumpDataCollectorTest.php";s:4:"file";s:%a', - str_replace("\0", '', $collector->serialize()) - ); - - $this->assertSame(0, $collector->getDumpsCount()); - $this->assertSame('a:0:{}', $collector->serialize()); - } - - public function testCollectDefault() - { - $data = new Data(array(array(123))); - - $collector = new DumpDataCollector(); - - $collector->dump($data); - $line = __LINE__ - 1; - - ob_start(); - $collector->collect(new Request(), new Response()); - $output = ob_get_clean(); - - if (PHP_VERSION_ID >= 50400) { - $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output); - } else { - $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n123\n", $output); - } - $this->assertSame(1, $collector->getDumpsCount()); - $collector->serialize(); - } - - public function testCollectHtml() - { - $data = new Data(array(array(123))); - - $collector = new DumpDataCollector(null, 'test://%f:%l'); - - $collector->dump($data); - $line = __LINE__ - 1; - $file = __FILE__; - if (PHP_VERSION_ID >= 50400) { - $xOutput = <<DumpDataCollectorTest.php on line {$line}: -123 -
- -EOTXT; - } else { - $len = strlen("DumpDataCollectorTest.php on line {$line}:"); - $xOutput = <<"DumpDataCollectorTest.php on line {$line}:" - -
123
-
- -EOTXT; - } - - ob_start(); - $response = new Response(); - $response->headers->set('Content-Type', 'text/html'); - $collector->collect(new Request(), $response); - $output = ob_get_clean(); - $output = preg_replace('#<(script|style).*?#s', '', $output); - $output = preg_replace('/sf-dump-\d+/', 'sf-dump', $output); - - $this->assertSame($xOutput, $output); - $this->assertSame(1, $collector->getDumpsCount()); - $collector->serialize(); - } - - public function testFlush() - { - $data = new Data(array(array(456))); - $collector = new DumpDataCollector(); - $collector->dump($data); - $line = __LINE__ - 1; - - ob_start(); - $collector = null; - if (PHP_VERSION_ID >= 50400) { - $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean()); - } else { - $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean()); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php deleted file mode 100644 index 6c71f4c9e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * 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\Debug\Exception\FlattenException; -use Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class ExceptionDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - public function testCollect() - { - $e = new \Exception('foo', 500); - $c = new ExceptionDataCollector(); - $flattened = FlattenException::create($e); - $trace = $flattened->getTrace(); - - $this->assertFalse($c->hasException()); - - $c->collect(new Request(), new Response(), $e); - - $this->assertTrue($c->hasException()); - $this->assertEquals($flattened, $c->getException()); - $this->assertSame('foo', $c->getMessage()); - $this->assertSame(500, $c->getCode()); - $this->assertSame('exception', $c->getName()); - $this->assertSame($trace, $c->getTrace()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php deleted file mode 100644 index 4303ab134..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * 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\LoggerDataCollector; - -class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getCollectTestData - */ - public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null) - { - $logger = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface'); - $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); - - $c = new LoggerDataCollector($logger); - $c->lateCollect(); - - $this->assertSame('logger', $c->getName()); - $this->assertSame($nb, $c->countErrors()); - $this->assertSame($expectedLogs ?: $logs, $c->getLogs()); - $this->assertSame($expectedDeprecationCount, $c->countDeprecations()); - $this->assertSame($expectedScreamCount, $c->countScreams()); - - if (isset($expectedPriorities)) { - $this->assertSame($expectedPriorities, $c->getPriorities()); - } - } - - public function getCollectTestData() - { - return array( - array( - 1, - array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')), - null, - 0, - 0, - ), - array( - 1, - array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'), 'priority' => 100, 'priorityName' => 'DEBUG')), - 0, - 0, - ), - array( - 1, - array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'), 'priority' => 100, 'priorityName' => 'DEBUG')), - 0, - 0, - ), - array( - 1, - array( - array('message' => 'foo', 'context' => array('type' => E_DEPRECATED, 'level' => E_ALL), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo2', 'context' => array('type' => E_USER_DEPRECATED, 'level' => E_ALL), 'priority' => 100, 'priorityName' => 'DEBUG'), - ), - null, - 2, - 0, - array(100 => array('count' => 2, 'name' => 'DEBUG')), - ), - array( - 1, - array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo3', 'context' => array('type' => E_USER_WARNING, 'level' => 0, 'scream' => true), 'priority' => 100, 'priorityName' => 'DEBUG')), - 0, - 1, - ), - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php deleted file mode 100644 index 340b42881..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/MemoryDataCollectorTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * 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\MemoryDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class MemoryDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - public function testCollect() - { - $collector = new MemoryDataCollector(); - $collector->collect(new Request(), new Response()); - - $this->assertInternalType('integer', $collector->getMemory()); - $this->assertInternalType('integer', $collector->getMemoryLimit()); - $this->assertSame('memory', $collector->getName()); - } - - /** @dataProvider getBytesConversionTestData */ - public function testBytesConversion($limit, $bytes) - { - $collector = new MemoryDataCollector(); - $method = new \ReflectionMethod($collector, 'convertToBytes'); - $method->setAccessible(true); - $this->assertEquals($bytes, $method->invoke($collector, $limit)); - } - - public function getBytesConversionTestData() - { - return array( - array('2k', 2048), - array('2 k', 2048), - array('8m', 8 * 1024 * 1024), - array('+2 k', 2048), - array('+2???k', 2048), - array('0x10', 16), - array('0xf', 15), - array('010', 8), - array('+0x10 k', 16 * 1024), - array('1g', 1024 * 1024 * 1024), - array('1G', 1024 * 1024 * 1024), - array('-1', -1), - array('0', 0), - array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm' - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php deleted file mode 100644 index 2eb1c41e8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ /dev/null @@ -1,222 +0,0 @@ - - * - * 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\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 -{ - public function testCollect() - { - $c = new RequestDataCollector(); - - $c->collect($this->createRequest(), $this->createResponse()); - - $attributes = $c->getRequestAttributes(); - - $this->assertSame('request', $c->getName()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getRequestHeaders()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery()); - $this->assertSame('html', $c->getFormat()); - $this->assertSame('foobar', $c->getRoute()); - $this->assertSame(array('name' => 'foo'), $c->getRouteParams()); - $this->assertSame(array(), $c->getSessionAttributes()); - $this->assertSame('en', $c->getLocale()); - $this->assertRegExp('/Resource\(stream#\d+\)/', $attributes->get('resource')); - $this->assertSame('Object(stdClass)', $attributes->get('object')); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getResponseHeaders()); - $this->assertSame('OK', $c->getStatusText()); - $this->assertSame(200, $c->getStatusCode()); - $this->assertSame('application/json', $c->getContentType()); - } - - /** - * Test various types of controller callables. - */ - public function testControllerInspection() - { - // make sure we always match the line number - $r1 = new \ReflectionMethod($this, 'testControllerInspection'); - $r2 = new \ReflectionMethod($this, 'staticControllerMethod'); - $r3 = new \ReflectionClass($this); - // 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'; }, - array( - 'class' => __NAMESPACE__.'\{closure}', - 'method' => null, - 'file' => __FILE__, - 'line' => __LINE__ - 5, - ), - ), - - 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', - ), - ), - - array( - 'Invokable controller', - $this, - array( - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', - 'method' => null, - 'file' => __FILE__, - 'line' => $r3->getStartLine(), - ), - ), - ); - - $c = new RequestDataCollector(); - $request = $this->createRequest(); - $response = $this->createResponse(); - foreach ($controllerTests as $controllerTest) { - $this->injectController($c, $controllerTest[1], $request); - $c->collect($request, $response); - $this->assertSame($controllerTest[2], $c->getController(), sprintf('Testing: %s', $controllerTest[0])); - } - } - - protected function createRequest() - { - $request = Request::create('http://test.com/foo?bar=baz'); - $request->attributes->set('foo', 'bar'); - $request->attributes->set('_route', 'foobar'); - $request->attributes->set('_route_params', array('name' => 'foo')); - $request->attributes->set('resource', fopen(__FILE__, 'r')); - $request->attributes->set('object', new \stdClass()); - - return $request; - } - - protected function createResponse() - { - $response = new Response(); - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'application/json'); - $response->headers->setCookie(new Cookie('foo', 'bar', 1, '/foo', 'localhost', true, true)); - $response->headers->setCookie(new Cookie('bar', 'foo', new \DateTime('@946684800'))); - $response->headers->setCookie(new Cookie('bazz', 'foo', '2000-12-12')); - - return $response; - } - - /** - * 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'); - } - - public function __invoke() - { - throw new \LogicException('Unexpected method call'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php deleted file mode 100644 index b5d64bffe..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * 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\TimeDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - public function testCollect() - { - $c = new TimeDataCollector(); - - $request = new Request(); - $request->server->set('REQUEST_TIME', 1); - - $c->collect($request, new Response()); - - $this->assertEquals(1000, $c->getStartTime()); - - $request->server->set('REQUEST_TIME_FLOAT', 2); - - $c->collect($request, new Response()); - - $this->assertEquals(2000, $c->getStartTime()); - - $request = new Request(); - $c->collect($request, new Response()); - $this->assertEquals(0, $c->getStartTime()); - - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); - $kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456)); - - $c = new TimeDataCollector($kernel); - $request = new Request(); - $request->server->set('REQUEST_TIME', 1); - - $c->collect($request, new Response()); - $this->assertEquals(123456000, $c->getStartTime()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php deleted file mode 100644 index 8d3ddb4e5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * 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\Util; - -use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; - -class ValueExporterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ValueExporter - */ - private $valueExporter; - - protected function setUp() - { - $this->valueExporter = new ValueExporter(); - } - - public function testDateTime() - { - $dateTime = new \DateTime('2014-06-10 07:35:40', new \DateTimeZone('UTC')); - $this->assertSame('Object(DateTime) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime)); - } - - public function testDateTimeImmutable() - { - if (!class_exists('DateTimeImmutable', false)) { - $this->markTestSkipped('Test skipped, class DateTimeImmutable does not exist.'); - } - - $dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC')); - $this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php deleted file mode 100644 index f64d7247c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * 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\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 -{ - 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.controller', - 'controller', - 'kernel.response', - 'kernel.terminate', - ), array_keys($events)); - } - - public function testStopwatchCheckControllerOnRequestEvent() - { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') - ->setMethods(array('isStarted')) - ->getMock(); - $stopwatch->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(false)); - - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch); - - $kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); }); - $request = Request::create('/'); - $kernel->handle($request); - } - - public function testStopwatchStopControllerOnRequestEvent() - { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') - ->setMethods(array('isStarted', 'stop', 'stopSection')) - ->getMock(); - $stopwatch->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(true)); - $stopwatch->expects($this->once()) - ->method('stop'); - $stopwatch->expects($this->once()) - ->method('stopSection'); - - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch); - - $kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); }); - $request = Request::create('/'); - $kernel->handle($request); - } - - public function testAddListenerNested() - { - $called1 = false; - $called2 = false; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('my-event', function () use ($dispatcher, &$called1, &$called2) { - $called1 = true; - $dispatcher->addListener('my-event', function () use (&$called2) { - $called2 = true; - }); - }); - $dispatcher->dispatch('my-event'); - $this->assertTrue($called1); - $this->assertFalse($called2); - $dispatcher->dispatch('my-event'); - $this->assertTrue($called2); - } - - public function testListenerCanRemoveItselfWhenExecuted() - { - $eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $listener1 = function () use ($eventDispatcher, &$listener1) { - $eventDispatcher->removeListener('foo', $listener1); - }; - $eventDispatcher->addListener('foo', $listener1); - $eventDispatcher->addListener('foo', function () {}); - $eventDispatcher->dispatch('foo'); - - $this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed'); - } - - 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); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php deleted file mode 100644 index 5a99e3bcb..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getProviderTypes - */ - public function testHandle($type) - { - $request = new Request(); - $expected = new Response(); - $controller = function () use ($expected) { - return $expected; - }; - - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $this - ->expectsEnterScopeOnce($container) - ->expectsLeaveScopeOnce($container) - ->expectsSetRequestWithAt($container, $request, 3) - ->expectsSetRequestWithAt($container, null, 4) - ; - - $dispatcher = new EventDispatcher(); - $resolver = $this->getResolverMockFor($controller, $request); - $stack = new RequestStack(); - $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); - - $actual = $kernel->handle($request, $type); - - $this->assertSame($expected, $actual, '->handle() returns the response'); - } - - /** - * @dataProvider getProviderTypes - */ - public function testVerifyRequestStackPushPopDuringHandle($type) - { - $request = new Request(); - $expected = new Response(); - $controller = function () use ($expected) { - return $expected; - }; - - $stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop')); - $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); - $stack->expects($this->at(1))->method('pop'); - - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $dispatcher = new EventDispatcher(); - $resolver = $this->getResolverMockFor($controller, $request); - $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); - - $kernel->handle($request, $type); - } - - /** - * @dataProvider getProviderTypes - */ - public function testHandleRestoresThePreviousRequestOnException($type) - { - $request = new Request(); - $expected = new \Exception(); - $controller = function () use ($expected) { - throw $expected; - }; - - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $this - ->expectsEnterScopeOnce($container) - ->expectsLeaveScopeOnce($container) - ->expectsSetRequestWithAt($container, $request, 3) - ->expectsSetRequestWithAt($container, null, 4) - ; - - $dispatcher = new EventDispatcher(); - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $resolver = $this->getResolverMockFor($controller, $request); - $stack = new RequestStack(); - $kernel = new ContainerAwareHttpKernel($dispatcher, $container, $resolver, $stack); - - try { - $kernel->handle($request, $type); - $this->fail('->handle() suppresses the controller exception'); - } catch (\PHPUnit_Framework_Exception $e) { - throw $e; - } catch (\Exception $e) { - $this->assertSame($expected, $e, '->handle() throws the controller exception'); - } - } - - public function getProviderTypes() - { - return array( - array(HttpKernelInterface::MASTER_REQUEST), - array(HttpKernelInterface::SUB_REQUEST), - ); - } - - private function getResolverMockFor($controller, $request) - { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $resolver->expects($this->once()) - ->method('getController') - ->with($request) - ->will($this->returnValue($controller)); - $resolver->expects($this->once()) - ->method('getArguments') - ->with($request, $controller) - ->will($this->returnValue(array())); - - return $resolver; - } - - private function expectsSetRequestWithAt($container, $with, $at) - { - $container - ->expects($this->at($at)) - ->method('set') - ->with($this->equalTo('request'), $this->equalTo($with), $this->equalTo('request')) - ; - - return $this; - } - - private function expectsEnterScopeOnce($container) - { - $container - ->expects($this->once()) - ->method('enterScope') - ->with($this->equalTo('request')) - ; - - return $this; - } - - private function expectsLeaveScopeOnce($container) - { - $container - ->expects($this->once()) - ->method('leaveScope') - ->with($this->equalTo('request')) - ; - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php deleted file mode 100644 index 3426f6f9a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; - -class MergeExtensionConfigurationPassTest extends \PHPUnit_Framework_TestCase -{ - public function testAutoloadMainExtension() - { - $container = $this->getMock( - 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', - array('getExtensionConfig', 'loadFromExtension', 'getParameterBag') - ); - $params = $this->getMock('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag'); - - $container->expects($this->at(0)) - ->method('getExtensionConfig') - ->with('loaded') - ->will($this->returnValue(array(array()))); - $container->expects($this->at(1)) - ->method('getExtensionConfig') - ->with('notloaded') - ->will($this->returnValue(array())); - $container->expects($this->once()) - ->method('loadFromExtension') - ->with('notloaded', array()); - - $container->expects($this->any()) - ->method('getParameterBag') - ->will($this->returnValue($params)); - $params->expects($this->any()) - ->method('all') - ->will($this->returnValue(array())); - $container->expects($this->any()) - ->method('getDefinitions') - ->will($this->returnValue(array())); - $container->expects($this->any()) - ->method('getAliases') - ->will($this->returnValue(array())); - $container->expects($this->any()) - ->method('getExtensions') - ->will($this->returnValue(array())); - - $configPass = new MergeExtensionConfigurationPass(array('loaded', 'notloaded')); - $configPass->process($container); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php deleted file mode 100644 index 26bdf7067..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Test AddRequestFormatsListener class - * - * @author Gildas Quemener - */ -class AddRequestFormatsListenerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var AddRequestFormatsListener - */ - private $listener; - - protected function setUp() - { - $this->listener = new AddRequestFormatsListener(array('csv' => array('text/csv', 'text/plain'))); - } - - protected function tearDown() - { - $this->listener = null; - } - - public function testIsAnEventSubscriber() - { - $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener); - } - - public function testRegisteredEvent() - { - $this->assertEquals( - array(KernelEvents::REQUEST => 'onKernelRequest'), - AddRequestFormatsListener::getSubscribedEvents() - ); - } - - public function testSetAdditionalFormats() - { - $request = $this->getRequestMock(); - $event = $this->getGetResponseEventMock($request); - - $request->expects($this->once()) - ->method('setFormat') - ->with('csv', array('text/csv', 'text/plain')); - - $this->listener->onKernelRequest($event); - } - - protected function getRequestMock() - { - return $this->getMock('Symfony\Component\HttpFoundation\Request'); - } - - protected function getGetResponseEventMock(Request $request) - { - $event = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') - ->disableOriginalConstructor() - ->getMock(); - - $event->expects($this->any()) - ->method('getRequest') - ->will($this->returnValue($request)); - - return $event; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php deleted file mode 100644 index f3cd05e23..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Psr\Log\LogLevel; -use Symfony\Component\Console\Event\ConsoleEvent; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\Console\Helper\HelperSet; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * DebugHandlersListenerTest - * - * @author Nicolas Grekas - */ -class DebugHandlersListenerTest extends \PHPUnit_Framework_TestCase -{ - public function testConfigure() - { - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $userHandler = function () {}; - $listener = new DebugHandlersListener($userHandler, $logger); - $xHandler = new ExceptionHandler(); - $eHandler = new ErrorHandler(); - $eHandler->setExceptionHandler(array($xHandler, 'handle')); - - $exception = null; - set_error_handler(array($eHandler, 'handleError')); - set_exception_handler(array($eHandler, 'handleException')); - try { - $listener->configure(); - } catch (\Exception $exception) { - } - restore_exception_handler(); - restore_error_handler(); - - if (null !== $exception) { - throw $exception; - } - - $this->assertSame($userHandler, $xHandler->setHandler('var_dump')); - - $loggers = $eHandler->setLoggers(array()); - - $this->assertArrayHasKey(E_DEPRECATED, $loggers); - $this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]); - } - - public function testConsoleEvent() - { - $dispatcher = new EventDispatcher(); - $listener = new DebugHandlersListener(null); - $app = $this->getMock('Symfony\Component\Console\Application'); - $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet())); - $command = new Command(__FUNCTION__); - $command->setApplication($app); - $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput()); - - $dispatcher->addSubscriber($listener); - - $xListeners = array( - KernelEvents::REQUEST => array(array($listener, 'configure')), - ConsoleEvents::COMMAND => array(array($listener, 'configure')), - ); - $this->assertSame($xListeners, $dispatcher->getListeners()); - - $exception = null; - $eHandler = new ErrorHandler(); - set_error_handler(array($eHandler, 'handleError')); - set_exception_handler(array($eHandler, 'handleException')); - try { - $dispatcher->dispatch(ConsoleEvents::COMMAND, $event); - } catch (\Exception $exception) { - } - restore_exception_handler(); - restore_error_handler(); - - if (null !== $exception) { - throw $exception; - } - - $xHandler = $eHandler->setExceptionHandler('var_dump'); - $this->assertInstanceOf('Closure', $xHandler); - - $app->expects($this->once()) - ->method('renderException'); - - $xHandler(new \Exception()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php deleted file mode 100644 index a9b715bac..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\EventListener\DumpListener; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\VarDumper\Cloner\ClonerInterface; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Dumper\DataDumperInterface; -use Symfony\Component\VarDumper\VarDumper; - -/** - * DumpListenerTest - * - * @author Nicolas Grekas - */ -class DumpListenerTest extends \PHPUnit_Framework_TestCase -{ - public function testSubscribedEvents() - { - $this->assertSame( - array(KernelEvents::REQUEST => array('configure', 1024)), - DumpListener::getSubscribedEvents() - ); - } - - public function testConfigure() - { - $prevDumper = VarDumper::setHandler('var_dump'); - VarDumper::setHandler($prevDumper); - - $cloner = new MockCloner(); - $dumper = new MockDumper(); - - ob_start(); - $exception = null; - $listener = new DumpListener($cloner, $dumper); - - try { - $listener->configure(); - - VarDumper::dump('foo'); - VarDumper::dump('bar'); - - $this->assertSame('+foo-+bar-', ob_get_clean()); - } catch (\Exception $exception) { - } - - VarDumper::setHandler($prevDumper); - - if (null !== $exception) { - throw $exception; - } - } -} - -class MockCloner implements ClonerInterface -{ - public function cloneVar($var) - { - return new Data(array($var.'-')); - } -} - -class MockDumper implements DataDumperInterface -{ - public function dump(Data $data) - { - $rawData = $data->getRawData(); - - echo '+'.$rawData[0]; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php deleted file mode 100644 index 8fb00f51c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ /dev/null @@ -1,146 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\EventListener\ExceptionListener; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Logger; - -/** - * ExceptionListenerTest. - * - * @author Robert Schönthal - */ -class ExceptionListenerTest extends \PHPUnit_Framework_TestCase -{ - public function testConstruct() - { - $logger = new TestLogger(); - $l = new ExceptionListener('foo', $logger); - - $_logger = new \ReflectionProperty(get_class($l), 'logger'); - $_logger->setAccessible(true); - $_controller = new \ReflectionProperty(get_class($l), 'controller'); - $_controller->setAccessible(true); - - $this->assertSame($logger, $_logger->getValue($l)); - $this->assertSame('foo', $_controller->getValue($l)); - } - - /** - * @dataProvider provider - */ - public function testHandleWithoutLogger($event, $event2) - { - $this->iniSet('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul'); - - $l = new ExceptionListener('foo'); - $l->onKernelException($event); - - $this->assertEquals(new Response('foo'), $event->getResponse()); - - try { - $l->onKernelException($event2); - $this->fail('RuntimeException expected'); - } catch (\RuntimeException $e) { - $this->assertSame('bar', $e->getMessage()); - $this->assertSame('foo', $e->getPrevious()->getMessage()); - } - } - - /** - * @dataProvider provider - */ - public function testHandleWithLogger($event, $event2) - { - $logger = new TestLogger(); - - $l = new ExceptionListener('foo', $logger); - $l->onKernelException($event); - - $this->assertEquals(new Response('foo'), $event->getResponse()); - - try { - $l->onKernelException($event2); - $this->fail('RuntimeException expected'); - } catch (\RuntimeException $e) { - $this->assertSame('bar', $e->getMessage()); - $this->assertSame('foo', $e->getPrevious()->getMessage()); - } - - $this->assertEquals(3, $logger->countErrors()); - $this->assertCount(3, $logger->getLogs('critical')); - } - - public function provider() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - return array(array(null, null)); - } - - $request = new Request(); - $exception = new \Exception('foo'); - $event = new GetResponseForExceptionEvent(new TestKernel(), $request, 'foo', $exception); - $event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, 'foo', $exception); - - return array( - array($event, $event2), - ); - } - - public function testSubRequestFormat() - { - $listener = new ExceptionListener('foo', $this->getMock('Psr\Log\LoggerInterface')); - - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { - return new Response($request->getRequestFormat()); - })); - - $request = Request::create('/'); - $request->setRequestFormat('xml'); - - $event = new GetResponseForExceptionEvent($kernel, $request, 'foo', new \Exception('foo')); - $listener->onKernelException($event); - - $response = $event->getResponse(); - $this->assertEquals('xml', $response->getContent()); - } -} - -class TestLogger extends Logger implements DebugLoggerInterface -{ - public function countErrors() - { - return count($this->logs['critical']); - } -} - -class TestKernel implements HttpKernelInterface -{ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - return new Response('foo'); - } -} - -class TestKernelThatThrowsException implements HttpKernelInterface -{ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - throw new \RuntimeException('bar'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php deleted file mode 100644 index fd5d63b16..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\EventListener\FragmentListener; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\UriSigner; - -class FragmentListenerTest extends \PHPUnit_Framework_TestCase -{ - public function testOnlyTriggeredOnFragmentRoute() - { - $request = Request::create('http://example.com/foo?_path=foo%3Dbar%26_controller%3Dfoo'); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $expected = $request->attributes->all(); - - $listener->onKernelRequest($event); - - $this->assertEquals($expected, $request->attributes->all()); - $this->assertTrue($request->query->has('_path')); - } - - public function testOnlyTriggeredIfControllerWasNotDefinedYet() - { - $request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'); - $request->attributes->set('_controller', 'bar'); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST); - - $expected = $request->attributes->all(); - - $listener->onKernelRequest($event); - - $this->assertEquals($expected, $request->attributes->all()); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ - public function testAccessDeniedWithNonSafeMethods() - { - $request = Request::create('http://example.com/_fragment', 'POST'); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ - public function testAccessDeniedWithWrongSignature() - { - $request = Request::create('http://example.com/_fragment', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - } - - public function testWithSignature() - { - $signer = new UriSigner('foo'); - $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); - - $listener = new FragmentListener($signer); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - - $this->assertEquals(array('foo' => 'bar', '_controller' => 'foo'), $request->attributes->get('_route_params')); - $this->assertFalse($request->query->has('_path')); - } - - private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST) - { - return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, $requestType); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php deleted file mode 100644 index ecc4eb027..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\EventListener\LocaleListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; - -class LocaleListenerTest extends \PHPUnit_Framework_TestCase -{ - private $requestStack; - - protected function setUp() - { - $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false); - } - - public function testDefaultLocaleWithoutSession() - { - $listener = new LocaleListener('fr', null, $this->requestStack); - $event = $this->getEvent($request = Request::create('/')); - - $listener->onKernelRequest($event); - $this->assertEquals('fr', $request->getLocale()); - } - - public function testLocaleFromRequestAttribute() - { - $request = Request::create('/'); - session_name('foo'); - $request->cookies->set('foo', 'value'); - - $request->attributes->set('_locale', 'es'); - $listener = new LocaleListener('fr', null, $this->requestStack); - $event = $this->getEvent($request); - - $listener->onKernelRequest($event); - $this->assertEquals('es', $request->getLocale()); - } - - public function testLocaleSetForRoutingContext() - { - // the request context is updated - $context = $this->getMock('Symfony\Component\Routing\RequestContext'); - $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - - $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); - - $request = Request::create('/'); - - $request->attributes->set('_locale', 'es'); - $listener = new LocaleListener('fr', $router, $this->requestStack); - $listener->onKernelRequest($this->getEvent($request)); - } - - public function testRouterResetWithParentRequestOnKernelFinishRequest() - { - // the request context is updated - $context = $this->getMock('Symfony\Component\Routing\RequestContext'); - $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - - $router = $this->getMock('Symfony\Component\Routing\Router', array('getContext'), array(), '', false); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); - - $parentRequest = Request::create('/'); - $parentRequest->setLocale('es'); - - $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); - - $event = $this->getMock('Symfony\Component\HttpKernel\Event\FinishRequestEvent', array(), array(), '', false); - - $listener = new LocaleListener('fr', $router, $this->requestStack); - $listener->onKernelFinishRequest($event); - } - - public function testRequestLocaleIsNotOverridden() - { - $request = Request::create('/'); - $request->setLocale('de'); - $listener = new LocaleListener('fr', null, $this->requestStack); - $event = $this->getEvent($request); - - $listener->onKernelRequest($event); - $this->assertEquals('de', $request->getLocale()); - } - - private function getEvent(Request $request) - { - return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php deleted file mode 100644 index 605ea9dd2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\EventListener\ProfilerListener; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpKernel\Exception\HttpException; -use Symfony\Component\HttpKernel\Kernel; - -class ProfilerListenerTest extends \PHPUnit_Framework_TestCase -{ - /** - * Test to ensure BC without RequestStack - * - * @group legacy - */ - public function testLegacyEventsWithoutRequestStack() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile') - ->disableOriginalConstructor() - ->getMock(); - - $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') - ->disableOriginalConstructor() - ->getMock(); - $profiler->expects($this->once()) - ->method('collect') - ->will($this->returnValue($profile)); - - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') - ->disableOriginalConstructor() - ->getMock(); - - $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') - ->disableOriginalConstructor() - ->getMock(); - - $listener = new ProfilerListener($profiler); - $listener->onKernelRequest(new GetResponseEvent($kernel, $request, Kernel::MASTER_REQUEST)); - $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, Kernel::MASTER_REQUEST, $response)); - $listener->onKernelTerminate(new PostResponseEvent($kernel, $request, $response)); - } - - /** - * Test a master and sub request with an exception and `onlyException` profiler option enabled. - */ - public function testKernelTerminate() - { - $profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile') - ->disableOriginalConstructor() - ->getMock(); - - $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') - ->disableOriginalConstructor() - ->getMock(); - - $profiler->expects($this->once()) - ->method('collect') - ->will($this->returnValue($profile)); - - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - - $masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') - ->disableOriginalConstructor() - ->getMock(); - - $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') - ->disableOriginalConstructor() - ->getMock(); - - $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') - ->disableOriginalConstructor() - ->getMock(); - - $requestStack = new RequestStack(); - $requestStack->push($masterRequest); - - $onlyException = true; - $listener = new ProfilerListener($profiler, null, $onlyException, false, $requestStack); - - // master request - $listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response)); - - // sub request - $listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404))); - $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response)); - - $listener->onKernelTerminate(new PostResponseEvent($kernel, $masterRequest, $response)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php deleted file mode 100644 index 821688eff..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\EventListener\ResponseListener; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class ResponseListenerTest extends \PHPUnit_Framework_TestCase -{ - private $dispatcher; - - private $kernel; - - protected function setUp() - { - $this->dispatcher = new EventDispatcher(); - $listener = new ResponseListener('UTF-8'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - - $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->kernel = null; - } - - public function testFilterDoesNothingForSubRequests() - { - $response = new Response('foo'); - - $event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('', $event->getResponse()->headers->get('content-type')); - } - - public function testFilterSetsNonDefaultCharsetIfNotOverridden() - { - $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); - - $response = new Response('foo'); - - $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('ISO-8859-15', $response->getCharset()); - } - - public function testFilterDoesNothingIfCharsetIsOverridden() - { - $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); - - $response = new Response('foo'); - $response->setCharset('ISO-8859-1'); - - $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('ISO-8859-1', $response->getCharset()); - } - - public function testFiltersSetsNonDefaultCharsetIfNotOverriddenOnNonTextContentType() - { - $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); - - $response = new Response('foo'); - $request = Request::create('/'); - $request->setRequestFormat('application/json'); - - $event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('ISO-8859-15', $response->getCharset()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php deleted file mode 100644 index d6e5b45ba..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\EventListener\RouterListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\Routing\RequestContext; - -class RouterListenerTest extends \PHPUnit_Framework_TestCase -{ - private $requestStack; - - protected function setUp() - { - $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array(), array(), '', false); - } - - /** - * @dataProvider getPortData - */ - public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHttpPort, $expectedHttpsPort) - { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface') - ->disableOriginalConstructor() - ->getMock(); - $context = new RequestContext(); - $context->setHttpPort($defaultHttpPort); - $context->setHttpsPort($defaultHttpsPort); - $urlMatcher->expects($this->any()) - ->method('getContext') - ->will($this->returnValue($context)); - - $listener = new RouterListener($urlMatcher, null, null, $this->requestStack); - $event = $this->createGetResponseEventForUri($uri); - $listener->onKernelRequest($event); - - $this->assertEquals($expectedHttpPort, $context->getHttpPort()); - $this->assertEquals($expectedHttpsPort, $context->getHttpsPort()); - $this->assertEquals(0 === strpos($uri, 'https') ? 'https' : 'http', $context->getScheme()); - } - - public function getPortData() - { - return array( - array(80, 443, 'http://localhost/', 80, 443), - array(80, 443, 'http://localhost:90/', 90, 443), - array(80, 443, 'https://localhost/', 80, 443), - array(80, 443, 'https://localhost:90/', 80, 90), - ); - } - - /** - * @param string $uri - * - * @return GetResponseEvent - */ - private function createGetResponseEventForUri($uri) - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $request = Request::create($uri); - $request->attributes->set('_controller', null); // Prevents going in to routing process - - return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidMatcher() - { - new RouterListener(new \stdClass(), null, null, $this->requestStack); - } - - public function testRequestMatcher() - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $request = Request::create('http://localhost/'); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); - $requestMatcher->expects($this->once()) - ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue(array())); - - $listener = new RouterListener($requestMatcher, new RequestContext(), null, $this->requestStack); - $listener->onKernelRequest($event); - } - - public function testSubRequestWithDifferentMethod() - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $request = Request::create('http://localhost/', 'post'); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); - $requestMatcher->expects($this->any()) - ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue(array())); - - $context = new RequestContext(); - $requestMatcher->expects($this->any()) - ->method('getContext') - ->will($this->returnValue($context)); - - $listener = new RouterListener($requestMatcher, new RequestContext(), null, $this->requestStack); - $listener->onKernelRequest($event); - - // sub-request with another HTTP method - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $request = Request::create('http://localhost/', 'get'); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST); - - $listener->onKernelRequest($event); - - $this->assertEquals('GET', $context->getMethod()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php deleted file mode 100644 index 1a0acf92f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/SurrogateListenerTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\EventListener\SurrogateListener; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class SurrogateListenerTest extends \PHPUnit_Framework_TestCase -{ - public function testFilterDoesNothingForSubRequests() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $response = new Response('foo '); - $listener = new SurrogateListener(new Esi()); - - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response); - $dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control')); - } - - public function testFilterWhenThereIsSomeEsiIncludes() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $response = new Response('foo '); - $listener = new SurrogateListener(new Esi()); - - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); - $dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('content="ESI/1.0"', $event->getResponse()->headers->get('Surrogate-Control')); - } - - public function testFilterWhenThereIsNoEsiIncludes() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $response = new Response('foo'); - $listener = new SurrogateListener(new Esi()); - - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); - $dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control')); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php deleted file mode 100644 index cbaaf5f93..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpFoundation\Session\SessionInterface; - -/** - * SessionListenerTest. - * - * Tests SessionListener. - * - * @author Bulat Shakirzyanov - */ -class TestSessionListenerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var TestSessionListener - */ - private $listener; - - /** - * @var SessionInterface - */ - private $session; - - protected function setUp() - { - $this->listener = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\EventListener\TestSessionListener'); - $this->session = $this->getSession(); - } - - public function testShouldSaveMasterRequestSession() - { - $this->sessionHasBeenStarted(); - $this->sessionMustBeSaved(); - - $this->filterResponse(new Request()); - } - - public function testShouldNotSaveSubRequestSession() - { - $this->sessionMustNotBeSaved(); - - $this->filterResponse(new Request(), HttpKernelInterface::SUB_REQUEST); - } - - public function testDoesNotDeleteCookieIfUsingSessionLifetime() - { - $this->sessionHasBeenStarted(); - - $params = session_get_cookie_params(); - session_set_cookie_params(0, $params['path'], $params['domain'], $params['secure'], $params['httponly']); - - $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); - $cookies = $response->headers->getCookies(); - - $this->assertEquals(0, reset($cookies)->getExpiresTime()); - } - - public function testUnstartedSessionIsNotSave() - { - $this->sessionHasNotBeenStarted(); - $this->sessionMustNotBeSaved(); - - $this->filterResponse(new Request()); - } - - private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST) - { - $request->setSession($this->session); - $response = new Response(); - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $event = new FilterResponseEvent($kernel, $request, $type, $response); - - $this->listener->onKernelResponse($event); - - $this->assertSame($response, $event->getResponse()); - - return $response; - } - - private function sessionMustNotBeSaved() - { - $this->session->expects($this->never()) - ->method('save'); - } - - private function sessionMustBeSaved() - { - $this->session->expects($this->once()) - ->method('save'); - } - - private function sessionHasBeenStarted() - { - $this->session->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(true)); - } - - private function sessionHasNotBeenStarted() - { - $this->session->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(false)); - } - - private function getSession() - { - $mock = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session') - ->disableOriginalConstructor() - ->getMock(); - - // set return value for getName() - $mock->expects($this->any())->method('getName')->will($this->returnValue('MOCKSESSID')); - - return $mock; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php deleted file mode 100644 index c37d64786..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\EventListener\TranslatorListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class TranslatorListenerTest extends \PHPUnit_Framework_TestCase -{ - private $listener; - private $translator; - private $requestStack; - - protected function setUp() - { - $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); - $this->listener = new TranslatorListener($this->translator, $this->requestStack); - } - - public function testLocaleIsSetInOnKernelRequest() - { - $this->translator - ->expects($this->once()) - ->method('setLocale') - ->with($this->equalTo('fr')); - - $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); - $this->listener->onKernelRequest($event); - } - - public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() - { - $this->translator - ->expects($this->at(0)) - ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->translator - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); - - $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); - $this->listener->onKernelRequest($event); - } - - public function testLocaleIsSetInOnKernelFinishRequestWhenParentRequestExists() - { - $this->translator - ->expects($this->once()) - ->method('setLocale') - ->with($this->equalTo('fr')); - - $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); - $this->listener->onKernelFinishRequest($event); - } - - public function testLocaleIsNotSetInOnKernelFinishRequestWhenParentRequestDoesNotExist() - { - $this->translator - ->expects($this->never()) - ->method('setLocale'); - - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); - $this->listener->onKernelFinishRequest($event); - } - - public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() - { - $this->translator - ->expects($this->at(0)) - ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->translator - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); - - $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); - $this->listener->onKernelFinishRequest($event); - } - - private function createHttpKernel() - { - return $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - } - - private function createRequest($locale) - { - $request = new Request(); - $request->setLocale($locale); - - return $request; - } - - private function setMasterRequest($request) - { - $this->requestStack - ->expects($this->any()) - ->method('getParentRequest') - ->will($this->returnValue($request)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/BaseBundle/Resources/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/BaseBundle/Resources/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/BaseBundle/Resources/hide.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/BaseBundle/Resources/hide.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/Resources/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/Resources/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/bar.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/bar.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle1Bundle/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle2Bundle/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Bundle2Bundle/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ChildBundle/Resources/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ChildBundle/Resources/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ChildBundle/Resources/hide.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ChildBundle/Resources/hide.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php deleted file mode 100644 index c8bfd36e6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionAbsentBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php deleted file mode 100644 index 3b31781aa..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionLoadedBundle\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; - -class ExtensionLoadedExtension extends Extension -{ - public function load(array $configs, ContainerBuilder $container) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php deleted file mode 100644 index 3af81cb07..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionLoadedBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionLoadedBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php deleted file mode 100644 index 0fd64316f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\DependencyInjection; - -class ExtensionNotValidExtension -{ - public function getAlias() - { - return 'extension_not_valid'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php deleted file mode 100644 index 34e292039..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionNotValidBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php deleted file mode 100644 index f3fd14b55..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command; - -use Symfony\Component\Console\Command\Command; - -class FooCommand extends Command -{ - protected function configure() - { - $this->setName('foo'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php deleted file mode 100644 index e42f8162c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; - -class ExtensionPresentExtension extends Extension -{ - public function load(array $configs, ContainerBuilder $container) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php deleted file mode 100644 index 36a7ad404..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionPresentBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php deleted file mode 100644 index f940f8369..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class FooBarBundle extends Bundle -{ - // We need a full namespaced bundle instance to test isClassInActiveBundle -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php deleted file mode 100644 index a1102ab78..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Config\Loader\LoaderInterface; - -class KernelForOverrideName extends Kernel -{ - protected $name = 'overridden'; - - public function registerBundles() - { - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php deleted file mode 100644 index 5fd61bbc7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Config\Loader\LoaderInterface; - -class KernelForTest extends Kernel -{ - public function getBundleMap() - { - return $this->bundleMap; - } - - public function registerBundles() - { - return array(); - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } - - public function isBooted() - { - return $this->booted; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/BaseBundle/hide.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/BaseBundle/hide.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/Bundle1Bundle/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/Bundle1Bundle/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/ChildBundle/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/ChildBundle/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/FooBundle/foo.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/Resources/FooBundle/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php deleted file mode 100644 index e7d60cff3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Client; - -class TestClient extends Client -{ - protected function getScript($request) - { - $script = parent::getScript($request); - - $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/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php deleted file mode 100644 index da7ef5bd6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestEventDispatcher extends EventDispatcher implements TraceableEventDispatcherInterface -{ - public function getCalledListeners() - { - return array('foo'); - } - - public function getNotCalledListeners() - { - return array('bar'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php deleted file mode 100644 index 90768f9da..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\UriSigner; - -class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase -{ - public function testRenderFallbackToInlineStrategyIfNoRequest() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true)); - $strategy->render('/', Request::create('/')); - } - - public function testRenderFallbackToInlineStrategyIfEsiNotSupported() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true)); - $strategy->render('/', Request::create('/')); - } - - public function testRender() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $this->assertEquals('', $strategy->render('/', $request)->getContent()); - $this->assertEquals("\n", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent()); - $this->assertEquals('', $strategy->render('/', $request, array('alt' => 'foo'))->getContent()); - } - - public function testRenderControllerReference() - { - $signer = new UriSigner('foo'); - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(), $signer); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $reference = new ControllerReference('main_controller', array(), array()); - $altReference = new ControllerReference('alt_controller', array(), array()); - - $this->assertEquals( - '', - $strategy->render($reference, $request, array('alt' => $altReference))->getContent() - ); - } - - /** - * @expectedException \LogicException - */ - public function testRenderControllerReferenceWithoutSignerThrowsException() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $strategy->render(new ControllerReference('main_controller'), $request); - } - - /** - * @expectedException \LogicException - */ - public function testRenderAltControllerReferenceWithoutSignerThrowsException() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); - } - - private function getInlineStrategy($called = false) - { - $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); - - if ($called) { - $inline->expects($this->once())->method('render'); - } - - return $inline; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php deleted file mode 100644 index b2903b84a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use Symfony\Component\HttpKernel\Fragment\FragmentHandler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class FragmentHandlerTest extends \PHPUnit_Framework_TestCase -{ - private $requestStack; - - protected function setUp() - { - $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') - ->disableOriginalConstructor() - ->getMock() - ; - $this->requestStack - ->expects($this->any()) - ->method('getCurrentRequest') - ->will($this->returnValue(Request::create('/'))) - ; - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRenderWhenRendererDoesNotExist() - { - $handler = new FragmentHandler(array(), null, $this->requestStack); - $handler->render('/', 'foo'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRenderWithUnknownRenderer() - { - $handler = $this->getHandler($this->returnValue(new Response('foo'))); - - $handler->render('/', 'bar'); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Error when rendering "http://localhost/" (Status code is 404). - */ - public function testDeliverWithUnsuccessfulResponse() - { - $handler = $this->getHandler($this->returnValue(new Response('foo', 404))); - - $handler->render('/', 'foo'); - } - - public function testRender() - { - $handler = $this->getHandler($this->returnValue(new Response('foo')), array('/', Request::create('/'), array('foo' => 'foo', 'ignore_errors' => true))); - - $this->assertEquals('foo', $handler->render('/', 'foo', array('foo' => 'foo'))); - } - - protected function getHandler($returnValue, $arguments = array()) - { - $renderer = $this->getMock('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface'); - $renderer - ->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')) - ; - $e = $renderer - ->expects($this->any()) - ->method('render') - ->will($returnValue) - ; - - if ($arguments) { - call_user_func_array(array($e, 'with'), $arguments); - } - - $handler = new FragmentHandler(array(), null, $this->requestStack); - $handler->addRenderer($renderer); - - return $handler; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php deleted file mode 100644 index 2f266dba7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; -use Symfony\Component\HttpKernel\UriSigner; -use Symfony\Component\HttpFoundation\Request; - -class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \LogicException - */ - public function testRenderExceptionWhenControllerAndNoSigner() - { - $strategy = new HIncludeFragmentRenderer(); - $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/')); - } - - public function testRenderWithControllerAndSigner() - { - $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); - } - - public function testRenderWithUri() - { - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('', $strategy->render('/foo', Request::create('/'))->getContent()); - - $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - $this->assertEquals('', $strategy->render('/foo', Request::create('/'))->getContent()); - } - - public function testRenderWithDefault() - { - // only default - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); - - // only global default - $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); - $this->assertEquals('global_default', $strategy->render('/foo', Request::create('/'), array())->getContent()); - - // global default and default - $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); - } - - public function testRenderWithAttributesOptions() - { - // with id - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar'))->getContent()); - - // with attributes - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); - - // with id & attributes - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); - } - - public function testRenderWithDefaultText() - { - $engine = $this->getMock('Symfony\\Component\\Templating\\EngineInterface'); - $engine->expects($this->once()) - ->method('exists') - ->with('default') - ->will($this->throwException(new \InvalidArgumentException())); - - // only default - $strategy = new HIncludeFragmentRenderer($engine); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php deleted file mode 100644 index 4e487a478..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ /dev/null @@ -1,210 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase -{ - public function testRender() - { - $strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo')))); - - $this->assertEquals('foo', $strategy->render('/', Request::create('/'))->getContent()); - } - - public function testRenderWithControllerReference() - { - $strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo')))); - - $this->assertEquals('foo', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); - } - - public function testRenderWithObjectsAsAttributes() - { - $object = new \stdClass(); - - $subRequest = Request::create('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller'); - $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); - $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); - - $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/')); - } - - public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController() - { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver', array('getController')); - $resolver - ->expects($this->once()) - ->method('getController') - ->will($this->returnValue(function (\stdClass $object, Bar $object1) { - return new Response($object1->getBar()); - })) - ; - - $kernel = new HttpKernel(new EventDispatcher(), $resolver); - $renderer = new InlineFragmentRenderer($kernel); - - $response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/')); - $this->assertEquals('bar', $response->getContent()); - } - - public function testRenderWithTrustedHeaderDisabled() - { - $trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP); - - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); - - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); - $strategy->render('/', Request::create('/')); - - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName); - } - - /** - * @expectedException \RuntimeException - */ - public function testRenderExceptionNoIgnoreErrors() - { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $dispatcher->expects($this->never())->method('dispatch'); - - $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); - - $this->assertEquals('foo', $strategy->render('/', Request::create('/'))->getContent()); - } - - public function testRenderExceptionIgnoreErrors() - { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $dispatcher->expects($this->once())->method('dispatch')->with(KernelEvents::EXCEPTION); - - $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); - - $this->assertEmpty($strategy->render('/', Request::create('/'), array('ignore_errors' => true))->getContent()); - } - - public function testRenderExceptionIgnoreErrorsWithAlt() - { - $strategy = new InlineFragmentRenderer($this->getKernel($this->onConsecutiveCalls( - $this->throwException(new \RuntimeException('foo')), - $this->returnValue(new Response('bar')) - ))); - - $this->assertEquals('bar', $strategy->render('/', Request::create('/'), array('ignore_errors' => true, 'alt' => '/foo'))->getContent()); - } - - private function getKernel($returnValue) - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $kernel - ->expects($this->any()) - ->method('handle') - ->will($returnValue) - ; - - return $kernel; - } - - /** - * Creates a Kernel expecting a request equals to $request - * Allows delta in comparison in case REQUEST_TIME changed by 1 second. - */ - private function getKernelExpectingRequest(Request $request) - { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $kernel - ->expects($this->any()) - ->method('handle') - ->with($this->equalTo($request, 1)) - ; - - return $kernel; - } - - public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() - { - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $resolver - ->expects($this->once()) - ->method('getController') - ->will($this->returnValue(function () { - ob_start(); - echo 'bar'; - throw new \RuntimeException(); - })) - ; - $resolver - ->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue(array())) - ; - - $kernel = new HttpKernel(new EventDispatcher(), $resolver); - $renderer = new InlineFragmentRenderer($kernel); - - // simulate a main request with output buffering - ob_start(); - echo 'Foo'; - - // simulate a sub-request with output buffering and an exception - $renderer->render('/', Request::create('/'), array('ignore_errors' => true)); - - $this->assertEquals('Foo', ob_get_clean()); - } - - public function testESIHeaderIsKeptInSubrequest() - { - $expectedSubRequest = Request::create('/'); - $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - - if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - } - - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $strategy->render('/', $request); - } - - public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled() - { - $trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP); - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); - - $this->testESIHeaderIsKeptInSubrequest(); - - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName); - } -} - -class Bar -{ - public $bar = 'bar'; - - public function getBar() - { - return $this->bar; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php deleted file mode 100644 index 184175cc8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ControllerReference; - -class RoutableFragmentRendererTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getGenerateFragmentUriData - */ - public function testGenerateFragmentUri($uri, $controller) - { - $this->assertEquals($uri, $this->callGenerateFragmentUriMethod($controller, Request::create('/'))); - } - - /** - * @dataProvider getGenerateFragmentUriData - */ - public function testGenerateAbsoluteFragmentUri($uri, $controller) - { - $this->assertEquals('http://localhost'.$uri, $this->callGenerateFragmentUriMethod($controller, Request::create('/'), true)); - } - - public function getGenerateFragmentUriData() - { - return array( - array('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())), - array('/_fragment?_path=_format%3Dxml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())), - array('/_fragment?_path=foo%3Dfoo%26_format%3Djson%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())), - array('/_fragment?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))), - array('/_fragment?foo=foo&_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))), - array('/_fragment?_path=foo%255B0%255D%3Dfoo%26foo%255B1%255D%3Dbar%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => array('foo', 'bar')), array())), - ); - } - - public function testGenerateFragmentUriWithARequest() - { - $request = Request::create('/'); - $request->attributes->set('_format', 'json'); - $request->setLocale('fr'); - $controller = new ControllerReference('controller', array(), array()); - - $this->assertEquals('/_fragment?_path=_format%3Djson%26_locale%3Dfr%26_controller%3Dcontroller', $this->callGenerateFragmentUriMethod($controller, $request)); - } - - /** - * @expectedException LogicException - * @dataProvider getGenerateFragmentUriDataWithNonScalar - */ - public function testGenerateFragmentUriWithNonScalar($controller) - { - $this->callGenerateFragmentUriMethod($controller, Request::create('/')); - } - - public function getGenerateFragmentUriDataWithNonScalar() - { - return array( - array(new ControllerReference('controller', array('foo' => new Foo(), 'bar' => 'bar'), array())), - array(new ControllerReference('controller', array('foo' => array('foo' => 'foo'), 'bar' => array('bar' => new Foo())), array())), - ); - } - - private function callGenerateFragmentUriMethod(ControllerReference $reference, Request $request, $absolute = false) - { - $renderer = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer'); - $r = new \ReflectionObject($renderer); - $m = $r->getMethod('generateFragmentUri'); - $m->setAccessible(true); - - return $m->invoke($renderer, $reference, $request, $absolute); - } -} - -class Foo -{ - public $foo; - - public function getFoo() - { - return $this->foo; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php deleted file mode 100644 index 00a936760..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ /dev/null @@ -1,225 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class EsiTest extends \PHPUnit_Framework_TestCase -{ - public function testHasSurrogateEsiCapability() - { - $esi = new Esi(); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $this->assertTrue($esi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'foobar'); - $this->assertFalse($esi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $this->assertFalse($esi->hasSurrogateCapability($request)); - } - - public function testAddSurrogateEsiCapability() - { - $esi = new Esi(); - - $request = Request::create('/'); - $esi->addSurrogateCapability($request); - $this->assertEquals('symfony2="ESI/1.0"', $request->headers->get('Surrogate-Capability')); - - $esi->addSurrogateCapability($request); - $this->assertEquals('symfony2="ESI/1.0", symfony2="ESI/1.0"', $request->headers->get('Surrogate-Capability')); - } - - public function testAddSurrogateControl() - { - $esi = new Esi(); - - $response = new Response('foo '); - $esi->addSurrogateControl($response); - $this->assertEquals('content="ESI/1.0"', $response->headers->get('Surrogate-Control')); - - $response = new Response('foo'); - $esi->addSurrogateControl($response); - $this->assertEquals('', $response->headers->get('Surrogate-Control')); - } - - public function testNeedsEsiParsing() - { - $esi = new Esi(); - - $response = new Response(); - $response->headers->set('Surrogate-Control', 'content="ESI/1.0"'); - $this->assertTrue($esi->needsParsing($response)); - - $response = new Response(); - $this->assertFalse($esi->needsParsing($response)); - } - - public function testRenderIncludeTag() - { - $esi = new Esi(); - - $this->assertEquals('', $esi->renderIncludeTag('/', '/alt', true)); - $this->assertEquals('', $esi->renderIncludeTag('/', '/alt', false)); - $this->assertEquals('', $esi->renderIncludeTag('/')); - $this->assertEquals(''."\n".'', $esi->renderIncludeTag('/', '/alt', true, 'some comment')); - } - - public function testProcessDoesNothingIfContentTypeIsNotHtml() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response(); - $response->headers->set('Content-Type', 'text/plain'); - $esi->process($request, $response); - - $this->assertFalse($response->headers->has('x-body-eval')); - } - - public function testProcess() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'alt\', true) ?>'."\n", $response->getContent()); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'foo\\\'\', \'bar\\\'\', true) ?>'."\n", $response->getContent()); - - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent()); - - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent()); - } - - public function testProcessEscapesPhpTags() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response(''); - $esi->process($request, $response); - - $this->assertEquals('php cript language=php>', $response->getContent()); - } - - /** - * @expectedException \RuntimeException - */ - public function testProcessWhenNoSrcInAnEsi() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $esi->process($request, $response); - } - - public function testProcessRemoveSurrogateControlHeader() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $response->headers->set('Surrogate-Control', 'content="ESI/1.0"'); - $esi->process($request, $response); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - - $response->headers->set('Surrogate-Control', 'no-store, content="ESI/1.0"'); - $esi->process($request, $response); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - - $response->headers->set('Surrogate-Control', 'content="ESI/1.0", no-store'); - $esi->process($request, $response); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - } - - public function testHandle() - { - $esi = new Esi(); - $cache = $this->getCache(Request::create('/'), new Response('foo')); - $this->assertEquals('foo', $esi->handle($cache, '/', '/alt', true)); - } - - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenResponseIsNot200() - { - $esi = new Esi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $esi->handle($cache, '/', '/alt', false); - } - - public function testHandleWhenResponseIsNot200AndErrorsAreIgnored() - { - $esi = new Esi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $this->assertEquals('', $esi->handle($cache, '/', '/alt', true)); - } - - public function testHandleWhenResponseIsNot200AndAltIsPresent() - { - $esi = new Esi(); - $response1 = new Response('foo'); - $response1->setStatusCode(404); - $response2 = new Response('bar'); - $cache = $this->getCache(Request::create('/'), array($response1, $response2)); - $this->assertEquals('bar', $esi->handle($cache, '/', '/alt', false)); - } - - protected function getCache($request, $response) - { - $cache = $this->getMock('Symfony\Component\HttpKernel\HttpCache\HttpCache', array('getRequest', 'handle'), array(), '', false); - $cache->expects($this->any()) - ->method('getRequest') - ->will($this->returnValue($request)) - ; - if (is_array($response)) { - $cache->expects($this->any()) - ->method('handle') - ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) - ; - } else { - $cache->expects($this->any()) - ->method('handle') - ->will($this->returnValue($response)) - ; - } - - return $cache; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php deleted file mode 100644 index 97fde8de3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ /dev/null @@ -1,1225 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\HttpCache\HttpCache; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class HttpCacheTest extends HttpCacheTestCase -{ - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() - { - $storeMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface') - ->disableOriginalConstructor() - ->getMock(); - - // does not implement TerminableInterface - $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface') - ->disableOriginalConstructor() - ->getMock(); - - $kernelMock->expects($this->never()) - ->method('terminate'); - - $kernel = new HttpCache($kernelMock, $storeMock); - $kernel->terminate(Request::create('/'), new Response()); - - // implements TerminableInterface - $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel') - ->disableOriginalConstructor() - ->setMethods(array('terminate', 'registerBundles', 'registerContainerConfiguration')) - ->getMock(); - - $kernelMock->expects($this->once()) - ->method('terminate'); - - $kernel = new HttpCache($kernelMock, $storeMock); - $kernel->terminate(Request::create('/'), new Response()); - } - - public function testPassesOnNonGetHeadRequests() - { - $this->setNextResponse(200); - $this->request('POST', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('pass'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testInvalidatesOnPostPutDeleteRequests() - { - foreach (array('post', 'put', 'delete') as $method) { - $this->setNextResponse(200); - $this->request($method, '/'); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('invalidate'); - $this->assertTraceContains('pass'); - } - } - - public function testDoesNotCacheWithAuthorizationRequestHeaderAndNonPublicResponse() - { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesCacheWithAuthorizationRequestHeaderAndPublicResponse() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - $this->assertEquals('public', $this->response->headers->get('Cache-Control')); - } - - public function testDoesNotCacheWithCookieHeaderAndNonPublicResponse() - { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array(), array('foo' => 'bar')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesNotCacheRequestsWithACookieHeader() - { - $this->setNextResponse(200); - $this->request('GET', '/', array(), array('foo' => 'bar')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() - { - $time = new \DateTime(); - - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822), 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->headers->get('Content-Type')); - $this->assertEmpty($this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testRespondsWith304WhenIfNoneMatchMatchesETag() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '12345', 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345')); - - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->headers->get('Content-Type')); - $this->assertTrue($this->response->headers->has('ETag')); - $this->assertEmpty($this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch() - { - $time = new \DateTime(); - - $this->setNextResponse(200, array(), '', function ($request, $response) use ($time) { - $response->setStatusCode(200); - $response->headers->set('ETag', '12345'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('Hello World'); - }); - - // only ETag matches - $t = \DateTime::createFromFormat('U', time() - 3600); - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - - // only Last-Modified matches - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - - // Both matches - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - } - - public function testValidatesPrivateResponsesCachedOnTheClient() - { - $this->setNextResponse(200, array(), '', function ($request, $response) { - $etags = preg_split('/\s*,\s*/', $request->headers->get('IF_NONE_MATCH')); - if ($request->cookies->has('authenticated')) { - $response->headers->set('Cache-Control', 'private, no-store'); - $response->setETag('"private tag"'); - if (in_array('"private tag"', $etags)) { - $response->setStatusCode(304); - } else { - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('private data'); - } - } else { - $response->headers->set('Cache-Control', 'public'); - $response->setETag('"public tag"'); - if (in_array('"public tag"', $etags)) { - $response->setStatusCode(304); - } else { - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('public data'); - } - } - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('"public tag"', $this->response->headers->get('ETag')); - $this->assertEquals('public data', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $this->request('GET', '/', array(), array('authenticated' => '')); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('"private tag"', $this->response->headers->get('ETag')); - $this->assertEquals('private data', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceNotContains('store'); - } - - public function testStoresResponsesWhenNoCacheRequestDirectivePresent() - { - $time = \DateTime::createFromFormat('U', time() + 5); - - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testReloadsResponsesWhenCacheHitsButNoCacheRequestDirectivePresentWhenAllowReloadIsSetTrue() - { - $count = 0; - - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) { - ++$count; - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_reload'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Goodbye World', $this->response->getContent()); - $this->assertTraceContains('reload'); - $this->assertTraceContains('store'); - } - - public function testDoesNotReloadResponsesWhenAllowReloadIsSetFalseDefault() - { - $count = 0; - - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) { - ++$count; - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_reload'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('reload'); - - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('reload'); - } - - public function testRevalidatesFreshCacheEntryWhenMaxAgeRequestDirectiveIsExceededWhenAllowRevalidateOptionIsSetTrue() - { - $count = 0; - - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) { - ++$count; - $response->headers->set('Cache-Control', 'public, max-age=10000'); - $response->setETag($count); - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_revalidate'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Goodbye World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - } - - public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIsSetFalseDefault() - { - $count = 0; - - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) { - ++$count; - $response->headers->set('Cache-Control', 'public, max-age=10000'); - $response->setETag($count); - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_revalidate'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('stale'); - $this->assertTraceNotContains('invalid'); - $this->assertTraceContains('fresh'); - - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('stale'); - $this->assertTraceNotContains('invalid'); - $this->assertTraceContains('fresh'); - } - - public function testFetchesResponseFromBackendWhenCacheMisses() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testDoesNotCacheSomeStatusCodeResponses() - { - foreach (array_merge(range(201, 202), range(204, 206), range(303, 305), range(400, 403), range(405, 409), range(411, 417), range(500, 505)) as $code) { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse($code, array('Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals($code, $this->response->getStatusCode()); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - } - - public function testDoesNotCacheResponsesWithExplicitNoStoreDirective() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'no-store')); - - $this->request('GET', '/'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesNotCacheResponsesWithoutFreshnessInformationOrAValidator() - { - $this->setNextResponse(); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceNotContains('store'); - } - - public function testCachesResponsesWithExplicitNoCacheDirective() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, no-cache')); - - $this->request('GET', '/'); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testCachesResponsesWithAnExpirationHeader() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithAMaxAgeDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=5')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithASMaxAgeDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 's-maxage=5')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithALastModifiedValidatorButNoFreshnessInformation() - { - $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testCachesResponsesWithAnETagValidatorButNoFreshnessInformation() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"123456"')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testHitsCachedResponsesWithExpiresHeader() - { - $time1 = \DateTime::createFromFormat('U', time() - 5); - $time2 = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Date' => $time1->format(DATE_RFC2822), 'Expires' => $time2->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2); - $this->assertTrue($this->response->headers->get('Age') > 0); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testHitsCachedResponseWithMaxAgeDirective() - { - $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, max-age=10')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2); - $this->assertTrue($this->response->headers->get('Age') > 0); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testHitsCachedResponseWithSMaxAgeDirective() - { - $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 's-maxage=10, max-age=0')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue(strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date')) < 2); - $this->assertTrue($this->response->headers->get('Age') > 0); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() - { - $this->setNextResponse(); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); - } - - public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpired() - { - $this->setNextResponse(); - - $this->cacheConfig['default_ttl'] = 2; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(?:2|3)/', $this->response->headers->get('Cache-Control')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - // expires the cache - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - $tmp = unserialize($values[0]); - $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('save'); - $m->setAccessible(true); - $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - $this->setNextResponse(); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - } - - public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304() - { - $this->setNextResponse(); - - $this->cacheConfig['default_ttl'] = 2; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - // expires the cache - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - $tmp = unserialize($values[0]); - $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('save'); - $m->setAccessible(true); - $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - } - - public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 'must-revalidate')); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertNotRegExp('/s-maxage/', $this->response->headers->get('Cache-Control')); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertNotNull($this->response->headers->get('Age')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - # go in and play around with the cached metadata directly ... - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - $tmp = unserialize($values[0]); - $time = \DateTime::createFromFormat('U', time()); - $tmp[0][1]['expires'] = $time->format(DATE_RFC2822); - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('save'); - $m->setAccessible(true); - $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTrue($this->response->headers->get('Age') <= 1); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('stale'); - $this->assertTraceNotContains('fresh'); - $this->assertTraceNotContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInformation() - { - $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time) { - $response->headers->set('Cache-Control', 'public'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - if ($time->format(DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) { - $response->setStatusCode(304); - $response->setContent(''); - } - }); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Last-Modified')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('stale'); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Last-Modified')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTrue($this->response->headers->get('Age') <= 1); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - } - - public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { - $response->headers->set('Cache-Control', 'public'); - $response->headers->set('ETag', '"12345"'); - if ($response->getETag() == $request->headers->get('IF_NONE_MATCH')) { - $response->setStatusCode(304); - $response->setContent(''); - } - }); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('ETag')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('ETag')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTrue($this->response->headers->get('Age') <= 1); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - } - - public function testReplacesCachedResponsesWhenValidationResultsInNon304Response() - { - $time = \DateTime::createFromFormat('U', time()); - $count = 0; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time, &$count) { - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - $response->headers->set('Cache-Control', 'public'); - switch (++$count) { - case 1: - $response->setContent('first response'); - break; - case 2: - $response->setContent('second response'); - break; - case 3: - $response->setContent(''); - $response->setStatusCode(304); - break; - } - }); - - // first request should fetch from backend and store in cache - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('first response', $this->response->getContent()); - - // second request is validated, is invalid, and replaces cached entry - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('second response', $this->response->getContent()); - - // third response is validated, valid, and returns cached entry - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('second response', $this->response->getContent()); - - $this->assertEquals(3, $count); - } - - public function testPassesHeadRequestsThroughDirectlyOnPass() - { - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) { - $response->setContent(''); - $response->setStatusCode(200); - $that->assertEquals('HEAD', $request->getMethod()); - }); - - $this->request('HEAD', '/', array('HTTP_EXPECT' => 'something ...')); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('', $this->response->getContent()); - } - - public function testUsesCacheToRespondToHeadRequestsWhenFresh() - { - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) { - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->setContent('Hello World'); - $response->setStatusCode(200); - $that->assertNotEquals('HEAD', $request->getMethod()); - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('HEAD', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->getContent()); - $this->assertEquals(strlen('Hello World'), $this->response->headers->get('Content-Length')); - } - - public function testSendsNoContentWhenFresh() - { - $time = \DateTime::createFromFormat('U', time()); - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time) { - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/', array('HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->getContent()); - } - - public function testInvalidatesCachedResponsesOnPost() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { - if ('GET' == $request->getMethod()) { - $response->setStatusCode(200); - $response->headers->set('Cache-Control', 'public, max-age=500'); - $response->setContent('Hello World'); - } elseif ('POST' == $request->getMethod()) { - $response->setStatusCode(303); - $response->headers->set('Location', '/'); - $response->headers->remove('Cache-Control'); - $response->setContent(''); - } - }); - - // build initial request to enter into the cache - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - // make sure it is valid - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - // now POST to same URL - $this->request('POST', '/helloworld'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('/', $this->response->headers->get('Location')); - $this->assertTraceContains('invalidate'); - $this->assertTraceContains('pass'); - $this->assertEquals('', $this->response->getContent()); - - // now make sure it was actually invalidated - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - } - - public function testServesFromCacheWhenHeadersMatch() - { - $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) { - $response->headers->set('Vary', 'Accept User-Agent Foo'); - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('X-Response-Count', ++$count); - $response->setContent($request->headers->get('USER_AGENT')); - }); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - } - - public function testStoresMultipleResponsesWhenHeadersDiffer() - { - $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) { - $response->headers->set('Vary', 'Accept User-Agent Foo'); - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('X-Response-Count', ++$count); - $response->setContent($request->headers->get('USER_AGENT')); - }); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertTraceContains('fresh'); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertTraceContains('fresh'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertTraceContains('miss'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(3, $this->response->headers->get('X-Response-Count')); - } - - public function testShouldCatchExceptions() - { - $this->catchExceptions(); - - $this->setNextResponse(); - $this->request('GET', '/'); - - $this->assertExceptionsAreCaught(); - } - - public function testShouldCatchExceptionsWhenReloadingAndNoCacheRequest() - { - $this->catchExceptions(); - - $this->setNextResponse(); - $this->cacheConfig['allow_reload'] = true; - $this->request('GET', '/', array(), array(), false, array('Pragma' => 'no-cache')); - - $this->assertExceptionsAreCaught(); - } - - public function testShouldNotCatchExceptions() - { - $this->catchExceptions(false); - - $this->setNextResponse(); - $this->request('GET', '/'); - - $this->assertExceptionsAreNotCaught(); - } - - public function testEsiCacheSendsTheLowestTtl() - { - $responses = array( - array( - 'status' => 200, - 'body' => ' ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array('Cache-Control' => 's-maxage=300'), - ), - array( - 'status' => 200, - 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); - - // check for 100 or 99 as the test can be executed after a second change - $this->assertTrue(in_array($this->response->getTtl(), array(99, 100))); - } - - public function testEsiCacheForceValidation() - { - $responses = array( - array( - 'status' => 200, - 'body' => ' ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array('ETag' => 'foobar'), - ), - array( - 'status' => 200, - 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); - $this->assertNull($this->response->getTtl()); - $this->assertTrue($this->response->mustRevalidate()); - $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); - $this->assertTrue($this->response->headers->hasCacheControlDirective('no-cache')); - } - - public function testEsiRecalculateContentLengthHeader() - { - $responses = array( - array( - 'status' => 200, - 'body' => '', - 'headers' => array( - 'Content-Length' => 26, - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array(), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World!', $this->response->getContent()); - $this->assertEquals(12, $this->response->headers->get('Content-Length')); - } - - public function testClientIpIsAlwaysLocalhostForForwardedRequests() - { - $this->setNextResponse(); - $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); - - $this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR')); - } - - /** - * @dataProvider getTrustedProxyData - */ - public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected) - { - Request::setTrustedProxies($existing); - - $this->setNextResponse(); - $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); - - $this->assertEquals($expected, Request::getTrustedProxies()); - } - - public function getTrustedProxyData() - { - return array( - array(array(), array('127.0.0.1')), - array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')), - array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')), - ); - } - - /** - * @dataProvider getXForwardedForData - */ - public function testXForwarderForHeaderForForwardedRequests($xForwardedFor, $expected) - { - $this->setNextResponse(); - $server = array('REMOTE_ADDR' => '10.0.0.1'); - if (false !== $xForwardedFor) { - $server['HTTP_X_FORWARDED_FOR'] = $xForwardedFor; - } - $this->request('GET', '/', $server); - - $this->assertEquals($expected, $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For')); - } - - public function getXForwardedForData() - { - return array( - array(false, '10.0.0.1'), - array('10.0.0.2', '10.0.0.2, 10.0.0.1'), - array('10.0.0.2, 10.0.0.3', '10.0.0.2, 10.0.0.3, 10.0.0.1'), - ); - } - - public function testXForwarderForHeaderForPassRequests() - { - $this->setNextResponse(); - $server = array('REMOTE_ADDR' => '10.0.0.1'); - $this->request('POST', '/', $server); - - $this->assertEquals('10.0.0.1', $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For')); - } - - public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses() - { - $time = new \DateTime(); - - $responses = array( - array( - 'status' => 200, - 'body' => '', - 'headers' => array( - 'Surrogate-Control' => 'content="ESI/1.0"', - 'ETag' => 'hey', - 'Last-Modified' => $time->format(DATE_RFC2822), - ), - ), - array( - 'status' => 200, - 'body' => 'Hey!', - 'headers' => array(), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertNull($this->response->getETag()); - $this->assertNull($this->response->getLastModified()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php deleted file mode 100644 index 766e2b1d4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php +++ /dev/null @@ -1,176 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\HttpCache\HttpCache; -use Symfony\Component\HttpKernel\HttpCache\Store; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class HttpCacheTestCase extends \PHPUnit_Framework_TestCase -{ - protected $kernel; - protected $cache; - protected $caches; - protected $cacheConfig; - protected $request; - protected $response; - protected $responses; - protected $catch; - protected $esi; - - protected function setUp() - { - $this->kernel = null; - - $this->cache = null; - $this->esi = null; - $this->caches = array(); - $this->cacheConfig = array(); - - $this->request = null; - $this->response = null; - $this->responses = array(); - - $this->catch = false; - - $this->clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - protected function tearDown() - { - $this->kernel = null; - $this->cache = null; - $this->caches = null; - $this->request = null; - $this->response = null; - $this->responses = null; - $this->cacheConfig = null; - $this->catch = null; - $this->esi = null; - - $this->clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - public function assertHttpKernelIsCalled() - { - $this->assertTrue($this->kernel->hasBeenCalled()); - } - - public function assertHttpKernelIsNotCalled() - { - $this->assertFalse($this->kernel->hasBeenCalled()); - } - - public function assertResponseOk() - { - $this->assertEquals(200, $this->response->getStatusCode()); - } - - public function assertTraceContains($trace) - { - $traces = $this->cache->getTraces(); - $traces = current($traces); - - $this->assertRegExp('/'.$trace.'/', implode(', ', $traces)); - } - - public function assertTraceNotContains($trace) - { - $traces = $this->cache->getTraces(); - $traces = current($traces); - - $this->assertNotRegExp('/'.$trace.'/', implode(', ', $traces)); - } - - public function assertExceptionsAreCaught() - { - $this->assertTrue($this->kernel->isCatchingExceptions()); - } - - public function assertExceptionsAreNotCaught() - { - $this->assertFalse($this->kernel->isCatchingExceptions()); - } - - public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false, $headers = array()) - { - if (null === $this->kernel) { - throw new \LogicException('You must call setNextResponse() before calling request().'); - } - - $this->kernel->reset(); - - $this->store = new Store(sys_get_temp_dir().'/http_cache'); - - $this->cacheConfig['debug'] = true; - - $this->esi = $esi ? new Esi() : null; - $this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig); - $this->request = Request::create($uri, $method, array(), $cookies, array(), $server); - $this->request->headers->add($headers); - - $this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch); - - $this->responses[] = $this->response; - } - - public function getMetaStorageValues() - { - $values = array(); - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(sys_get_temp_dir().'/http_cache/md', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - $values[] = file_get_contents($file); - } - - return $values; - } - - // A basic response with 200 status code and a tiny body. - public function setNextResponse($statusCode = 200, array $headers = array(), $body = 'Hello World', \Closure $customizer = null) - { - $this->kernel = new TestHttpKernel($body, $statusCode, $headers, $customizer); - } - - public function setNextResponses($responses) - { - $this->kernel = new TestMultipleHttpKernel($responses); - } - - public function catchExceptions($catch = true) - { - $this->catch = $catch; - } - - public static function clearDirectory($directory) - { - if (!is_dir($directory)) { - return; - } - - $fp = opendir($directory); - while (false !== $file = readdir($fp)) { - if (!in_array($file, array('.', '..'))) { - if (is_link($directory.'/'.$file)) { - unlink($directory.'/'.$file); - } elseif (is_dir($directory.'/'.$file)) { - self::clearDirectory($directory.'/'.$file); - rmdir($directory.'/'.$file); - } else { - unlink($directory.'/'.$file); - } - } - } - - closedir($fp); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php deleted file mode 100644 index 07b70dcee..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php +++ /dev/null @@ -1,214 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\Ssi; - -class SsiTest extends \PHPUnit_Framework_TestCase -{ - public function testHasSurrogateSsiCapability() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'abc="SSI/1.0"'); - $this->assertTrue($ssi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'foobar'); - $this->assertFalse($ssi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $this->assertFalse($ssi->hasSurrogateCapability($request)); - } - - public function testAddSurrogateSsiCapability() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $ssi->addSurrogateCapability($request); - $this->assertEquals('symfony2="SSI/1.0"', $request->headers->get('Surrogate-Capability')); - - $ssi->addSurrogateCapability($request); - $this->assertEquals('symfony2="SSI/1.0", symfony2="SSI/1.0"', $request->headers->get('Surrogate-Capability')); - } - - public function testAddSurrogateControl() - { - $ssi = new Ssi(); - - $response = new Response('foo '); - $ssi->addSurrogateControl($response); - $this->assertEquals('content="SSI/1.0"', $response->headers->get('Surrogate-Control')); - - $response = new Response('foo'); - $ssi->addSurrogateControl($response); - $this->assertEquals('', $response->headers->get('Surrogate-Control')); - } - - public function testNeedsSsiParsing() - { - $ssi = new Ssi(); - - $response = new Response(); - $response->headers->set('Surrogate-Control', 'content="SSI/1.0"'); - $this->assertTrue($ssi->needsParsing($response)); - - $response = new Response(); - $this->assertFalse($ssi->needsParsing($response)); - } - - public function testRenderIncludeTag() - { - $ssi = new Ssi(); - - $this->assertEquals('', $ssi->renderIncludeTag('/', '/alt', true)); - $this->assertEquals('', $ssi->renderIncludeTag('/', '/alt', false)); - $this->assertEquals('', $ssi->renderIncludeTag('/')); - } - - public function testProcessDoesNothingIfContentTypeIsNotHtml() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response(); - $response->headers->set('Content-Type', 'text/plain'); - $ssi->process($request, $response); - - $this->assertFalse($response->headers->has('x-body-eval')); - } - - public function testProcess() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $ssi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent()); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - - $response = new Response('foo '); - $ssi->process($request, $response); - - $this->assertEquals("foo surrogate->handle(\$this, 'foo\\'', '', false) ?>"."\n", $response->getContent()); - } - - public function testProcessEscapesPhpTags() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response(''); - $ssi->process($request, $response); - - $this->assertEquals('php cript language=php>', $response->getContent()); - } - - /** - * @expectedException \RuntimeException - */ - public function testProcessWhenNoSrcInAnSsi() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $ssi->process($request, $response); - } - - public function testProcessRemoveSurrogateControlHeader() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $response->headers->set('Surrogate-Control', 'content="SSI/1.0"'); - $ssi->process($request, $response); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - - $response->headers->set('Surrogate-Control', 'no-store, content="SSI/1.0"'); - $ssi->process($request, $response); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - - $response->headers->set('Surrogate-Control', 'content="SSI/1.0", no-store'); - $ssi->process($request, $response); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - } - - public function testHandle() - { - $ssi = new Ssi(); - $cache = $this->getCache(Request::create('/'), new Response('foo')); - $this->assertEquals('foo', $ssi->handle($cache, '/', '/alt', true)); - } - - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenResponseIsNot200() - { - $ssi = new Ssi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $ssi->handle($cache, '/', '/alt', false); - } - - public function testHandleWhenResponseIsNot200AndErrorsAreIgnored() - { - $ssi = new Ssi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $this->assertEquals('', $ssi->handle($cache, '/', '/alt', true)); - } - - public function testHandleWhenResponseIsNot200AndAltIsPresent() - { - $ssi = new Ssi(); - $response1 = new Response('foo'); - $response1->setStatusCode(404); - $response2 = new Response('bar'); - $cache = $this->getCache(Request::create('/'), array($response1, $response2)); - $this->assertEquals('bar', $ssi->handle($cache, '/', '/alt', false)); - } - - protected function getCache($request, $response) - { - $cache = $this->getMock('Symfony\Component\HttpKernel\HttpCache\HttpCache', array('getRequest', 'handle'), array(), '', false); - $cache->expects($this->any()) - ->method('getRequest') - ->will($this->returnValue($request)) - ; - if (is_array($response)) { - $cache->expects($this->any()) - ->method('handle') - ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) - ; - } else { - $cache->expects($this->any()) - ->method('handle') - ->will($this->returnValue($response)) - ; - } - - return $cache; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php deleted file mode 100644 index 4198ce403..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php +++ /dev/null @@ -1,269 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\Store; - -class StoreTest extends \PHPUnit_Framework_TestCase -{ - protected $request; - protected $response; - protected $store; - - protected function setUp() - { - $this->request = Request::create('/'); - $this->response = new Response('hello world', 200, array()); - - HttpCacheTestCase::clearDirectory(sys_get_temp_dir().'/http_cache'); - - $this->store = new Store(sys_get_temp_dir().'/http_cache'); - } - - protected function tearDown() - { - $this->store = null; - $this->request = null; - $this->response = null; - - HttpCacheTestCase::clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - 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'); - $this->store->write($request, new Response('foo')); - - $metadata = $this->getStoreMetadata($request); - $this->assertNotEmpty($metadata); - - $this->assertTrue($this->store->purge('/foo')); - $this->assertEmpty($this->getStoreMetadata($request)); - - // cached content should be kept after purging - $path = $this->store->getPath($metadata[0][1]['x-content-digest'][0]); - $this->assertTrue(is_file($path)); - - $this->assertFalse($this->store->purge('/bar')); - } - - public function testStoresACacheEntry() - { - $cacheKey = $this->storeSimpleEntry(); - - $this->assertNotEmpty($this->getStoreMetadata($cacheKey)); - } - - public function testSetsTheXContentDigestResponseHeaderBeforeStoring() - { - $cacheKey = $this->storeSimpleEntry(); - $entries = $this->getStoreMetadata($cacheKey); - list($req, $res) = $entries[0]; - - $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); - } - - public function testFindsAStoredEntryWithLookup() - { - $this->storeSimpleEntry(); - $response = $this->store->lookup($this->request); - - $this->assertNotNull($response); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - } - - public function testDoesNotFindAnEntryWithLookupWhenNoneExists() - { - $request = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - - $this->assertNull($this->store->lookup($request)); - } - - public function testCanonizesUrlsForCacheKeys() - { - $this->storeSimpleEntry($path = '/test?x=y&p=q'); - $hitsReq = Request::create($path); - $missReq = Request::create('/test?p=x'); - - $this->assertNotNull($this->store->lookup($hitsReq)); - $this->assertNull($this->store->lookup($missReq)); - } - - public function testDoesNotFindAnEntryWithLookupWhenTheBodyDoesNotExist() - { - $this->storeSimpleEntry(); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $path = $this->getStorePath($this->response->headers->get('X-Content-Digest')); - @unlink($path); - $this->assertNull($this->store->lookup($this->request)); - } - - public function testRestoresResponseHeadersProperlyWithLookup() - { - $this->storeSimpleEntry(); - $response = $this->store->lookup($this->request); - - $this->assertEquals($response->headers->all(), array_merge(array('content-length' => 4, 'x-body-file' => array($this->getStorePath($response->headers->get('X-Content-Digest')))), $this->response->headers->all())); - } - - public function testRestoresResponseContentFromEntityStoreWithLookup() - { - $this->storeSimpleEntry(); - $response = $this->store->lookup($this->request); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test')), $response->getContent()); - } - - public function testInvalidatesMetaAndEntityStoreEntriesWithInvalidate() - { - $this->storeSimpleEntry(); - $this->store->invalidate($this->request); - $response = $this->store->lookup($this->request); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - $this->assertFalse($response->isFresh()); - } - - public function testSucceedsQuietlyWhenInvalidateCalledWithNoMatchingEntries() - { - $req = Request::create('/test'); - $this->store->invalidate($req); - $this->assertNull($this->store->lookup($this->request)); - } - - public function testDoesNotReturnEntriesThatVaryWithLookup() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res = new Response('test', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req1, $res); - - $this->assertNull($this->store->lookup($req2)); - } - - public function testDoesNotReturnEntriesThatSlightlyVaryWithLookup() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bam')); - $res = new Response('test', 200, array('Vary' => array('Foo', 'Bar'))); - $this->store->write($req1, $res); - - $this->assertNull($this->store->lookup($req2)); - } - - public function testStoresMultipleResponsesForEachVaryCombination() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res1 = new Response('test 1', 200, array('Vary' => 'Foo Bar')); - $key = $this->store->write($req1, $res1); - - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res2 = new Response('test 2', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req2, $res2); - - $req3 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Baz', 'HTTP_BAR' => 'Boom')); - $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req3, $res3); - - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 2')), $this->store->lookup($req2)->getContent()); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent()); - - $this->assertCount(3, $this->getStoreMetadata($key)); - } - - public function testOverwritesNonVaryingResponseWithStore() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res1 = new Response('test 1', 200, array('Vary' => 'Foo Bar')); - $key = $this->store->write($req1, $res1); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent()); - - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res2 = new Response('test 2', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req2, $res2); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 2')), $this->store->lookup($req2)->getContent()); - - $req3 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); - $key = $this->store->write($req3, $res3); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); - - $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) { - $path = '/test'; - } - - $this->request = Request::create($path, 'get', array(), array(), array(), $headers); - $this->response = new Response('test', 200, array('Cache-Control' => 'max-age=420')); - - return $this->store->write($this->request, $this->response); - } - - protected function getStoreMetadata($key) - { - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('getMetadata'); - $m->setAccessible(true); - - if ($key instanceof Request) { - $m1 = $r->getMethod('getCacheKey'); - $m1->setAccessible(true); - $key = $m1->invoke($this->store, $key); - } - - return $m->invoke($this->store, $key); - } - - protected function getStorePath($key) - { - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('getPath'); - $m->setAccessible(true); - - return $m->invoke($this->store, $key); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php deleted file mode 100644 index 5546ba2ed..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestHttpKernel extends HttpKernel implements ControllerResolverInterface -{ - protected $body; - protected $status; - protected $headers; - protected $called = false; - protected $customizer; - protected $catch = false; - protected $backendRequest; - - public function __construct($body, $status, $headers, \Closure $customizer = null) - { - $this->body = $body; - $this->status = $status; - $this->headers = $headers; - $this->customizer = $customizer; - - parent::__construct(new EventDispatcher(), $this); - } - - public function getBackendRequest() - { - return $this->backendRequest; - } - - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) - { - $this->catch = $catch; - $this->backendRequest = $request; - - return parent::handle($request, $type, $catch); - } - - public function isCatchingExceptions() - { - return $this->catch; - } - - public function getController(Request $request) - { - return array($this, 'callController'); - } - - public function getArguments(Request $request, $controller) - { - return array($request); - } - - public function callController(Request $request) - { - $this->called = true; - - $response = new Response($this->body, $this->status, $this->headers); - - if (null !== $customizer = $this->customizer) { - $customizer($request, $response); - } - - return $response; - } - - public function hasBeenCalled() - { - return $this->called; - } - - public function reset() - { - $this->called = false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php deleted file mode 100644 index 773e22148..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface -{ - protected $bodies = array(); - protected $statuses = array(); - protected $headers = array(); - protected $call = false; - protected $backendRequest; - - public function __construct($responses) - { - foreach ($responses as $response) { - $this->bodies[] = $response['body']; - $this->statuses[] = $response['status']; - $this->headers[] = $response['headers']; - } - - parent::__construct(new EventDispatcher(), $this); - } - - public function getBackendRequest() - { - return $this->backendRequest; - } - - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) - { - $this->backendRequest = $request; - - return parent::handle($request, $type, $catch); - } - - public function getController(Request $request) - { - return array($this, 'callController'); - } - - public function getArguments(Request $request, $controller) - { - return array($request); - } - - public function callController(Request $request) - { - $this->called = true; - - $response = new Response(array_shift($this->bodies), array_shift($this->statuses), array_shift($this->headers)); - - return $response; - } - - public function hasBeenCalled() - { - return $this->called; - } - - public function reset() - { - $this->call = false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php deleted file mode 100644 index 43a4478eb..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ /dev/null @@ -1,314 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class HttpKernelTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue() - { - $kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); })); - - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); - } - - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered() - { - $kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); })); - - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); - } - - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithAHandlingListener() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - $event->setResponse(new Response($event->getException()->getMessage())); - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new \RuntimeException('foo'); })); - $response = $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); - - $this->assertEquals('500', $response->getStatusCode()); - $this->assertEquals('foo', $response->getContent()); - } - - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithANonHandlingListener() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - // should set a response, but does not - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new \RuntimeException('foo'); })); - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); - } - - public function testHandleExceptionWithARedirectionResponse() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - $event->setResponse(new RedirectResponse('/login', 301)); - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new AccessDeniedHttpException(); })); - $response = $kernel->handle(new Request()); - - $this->assertEquals('301', $response->getStatusCode()); - $this->assertEquals('/login', $response->headers->get('Location')); - } - - public function testHandleHttpException() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - $event->setResponse(new Response($event->getException()->getMessage())); - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new MethodNotAllowedHttpException(array('POST')); })); - $response = $kernel->handle(new Request()); - - $this->assertEquals('405', $response->getStatusCode()); - $this->assertEquals('POST', $response->headers->get('Allow')); - } - - /** - * @dataProvider getStatusCodes - */ - public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($responseStatusCode, $expectedStatusCode) - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($responseStatusCode, $expectedStatusCode) { - $event->setResponse(new Response('', $responseStatusCode, array('X-Status-Code' => $expectedStatusCode))); - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new \RuntimeException(); })); - $response = $kernel->handle(new Request()); - - $this->assertEquals($expectedStatusCode, $response->getStatusCode()); - $this->assertFalse($response->headers->has('X-Status-Code')); - } - - public function getStatusCodes() - { - return array( - array(200, 404), - array(404, 200), - array(301, 200), - array(500, 200), - ); - } - - public function testHandleWhenAListenerReturnsAResponse() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::REQUEST, function ($event) { - $event->setResponse(new Response('hello')); - }); - - $kernel = new HttpKernel($dispatcher, $this->getResolver()); - - $this->assertEquals('hello', $kernel->handle(new Request())->getContent()); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ - public function testHandleWhenNoControllerIsFound() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(false)); - - $kernel->handle(new Request()); - } - - /** - * @expectedException \LogicException - */ - public function testHandleWhenTheControllerIsNotACallable() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver('foobar')); - - $kernel->handle(new Request()); - } - - public function testHandleWhenTheControllerIsAClosure() - { - $response = new Response('foo'); - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () use ($response) { return $response; })); - - $this->assertSame($response, $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAnObjectWithInvoke() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(new Controller())); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAFunction() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver('Symfony\Component\HttpKernel\Tests\controller_func')); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAnArray() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(array(new Controller(), 'controller'))); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAStaticArray() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(array('Symfony\Component\HttpKernel\Tests\Controller', 'staticcontroller'))); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - /** - * @expectedException \LogicException - */ - public function testHandleWhenTheControllerDoesNotReturnAResponse() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; })); - - $kernel->handle(new Request()); - } - - public function testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::VIEW, function ($event) { - $event->setResponse(new Response($event->getControllerResult())); - }); - $kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; })); - - $this->assertEquals('foo', $kernel->handle(new Request())->getContent()); - } - - public function testHandleWithAResponseListener() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::RESPONSE, function ($event) { - $event->setResponse(new Response('foo')); - }); - $kernel = new HttpKernel($dispatcher, $this->getResolver()); - - $this->assertEquals('foo', $kernel->handle(new Request())->getContent()); - } - - public function testTerminate() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver()); - $dispatcher->addListener(KernelEvents::TERMINATE, function ($event) use (&$called, &$capturedKernel, &$capturedRequest, &$capturedResponse) { - $called = true; - $capturedKernel = $event->getKernel(); - $capturedRequest = $event->getRequest(); - $capturedResponse = $event->getResponse(); - }); - - $kernel->terminate($request = Request::create('/'), $response = new Response()); - $this->assertTrue($called); - $this->assertEquals($kernel, $capturedKernel); - $this->assertEquals($request, $capturedRequest); - $this->assertEquals($response, $capturedResponse); - } - - public function testVerifyRequestStackPushPopDuringHandle() - { - $request = new Request(); - - $stack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('push', 'pop')); - $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); - $stack->expects($this->at(1))->method('pop'); - - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver(), $stack); - - $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST); - } - - protected function getResolver($controller = null) - { - if (null === $controller) { - $controller = function () { return new Response('Hello'); }; - } - - $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); - $resolver->expects($this->any()) - ->method('getController') - ->will($this->returnValue($controller)); - $resolver->expects($this->any()) - ->method('getArguments') - ->will($this->returnValue(array())); - - return $resolver; - } - - protected function assertResponseEquals(Response $expected, Response $actual) - { - $expected->setDate($actual->getDate()); - $this->assertEquals($expected, $actual); - } -} - -class Controller -{ - public function __invoke() - { - return new Response('foo'); - } - - public function controller() - { - return new Response('foo'); - } - - public static function staticController() - { - return new Response('foo'); - } -} - -function controller_func() -{ - return new Response('foo'); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php deleted file mode 100644 index 2b75ba222..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ /dev/null @@ -1,850 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Config\EnvParametersResource; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; -use Symfony\Component\HttpKernel\Tests\Fixtures\FooBarBundle; - -class KernelTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $this->assertEquals($env, $kernel->getEnvironment()); - $this->assertEquals($debug, $kernel->isDebug()); - $this->assertFalse($kernel->isBooted()); - $this->assertLessThanOrEqual(microtime(true), $kernel->getStartTime()); - $this->assertNull($kernel->getContainer()); - } - - public function testClone() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $clone = clone $kernel; - - $this->assertEquals($env, $clone->getEnvironment()); - $this->assertEquals($debug, $clone->isDebug()); - $this->assertFalse($clone->isBooted()); - $this->assertLessThanOrEqual(microtime(true), $clone->getStartTime()); - $this->assertNull($clone->getContainer()); - } - - public function testBootInitializesBundlesAndContainer() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); - $kernel->expects($this->once()) - ->method('initializeBundles'); - $kernel->expects($this->once()) - ->method('initializeContainer'); - - $kernel->boot(); - } - - public function testBootSetsTheContainerToTheBundles() - { - $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); - $bundle->expects($this->once()) - ->method('setContainer'); - - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'getBundles')); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - $kernel->boot(); - } - - public function testBootSetsTheBootedFlagToTrue() - { - // use test kernel to access isBooted() - $kernel = $this->getKernelForTest(array('initializeBundles', 'initializeContainer')); - $kernel->boot(); - - $this->assertTrue($kernel->isBooted()); - } - - public function testClassCacheIsLoaded() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); - $kernel->loadClassCache('name', '.extension'); - $kernel->expects($this->once()) - ->method('doLoadClassCache') - ->with('name', '.extension'); - - $kernel->boot(); - } - - public function testClassCacheIsNotLoadedByDefault() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); - $kernel->expects($this->never()) - ->method('doLoadClassCache'); - - $kernel->boot(); - } - - public function testClassCacheIsNotLoadedWhenKernelIsNotBooted() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); - $kernel->loadClassCache(); - $kernel->expects($this->never()) - ->method('doLoadClassCache'); - } - - public function testEnvParametersResourceIsAdded() - { - $container = new ContainerBuilder(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getContainerBuilder', 'prepareContainer', 'getCacheDir', 'getLogDir')) - ->getMock(); - $kernel->expects($this->any()) - ->method('getContainerBuilder') - ->will($this->returnValue($container)); - $kernel->expects($this->any()) - ->method('prepareContainer') - ->will($this->returnValue(null)); - $kernel->expects($this->any()) - ->method('getCacheDir') - ->will($this->returnValue(sys_get_temp_dir())); - $kernel->expects($this->any()) - ->method('getLogDir') - ->will($this->returnValue(sys_get_temp_dir())); - - $reflection = new \ReflectionClass(get_class($kernel)); - $method = $reflection->getMethod('buildContainer'); - $method->setAccessible(true); - $method->invoke($kernel); - - $found = false; - foreach ($container->getResources() as $resource) { - if ($resource instanceof EnvParametersResource) { - $found = true; - break; - } - } - - $this->assertTrue($found); - } - - public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); - $kernel->expects($this->once()) - ->method('initializeBundles'); - - $kernel->boot(); - $kernel->boot(); - } - - public function testShutdownCallsShutdownOnAllBundles() - { - $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); - $bundle->expects($this->once()) - ->method('shutdown'); - - $kernel = $this->getKernel(array(), array($bundle)); - - $kernel->boot(); - $kernel->shutdown(); - } - - public function testShutdownGivesNullContainerToAllBundles() - { - $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); - $bundle->expects($this->at(3)) - ->method('setContainer') - ->with(null); - - $kernel = $this->getKernel(array('getBundles')); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - $kernel->boot(); - $kernel->shutdown(); - } - - public function testHandleCallsHandleOnHttpKernel() - { - $type = HttpKernelInterface::MASTER_REQUEST; - $catch = true; - $request = new Request(); - - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->getMock(); - $httpKernelMock - ->expects($this->once()) - ->method('handle') - ->with($request, $type, $catch); - - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->handle($request, $type, $catch); - } - - public function testHandleBootsTheKernel() - { - $type = HttpKernelInterface::MASTER_REQUEST; - $catch = true; - $request = new Request(); - - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->getMock(); - - $kernel = $this->getKernel(array('getHttpKernel', 'boot')); - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->expects($this->once()) - ->method('boot'); - - $kernel->handle($request, $type, $catch); - } - - public function testStripComments() - { - $source = <<<'EOF' -assertEquals($expected, $output); - } - - /** - * @group legacy - */ - public function testLegacyIsClassInActiveBundleFalse() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertFalse($kernel->isClassInActiveBundle('Not\In\Active\Bundle')); - } - - /** - * @group legacy - */ - public function testLegacyIsClassInActiveBundleFalseNoNamespace() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertFalse($kernel->isClassInActiveBundle('NotNamespacedClass')); - } - - /** - * @group legacy - */ - public function testLegacyIsClassInActiveBundleTrue() - { - $kernel = $this->getKernelMockForIsClassInActiveBundleTest(); - - $this->assertTrue($kernel->isClassInActiveBundle(__NAMESPACE__.'\Fixtures\FooBarBundle\SomeClass')); - } - - protected function getKernelMockForIsClassInActiveBundleTest() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $bundle = new FooBarBundle(); - - $kernel = $this->getKernel(array('getBundles')); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - return $kernel; - } - - public function testGetRootDir() - { - $kernel = new KernelForTest('test', true); - - $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir())); - } - - public function testGetName() - { - $kernel = new KernelForTest('test', true); - - $this->assertEquals('Fixtures', $kernel->getName()); - } - - public function testOverrideGetName() - { - $kernel = new KernelForOverrideName('test', true); - - $this->assertEquals('overridden', $kernel->getName()); - } - - public function testSerialize() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $expected = serialize(array($env, $debug)); - $this->assertEquals($expected, $kernel->serialize()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenNameIsNotValid() - { - $this->getKernel()->locateResource('Foo'); - } - - /** - * @expectedException \RuntimeException - */ - public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() - { - $this->getKernel()->locateResource('@FooBundle/../bar'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() - { - $this->getKernel()->locateResource('@FooBundle/config/routing.xml'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $kernel->locateResource('@Bundle1Bundle/config/routing.xml'); - } - - public function testLocateResourceReturnsTheFirstThatMatches() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt')); - } - - public function testLocateResourceReturnsTheFirstThatMatchesWithParent() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(__DIR__.'/Fixtures/Bundle2Bundle/foo.txt', $kernel->locateResource('@ParentAABundle/foo.txt')); - $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/bar.txt', $kernel->locateResource('@ParentAABundle/bar.txt')); - } - - public function testLocateResourceReturnsAllMatches() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Bundle2Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', ), - $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false)); - } - - public function testLocateResourceReturnsAllMatchesBis() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array( - $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), - $this->getBundle(__DIR__.'/Foobar'), - ))) - ; - - $this->assertEquals( - array(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt'), - $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false) - ); - } - - public function testLocateResourceIgnoresDirOnNonResource() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', - $kernel->locateResource('@Bundle1Bundle/foo.txt', __DIR__.'/Fixtures') - ); - } - - public function testLocateResourceReturnsTheDirOneForResources() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle/foo.txt', - $kernel->locateResource('@FooBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources') - ); - } - - public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Resources/Bundle1Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt', ), - $kernel->locateResource('@Bundle1Bundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) - ); - } - - public function testLocateResourceOverrideBundleAndResourcesFolders() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle'); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(4)) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt', - __DIR__.'/Fixtures/ChildBundle/Resources/foo.txt', - __DIR__.'/Fixtures/BaseBundle/Resources/foo.txt', - ), - $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) - ); - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt', - $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources') - ); - - try { - $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', false); - $this->fail('Hidden resources should raise an exception when returning an array of matching paths'); - } catch (\RuntimeException $e) { - } - - try { - $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', true); - $this->fail('Hidden resources should raise an exception when returning the first matching path'); - } catch (\RuntimeException $e) { - } - } - - public function testLocateResourceOnDirectories() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle/', - $kernel->locateResource('@FooBundle/Resources/', __DIR__.'/Fixtures/Resources') - ); - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle', - $kernel->locateResource('@FooBundle/Resources', __DIR__.'/Fixtures/Resources') - ); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/Resources/', - $kernel->locateResource('@Bundle1Bundle/Resources/') - ); - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/Resources', - $kernel->locateResource('@Bundle1Bundle/Resources') - ); - } - - public function testInitializeBundles() - { - $parent = $this->getBundle(null, null, 'ParentABundle'); - $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle'); - - // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $child))) - ; - $kernel->boot(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent), $map['ParentABundle']); - } - - public function testInitializeBundlesSupportInheritanceCascade() - { - $grandparent = $this->getBundle(null, null, 'GrandParentBBundle'); - $parent = $this->getBundle(null, 'GrandParentBBundle', 'ParentBBundle'); - $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle'); - - // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($grandparent, $parent, $child))) - ; - $kernel->boot(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentBBundle']); - $this->assertEquals(array($child, $parent), $map['ParentBBundle']); - $this->assertEquals(array($child), $map['ChildBBundle']); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Bundle "ChildCBundle" extends bundle "FooBar", which is not registered. - */ - public function testInitializeBundlesThrowsExceptionWhenAParentDoesNotExists() - { - $child = $this->getBundle(null, 'FooBar', 'ChildCBundle'); - $kernel = $this->getKernel(array(), array($child)); - $kernel->boot(); - } - - public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() - { - $grandparent = $this->getBundle(null, null, 'GrandParentCBundle'); - $parent = $this->getBundle(null, 'GrandParentCBundle', 'ParentCBundle'); - $child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle'); - - // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $grandparent, $child))) - ; - $kernel->boot(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCBundle']); - $this->assertEquals(array($child, $parent), $map['ParentCBundle']); - $this->assertEquals(array($child), $map['ChildCBundle']); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Bundle "ParentCBundle" is directly extended by two bundles "ChildC2Bundle" and "ChildC1Bundle". - */ - public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtendedByTwoBundles() - { - $parent = $this->getBundle(null, null, 'ParentCBundle'); - $child1 = $this->getBundle(null, 'ParentCBundle', 'ChildC1Bundle'); - $child2 = $this->getBundle(null, 'ParentCBundle', 'ChildC2Bundle'); - - $kernel = $this->getKernel(array(), array($parent, $child1, $child2)); - $kernel->boot(); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName" - */ - public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName() - { - $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName'); - $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName'); - - $kernel = $this->getKernel(array(), array($fooBundle, $barBundle)); - $kernel->boot(); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Bundle "CircularRefBundle" can not extend itself. - */ - public function testInitializeBundleThrowsExceptionWhenABundleExtendsItself() - { - $circularRef = $this->getBundle(null, 'CircularRefBundle', 'CircularRefBundle'); - - $kernel = $this->getKernel(array(), array($circularRef)); - $kernel->boot(); - } - - public function testTerminateReturnsSilentlyIfKernelIsNotBooted() - { - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->never()) - ->method('getHttpKernel'); - - $kernel->terminate(Request::create('/'), new Response()); - } - - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() - { - // does not implement TerminableInterface - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface') - ->disableOriginalConstructor() - ->getMock(); - - $httpKernelMock - ->expects($this->never()) - ->method('terminate'); - - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->boot(); - $kernel->terminate(Request::create('/'), new Response()); - - // implements TerminableInterface - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->setMethods(array('terminate')) - ->getMock(); - - $httpKernelMock - ->expects($this->once()) - ->method('terminate'); - - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->exactly(2)) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->boot(); - $kernel->terminate(Request::create('/'), new Response()); - } - - /** - * Returns a mock for the BundleInterface - * - * @return BundleInterface - */ - protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null) - { - $bundle = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') - ->setMethods(array('getPath', 'getParent', 'getName')) - ->disableOriginalConstructor() - ; - - if ($className) { - $bundle->setMockClassName($className); - } - - $bundle = $bundle->getMockForAbstractClass(); - - $bundle - ->expects($this->any()) - ->method('getName') - ->will($this->returnValue(null === $bundleName ? get_class($bundle) : $bundleName)) - ; - - $bundle - ->expects($this->any()) - ->method('getPath') - ->will($this->returnValue($dir)) - ; - - $bundle - ->expects($this->any()) - ->method('getParent') - ->will($this->returnValue($parent)) - ; - - return $bundle; - } - - /** - * Returns a mock for the abstract kernel. - * - * @param array $methods Additional methods to mock (besides the abstract ones) - * @param array $bundles Bundles to register - * - * @return Kernel - */ - protected function getKernel(array $methods = array(), array $bundles = array()) - { - $methods[] = 'registerBundles'; - - $kernel = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') - ->setMethods($methods) - ->setConstructorArgs(array('test', false)) - ->getMockForAbstractClass() - ; - $kernel->expects($this->any()) - ->method('registerBundles') - ->will($this->returnValue($bundles)) - ; - $p = new \ReflectionProperty($kernel, 'rootDir'); - $p->setAccessible(true); - $p->setValue($kernel, __DIR__.'/Fixtures'); - - return $kernel; - } - - protected function getKernelForTest(array $methods = array()) - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setConstructorArgs(array('test', false)) - ->setMethods($methods) - ->getMock(); - $p = new \ReflectionProperty($kernel, 'rootDir'); - $p->setAccessible(true); - $p->setValue($kernel, __DIR__.'/Fixtures'); - - return $kernel; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php deleted file mode 100644 index 017518a30..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Psr\Log\LoggerInterface; - -class Logger implements LoggerInterface -{ - protected $logs; - - public function __construct() - { - $this->clear(); - } - - public function getLogs($level = false) - { - return false === $level ? $this->logs : $this->logs[$level]; - } - - public function clear() - { - $this->logs = array( - 'emergency' => array(), - 'alert' => array(), - 'critical' => array(), - 'error' => array(), - 'warning' => array(), - 'notice' => array(), - 'info' => array(), - 'debug' => array(), - ); - } - - public function log($level, $message, array $context = array()) - { - $this->logs[$level][] = $message; - } - - public function emergency($message, array $context = array()) - { - $this->log('emergency', $message, $context); - } - - public function alert($message, array $context = array()) - { - $this->log('alert', $message, $context); - } - - public function critical($message, array $context = array()) - { - $this->log('critical', $message, $context); - } - - public function error($message, array $context = array()) - { - $this->log('error', $message, $context); - } - - public function warning($message, array $context = array()) - { - $this->log('warning', $message, $context); - } - - public function notice($message, array $context = array()) - { - $this->log('notice', $message, $context); - } - - public function info($message, array $context = array()) - { - $this->log('info', $message, $context); - } - - public function debug($message, array $context = array()) - { - $this->log('debug', $message, $context); - } - - /** - * @deprecated - */ - public function emerg($message, array $context = array()) - { - trigger_error('Use emergency() which is PSR-3 compatible', E_USER_DEPRECATED); - - $this->log('emergency', $message, $context); - } - - /** - * @deprecated - */ - public function crit($message, array $context = array()) - { - trigger_error('Use critical() which is PSR-3 compatible', E_USER_DEPRECATED); - - $this->log('critical', $message, $context); - } - - /** - * @deprecated - */ - public function err($message, array $context = array()) - { - trigger_error('Use error() which is PSR-3 compatible', E_USER_DEPRECATED); - - $this->log('error', $message, $context); - } - - /** - * @deprecated - */ - public function warn($message, array $context = array()) - { - trigger_error('Use warning() which is PSR-3 compatible', E_USER_DEPRECATED); - - $this->log('warning', $message, $context); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php deleted file mode 100644 index aa2b31dbc..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/AbstractProfilerStorageTest.php +++ /dev/null @@ -1,254 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\Profile; - -abstract class AbstractProfilerStorageTest extends \PHPUnit_Framework_TestCase -{ - public function testStore() - { - for ($i = 0; $i < 10; ++$i) { - $profile = new Profile('token_'.$i); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - } - $this->assertCount(10, $this->getStorage()->find('127.0.0.1', 'http://foo.bar', 20, 'GET'), '->write() stores data in the storage'); - } - - public function testChildren() - { - $parentProfile = new Profile('token_parent'); - $parentProfile->setIp('127.0.0.1'); - $parentProfile->setUrl('http://foo.bar/parent'); - - $childProfile = new Profile('token_child'); - $childProfile->setIp('127.0.0.1'); - $childProfile->setUrl('http://foo.bar/child'); - - $parentProfile->addChild($childProfile); - - $this->getStorage()->write($parentProfile); - $this->getStorage()->write($childProfile); - - // Load them from storage - $parentProfile = $this->getStorage()->read('token_parent'); - $childProfile = $this->getStorage()->read('token_child'); - - // Check child has link to parent - $this->assertNotNull($childProfile->getParent()); - $this->assertEquals($parentProfile->getToken(), $childProfile->getParentToken()); - - // Check parent has child - $children = $parentProfile->getChildren(); - $this->assertCount(1, $children); - $this->assertEquals($childProfile->getToken(), $children[0]->getToken()); - } - - public function testStoreSpecialCharsInUrl() - { - // The storage accepts special characters in URLs (Even though URLs are not - // supposed to contain them) - $profile = new Profile('simple_quote'); - $profile->setUrl('http://foo.bar/\''); - $this->getStorage()->write($profile); - $this->assertTrue(false !== $this->getStorage()->read('simple_quote'), '->write() accepts single quotes in URL'); - - $profile = new Profile('double_quote'); - $profile->setUrl('http://foo.bar/"'); - $this->getStorage()->write($profile); - $this->assertTrue(false !== $this->getStorage()->read('double_quote'), '->write() accepts double quotes in URL'); - - $profile = new Profile('backslash'); - $profile->setUrl('http://foo.bar/\\'); - $this->getStorage()->write($profile); - $this->assertTrue(false !== $this->getStorage()->read('backslash'), '->write() accepts backslash in URL'); - - $profile = new Profile('comma'); - $profile->setUrl('http://foo.bar/,'); - $this->getStorage()->write($profile); - $this->assertTrue(false !== $this->getStorage()->read('comma'), '->write() accepts comma in URL'); - } - - public function testStoreDuplicateToken() - { - $profile = new Profile('token'); - $profile->setUrl('http://example.com/'); - - $this->assertTrue($this->getStorage()->write($profile), '->write() returns true when the token is unique'); - - $profile->setUrl('http://example.net/'); - - $this->assertTrue($this->getStorage()->write($profile), '->write() returns true when the token is already present in the storage'); - $this->assertEquals('http://example.net/', $this->getStorage()->read('token')->getUrl(), '->write() overwrites the current profile data'); - - $this->assertCount(1, $this->getStorage()->find('', '', 1000, ''), '->find() does not return the same profile twice'); - } - - public function testRetrieveByIp() - { - $profile = new Profile('token'); - $profile->setIp('127.0.0.1'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'), '->find() retrieve a record by IP'); - $this->assertCount(0, $this->getStorage()->find('127.0.%.1', '', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the IP'); - $this->assertCount(0, $this->getStorage()->find('127.0._.1', '', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the IP'); - } - - public function testRetrieveByUrl() - { - $profile = new Profile('simple_quote'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/\''); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $profile = new Profile('double_quote'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/"'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $profile = new Profile('backslash'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo\\bar/'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $profile = new Profile('percent'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/%'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $profile = new Profile('underscore'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/_'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $profile = new Profile('semicolon'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/;'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', 'http://foo.bar/\'', 10, 'GET'), '->find() accepts single quotes in URLs'); - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', 'http://foo.bar/"', 10, 'GET'), '->find() accepts double quotes in URLs'); - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', 'http://foo\\bar/', 10, 'GET'), '->find() accepts backslash in URLs'); - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', 'http://foo.bar/;', 10, 'GET'), '->find() accepts semicolon in URLs'); - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', 'http://foo.bar/%', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the URL'); - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', 'http://foo.bar/_', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the URL'); - } - - public function testStoreTime() - { - $dt = new \DateTime('now'); - $start = $dt->getTimestamp(); - - for ($i = 0; $i < 3; ++$i) { - $dt->modify('+1 minute'); - $profile = new Profile('time_'.$i); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar'); - $profile->setTime($dt->getTimestamp()); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - } - - $records = $this->getStorage()->find('', '', 3, 'GET', $start, time() + 3 * 60); - $this->assertCount(3, $records, '->find() returns all previously added records'); - $this->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[2]['token'], 'time_0', '->find() returns records ordered by time in descendant order'); - - $records = $this->getStorage()->find('', '', 3, 'GET', $start, time() + 2 * 60); - $this->assertCount(2, $records, '->find() should return only first two of the previously added records'); - } - - public function testRetrieveByEmptyUrlAndIp() - { - for ($i = 0; $i < 5; ++$i) { - $profile = new Profile('token_'.$i); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - } - $this->assertCount(5, $this->getStorage()->find('', '', 10, 'GET'), '->find() returns all previously added records'); - $this->getStorage()->purge(); - } - - public function testRetrieveByMethodAndLimit() - { - foreach (array('POST', 'GET') as $method) { - for ($i = 0; $i < 5; ++$i) { - $profile = new Profile('token_'.$i.$method); - $profile->setMethod($method); - $this->getStorage()->write($profile); - } - } - - $this->assertCount(5, $this->getStorage()->find('', '', 5, 'POST')); - - $this->getStorage()->purge(); - } - - public function testPurge() - { - $profile = new Profile('token1'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://example.com/'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $this->assertTrue(false !== $this->getStorage()->read('token1')); - $this->assertCount(1, $this->getStorage()->find('127.0.0.1', '', 10, 'GET')); - - $profile = new Profile('token2'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://example.net/'); - $profile->setMethod('GET'); - $this->getStorage()->write($profile); - - $this->assertTrue(false !== $this->getStorage()->read('token2')); - $this->assertCount(2, $this->getStorage()->find('127.0.0.1', '', 10, 'GET')); - - $this->getStorage()->purge(); - - $this->assertEmpty($this->getStorage()->read('token'), '->purge() removes all data stored by profiler'); - $this->assertCount(0, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'), '->purge() removes all items from index'); - } - - public function testDuplicates() - { - for ($i = 1; $i <= 5; ++$i) { - $profile = new Profile('foo'.$i); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://example.net/'); - $profile->setMethod('GET'); - - ///three duplicates - $this->getStorage()->write($profile); - $this->getStorage()->write($profile); - $this->getStorage()->write($profile); - } - $this->assertCount(3, $this->getStorage()->find('127.0.0.1', 'http://example.net/', 3, 'GET'), '->find() method returns incorrect number of entries'); - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - abstract protected function getStorage(); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php deleted file mode 100644 index d5edc7003..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage; -use Symfony\Component\HttpKernel\Profiler\Profile; - -class FileProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $tmpDir; - protected static $storage; - - protected static function cleanDir() - { - $flags = \FilesystemIterator::SKIP_DOTS; - $iterator = new \RecursiveDirectoryIterator(self::$tmpDir, $flags); - $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST); - - foreach ($iterator as $file) { - if (is_file($file)) { - unlink($file); - } - } - } - - public static function setUpBeforeClass() - { - self::$tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage'; - if (is_dir(self::$tmpDir)) { - self::cleanDir(); - } - self::$storage = new FileProfilerStorage('file:'.self::$tmpDir); - } - - public static function tearDownAfterClass() - { - self::cleanDir(); - } - - protected function setUp() - { - self::$storage->purge(); - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } - - public function testMultiRowIndexFile() - { - $iteration = 3; - for ($i = 0; $i < $iteration; ++$i) { - $profile = new Profile('token'.$i); - $profile->setIp('127.0.0.'.$i); - $profile->setUrl('http://foo.bar/'.$i); - $storage = $this->getStorage(); - - $storage->write($profile); - $storage->write($profile); - $storage->write($profile); - } - - $handle = fopen(self::$tmpDir.'/index.csv', 'r'); - for ($i = 0; $i < $iteration; ++$i) { - $row = fgetcsv($handle); - $this->assertEquals('token'.$i, $row[0]); - $this->assertEquals('127.0.0.'.$i, $row[1]); - $this->assertEquals('http://foo.bar/'.$i, $row[3]); - } - $this->assertFalse(fgetcsv($handle)); - } - - public function testReadLineFromFile() - { - $r = new \ReflectionMethod(self::$storage, 'readLineFromFile'); - - $r->setAccessible(true); - - $h = tmpfile(); - - fwrite($h, "line1\n\n\nline2\n"); - fseek($h, 0, SEEK_END); - - $this->assertEquals('line2', $r->invoke(self::$storage, $h)); - $this->assertEquals('line1', $r->invoke(self::$storage, $h)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcacheProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcacheProfilerStorageTest.php deleted file mode 100644 index f582dff79..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcacheProfilerStorageTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage; -use Symfony\Component\HttpKernel\Tests\Profiler\Mock\MemcacheMock; - -class MemcacheProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $storage; - - protected function setUp() - { - $memcacheMock = new MemcacheMock(); - $memcacheMock->addServer('127.0.0.1', 11211); - - self::$storage = new MemcacheProfilerStorage('memcache://127.0.0.1:11211', '', '', 86400); - self::$storage->setMemcache($memcacheMock); - - if (self::$storage) { - self::$storage->purge(); - } - } - - protected function tearDown() - { - if (self::$storage) { - self::$storage->purge(); - self::$storage = false; - } - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcachedProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcachedProfilerStorageTest.php deleted file mode 100644 index 565ac35f3..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MemcachedProfilerStorageTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage; -use Symfony\Component\HttpKernel\Tests\Profiler\Mock\MemcachedMock; - -class MemcachedProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $storage; - - protected function setUp() - { - $memcachedMock = new MemcachedMock(); - $memcachedMock->addServer('127.0.0.1', 11211); - - self::$storage = new MemcachedProfilerStorage('memcached://127.0.0.1:11211', '', '', 86400); - self::$storage->setMemcached($memcachedMock); - - if (self::$storage) { - self::$storage->purge(); - } - } - - protected function tearDown() - { - if (self::$storage) { - self::$storage->purge(); - self::$storage = false; - } - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php deleted file mode 100644 index 9ca981680..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php +++ /dev/null @@ -1,254 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler\Mock; - -/** - * MemcacheMock for simulating Memcache extension in tests. - * - * @author Andrej Hudec - */ -class MemcacheMock -{ - private $connected = false; - private $storage = array(); - - /** - * Open memcached server connection. - * - * @param string $host - * @param int $port - * @param int $timeout - * - * @return bool - */ - public function connect($host, $port = null, $timeout = null) - { - if ('127.0.0.1' == $host && 11211 == $port) { - $this->connected = true; - - return true; - } - - return false; - } - - /** - * Open memcached server persistent connection. - * - * @param string $host - * @param int $port - * @param int $timeout - * - * @return bool - */ - public function pconnect($host, $port = null, $timeout = null) - { - if ('127.0.0.1' == $host && 11211 == $port) { - $this->connected = true; - - return true; - } - - return false; - } - - /** - * Add a memcached server to connection pool. - * - * @param string $host - * @param int $port - * @param bool $persistent - * @param int $weight - * @param int $timeout - * @param int $retry_interval - * @param bool $status - * @param callable $failure_callback - * @param int $timeoutms - * - * @return bool - */ - public function addServer($host, $port = 11211, $persistent = null, $weight = null, $timeout = null, $retry_interval = null, $status = null, $failure_callback = null, $timeoutms = null) - { - if ('127.0.0.1' == $host && 11211 == $port) { - $this->connected = true; - - return true; - } - - return false; - } - - /** - * Add an item to the server only if such key doesn't exist at the server yet. - * - * @param string $key - * @param mixed $var - * @param int $flag - * @param int $expire - * - * @return bool - */ - public function add($key, $var, $flag = null, $expire = null) - { - if (!$this->connected) { - return false; - } - - if (!isset($this->storage[$key])) { - $this->storeData($key, $var); - - return true; - } - - return false; - } - - /** - * Store data at the server. - * - * @param string $key - * @param string $var - * @param int $flag - * @param int $expire - * - * @return bool - */ - public function set($key, $var, $flag = null, $expire = null) - { - if (!$this->connected) { - return false; - } - - $this->storeData($key, $var); - - return true; - } - - /** - * Replace value of the existing item. - * - * @param string $key - * @param mixed $var - * @param int $flag - * @param int $expire - * - * @return bool - */ - public function replace($key, $var, $flag = null, $expire = null) - { - if (!$this->connected) { - return false; - } - - if (isset($this->storage[$key])) { - $this->storeData($key, $var); - - return true; - } - - return false; - } - - /** - * Retrieve item from the server. - * - * @param string|array $key - * @param int|array $flags - * - * @return mixed - */ - public function get($key, &$flags = null) - { - if (!$this->connected) { - return false; - } - - if (is_array($key)) { - $result = array(); - foreach ($key as $k) { - if (isset($this->storage[$k])) { - $result[] = $this->getData($k); - } - } - - return $result; - } - - return $this->getData($key); - } - - /** - * Delete item from the server. - * - * @param string $key - * - * @return bool - */ - public function delete($key) - { - if (!$this->connected) { - return false; - } - - if (isset($this->storage[$key])) { - unset($this->storage[$key]); - - return true; - } - - return false; - } - - /** - * Flush all existing items at the server. - * - * @return bool - */ - public function flush() - { - if (!$this->connected) { - return false; - } - - $this->storage = array(); - - return true; - } - - /** - * Close memcached server connection. - * - * @return bool - */ - public function close() - { - $this->connected = false; - - return true; - } - - private function getData($key) - { - if (isset($this->storage[$key])) { - return unserialize($this->storage[$key]); - } - - return false; - } - - private function storeData($key, $value) - { - $this->storage[$key] = serialize($value); - - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php deleted file mode 100644 index da98a1270..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php +++ /dev/null @@ -1,219 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler\Mock; - -/** - * MemcachedMock for simulating Memcached extension in tests. - * - * @author Andrej Hudec - */ -class MemcachedMock -{ - private $connected = false; - private $storage = array(); - - /** - * Set a Memcached option. - * - * @param int $option - * @param mixed $value - * - * @return bool - */ - public function setOption($option, $value) - { - return true; - } - - /** - * Add a memcached server to connection pool. - * - * @param string $host - * @param int $port - * @param int $weight - * - * @return bool - */ - public function addServer($host, $port = 11211, $weight = 0) - { - if ('127.0.0.1' == $host && 11211 == $port) { - $this->connected = true; - - return true; - } - - return false; - } - - /** - * Add an item to the server only if such key doesn't exist at the server yet. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * - * @return bool - */ - public function add($key, $value, $expiration = 0) - { - if (!$this->connected) { - return false; - } - - if (!isset($this->storage[$key])) { - $this->storeData($key, $value); - - return true; - } - - return false; - } - - /** - * Store data at the server. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * - * @return bool - */ - public function set($key, $value, $expiration = null) - { - if (!$this->connected) { - return false; - } - - $this->storeData($key, $value); - - return true; - } - - /** - * Replace value of the existing item. - * - * @param string $key - * @param mixed $value - * @param int $expiration - * - * @return bool - */ - public function replace($key, $value, $expiration = null) - { - if (!$this->connected) { - return false; - } - - if (isset($this->storage[$key])) { - $this->storeData($key, $value); - - return true; - } - - return false; - } - - /** - * Retrieve item from the server. - * - * @param string $key - * @param callable $cache_cb - * @param float $cas_token - * - * @return bool - */ - public function get($key, $cache_cb = null, &$cas_token = null) - { - if (!$this->connected) { - return false; - } - - return $this->getData($key); - } - - /** - * Append data to an existing item. - * - * @param string $key - * @param string $value - * - * @return bool - */ - public function append($key, $value) - { - if (!$this->connected) { - return false; - } - - if (isset($this->storage[$key])) { - $this->storeData($key, $this->getData($key).$value); - - return true; - } - - return false; - } - - /** - * Delete item from the server. - * - * @param string $key - * - * @return bool - */ - public function delete($key) - { - if (!$this->connected) { - return false; - } - - if (isset($this->storage[$key])) { - unset($this->storage[$key]); - - return true; - } - - return false; - } - - /** - * Flush all existing items at the server. - * - * @return bool - */ - public function flush() - { - if (!$this->connected) { - return false; - } - - $this->storage = array(); - - return true; - } - - private function getData($key) - { - if (isset($this->storage[$key])) { - return unserialize($this->storage[$key]); - } - - return false; - } - - private function storeData($key, $value) - { - $this->storage[$key] = serialize($value); - - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php deleted file mode 100644 index 694dc1e5b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php +++ /dev/null @@ -1,247 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler\Mock; - -/** - * RedisMock for simulating Redis extension in tests. - * - * @author Andrej Hudec - */ -class RedisMock -{ - private $connected = false; - private $storage = array(); - - /** - * Add a server to connection pool. - * - * @param string $host - * @param int $port - * @param float $timeout - * - * @return bool - */ - public function connect($host, $port = 6379, $timeout = 0) - { - if ('127.0.0.1' == $host && 6379 == $port) { - $this->connected = true; - - return true; - } - - return false; - } - - /** - * Set client option. - * - * @param int $name - * @param int $value - * - * @return bool - */ - public function setOption($name, $value) - { - if (!$this->connected) { - return false; - } - - return true; - } - - /** - * Verify if the specified key exists. - * - * @param string $key - * - * @return bool - */ - public function exists($key) - { - if (!$this->connected) { - return false; - } - - return isset($this->storage[$key]); - } - - /** - * Store data at the server with expiration time. - * - * @param string $key - * @param int $ttl - * @param mixed $value - * - * @return bool - */ - public function setex($key, $ttl, $value) - { - if (!$this->connected) { - return false; - } - - $this->storeData($key, $value); - - return true; - } - - /** - * Sets an expiration time on an item. - * - * @param string $key - * @param int $ttl - * - * @return bool - */ - public function setTimeout($key, $ttl) - { - if (!$this->connected) { - return false; - } - - if (isset($this->storage[$key])) { - return true; - } - - return false; - } - - /** - * Retrieve item from the server. - * - * @param string $key - * - * @return bool - */ - public function get($key) - { - if (!$this->connected) { - return false; - } - - return $this->getData($key); - } - - /** - * Append data to an existing item. - * - * @param string $key - * @param string $value - * - * @return int Size of the value after the append. - */ - public function append($key, $value) - { - if (!$this->connected) { - return false; - } - - if (isset($this->storage[$key])) { - $this->storeData($key, $this->getData($key).$value); - - return strlen($this->storage[$key]); - } - - return false; - } - - /** - * Remove specified keys. - * - * @param string|array $key - * - * @return int - */ - public function delete($key) - { - if (!$this->connected) { - return false; - } - - if (is_array($key)) { - $result = 0; - foreach ($key as $k) { - if (isset($this->storage[$k])) { - unset($this->storage[$k]); - ++$result; - } - } - - return $result; - } - - if (isset($this->storage[$key])) { - unset($this->storage[$key]); - - return 1; - } - - return 0; - } - - /** - * Flush all existing items from all databases at the server. - * - * @return bool - */ - public function flushAll() - { - if (!$this->connected) { - return false; - } - - $this->storage = array(); - - return true; - } - - /** - * Close Redis server connection. - * - * @return bool - */ - public function close() - { - $this->connected = false; - - return true; - } - - private function getData($key) - { - if (isset($this->storage[$key])) { - return unserialize($this->storage[$key]); - } - - return false; - } - - private function storeData($key, $value) - { - $this->storage[$key] = serialize($value); - - return true; - } - - public function select($dbnum) - { - if (!$this->connected) { - return false; - } - - if (0 > $dbnum) { - return false; - } - - return true; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php deleted file mode 100644 index 29525fe6b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -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 -{ - public function getMongo() - { - return parent::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; - - public static function setUpBeforeClass() - { - if (extension_loaded('mongo')) { - self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400); - try { - self::$storage->getMongo(); - } catch (\MongoConnectionException $e) { - self::$storage = null; - } - } - } - - public static function tearDownAfterClass() - { - if (self::$storage) { - self::$storage->purge(); - self::$storage = null; - } - } - - public function getDsns() - { - return array( - array('mongodb://localhost/symfony_tests/profiler_data', array( - 'mongodb://localhost/symfony_tests', - 'symfony_tests', - 'profiler_data', - )), - array('mongodb://user:password@localhost/symfony_tests/profiler_data', array( - 'mongodb://user:password@localhost/symfony_tests', - 'symfony_tests', - 'profiler_data', - )), - array('mongodb://user:password@localhost/admin/symfony_tests/profiler_data', array( - 'mongodb://user:password@localhost/admin', - 'symfony_tests', - 'profiler_data', - )), - array('mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin/symfony_tests/profiler_data', array( - 'mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin', - 'symfony_tests', - 'profiler_data', - )), - ); - } - - public function testCleanup() - { - $dt = new \DateTime('-2 day'); - for ($i = 0; $i < 3; ++$i) { - $dt->modify('-1 day'); - $profile = new Profile('time_'.$i); - $profile->setTime($dt->getTimestamp()); - $profile->setMethod('GET'); - self::$storage->write($profile); - } - $records = self::$storage->find('', '', 3, 'GET'); - $this->assertCount(1, $records, '->find() returns only one record'); - $this->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record'); - self::$storage->purge(); - } - - /** - * @dataProvider getDsns - */ - public function testDsnParser($dsn, $expected) - { - $m = new \ReflectionMethod(self::$storage, 'parseDsn'); - $m->setAccessible(true); - - $this->assertEquals($expected, $m->invoke(self::$storage, $dsn)); - } - - 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 - */ - protected function getStorage() - { - return self::$storage; - } - - protected function setUp() - { - if (self::$storage) { - self::$storage->purge(); - } else { - $this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost'); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php deleted file mode 100644 index 43a896002..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; -use Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class ProfilerTest extends \PHPUnit_Framework_TestCase -{ - private $tmp; - private $storage; - - public function testCollect() - { - $request = new Request(); - $request->query->set('foo', 'bar'); - $response = new Response(); - $collector = new RequestDataCollector(); - - $profiler = new Profiler($this->storage); - $profiler->add($collector); - $profile = $profiler->collect($request, $response); - - $profile = $profiler->loadProfile($profile->getToken()); - $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all()); - } - - public function testFindWorksWithDates() - { - $profiler = new Profiler($this->storage); - - $this->assertCount(0, $profiler->find(null, null, null, null, '7th April 2014', '9th April 2014')); - } - - public function testFindWorksWithTimestamps() - { - $profiler = new Profiler($this->storage); - - $this->assertCount(0, $profiler->find(null, null, null, null, '1396828800', '1397001600')); - } - - public function testFindWorksWithInvalidDates() - { - $profiler = new Profiler($this->storage); - - $this->assertCount(0, $profiler->find(null, null, null, null, 'some string', '')); - } - - protected function setUp() - { - if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) { - $this->markTestSkipped('This test requires SQLite support in your environment'); - } - - $this->tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler'); - if (file_exists($this->tmp)) { - @unlink($this->tmp); - } - - $this->storage = new SqliteProfilerStorage('sqlite:'.$this->tmp); - $this->storage->purge(); - } - - protected function tearDown() - { - if (null !== $this->storage) { - $this->storage->purge(); - $this->storage = null; - - @unlink($this->tmp); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php deleted file mode 100644 index 91354ae93..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage; -use Symfony\Component\HttpKernel\Tests\Profiler\Mock\RedisMock; - -class RedisProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $storage; - - protected function setUp() - { - $redisMock = new RedisMock(); - $redisMock->connect('127.0.0.1', 6379); - - self::$storage = new RedisProfilerStorage('redis://127.0.0.1:6379', '', '', 86400); - self::$storage->setRedis($redisMock); - - if (self::$storage) { - self::$storage->purge(); - } - } - - protected function tearDown() - { - if (self::$storage) { - self::$storage->purge(); - self::$storage = false; - } - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php deleted file mode 100644 index 43546c1a1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage; - -class SqliteProfilerStorageTest extends AbstractProfilerStorageTest -{ - protected static $dbFile; - protected static $storage; - - public static function setUpBeforeClass() - { - self::$dbFile = tempnam(sys_get_temp_dir(), 'sf2_sqlite_storage'); - if (file_exists(self::$dbFile)) { - @unlink(self::$dbFile); - } - self::$storage = new SqliteProfilerStorage('sqlite:'.self::$dbFile); - } - - public static function tearDownAfterClass() - { - @unlink(self::$dbFile); - } - - protected function setUp() - { - if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) { - $this->markTestSkipped('This test requires SQLite support in your environment'); - } - self::$storage->purge(); - } - - /** - * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface - */ - protected function getStorage() - { - return self::$storage; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php deleted file mode 100644 index d526c4de8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestHttpKernel extends HttpKernel implements ControllerResolverInterface -{ - public function __construct() - { - parent::__construct(new EventDispatcher(), $this); - } - - public function getController(Request $request) - { - return array($this, 'callController'); - } - - public function getArguments(Request $request, $controller) - { - return array($request); - } - - public function callController(Request $request) - { - return new Response('Request: '.$request->getRequestUri()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/UriSignerTest.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/UriSignerTest.php deleted file mode 100644 index f4d07282f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/UriSignerTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\HttpKernel\UriSigner; - -class UriSignerTest extends \PHPUnit_Framework_TestCase -{ - public function testSign() - { - $signer = new UriSigner('foobar'); - - $this->assertContains('?_hash=', $signer->sign('http://example.com/foo')); - $this->assertContains('&_hash=', $signer->sign('http://example.com/foo?foo=bar')); - } - - public function testCheck() - { - $signer = new UriSigner('foobar'); - - $this->assertFalse($signer->check('http://example.com/foo?_hash=foo')); - $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo')); - $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo&bar=foo')); - - $this->assertTrue($signer->check($signer->sign('http://example.com/foo'))); - $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar'))); - - $this->assertTrue($signer->sign('http://example.com/foo?foo=bar&bar=foo') === $signer->sign('http://example.com/foo?bar=foo&foo=bar')); - } - - public function testCheckWithDifferentArgSeparator() - { - $this->iniSet('arg_separator.output', '&'); - $signer = new UriSigner('foobar'); - - $this->assertSame( - "http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D", - $signer->sign('http://example.com/foo?foo=bar&baz=bay') - ); - $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php deleted file mode 100644 index 6ddce8736..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -/** - * Signs URIs. - * - * @author Fabien Potencier - */ -class UriSigner -{ - private $secret; - - /** - * Constructor. - * - * @param string $secret A secret - */ - public function __construct($secret) - { - $this->secret = $secret; - } - - /** - * Signs a URI. - * - * The given URI is signed by adding a _hash query string parameter - * which value depends on the URI and the secret. - * - * @param string $uri A URI to sign - * - * @return string The signed URI - */ - public function sign($uri) - { - $url = parse_url($uri); - if (isset($url['query'])) { - parse_str($url['query'], $params); - } else { - $params = array(); - } - - $uri = $this->buildUrl($url, $params); - - return $uri.(false === (strpos($uri, '?')) ? '?' : '&').'_hash='.$this->computeHash($uri); - } - - /** - * Checks that a URI contains the correct hash. - * - * The _hash query string parameter must be the last one - * (as it is generated that way by the sign() method, it should - * never be a problem). - * - * @param string $uri A signed URI - * - * @return bool True if the URI is signed correctly, false otherwise - */ - public function check($uri) - { - $url = parse_url($uri); - if (isset($url['query'])) { - parse_str($url['query'], $params); - } else { - $params = array(); - } - - if (empty($params['_hash'])) { - return false; - } - - $hash = urlencode($params['_hash']); - unset($params['_hash']); - - return $this->computeHash($this->buildUrl($url, $params)) === $hash; - } - - private function computeHash($uri) - { - return urlencode(base64_encode(hash_hmac('sha256', $uri, $this->secret, true))); - } - - private function buildUrl(array $url, array $params = array()) - { - ksort($params); - $url['query'] = http_build_query($params, '', '&'); - - $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; - $host = isset($url['host']) ? $url['host'] : ''; - $port = isset($url['port']) ? ':'.$url['port'] : ''; - $user = isset($url['user']) ? $url['user'] : ''; - $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; - $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($url['path']) ? $url['path'] : ''; - $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; - $fragment = isset($url['fragment']) ? '#'.$url['fragment'] : ''; - - return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json deleted file mode 100644 index 584afc263..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/composer.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "symfony/http-kernel", - "type": "library", - "description": "Symfony HttpKernel Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.6,>=2.6.7", - "symfony/http-foundation": "~2.5,>=2.5.4", - "symfony/debug": "~2.6,>=2.6.2", - "psr/log": "~1.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7", - "symfony/browser-kit": "~2.3", - "symfony/class-loader": "~2.1", - "symfony/config": "~2.0,>=2.0.5", - "symfony/console": "~2.3", - "symfony/css-selector": "~2.0,>=2.0.5", - "symfony/dependency-injection": "~2.2", - "symfony/dom-crawler": "~2.0,>=2.0.5", - "symfony/expression-language": "~2.4", - "symfony/finder": "~2.0,>=2.0.5", - "symfony/process": "~2.0,>=2.0.5", - "symfony/routing": "~2.2", - "symfony/stopwatch": "~2.3", - "symfony/templating": "~2.2", - "symfony/translation": "~2.0,>=2.0.5", - "symfony/var-dumper": "~2.6" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/class-loader": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\HttpKernel\\": "" } - }, - "target-dir": "Symfony/Component/HttpKernel", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/exclude.txt b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/exclude.txt deleted file mode 100644 index 9010fbf2e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/exclude.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -# The following source files are not re-distributed with the "build" of the application -# since they are used solely for constructing other files during the build process -# -Tests \ No newline at end of file diff --git a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist b/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist deleted file mode 100644 index 7901a0b8b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/symfony/http-kernel/TerminableInterface.php b/lib/silex/vendor/symfony/http-kernel/TerminableInterface.php deleted file mode 100644 index 8aa331979..000000000 --- a/lib/silex/vendor/symfony/http-kernel/TerminableInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Terminable extends the Kernel request/response cycle with dispatching a post - * response event after sending the response and before shutting down the kernel. - * - * @author Jordi Boggiano - * @author Pierre Minnieur - */ -interface TerminableInterface -{ - /** - * Terminates a request/response cycle. - * - * Should be called after sending the response and before shutting down the kernel. - */ - public function terminate(Request $request, Response $response); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Bundle/BundleTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Bundle/BundleTest.php deleted file mode 100644 index 8e52b097d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Bundle/BundleTest.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Bundle; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Bundle\Bundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\ExtensionNotValidBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand; - -class BundleTest extends TestCase -{ - public function testGetContainerExtension() - { - $bundle = new ExtensionPresentBundle(); - - $this->assertInstanceOf( - 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\DependencyInjection\ExtensionPresentExtension', - $bundle->getContainerExtension() - ); - } - - /** - * @group legacy - * @expectedDeprecation Auto-registration of the command "Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand" is deprecated since Symfony 3.4 and won't be supported in 4.0. Use PSR-4 based service discovery instead. - */ - public function testRegisterCommands() - { - $cmd = new FooCommand(); - $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); - $app->expects($this->once())->method('add')->with($this->equalTo($cmd)); - - $bundle = new ExtensionPresentBundle(); - $bundle->registerCommands($app); - - $bundle2 = new ExtensionAbsentBundle(); - - $this->assertNull($bundle2->registerCommands($app)); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface - */ - public function testGetContainerExtensionWithInvalidClass() - { - $bundle = new ExtensionNotValidBundle(); - $bundle->getContainerExtension(); - } - - public function testHttpKernelRegisterCommandsIgnoresCommandsThatAreRegisteredAsServices() - { - $container = new ContainerBuilder(); - $container->register('console.command.symfony_component_httpkernel_tests_fixtures_extensionpresentbundle_command_foocommand', 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand'); - - $application = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); - // add() is never called when the found command classes are already registered as services - $application->expects($this->never())->method('add'); - - $bundle = new ExtensionPresentBundle(); - $bundle->setContainer($container); - $bundle->registerCommands($application); - } - - public function testBundleNameIsGuessedFromClass() - { - $bundle = new GuessedNameBundle(); - - $this->assertSame('Symfony\Component\HttpKernel\Tests\Bundle', $bundle->getNamespace()); - $this->assertSame('GuessedNameBundle', $bundle->getName()); - } - - public function testBundleNameCanBeExplicitlyProvided() - { - $bundle = new NamedBundle(); - - $this->assertSame('ExplicitlyNamedBundle', $bundle->getName()); - $this->assertSame('Symfony\Component\HttpKernel\Tests\Bundle', $bundle->getNamespace()); - $this->assertSame('ExplicitlyNamedBundle', $bundle->getName()); - } -} - -class NamedBundle extends Bundle -{ - public function __construct() - { - $this->name = 'ExplicitlyNamedBundle'; - } -} - -class GuessedNameBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/ChainCacheClearerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/ChainCacheClearerTest.php deleted file mode 100644 index ec2ecff94..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/ChainCacheClearerTest.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\CacheClearer; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer; - -class ChainCacheClearerTest extends TestCase -{ - protected static $cacheDir; - - public static function setUpBeforeClass() - { - self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_clearer_dir'); - } - - public static function tearDownAfterClass() - { - @unlink(self::$cacheDir); - } - - public function testInjectClearersInConstructor() - { - $clearer = $this->getMockClearer(); - $clearer - ->expects($this->once()) - ->method('clear'); - - $chainClearer = new ChainCacheClearer(array($clearer)); - $chainClearer->clear(self::$cacheDir); - } - - /** - * @group legacy - */ - public function testInjectClearerUsingAdd() - { - $clearer = $this->getMockClearer(); - $clearer - ->expects($this->once()) - ->method('clear'); - - $chainClearer = new ChainCacheClearer(); - $chainClearer->add($clearer); - $chainClearer->clear(self::$cacheDir); - } - - protected function getMockClearer() - { - return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/Psr6CacheClearerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/Psr6CacheClearerTest.php deleted file mode 100644 index 3e20efbf1..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/CacheClearer/Psr6CacheClearerTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\CacheClearer; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer; -use Psr\Cache\CacheItemPoolInterface; - -class Psr6CacheClearerTest extends TestCase -{ - public function testClearPoolsInjectedInConstructor() - { - $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); - $pool - ->expects($this->once()) - ->method('clear'); - - (new Psr6CacheClearer(array('pool' => $pool)))->clear(''); - } - - public function testClearPool() - { - $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); - $pool - ->expects($this->once()) - ->method('clear'); - - (new Psr6CacheClearer(array('pool' => $pool)))->clearPool('pool'); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Cache pool not found: unknown - */ - public function testClearPoolThrowsExceptionOnUnreferencedPool() - { - (new Psr6CacheClearer())->clearPool('unknown'); - } - - /** - * @group legacy - * @expectedDeprecation The Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer::addPool() method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead. - */ - public function testClearPoolsInjectedByAdder() - { - $pool1 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); - $pool1 - ->expects($this->once()) - ->method('clear'); - - $pool2 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); - $pool2 - ->expects($this->once()) - ->method('clear'); - - $clearer = new Psr6CacheClearer(array('pool1' => $pool1)); - $clearer->addPool($pool2); - $clearer->clear(''); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php deleted file mode 100644 index ba159124c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\CacheWarmer; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate; - -class CacheWarmerAggregateTest extends TestCase -{ - protected static $cacheDir; - - public static function setUpBeforeClass() - { - self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_warmer_dir'); - } - - public static function tearDownAfterClass() - { - @unlink(self::$cacheDir); - } - - public function testInjectWarmersUsingConstructor() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(array($warmer)); - $aggregate->warmUp(self::$cacheDir); - } - - /** - * @group legacy - */ - public function testInjectWarmersUsingAdd() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(); - $aggregate->add($warmer); - $aggregate->warmUp(self::$cacheDir); - } - - /** - * @group legacy - */ - public function testInjectWarmersUsingSetWarmers() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(); - $aggregate->setWarmers(array($warmer)); - $aggregate->warmUp(self::$cacheDir); - } - - public function testWarmupDoesCallWarmupOnOptionalWarmersWhenEnableOptionalWarmersIsEnabled() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->never()) - ->method('isOptional'); - $warmer - ->expects($this->once()) - ->method('warmUp'); - - $aggregate = new CacheWarmerAggregate(array($warmer)); - $aggregate->enableOptionalWarmers(); - $aggregate->warmUp(self::$cacheDir); - } - - public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWarmersIsNotEnabled() - { - $warmer = $this->getCacheWarmerMock(); - $warmer - ->expects($this->once()) - ->method('isOptional') - ->will($this->returnValue(true)); - $warmer - ->expects($this->never()) - ->method('warmUp'); - - $aggregate = new CacheWarmerAggregate(array($warmer)); - $aggregate->warmUp(self::$cacheDir); - } - - protected function getCacheWarmerMock() - { - $warmer = $this->getMockBuilder('Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface') - ->disableOriginalConstructor() - ->getMock(); - - return $warmer; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerTest.php deleted file mode 100644 index 05666cb0d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/CacheWarmer/CacheWarmerTest.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\CacheWarmer; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer; - -class CacheWarmerTest extends TestCase -{ - protected static $cacheFile; - - public static function setUpBeforeClass() - { - self::$cacheFile = tempnam(sys_get_temp_dir(), 'sf2_cache_warmer_dir'); - } - - public static function tearDownAfterClass() - { - @unlink(self::$cacheFile); - } - - public function testWriteCacheFileCreatesTheFile() - { - $warmer = new TestCacheWarmer(self::$cacheFile); - $warmer->warmUp(dirname(self::$cacheFile)); - - $this->assertFileExists(self::$cacheFile); - } - - /** - * @expectedException \RuntimeException - */ - public function testWriteNonWritableCacheFileThrowsARuntimeException() - { - $nonWritableFile = '/this/file/is/very/probably/not/writable'; - $warmer = new TestCacheWarmer($nonWritableFile); - $warmer->warmUp(dirname($nonWritableFile)); - } -} - -class TestCacheWarmer extends CacheWarmer -{ - protected $file; - - public function __construct($file) - { - $this->file = $file; - } - - public function warmUp($cacheDir) - { - $this->writeCacheFile($this->file, 'content'); - } - - public function isOptional() - { - return false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/ClientTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/ClientTest.php deleted file mode 100644 index 1ac72c735..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/ClientTest.php +++ /dev/null @@ -1,183 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Client; -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; - -/** - * @group time-sensitive - */ -class ClientTest extends TestCase -{ - public function testDoRequest() - { - $client = new Client(new TestHttpKernel()); - - $client->request('GET', '/'); - $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Request', $client->getRequest()); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $client->getResponse()); - - $client->request('GET', 'http://www.example.com/'); - $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); - $this->assertEquals('www.example.com', $client->getRequest()->getHost(), '->doRequest() uses the request handler to make the request'); - - $client->request('GET', 'http://www.example.com/?parameter=http://google.com'); - $this->assertEquals('http://www.example.com/?parameter='.urlencode('http://google.com'), $client->getRequest()->getUri(), '->doRequest() uses the request handler to make the request'); - } - - public function testGetScript() - { - $client = new TestClient(new TestHttpKernel()); - $client->insulate(); - $client->request('GET', '/'); - - $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->getScript() returns a script that uses the request handler to make the request'); - } - - public function testFilterResponseConvertsCookies() - { - $client = new Client(new TestHttpKernel()); - - $r = new \ReflectionObject($client); - $m = $r->getMethod('filterResponse'); - $m->setAccessible(true); - - $expected = array( - 'foo=bar; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly', - 'foo1=bar1; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly', - ); - - $response = new Response(); - $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); - $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); - - $response = new Response(); - $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); - $response->headers->setCookie(new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); - $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); - $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'); - $target = sys_get_temp_dir().'/sf.moved.file'; - @unlink($target); - - $kernel = new TestHttpKernel(); - $client = new Client($kernel); - - $files = array( - array('tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => 123, 'error' => UPLOAD_ERR_OK), - new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true), - ); - - $file = null; - foreach ($files as $file) { - $client->request('POST', '/', array(), array('foo' => $file)); - - $files = $client->getRequest()->files->all(); - - $this->assertCount(1, $files); - - $file = $files['foo']; - - $this->assertEquals('original', $file->getClientOriginalName()); - $this->assertEquals('mime/original', $file->getClientMimeType()); - $this->assertEquals('123', $file->getClientSize()); - $this->assertTrue($file->isValid()); - } - - $file->move(dirname($target), basename($target)); - - $this->assertFileExists($target); - unlink($target); - } - - public function testUploadedFileWhenNoFileSelected() - { - $kernel = new TestHttpKernel(); - $client = new Client($kernel); - - $file = array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE); - - $client->request('POST', '/', array(), array('foo' => $file)); - - $files = $client->getRequest()->files->all(); - - $this->assertCount(1, $files); - $this->assertNull($files['foo']); - } - - public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() - { - $source = tempnam(sys_get_temp_dir(), 'source'); - - $kernel = new TestHttpKernel(); - $client = new Client($kernel); - - $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true)) - ->setMethods(array('getSize')) - ->getMock() - ; - - $file->expects($this->once()) - ->method('getSize') - ->will($this->returnValue(INF)) - ; - - $client->request('POST', '/', array(), array($file)); - - $files = $client->getRequest()->files->all(); - - $this->assertCount(1, $files); - - $file = $files[0]; - - $this->assertFalse($file->isValid()); - $this->assertEquals(UPLOAD_ERR_INI_SIZE, $file->getError()); - $this->assertEquals('mime/original', $file->getClientMimeType()); - $this->assertEquals('original', $file->getClientOriginalName()); - $this->assertEquals(0, $file->getClientSize()); - - unlink($source); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Config/EnvParametersResourceTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Config/EnvParametersResourceTest.php deleted file mode 100644 index 986e05d8b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Config/EnvParametersResourceTest.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Config; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Config\EnvParametersResource; - -/** - * @group legacy - */ -class EnvParametersResourceTest extends TestCase -{ - protected $prefix = '__DUMMY_'; - protected $initialEnv; - protected $resource; - - protected function setUp() - { - $this->initialEnv = array( - $this->prefix.'1' => 'foo', - $this->prefix.'2' => 'bar', - ); - - foreach ($this->initialEnv as $key => $value) { - $_SERVER[$key] = $value; - } - - $this->resource = new EnvParametersResource($this->prefix); - } - - protected function tearDown() - { - foreach ($_SERVER as $key => $value) { - if (0 === strpos($key, $this->prefix)) { - unset($_SERVER[$key]); - } - } - } - - public function testGetResource() - { - $this->assertSame( - array('prefix' => $this->prefix, 'variables' => $this->initialEnv), - $this->resource->getResource(), - '->getResource() returns the resource' - ); - } - - public function testToString() - { - $this->assertSame( - serialize(array('prefix' => $this->prefix, 'variables' => $this->initialEnv)), - (string) $this->resource - ); - } - - public function testIsFreshNotChanged() - { - $this->assertTrue( - $this->resource->isFresh(time()), - '->isFresh() returns true if the variables have not changed' - ); - } - - public function testIsFreshValueChanged() - { - reset($this->initialEnv); - $_SERVER[key($this->initialEnv)] = 'baz'; - - $this->assertFalse( - $this->resource->isFresh(time()), - '->isFresh() returns false if a variable has been changed' - ); - } - - public function testIsFreshValueRemoved() - { - reset($this->initialEnv); - unset($_SERVER[key($this->initialEnv)]); - - $this->assertFalse( - $this->resource->isFresh(time()), - '->isFresh() returns false if a variable has been removed' - ); - } - - public function testIsFreshValueAdded() - { - $_SERVER[$this->prefix.'3'] = 'foo'; - - $this->assertFalse( - $this->resource->isFresh(time()), - '->isFresh() returns false if a variable has been added' - ); - } - - public function testSerializeUnserialize() - { - $this->assertEquals($this->resource, unserialize(serialize($this->resource))); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php deleted file mode 100644 index 6265f0275..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Config; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Config\FileLocator; - -class FileLocatorTest extends TestCase -{ - public function testLocate() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); - $kernel - ->expects($this->atLeastOnce()) - ->method('locateResource') - ->with('@BundleName/some/path', null, true) - ->will($this->returnValue('/bundle-name/some/path')); - $locator = new FileLocator($kernel); - $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path')); - - $kernel - ->expects($this->never()) - ->method('locateResource'); - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException'); - $locator->locate('/some/path'); - } - - public function testLocateWithGlobalResourcePath() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); - $kernel - ->expects($this->atLeastOnce()) - ->method('locateResource') - ->with('@BundleName/some/path', '/global/resource/path', false); - - $locator = new FileLocator($kernel, '/global/resource/path'); - $locator->locate('@BundleName/some/path', null, false); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php deleted file mode 100644 index b05828f5b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\ServiceLocator; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -class ServiceValueResolverTest extends TestCase -{ - public function testDoNotSupportWhenControllerDoNotExists() - { - $resolver = new ServiceValueResolver(new ServiceLocator(array())); - $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); - $request = $this->requestWithAttributes(array('_controller' => 'my_controller')); - - $this->assertFalse($resolver->supports($request, $argument)); - } - - public function testExistingController() - { - $resolver = new ServiceValueResolver(new ServiceLocator(array( - 'App\\Controller\\Mine::method' => function () { - return new ServiceLocator(array( - 'dummy' => function () { - return new DummyService(); - }, - )); - }, - ))); - - $request = $this->requestWithAttributes(array('_controller' => 'App\\Controller\\Mine::method')); - $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); - - $this->assertTrue($resolver->supports($request, $argument)); - $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); - } - - public function testControllerNameIsAnArray() - { - $resolver = new ServiceValueResolver(new ServiceLocator(array( - 'App\\Controller\\Mine::method' => function () { - return new ServiceLocator(array( - 'dummy' => function () { - return new DummyService(); - }, - )); - }, - ))); - - $request = $this->requestWithAttributes(array('_controller' => array('App\\Controller\\Mine', 'method'))); - $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); - - $this->assertTrue($resolver->supports($request, $argument)); - $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); - } - - private function requestWithAttributes(array $attributes) - { - $request = Request::create('/'); - - foreach ($attributes as $name => $value) { - $request->attributes->set($name, $value); - } - - return $request; - } - - private function assertYieldEquals(array $expected, \Generator $generator) - { - $args = array(); - foreach ($generator as $arg) { - $args[] = $arg; - } - - $this->assertEquals($expected, $args); - } -} - -class DummyService -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolverTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolverTest.php deleted file mode 100644 index 080413903..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolverTest.php +++ /dev/null @@ -1,349 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Controller; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver; -use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\ExtendingRequest; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\ExtendingSession; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; -use Symfony\Component\HttpFoundation\Request; - -class ArgumentResolverTest extends TestCase -{ - /** @var ArgumentResolver */ - private static $resolver; - - public static function setUpBeforeClass() - { - $factory = new ArgumentMetadataFactory(); - - self::$resolver = new ArgumentResolver($factory); - } - - public function testDefaultState() - { - $this->assertEquals(self::$resolver, new ArgumentResolver()); - $this->assertNotEquals(self::$resolver, new ArgumentResolver(null, array(new RequestAttributeValueResolver()))); - } - - public function testGetArguments() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerWithFoo'); - - $this->assertEquals(array('foo'), self::$resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method'); - } - - public function testGetArgumentsReturnsEmptyArrayWhenNoArguments() - { - $request = Request::create('/'); - $controller = array(new self(), 'controllerWithoutArguments'); - - $this->assertEquals(array(), self::$resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments'); - } - - public function testGetArgumentsUsesDefaultValue() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerWithFooAndDefaultBar'); - - $this->assertEquals(array('foo', null), self::$resolver->getArguments($request, $controller), '->getArguments() uses default values if present'); - } - - public function testGetArgumentsOverrideDefaultValueByRequestAttribute() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', 'bar'); - $controller = array(new self(), 'controllerWithFooAndDefaultBar'); - - $this->assertEquals(array('foo', 'bar'), self::$resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes'); - } - - public function testGetArgumentsFromClosure() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = function ($foo) {}; - - $this->assertEquals(array('foo'), self::$resolver->getArguments($request, $controller)); - } - - public function testGetArgumentsUsesDefaultValueFromClosure() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = function ($foo, $bar = 'bar') {}; - - $this->assertEquals(array('foo', 'bar'), self::$resolver->getArguments($request, $controller)); - } - - public function testGetArgumentsFromInvokableObject() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = new self(); - - $this->assertEquals(array('foo', null), self::$resolver->getArguments($request, $controller)); - - // Test default bar overridden by request attribute - $request->attributes->set('bar', 'bar'); - - $this->assertEquals(array('foo', 'bar'), self::$resolver->getArguments($request, $controller)); - } - - public function testGetArgumentsFromFunctionName() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('foobar', 'foobar'); - $controller = __NAMESPACE__.'\controller_function'; - - $this->assertEquals(array('foo', 'foobar'), self::$resolver->getArguments($request, $controller)); - } - - public function testGetArgumentsFailsOnUnresolvedValue() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('foobar', 'foobar'); - $controller = array(new self(), 'controllerWithFooBarFoobar'); - - try { - self::$resolver->getArguments($request, $controller); - $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } - } - - public function testGetArgumentsInjectsRequest() - { - $request = Request::create('/'); - $controller = array(new self(), 'controllerWithRequest'); - - $this->assertEquals(array($request), self::$resolver->getArguments($request, $controller), '->getArguments() injects the request'); - } - - public function testGetArgumentsInjectsExtendingRequest() - { - $request = ExtendingRequest::create('/'); - $controller = array(new self(), 'controllerWithExtendingRequest'); - - $this->assertEquals(array($request), self::$resolver->getArguments($request, $controller), '->getArguments() injects the request when extended'); - } - - /** - * @requires PHP 5.6 - */ - public function testGetVariadicArguments() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', array('foo', 'bar')); - $controller = array(new VariadicController(), 'action'); - - $this->assertEquals(array('foo', 'foo', 'bar'), self::$resolver->getArguments($request, $controller)); - } - - /** - * @requires PHP 5.6 - * @expectedException \InvalidArgumentException - */ - public function testGetVariadicArgumentsWithoutArrayInRequest() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', 'foo'); - $controller = array(new VariadicController(), 'action'); - - self::$resolver->getArguments($request, $controller); - } - - /** - * @requires PHP 5.6 - * @expectedException \InvalidArgumentException - */ - public function testGetArgumentWithoutArray() - { - $factory = new ArgumentMetadataFactory(); - $valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock(); - $resolver = new ArgumentResolver($factory, array($valueResolver)); - - $valueResolver->expects($this->any())->method('supports')->willReturn(true); - $valueResolver->expects($this->any())->method('resolve')->willReturn('foo'); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', 'foo'); - $controller = array($this, 'controllerWithFooAndDefaultBar'); - $resolver->getArguments($request, $controller); - } - - /** - * @expectedException \RuntimeException - */ - public function testIfExceptionIsThrownWhenMissingAnArgument() - { - $request = Request::create('/'); - $controller = array($this, 'controllerWithFoo'); - - self::$resolver->getArguments($request, $controller); - } - - /** - * @requires PHP 7.1 - */ - public function testGetNullableArguments() - { - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', new \stdClass()); - $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); - - $this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), self::$resolver->getArguments($request, $controller)); - } - - /** - * @requires PHP 7.1 - */ - public function testGetNullableArgumentsWithDefaults() - { - $request = Request::create('/'); - $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); - - $this->assertEquals(array(null, null, 'value', 'mandatory'), self::$resolver->getArguments($request, $controller)); - } - - public function testGetSessionArguments() - { - $session = new Session(new MockArraySessionStorage()); - $request = Request::create('/'); - $request->setSession($session); - $controller = array($this, 'controllerWithSession'); - - $this->assertEquals(array($session), self::$resolver->getArguments($request, $controller)); - } - - public function testGetSessionArgumentsWithExtendedSession() - { - $session = new ExtendingSession(new MockArraySessionStorage()); - $request = Request::create('/'); - $request->setSession($session); - $controller = array($this, 'controllerWithExtendingSession'); - - $this->assertEquals(array($session), self::$resolver->getArguments($request, $controller)); - } - - public function testGetSessionArgumentsWithInterface() - { - $session = $this->getMockBuilder(SessionInterface::class)->getMock(); - $request = Request::create('/'); - $request->setSession($session); - $controller = array($this, 'controllerWithSessionInterface'); - - $this->assertEquals(array($session), self::$resolver->getArguments($request, $controller)); - } - - /** - * @expectedException \RuntimeException - */ - public function testGetSessionMissMatchWithInterface() - { - $session = $this->getMockBuilder(SessionInterface::class)->getMock(); - $request = Request::create('/'); - $request->setSession($session); - $controller = array($this, 'controllerWithExtendingSession'); - - self::$resolver->getArguments($request, $controller); - } - - /** - * @expectedException \RuntimeException - */ - public function testGetSessionMissMatchWithImplementation() - { - $session = new Session(new MockArraySessionStorage()); - $request = Request::create('/'); - $request->setSession($session); - $controller = array($this, 'controllerWithExtendingSession'); - - self::$resolver->getArguments($request, $controller); - } - - /** - * @expectedException \RuntimeException - */ - public function testGetSessionMissMatchOnNull() - { - $request = Request::create('/'); - $controller = array($this, 'controllerWithExtendingSession'); - - self::$resolver->getArguments($request, $controller); - } - - public function __invoke($foo, $bar = null) - { - } - - public function controllerWithFoo($foo) - { - } - - public function controllerWithoutArguments() - { - } - - protected function controllerWithFooAndDefaultBar($foo, $bar = null) - { - } - - protected function controllerWithFooBarFoobar($foo, $bar, $foobar) - { - } - - protected function controllerWithRequest(Request $request) - { - } - - protected function controllerWithExtendingRequest(ExtendingRequest $request) - { - } - - protected function controllerWithSession(Session $session) - { - } - - protected function controllerWithSessionInterface(SessionInterface $session) - { - } - - protected function controllerWithExtendingSession(ExtendingSession $session) - { - } -} - -function controller_function($foo, $foobar) -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ContainerControllerResolverTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ContainerControllerResolverTest.php deleted file mode 100644 index 0019123b6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ContainerControllerResolverTest.php +++ /dev/null @@ -1,308 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Controller; - -use Psr\Container\ContainerInterface; -use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver; - -class ContainerControllerResolverTest extends ControllerResolverTest -{ - public function testGetControllerService() - { - $container = $this->createMockContainer(); - $container->expects($this->once()) - ->method('has') - ->with('foo') - ->will($this->returnValue(true)); - $container->expects($this->once()) - ->method('get') - ->with('foo') - ->will($this->returnValue($this)) - ; - - $resolver = $this->createControllerResolver(null, $container); - $request = Request::create('/'); - $request->attributes->set('_controller', 'foo:controllerMethod1'); - - $controller = $resolver->getController($request); - - $this->assertInstanceOf(get_class($this), $controller[0]); - $this->assertSame('controllerMethod1', $controller[1]); - } - - public function testGetControllerInvokableService() - { - $invokableController = new InvokableController('bar'); - - $container = $this->createMockContainer(); - $container->expects($this->once()) - ->method('has') - ->with('foo') - ->will($this->returnValue(true)) - ; - $container->expects($this->once()) - ->method('get') - ->with('foo') - ->will($this->returnValue($invokableController)) - ; - - $resolver = $this->createControllerResolver(null, $container); - $request = Request::create('/'); - $request->attributes->set('_controller', 'foo'); - - $controller = $resolver->getController($request); - - $this->assertEquals($invokableController, $controller); - } - - public function testGetControllerInvokableServiceWithClassNameAsName() - { - $invokableController = new InvokableController('bar'); - $className = __NAMESPACE__.'\InvokableController'; - - $container = $this->createMockContainer(); - $container->expects($this->once()) - ->method('has') - ->with($className) - ->will($this->returnValue(true)) - ; - $container->expects($this->once()) - ->method('get') - ->with($className) - ->will($this->returnValue($invokableController)) - ; - - $resolver = $this->createControllerResolver(null, $container); - $request = Request::create('/'); - $request->attributes->set('_controller', $className); - - $controller = $resolver->getController($request); - - $this->assertEquals($invokableController, $controller); - } - - public function testNonInstantiableController() - { - $container = $this->createMockContainer(); - $container->expects($this->once()) - ->method('has') - ->with(NonInstantiableController::class) - ->will($this->returnValue(false)) - ; - - $resolver = $this->createControllerResolver(null, $container); - $request = Request::create('/'); - $request->attributes->set('_controller', array(NonInstantiableController::class, 'action')); - - $controller = $resolver->getController($request); - - $this->assertSame(array(NonInstantiableController::class, 'action'), $controller); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Controller "Symfony\Component\HttpKernel\Tests\Controller\ImpossibleConstructController" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"? - */ - public function testNonConstructController() - { - $container = $this->getMockBuilder(Container::class)->getMock(); - $container->expects($this->at(0)) - ->method('has') - ->with(ImpossibleConstructController::class) - ->will($this->returnValue(true)) - ; - - $container->expects($this->at(1)) - ->method('has') - ->with(ImpossibleConstructController::class) - ->will($this->returnValue(false)) - ; - - $container->expects($this->atLeastOnce()) - ->method('getRemovedIds') - ->with() - ->will($this->returnValue(array(ImpossibleConstructController::class => true))) - ; - - $resolver = $this->createControllerResolver(null, $container); - $request = Request::create('/'); - $request->attributes->set('_controller', array(ImpossibleConstructController::class, 'action')); - - if (\PHP_VERSION_ID < 70100) { - ErrorHandler::register(); - try { - $resolver->getController($request); - } finally { - restore_error_handler(); - restore_exception_handler(); - } - } else { - $resolver->getController($request); - } - } - - public function testNonInstantiableControllerWithCorrespondingService() - { - $service = new \stdClass(); - - $container = $this->createMockContainer(); - $container->expects($this->atLeastOnce()) - ->method('has') - ->with(NonInstantiableController::class) - ->will($this->returnValue(true)) - ; - $container->expects($this->atLeastOnce()) - ->method('get') - ->with(NonInstantiableController::class) - ->will($this->returnValue($service)) - ; - - $resolver = $this->createControllerResolver(null, $container); - $request = Request::create('/'); - $request->attributes->set('_controller', array(NonInstantiableController::class, 'action')); - - $controller = $resolver->getController($request); - - $this->assertSame(array($service, 'action'), $controller); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"? - */ - public function testExceptionWhenUsingRemovedControllerService() - { - $container = $this->getMockBuilder(Container::class)->getMock(); - $container->expects($this->at(0)) - ->method('has') - ->with('app.my_controller') - ->will($this->returnValue(false)) - ; - - $container->expects($this->atLeastOnce()) - ->method('getRemovedIds') - ->with() - ->will($this->returnValue(array('app.my_controller' => true))) - ; - - $resolver = $this->createControllerResolver(null, $container); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'app.my_controller'); - $resolver->getController($request); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Controller "app.my_controller" cannot be called without a method name. Did you forget an "__invoke" method? - */ - public function testExceptionWhenUsingControllerWithoutAnInvokeMethod() - { - $container = $this->getMockBuilder(Container::class)->getMock(); - $container->expects($this->once()) - ->method('has') - ->with('app.my_controller') - ->will($this->returnValue(true)) - ; - $container->expects($this->once()) - ->method('get') - ->with('app.my_controller') - ->will($this->returnValue(new ImpossibleConstructController('toto', 'controller'))) - ; - - $resolver = $this->createControllerResolver(null, $container); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'app.my_controller'); - $resolver->getController($request); - } - - /** - * @dataProvider getUndefinedControllers - */ - public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null) - { - // All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected excetion and not use the regex - $resolver = $this->createControllerResolver(); - if (method_exists($this, 'expectException')) { - $this->expectException($exceptionName); - $this->expectExceptionMessageRegExp($exceptionMessage); - } else { - $this->setExpectedExceptionRegExp($exceptionName, $exceptionMessage); - } - - $request = Request::create('/'); - $request->attributes->set('_controller', $controller); - $resolver->getController($request); - } - - public function getUndefinedControllers() - { - return array( - array('foo', \LogicException::class, '/Controller not found: service "foo" does not exist\./'), - array('oof::bar', \InvalidArgumentException::class, '/Class "oof" does not exist\./'), - array('stdClass', \LogicException::class, '/Controller not found: service "stdClass" does not exist\./'), - array( - 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar', - \InvalidArgumentException::class, - '/.?[cC]ontroller(.*?) for URI "\/" is not callable\.( Expected method(.*) Available methods)?/', - ), - ); - } - - protected function createControllerResolver(LoggerInterface $logger = null, ContainerInterface $container = null) - { - if (!$container) { - $container = $this->createMockContainer(); - } - - return new ContainerControllerResolver($container, $logger); - } - - protected function createMockContainer() - { - return $this->getMockBuilder(ContainerInterface::class)->getMock(); - } -} - -class InvokableController -{ - public function __construct($bar) // mandatory argument to prevent automatic instantiation - { - } - - public function __invoke() - { - } -} - -abstract class NonInstantiableController -{ - public static function action() - { - } -} - -class ImpossibleConstructController -{ - public function __construct($toto, $controller) - { - } - - public function action() - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ControllerResolverTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ControllerResolverTest.php deleted file mode 100644 index 190e15ad6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Controller/ControllerResolverTest.php +++ /dev/null @@ -1,331 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Controller; - -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Controller\ControllerResolver; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; -use Symfony\Component\HttpFoundation\Request; - -class ControllerResolverTest extends TestCase -{ - public function testGetControllerWithoutControllerParameter() - { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.'); - $resolver = $this->createControllerResolver($logger); - - $request = Request::create('/'); - $this->assertFalse($resolver->getController($request), '->getController() returns false when the request has no _controller attribute'); - } - - public function testGetControllerWithLambda() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', $lambda = function () {}); - $controller = $resolver->getController($request); - $this->assertSame($lambda, $controller); - } - - public function testGetControllerWithObjectAndInvokeMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', $this); - $controller = $resolver->getController($request); - $this->assertSame($this, $controller); - } - - public function testGetControllerWithObjectAndMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', array($this, 'controllerMethod1')); - $controller = $resolver->getController($request); - $this->assertSame(array($this, 'controllerMethod1'), $controller); - } - - public function testGetControllerWithClassAndMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4')); - $controller = $resolver->getController($request); - $this->assertSame(array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4'), $controller); - } - - public function testGetControllerWithObjectAndMethodAsString() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::controllerMethod1'); - $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller[0], '->getController() returns a PHP callable'); - } - - public function testGetControllerWithClassAndInvokeMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest'); - $controller = $resolver->getController($request); - $this->assertInstanceOf('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', $controller); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetControllerOnObjectWithoutInvokeMethod() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', new \stdClass()); - $resolver->getController($request); - } - - public function testGetControllerWithFunction() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'); - $controller = $resolver->getController($request); - $this->assertSame('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function', $controller); - } - - /** - * @dataProvider getUndefinedControllers - */ - public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null) - { - $resolver = $this->createControllerResolver(); - if (method_exists($this, 'expectException')) { - $this->expectException($exceptionName); - $this->expectExceptionMessage($exceptionMessage); - } else { - $this->setExpectedException($exceptionName, $exceptionMessage); - } - - $request = Request::create('/'); - $request->attributes->set('_controller', $controller); - $resolver->getController($request); - } - - public function getUndefinedControllers() - { - return array( - array(1, 'InvalidArgumentException', 'Unable to find controller "1".'), - array('foo', 'InvalidArgumentException', 'Unable to find controller "foo".'), - array('oof::bar', 'InvalidArgumentException', 'Class "oof" does not exist.'), - array('stdClass', 'InvalidArgumentException', 'Unable to find controller "stdClass".'), - array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'), - array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'), - array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'), - array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::undefinedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "undefinedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest". Available methods: "publicAction", "staticAction"'), - ); - } - - /** - * @group legacy - */ - public function testGetArguments() - { - $resolver = $this->createControllerResolver(); - - $request = Request::create('/'); - $controller = array(new self(), 'testGetArguments'); - $this->assertEquals(array(), $resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments'); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerMethod1'); - $this->assertEquals(array('foo'), $resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method'); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerMethod2'); - $this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller), '->getArguments() uses default values if present'); - - $request->attributes->set('bar', 'bar'); - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes'); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = function ($foo) {}; - $this->assertEquals(array('foo'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = function ($foo, $bar = 'bar') {}; - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $controller = new self(); - $this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller)); - $request->attributes->set('bar', 'bar'); - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('foobar', 'foobar'); - $controller = 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'; - $this->assertEquals(array('foo', 'foobar'), $resolver->getArguments($request, $controller)); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('foobar', 'foobar'); - $controller = array(new self(), 'controllerMethod3'); - - try { - $resolver->getArguments($request, $controller); - $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } - - $request = Request::create('/'); - $controller = array(new self(), 'controllerMethod5'); - $this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request'); - } - - /** - * @requires PHP 5.6 - * @group legacy - */ - public function testGetVariadicArguments() - { - $resolver = new ControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', array('foo', 'bar')); - $controller = array(new VariadicController(), 'action'); - $this->assertEquals(array('foo', 'foo', 'bar'), $resolver->getArguments($request, $controller)); - } - - public function testCreateControllerCanReturnAnyCallable() - { - $mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(array('createController'))->getMock(); - $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function')); - - $request = Request::create('/'); - $request->attributes->set('_controller', 'foobar'); - $mock->getController($request); - } - - /** - * @expectedException \RuntimeException - * @group legacy - */ - public function testIfExceptionIsThrownWhenMissingAnArgument() - { - $resolver = new ControllerResolver(); - $request = Request::create('/'); - - $controller = array($this, 'controllerMethod1'); - - $resolver->getArguments($request, $controller); - } - - /** - * @requires PHP 7.1 - * @group legacy - */ - public function testGetNullableArguments() - { - $resolver = new ControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', new \stdClass()); - $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); - $this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), $resolver->getArguments($request, $controller)); - } - - /** - * @requires PHP 7.1 - * @group legacy - */ - public function testGetNullableArgumentsWithDefaults() - { - $resolver = new ControllerResolver(); - - $request = Request::create('/'); - $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); - $this->assertEquals(array(null, null, 'value', 'mandatory'), $resolver->getArguments($request, $controller)); - } - - protected function createControllerResolver(LoggerInterface $logger = null) - { - return new ControllerResolver($logger); - } - - public function __invoke($foo, $bar = null) - { - } - - public function controllerMethod1($foo) - { - } - - protected function controllerMethod2($foo, $bar = null) - { - } - - protected function controllerMethod3($foo, $bar, $foobar) - { - } - - protected static function controllerMethod4() - { - } - - protected function controllerMethod5(Request $request) - { - } -} - -function some_controller_function($foo, $foobar) -{ -} - -class ControllerTest -{ - public function publicAction() - { - } - - private function privateAction() - { - } - - protected function protectedAction() - { - } - - public static function staticAction() - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php deleted file mode 100644 index b4b449f35..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\ControllerMetadata; - -use Fake\ImportedAndFake; -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\BasicTypesController; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; - -class ArgumentMetadataFactoryTest extends TestCase -{ - /** - * @var ArgumentMetadataFactory - */ - private $factory; - - protected function setUp() - { - $this->factory = new ArgumentMetadataFactory(); - } - - public function testSignature1() - { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature1')); - - $this->assertEquals(array( - new ArgumentMetadata('foo', self::class, false, false, null), - new ArgumentMetadata('bar', 'array', false, false, null), - new ArgumentMetadata('baz', 'callable', false, false, null), - ), $arguments); - } - - public function testSignature2() - { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature2')); - - $this->assertEquals(array( - new ArgumentMetadata('foo', self::class, false, true, null, true), - new ArgumentMetadata('bar', __NAMESPACE__.'\FakeClassThatDoesNotExist', false, true, null, true), - new ArgumentMetadata('baz', 'Fake\ImportedAndFake', false, true, null, true), - ), $arguments); - } - - public function testSignature3() - { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature3')); - - $this->assertEquals(array( - new ArgumentMetadata('bar', __NAMESPACE__.'\FakeClassThatDoesNotExist', false, false, null), - new ArgumentMetadata('baz', 'Fake\ImportedAndFake', false, false, null), - ), $arguments); - } - - public function testSignature4() - { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature4')); - - $this->assertEquals(array( - new ArgumentMetadata('foo', null, false, true, 'default'), - new ArgumentMetadata('bar', null, false, true, 500), - new ArgumentMetadata('baz', null, false, true, array()), - ), $arguments); - } - - public function testSignature5() - { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature5')); - - $this->assertEquals(array( - new ArgumentMetadata('foo', 'array', false, true, null, true), - new ArgumentMetadata('bar', null, false, false, null), - ), $arguments); - } - - /** - * @requires PHP 5.6 - */ - public function testVariadicSignature() - { - $arguments = $this->factory->createArgumentMetadata(array(new VariadicController(), 'action')); - - $this->assertEquals(array( - new ArgumentMetadata('foo', null, false, false, null), - new ArgumentMetadata('bar', null, true, false, null), - ), $arguments); - } - - /** - * @requires PHP 7.0 - */ - public function testBasicTypesSignature() - { - $arguments = $this->factory->createArgumentMetadata(array(new BasicTypesController(), 'action')); - - $this->assertEquals(array( - new ArgumentMetadata('foo', 'string', false, false, null), - new ArgumentMetadata('bar', 'int', false, false, null), - new ArgumentMetadata('baz', 'float', false, false, null), - ), $arguments); - } - - /** - * @requires PHP 7.1 - */ - public function testNullableTypesSignature() - { - $arguments = $this->factory->createArgumentMetadata(array(new NullableController(), 'action')); - - $this->assertEquals(array( - new ArgumentMetadata('foo', 'string', false, false, null, true), - new ArgumentMetadata('bar', \stdClass::class, false, false, null, true), - new ArgumentMetadata('baz', 'string', false, true, 'value', true), - new ArgumentMetadata('mandatory', null, false, false, null, true), - ), $arguments); - } - - private function signature1(ArgumentMetadataFactoryTest $foo, array $bar, callable $baz) - { - } - - private function signature2(ArgumentMetadataFactoryTest $foo = null, FakeClassThatDoesNotExist $bar = null, ImportedAndFake $baz = null) - { - } - - private function signature3(FakeClassThatDoesNotExist $bar, ImportedAndFake $baz) - { - } - - private function signature4($foo = 'default', $bar = 500, $baz = array()) - { - } - - private function signature5(array $foo = null, $bar) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataTest.php deleted file mode 100644 index 05351445e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/ControllerMetadata/ArgumentMetadataTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\ControllerMetadata; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; - -class ArgumentMetadataTest extends TestCase -{ - public function testWithBcLayerWithDefault() - { - $argument = new ArgumentMetadata('foo', 'string', false, true, 'default value'); - - $this->assertFalse($argument->isNullable()); - } - - public function testDefaultValueAvailable() - { - $argument = new ArgumentMetadata('foo', 'string', false, true, 'default value', true); - - $this->assertTrue($argument->isNullable()); - $this->assertTrue($argument->hasDefaultValue()); - $this->assertSame('default value', $argument->getDefaultValue()); - } - - /** - * @expectedException \LogicException - */ - public function testDefaultValueUnavailable() - { - $argument = new ArgumentMetadata('foo', 'string', false, false, null, false); - - $this->assertFalse($argument->isNullable()); - $this->assertFalse($argument->hasDefaultValue()); - $argument->getDefaultValue(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log deleted file mode 100644 index 88b6840ea..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log +++ /dev/null @@ -1,4 +0,0 @@ -Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass: Removed service "Psr\Container\ContainerInterface"; reason: private alias. -Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass: Removed service "Symfony\Component\DependencyInjection\ContainerInterface"; reason: private alias. -Some custom logging message -With ending : diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ConfigDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ConfigDataCollectorTest.php deleted file mode 100644 index 4fb36afda..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class ConfigDataCollectorTest extends TestCase -{ - public function testCollect() - { - $kernel = new KernelForTest('test', true); - $c = new ConfigDataCollector(); - $c->setKernel($kernel); - $c->collect(new Request(), new Response()); - - $this->assertSame('test', $c->getEnv()); - $this->assertTrue($c->isDebug()); - $this->assertSame('config', $c->getName()); - $this->assertSame('testkernel', $c->getAppName()); - $this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); - $this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); - $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); - $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); - $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); - $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); - $this->assertNull($c->getToken()); - $this->assertSame(extension_loaded('xdebug'), $c->hasXDebug()); - $this->assertSame(extension_loaded('Zend OPcache') && ini_get('opcache.enable'), $c->hasZendOpcache()); - $this->assertSame(extension_loaded('apcu') && ini_get('apc.enabled'), $c->hasApcu()); - } -} - -class KernelForTest extends Kernel -{ - public function getName() - { - return 'testkernel'; - } - - public function registerBundles() - { - } - - public function getBundles() - { - return array(); - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DataCollectorTest.php deleted file mode 100644 index 54fd39e0d..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DataCollectorTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Fixtures\DataCollector\CloneVarDataCollector; -use Symfony\Component\VarDumper\Cloner\VarCloner; - -class DataCollectorTest extends TestCase -{ - public function testCloneVarStringWithScheme() - { - $c = new CloneVarDataCollector('scheme://foo'); - $c->collect(new Request(), new Response()); - $cloner = new VarCloner(); - - $this->assertEquals($cloner->cloneVar('scheme://foo'), $c->getData()); - } - - public function testCloneVarExistingFilePath() - { - $c = new CloneVarDataCollector(array($filePath = tempnam(sys_get_temp_dir(), 'clone_var_data_collector_'))); - $c->collect(new Request(), new Response()); - - $this->assertSame($filePath, $c->getData()[0]); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php deleted file mode 100644 index fc4b92b53..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\VarDumper\Cloner\Data; - -/** - * @author Nicolas Grekas - */ -class DumpDataCollectorTest extends TestCase -{ - public function testDump() - { - $data = new Data(array(array(123))); - - $collector = new DumpDataCollector(); - - $this->assertSame('dump', $collector->getName()); - - $collector->dump($data); - $line = __LINE__ - 1; - $this->assertSame(1, $collector->getDumpsCount()); - - $dump = $collector->getDumps('html'); - $this->assertArrayHasKey('data', $dump[0]); - $dump[0]['data'] = preg_replace('/^.*?
 "
123\n
\n", - 'name' => 'DumpDataCollectorTest.php', - 'file' => __FILE__, - 'line' => $line, - 'fileExcerpt' => false, - ), - ); - $this->assertEquals($xDump, $dump); - - $this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize()); - $this->assertSame(0, $collector->getDumpsCount()); - $this->assertSame('a:2:{i:0;b:0;i:1;s:5:"UTF-8";}', $collector->serialize()); - } - - public function testCollectDefault() - { - $data = new Data(array(array(123))); - - $collector = new DumpDataCollector(); - - $collector->dump($data); - $line = __LINE__ - 1; - - ob_start(); - $collector->collect(new Request(), new Response()); - $output = ob_get_clean(); - - $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output); - $this->assertSame(1, $collector->getDumpsCount()); - $collector->serialize(); - } - - public function testCollectHtml() - { - $data = new Data(array(array(123))); - - $collector = new DumpDataCollector(null, 'test://%f:%l'); - - $collector->dump($data); - $line = __LINE__ - 1; - $file = __FILE__; - $xOutput = <<DumpDataCollectorTest.php on line {$line}: -123 -
-EOTXT; - - ob_start(); - $response = new Response(); - $response->headers->set('Content-Type', 'text/html'); - $collector->collect(new Request(), $response); - $output = ob_get_clean(); - $output = preg_replace('#<(script|style).*?#s', '', $output); - $output = preg_replace('/sf-dump-\d+/', 'sf-dump', $output); - - $this->assertSame($xOutput, trim($output)); - $this->assertSame(1, $collector->getDumpsCount()); - $collector->serialize(); - } - - public function testFlush() - { - $data = new Data(array(array(456))); - $collector = new DumpDataCollector(); - $collector->dump($data); - $line = __LINE__ - 1; - - ob_start(); - $collector->__destruct(); - $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ExceptionDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ExceptionDataCollectorTest.php deleted file mode 100644 index 178f1f01a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/ExceptionDataCollectorTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class ExceptionDataCollectorTest extends TestCase -{ - public function testCollect() - { - $e = new \Exception('foo', 500); - $c = new ExceptionDataCollector(); - $flattened = FlattenException::create($e); - $trace = $flattened->getTrace(); - - $this->assertFalse($c->hasException()); - - $c->collect(new Request(), new Response(), $e); - - $this->assertTrue($c->hasException()); - $this->assertEquals($flattened, $c->getException()); - $this->assertSame('foo', $c->getMessage()); - $this->assertSame(500, $c->getCode()); - $this->assertSame('exception', $c->getName()); - $this->assertSame($trace, $c->getTrace()); - } - - public function testCollectWithoutException() - { - $c = new ExceptionDataCollector(); - $c->collect(new Request(), new Response()); - - $this->assertFalse($c->hasException()); - } - - public function testReset() - { - $c = new ExceptionDataCollector(); - - $c->collect(new Request(), new Response(), new \Exception()); - $c->reset(); - $c->collect(new Request(), new Response()); - - $this->assertFalse($c->hasException()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/LoggerDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/LoggerDataCollectorTest.php deleted file mode 100644 index 3dec3bd7f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\Debug\Exception\SilencedErrorContext; -use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector; - -class LoggerDataCollectorTest extends TestCase -{ - public function testCollectWithUnexpectedFormat() - { - $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') - ->setMethods(array('countErrors', 'getLogs', 'clear')) - ->getMock(); - $logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo')); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue(array())); - - $c = new LoggerDataCollector($logger, __DIR__.'/'); - $c->lateCollect(); - $compilerLogs = $c->getCompilerLogs()->getValue('message'); - - $this->assertSame(array( - array('message' => 'Removed service "Psr\Container\ContainerInterface"; reason: private alias.'), - array('message' => 'Removed service "Symfony\Component\DependencyInjection\ContainerInterface"; reason: private alias.'), - ), $compilerLogs['Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass']); - - $this->assertSame(array( - array('message' => 'Some custom logging message'), - array('message' => 'With ending :'), - ), $compilerLogs['Unknown Compiler Pass']); - } - - /** - * @dataProvider getCollectTestData - */ - public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null) - { - $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') - ->setMethods(array('countErrors', 'getLogs', 'clear')) - ->getMock(); - $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); - - $c = new LoggerDataCollector($logger); - $c->lateCollect(); - - $this->assertEquals('logger', $c->getName()); - $this->assertEquals($nb, $c->countErrors()); - - $logs = array_map(function ($v) { - if (isset($v['context']['exception'])) { - $e = &$v['context']['exception']; - $e = isset($e["\0*\0message"]) ? array($e["\0*\0message"], $e["\0*\0severity"]) : array($e["\0Symfony\Component\Debug\Exception\SilencedErrorContext\0severity"]); - } - - return $v; - }, $c->getLogs()->getValue(true)); - $this->assertEquals($expectedLogs, $logs); - $this->assertEquals($expectedDeprecationCount, $c->countDeprecations()); - $this->assertEquals($expectedScreamCount, $c->countScreams()); - - if (isset($expectedPriorities)) { - $this->assertSame($expectedPriorities, $c->getPriorities()->getValue(true)); - } - } - - public function testReset() - { - $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') - ->setMethods(array('countErrors', 'getLogs', 'clear')) - ->getMock(); - $logger->expects($this->once())->method('clear'); - - $c = new LoggerDataCollector($logger); - $c->reset(); - } - - public function getCollectTestData() - { - yield 'simple log' => array( - 1, - array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')), - 0, - 0, - ); - - yield 'log with a context' => array( - 1, - array(array('message' => 'foo', 'context' => array('foo' => 'bar'), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo', 'context' => array('foo' => 'bar'), 'priority' => 100, 'priorityName' => 'DEBUG')), - 0, - 0, - ); - - if (!class_exists(SilencedErrorContext::class)) { - return; - } - - yield 'logs with some deprecations' => array( - 1, - array( - array('message' => 'foo3', 'context' => array('exception' => new \ErrorException('warning', 0, E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo', 'context' => array('exception' => new \ErrorException('deprecated', 0, E_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo2', 'context' => array('exception' => new \ErrorException('deprecated', 0, E_USER_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG'), - ), - array( - array('message' => 'foo3', 'context' => array('exception' => array('warning', E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo', 'context' => array('exception' => array('deprecated', E_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false), - array('message' => 'foo2', 'context' => array('exception' => array('deprecated', E_USER_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false), - ), - 2, - 0, - array(100 => array('count' => 3, 'name' => 'DEBUG')), - ); - - yield 'logs with some silent errors' => array( - 1, - array( - array('message' => 'foo3', 'context' => array('exception' => new \ErrorException('warning', 0, E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo3', 'context' => array('exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)), 'priority' => 100, 'priorityName' => 'DEBUG'), - ), - array( - array('message' => 'foo3', 'context' => array('exception' => array('warning', E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo3', 'context' => array('exception' => array(E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true), - ), - 0, - 1, - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/MemoryDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/MemoryDataCollectorTest.php deleted file mode 100644 index ab78e9e8e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/MemoryDataCollectorTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class MemoryDataCollectorTest extends TestCase -{ - public function testCollect() - { - $collector = new MemoryDataCollector(); - $collector->collect(new Request(), new Response()); - - $this->assertInternalType('integer', $collector->getMemory()); - $this->assertInternalType('integer', $collector->getMemoryLimit()); - $this->assertSame('memory', $collector->getName()); - } - - /** @dataProvider getBytesConversionTestData */ - public function testBytesConversion($limit, $bytes) - { - $collector = new MemoryDataCollector(); - $method = new \ReflectionMethod($collector, 'convertToBytes'); - $method->setAccessible(true); - $this->assertEquals($bytes, $method->invoke($collector, $limit)); - } - - public function getBytesConversionTestData() - { - return array( - array('2k', 2048), - array('2 k', 2048), - array('8m', 8 * 1024 * 1024), - array('+2 k', 2048), - array('+2???k', 2048), - array('0x10', 16), - array('0xf', 15), - array('010', 8), - array('+0x10 k', 16 * 1024), - array('1g', 1024 * 1024 * 1024), - array('1G', 1024 * 1024 * 1024), - array('-1', -1), - array('0', 0), - array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm' - ); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php deleted file mode 100644 index 69bef76d4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php +++ /dev/null @@ -1,334 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -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 TestCase -{ - public function testCollect() - { - $c = new RequestDataCollector(); - - $c->collect($request = $this->createRequest(), $this->createResponse()); - $c->lateCollect(); - - $attributes = $c->getRequestAttributes(); - - $this->assertSame('request', $c->getName()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestHeaders()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery()); - $this->assertInstanceOf(ParameterBag::class, $c->getResponseCookies()); - $this->assertSame('html', $c->getFormat()); - $this->assertEquals('foobar', $c->getRoute()); - $this->assertEquals(array('name' => 'foo'), $c->getRouteParams()); - $this->assertSame(array(), $c->getSessionAttributes()); - $this->assertSame('en', $c->getLocale()); - $this->assertContains(__FILE__, $attributes->get('resource')); - $this->assertSame('stdClass', $attributes->get('object')->getType()); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders()); - $this->assertSame('OK', $c->getStatusText()); - $this->assertSame(200, $c->getStatusCode()); - $this->assertSame('application/json', $c->getContentType()); - } - - public function testCollectWithoutRouteParams() - { - $request = $this->createRequest(array()); - - $c = new RequestDataCollector(); - $c->collect($request, $this->createResponse()); - $c->lateCollect(); - - $this->assertEquals(array(), $c->getRouteParams()); - } - - /** - * @dataProvider provideControllerCallables - */ - public function testControllerInspection($name, $callable, $expected) - { - $c = new RequestDataCollector(); - $request = $this->createRequest(); - $response = $this->createResponse(); - $this->injectController($c, $callable, $request); - $c->collect($request, $response); - $c->lateCollect(); - - $this->assertSame($expected, $c->getController()->getValue(true), sprintf('Testing: %s', $name)); - } - - public function provideControllerCallables() - { - // make sure we always match the line number - $r1 = new \ReflectionMethod($this, 'testControllerInspection'); - $r2 = new \ReflectionMethod($this, 'staticControllerMethod'); - $r3 = new \ReflectionClass($this); - - // test name, callable, expected - return array( - array( - '"Regular" callable', - array($this, 'testControllerInspection'), - array( - 'class' => __NAMESPACE__.'\RequestDataCollectorTest', - 'method' => 'testControllerInspection', - 'file' => __FILE__, - 'line' => $r1->getStartLine(), - ), - ), - - array( - 'Closure', - function () { return 'foo'; }, - array( - 'class' => __NAMESPACE__.'\{closure}', - 'method' => null, - 'file' => __FILE__, - 'line' => __LINE__ - 5, - ), - ), - - array( - 'Static callback as string', - __NAMESPACE__.'\RequestDataCollectorTest::staticControllerMethod', - array( - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', - 'method' => 'staticControllerMethod', - 'file' => __FILE__, - 'line' => $r2->getStartLine(), - ), - ), - - 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', - ), - ), - - array( - 'Invokable controller', - $this, - array( - 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', - 'method' => null, - 'file' => __FILE__, - 'line' => $r3->getStartLine(), - ), - ), - ); - } - - public function testItIgnoresInvalidCallables() - { - $request = $this->createRequestWithSession(); - $response = new RedirectResponse('/'); - - $c = new RequestDataCollector(); - $c->collect($request, $response); - - $this->assertSame('n/a', $c->getController()); - } - - public function testItAddsRedirectedAttributesWhenRequestContainsSpecificCookie() - { - $request = $this->createRequest(); - $request->cookies->add(array( - 'sf_redirect' => '{}', - )); - - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); - - $c = new RequestDataCollector(); - $c->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $this->createResponse())); - - $this->assertTrue($request->attributes->get('_redirected')); - } - - public function testItSetsARedirectCookieIfTheResponseIsARedirection() - { - $c = new RequestDataCollector(); - - $response = $this->createResponse(); - $response->setStatusCode(302); - $response->headers->set('Location', '/somewhere-else'); - - $c->collect($request = $this->createRequest(), $response); - $c->lateCollect(); - - $cookie = $this->getCookieByName($response, 'sf_redirect'); - - $this->assertNotEmpty($cookie->getValue()); - } - - public function testItCollectsTheRedirectionAndClearTheCookie() - { - $c = new RequestDataCollector(); - - $request = $this->createRequest(); - $request->attributes->set('_redirected', true); - $request->cookies->add(array( - 'sf_redirect' => '{"method": "POST"}', - )); - - $c->collect($request, $response = $this->createResponse()); - $c->lateCollect(); - - $this->assertEquals('POST', $c->getRedirect()['method']); - - $cookie = $this->getCookieByName($response, 'sf_redirect'); - $this->assertNull($cookie->getValue()); - } - - protected function createRequest($routeParams = array('name' => 'foo')) - { - $request = Request::create('http://test.com/foo?bar=baz'); - $request->attributes->set('foo', 'bar'); - $request->attributes->set('_route', 'foobar'); - $request->attributes->set('_route_params', $routeParams); - $request->attributes->set('resource', fopen(__FILE__, 'r')); - $request->attributes->set('object', new \stdClass()); - - return $request; - } - - private function createRequestWithSession() - { - $request = $this->createRequest(); - $request->attributes->set('_controller', 'Foo::bar'); - $request->setSession(new Session(new MockArraySessionStorage())); - $request->getSession()->start(); - - return $request; - } - - protected function createResponse() - { - $response = new Response(); - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'application/json'); - $response->headers->set('X-Foo-Bar', null); - $response->headers->setCookie(new Cookie('foo', 'bar', 1, '/foo', 'localhost', true, true)); - $response->headers->setCookie(new Cookie('bar', 'foo', new \DateTime('@946684800'))); - $response->headers->setCookie(new Cookie('bazz', 'foo', '2000-12-12')); - - return $response; - } - - /** - * Inject the given controller callable into the data collector. - */ - protected function injectController($collector, $controller, $request) - { - $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); - $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock()); - $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'); - } - - public function __invoke() - { - throw new \LogicException('Unexpected method call'); - } - - private function getCookieByName(Response $response, $name) - { - foreach ($response->headers->getCookies() as $cookie) { - if ($cookie->getName() == $name) { - return $cookie; - } - } - - throw new \InvalidArgumentException(sprintf('Cookie named "%s" is not in response', $name)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/TimeDataCollectorTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/TimeDataCollectorTest.php deleted file mode 100644 index 8048cc37a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/TimeDataCollectorTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * @group time-sensitive - */ -class TimeDataCollectorTest extends TestCase -{ - public function testCollect() - { - $c = new TimeDataCollector(); - - $request = new Request(); - $request->server->set('REQUEST_TIME', 1); - - $c->collect($request, new Response()); - - $this->assertEquals(0, $c->getStartTime()); - - $request->server->set('REQUEST_TIME_FLOAT', 2); - - $c->collect($request, new Response()); - - $this->assertEquals(2000, $c->getStartTime()); - - $request = new Request(); - $c->collect($request, new Response()); - $this->assertEquals(0, $c->getStartTime()); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); - $kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456)); - - $c = new TimeDataCollector($kernel); - $request = new Request(); - $request->server->set('REQUEST_TIME', 1); - - $c->collect($request, new Response()); - $this->assertEquals(123456000, $c->getStartTime()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Util/ValueExporterTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Util/ValueExporterTest.php deleted file mode 100644 index 5fe92d60e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DataCollector/Util/ValueExporterTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * 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\Util; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; - -/** - * @group legacy - */ -class ValueExporterTest extends TestCase -{ - /** - * @var ValueExporter - */ - private $valueExporter; - - protected function setUp() - { - $this->valueExporter = new ValueExporter(); - } - - public function testDateTime() - { - $dateTime = new \DateTime('2014-06-10 07:35:40', new \DateTimeZone('UTC')); - $this->assertSame('Object(DateTime) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime)); - } - - public function testDateTimeImmutable() - { - $dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC')); - $this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime)); - } - - public function testIncompleteClass() - { - $foo = new \__PHP_Incomplete_Class(); - $array = new \ArrayObject($foo); - $array['__PHP_Incomplete_Class_Name'] = 'AppBundle/Foo'; - $this->assertSame('__PHP_Incomplete_Class(AppBundle/Foo)', $this->valueExporter->exportValue($foo)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php deleted file mode 100644 index d616098a5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; - -class FileLinkFormatterTest extends TestCase -{ - public function testWhenNoFileLinkFormatAndNoRequest() - { - $sut = new FileLinkFormatter(); - - $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3)); - } - - public function testWhenFileLinkFormatAndNoRequest() - { - $file = __DIR__.DIRECTORY_SEPARATOR.'file.php'; - - $sut = new FileLinkFormatter('debug://open?url=file://%f&line=%l', new RequestStack()); - - $this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3)); - } - - public function testWhenFileLinkFormatAndRequest() - { - $file = __DIR__.DIRECTORY_SEPARATOR.'file.php'; - $baseDir = __DIR__; - $requestStack = new RequestStack(); - $request = new Request(); - $requestStack->push($request); - - $sut = new FileLinkFormatter('debug://open?url=file://%f&line=%l', $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); - - $this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3)); - } - - public function testWhenNoFileLinkFormatAndRequest() - { - $file = __DIR__.DIRECTORY_SEPARATOR.'file.php'; - $requestStack = new RequestStack(); - $request = new Request(); - $requestStack->push($request); - - $request->server->set('SERVER_NAME', 'www.example.org'); - $request->server->set('SERVER_PORT', 80); - $request->server->set('SCRIPT_NAME', '/app.php'); - $request->server->set('SCRIPT_FILENAME', '/web/app.php'); - $request->server->set('REQUEST_URI', '/app.php/example'); - - $sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); - - $this->assertSame('http://www.example.org/app.php/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php deleted file mode 100644 index aaa82d524..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * 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 PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpFoundation\RequestStack; -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 TestCase -{ - 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.controller', - 'kernel.controller_arguments', - 'controller', - 'kernel.response', - 'kernel.terminate', - ), array_keys($events)); - } - - public function testStopwatchCheckControllerOnRequestEvent() - { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') - ->setMethods(array('isStarted')) - ->getMock(); - $stopwatch->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(false)); - - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch); - - $kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); }); - $request = Request::create('/'); - $kernel->handle($request); - } - - public function testStopwatchStopControllerOnRequestEvent() - { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') - ->setMethods(array('isStarted', 'stop', 'stopSection')) - ->getMock(); - $stopwatch->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(true)); - $stopwatch->expects($this->once()) - ->method('stop'); - $stopwatch->expects($this->once()) - ->method('stopSection'); - - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch); - - $kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); }); - $request = Request::create('/'); - $kernel->handle($request); - } - - public function testAddListenerNested() - { - $called1 = false; - $called2 = false; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('my-event', function () use ($dispatcher, &$called1, &$called2) { - $called1 = true; - $dispatcher->addListener('my-event', function () use (&$called2) { - $called2 = true; - }); - }); - $dispatcher->dispatch('my-event'); - $this->assertTrue($called1); - $this->assertFalse($called2); - $dispatcher->dispatch('my-event'); - $this->assertTrue($called2); - } - - public function testListenerCanRemoveItselfWhenExecuted() - { - $eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $listener1 = function () use ($eventDispatcher, &$listener1) { - $eventDispatcher->removeListener('foo', $listener1); - }; - $eventDispatcher->addListener('foo', $listener1); - $eventDispatcher->addListener('foo', function () {}); - $eventDispatcher->dispatch('foo'); - - $this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed'); - } - - protected function getHttpKernel($dispatcher, $controller) - { - $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); - $controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); - $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); - $argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue(array())); - - return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php deleted file mode 100644 index a2fb6afca..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; - -class AddAnnotatedClassesToCachePassTest extends TestCase -{ - public function testExpandClasses() - { - $r = new \ReflectionClass(AddAnnotatedClassesToCachePass::class); - $pass = $r->newInstanceWithoutConstructor(); - $r = new \ReflectionMethod(AddAnnotatedClassesToCachePass::class, 'expandClasses'); - $r->setAccessible(true); - $expand = $r->getClosure($pass); - - $this->assertSame('Foo', $expand(array('Foo'), array())[0]); - $this->assertSame('Foo', $expand(array('\\Foo'), array())[0]); - $this->assertSame('Foo', $expand(array('Foo'), array('\\Foo'))[0]); - $this->assertSame('Foo', $expand(array('Foo'), array('Foo'))[0]); - $this->assertSame('Foo', $expand(array('\\Foo'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo', $expand(array('Foo'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo', $expand(array('\\Foo'), array('\\Foo\\Bar\\Acme'))[0]); - - $this->assertSame('Foo\\Bar', $expand(array('Foo\\'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo\\Bar\\Acme', $expand(array('Foo\\'), array('\\Foo\\Bar\\Acme'))[0]); - $this->assertEmpty($expand(array('Foo\\'), array('\\Foo'))); - - $this->assertSame('Acme\\Foo\\Bar', $expand(array('**\\Foo\\'), array('\\Acme\\Foo\\Bar'))[0]); - $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo\\Bar'))); - $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Acme\\Foo'))); - $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo'))); - - $this->assertSame('Acme\\Foo', $expand(array('**\\Foo'), array('\\Acme\\Foo'))[0]); - $this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\Foo\\AcmeBundle'))); - $this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\FooBar\\AcmeBundle'))); - - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bar'))[0]); - $this->assertEmpty($expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))); - - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]); - $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]); - - $this->assertSame('Acme\\Bar', $expand(array('*\\Bar'), array('\\Acme\\Bar'))[0]); - $this->assertEmpty($expand(array('*\\Bar'), array('\\Bar'))); - $this->assertEmpty($expand(array('*\\Bar'), array('\\Foo\\Acme\\Bar'))); - - $this->assertSame('Foo\\Acme\\Bar', $expand(array('**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]); - $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(array('**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]); - $this->assertEmpty($expand(array('**\\Bar'), array('\\Bar'))); - - $this->assertSame('Foo\\Bar', $expand(array('Foo\\*'), array('\\Foo\\Bar'))[0]); - $this->assertEmpty($expand(array('Foo\\*'), array('\\Foo\\Acme\\Bar'))); - - $this->assertSame('Foo\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]); - - $this->assertSame(array('Foo\\Bar'), $expand(array('Foo\\*'), array('Foo\\Bar', 'Foo\\BarTest'))); - $this->assertSame(array('Foo\\Bar', 'Foo\\BarTest'), $expand(array('Foo\\*', 'Foo\\*Test'), array('Foo\\Bar', 'Foo\\BarTest'))); - - $this->assertSame( - 'Acme\\FooBundle\\Controller\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\DefaultController'))[0] - ); - - $this->assertSame( - 'FooBundle\\Controller\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\FooBundle\\Controller\\DefaultController'))[0] - ); - - $this->assertSame( - 'Acme\\FooBundle\\Controller\\Bar\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\Bar\\DefaultController'))[0] - ); - - $this->assertSame( - 'Bundle\\Controller\\Bar\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Bundle\\Controller\\Bar\\DefaultController'))[0] - ); - - $this->assertSame( - 'Acme\\Bundle\\Controller\\Bar\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Acme\\Bundle\\Controller\\Bar\\DefaultController'))[0] - ); - - $this->assertSame('Foo\\Bar', $expand(array('Foo\\Bar'), array())[0]); - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php deleted file mode 100644 index df8977de0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver; -use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass; - -class ControllerArgumentValueResolverPassTest extends TestCase -{ - public function testServicesAreOrderedAccordingToPriority() - { - $services = array( - 'n3' => array(array()), - 'n1' => array(array('priority' => 200)), - 'n2' => array(array('priority' => 100)), - ); - - $expected = array( - new Reference('n1'), - new Reference('n2'), - new Reference('n3'), - ); - - $definition = new Definition(ArgumentResolver::class, array(null, array())); - $container = new ContainerBuilder(); - $container->setDefinition('argument_resolver', $definition); - - foreach ($services as $id => list($tag)) { - $container->register($id)->addTag('controller.argument_value_resolver', $tag); - } - - (new ControllerArgumentValueResolverPass())->process($container); - $this->assertEquals($expected, $definition->getArgument(1)->getValues()); - } - - public function testReturningEmptyArrayWhenNoService() - { - $definition = new Definition(ArgumentResolver::class, array(null, array())); - $container = new ContainerBuilder(); - $container->setDefinition('argument_resolver', $definition); - - (new ControllerArgumentValueResolverPass())->process($container); - $this->assertEquals(array(), $definition->getArgument(1)->getValues()); - } - - public function testNoArgumentResolver() - { - $container = new ContainerBuilder(); - - (new ControllerArgumentValueResolverPass())->process($container); - - $this->assertFalse($container->hasDefinition('argument_resolver')); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/FragmentRendererPassTest.php deleted file mode 100644 index d28c6eca5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/FragmentRendererPassTest.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\DependencyInjection\FragmentRendererPass; -use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface; - -class FragmentRendererPassTest extends TestCase -{ - /** - * Tests that content rendering not implementing FragmentRendererInterface - * trigger an exception. - * - * @expectedException \InvalidArgumentException - */ - public function testContentRendererWithoutInterface() - { - // one service, not implementing any interface - $services = array( - 'my_content_renderer' => array(array('alias' => 'foo')), - ); - - $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - - $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock(); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.fragment_renderer here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->returnValue($services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $pass = new FragmentRendererPass(); - $pass->process($builder); - } - - public function testValidContentRenderer() - { - $services = array( - 'my_content_renderer' => array(array('alias' => 'foo')), - ); - - $renderer = new Definition('', array(null)); - - $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock(); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService')); - - $builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'getReflectionClass'))->getMock(); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.fragment_renderer here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->returnValue($services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->onConsecutiveCalls($renderer, $definition)); - - $builder->expects($this->atLeastOnce()) - ->method('getReflectionClass') - ->with('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService') - ->will($this->returnValue(new \ReflectionClass('Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService'))); - - $pass = new FragmentRendererPass(); - $pass->process($builder); - - $this->assertInstanceOf(Reference::class, $renderer->getArgument(0)); - } -} - -class RendererService implements FragmentRendererInterface -{ - public function render($uri, Request $request = null, array $options = array()) - { - } - - public function getName() - { - return 'test'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php deleted file mode 100644 index 730214837..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class LazyLoadingFragmentHandlerTest extends TestCase -{ - /** - * @group legacy - * @expectedDeprecation The Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler::addRendererService() method is deprecated since Symfony 3.3 and will be removed in 4.0. - */ - public function testRenderWithLegacyMapping() - { - $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); - $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); - $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); - - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); - - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); - - $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); - $handler->addRendererService('foo', 'foo'); - - $handler->render('/foo', 'foo'); - - // second call should not lazy-load anymore (see once() above on the get() method) - $handler->render('/foo', 'foo'); - } - - public function testRender() - { - $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); - $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); - $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); - - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); - - $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); - $container->expects($this->once())->method('has')->with('foo')->willReturn(true); - $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); - - $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); - - $handler->render('/foo', 'foo'); - - // second call should not lazy-load anymore (see once() above on the get() method) - $handler->render('/foo', 'foo'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LoggerPassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LoggerPassTest.php deleted file mode 100644 index b199e11da..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/LoggerPassTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass; -use Symfony\Component\HttpKernel\Log\Logger; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * @author Kévin Dunglas - */ -class LoggerPassTest extends TestCase -{ - public function testAlwaysSetAutowiringAlias() - { - $container = new ContainerBuilder(); - $container->register('logger', 'Foo'); - - (new LoggerPass())->process($container); - - $this->assertFalse($container->getAlias(LoggerInterface::class)->isPublic()); - } - - public function testDoNotOverrideExistingLogger() - { - $container = new ContainerBuilder(); - $container->register('logger', 'Foo'); - - (new LoggerPass())->process($container); - - $this->assertSame('Foo', $container->getDefinition('logger')->getClass()); - } - - public function testRegisterLogger() - { - $container = new ContainerBuilder(); - $container->setParameter('kernel.debug', false); - - (new LoggerPass())->process($container); - - $definition = $container->getDefinition('logger'); - $this->assertSame(Logger::class, $definition->getClass()); - $this->assertFalse($definition->isPublic()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php deleted file mode 100644 index 81fc8b455..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; - -class MergeExtensionConfigurationPassTest extends TestCase -{ - public function testAutoloadMainExtension() - { - $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->setMethods(array('getExtensionConfig', 'loadFromExtension', 'getParameterBag', 'getDefinitions', 'getAliases', 'getExtensions'))->getMock(); - $params = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag')->getMock(); - - $container->expects($this->at(0)) - ->method('getExtensionConfig') - ->with('loaded') - ->will($this->returnValue(array(array()))); - $container->expects($this->at(1)) - ->method('getExtensionConfig') - ->with('notloaded') - ->will($this->returnValue(array())); - $container->expects($this->once()) - ->method('loadFromExtension') - ->with('notloaded', array()); - - $container->expects($this->any()) - ->method('getParameterBag') - ->will($this->returnValue($params)); - $params->expects($this->any()) - ->method('all') - ->will($this->returnValue(array())); - $container->expects($this->any()) - ->method('getDefinitions') - ->will($this->returnValue(array())); - $container->expects($this->any()) - ->method('getAliases') - ->will($this->returnValue(array())); - $container->expects($this->any()) - ->method('getExtensions') - ->will($this->returnValue(array())); - - $configPass = new MergeExtensionConfigurationPass(array('loaded', 'notloaded')); - $configPass->process($container); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php deleted file mode 100644 index 4016deb4a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ /dev/null @@ -1,389 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\ServiceLocator; -use Symfony\Component\DependencyInjection\TypedReference; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass; - -class RegisterControllerArgumentLocatorsPassTest extends TestCase -{ - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found. - */ - public function testInvalidClass() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', NotFound::class) - ->addTag('controller.service_arguments') - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo". - */ - public function testNoAction() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('argument' => 'bar')) - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo". - */ - public function testNoArgument() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction')) - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo". - */ - public function testNoService() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar')) - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController". - */ - public function testInvalidMethod() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'barAction', 'argument' => 'bar', 'id' => 'bar_service')) - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController". - */ - public function testInvalidArgument() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'baz', 'id' => 'bar')) - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - public function testAllActions() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments') - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - - $this->assertEquals(array('foo:fooAction'), array_keys($locator)); - $this->assertInstanceof(ServiceClosureArgument::class, $locator['foo:fooAction']); - - $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); - - $this->assertSame(ServiceLocator::class, $locator->getClass()); - $this->assertFalse($locator->isPublic()); - - $expected = array('bar' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, RegisterTestController::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE))); - $this->assertEquals($expected, $locator->getArgument(0)); - } - - public function testExplicitArgument() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => 'bar')) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => 'baz')) // should be ignored, the first wins - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); - - $expected = array('bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, RegisterTestController::class))); - $this->assertEquals($expected, $locator->getArgument(0)); - } - - public function testOptionalArgument() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => '?bar')) - ; - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); - - $expected = array('bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, RegisterTestController::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE))); - $this->assertEquals($expected, $locator->getArgument(0)); - } - - public function testSkipSetContainer() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', ContainerAwareRegisterTestController::class) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertSame(array('foo:fooAction'), array_keys($locator)); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement? - */ - public function testExceptionOnNonExistentTypeHint() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', NonExistentClassController::class) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException - * @expectedExceptionMessage Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass". - */ - public function testExceptionOnNonExistentTypeHintDifferentNamespace() - { - $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', NonExistentClassDifferentNamespaceController::class) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - } - - public function testNoExceptionOnNonExistentTypeHintOptionalArg() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', NonExistentClassOptionalController::class) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertSame(array('foo:barAction', 'foo:fooAction'), array_keys($locator)); - } - - public function testArgumentWithNoTypeHintIsOk() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', ArgumentWithoutTypeController::class) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertEmpty(array_keys($locator)); - } - - public function testControllersAreMadePublic() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', ArgumentWithoutTypeController::class) - ->setPublic(false) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $this->assertTrue($container->getDefinition('foo')->isPublic()); - } - - /** - * @dataProvider provideBindings - */ - public function testBindings($bindingName) - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', RegisterTestController::class) - ->setBindings(array($bindingName => new Reference('foo'))) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - - $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); - - $expected = array('bar' => new ServiceClosureArgument(new Reference('foo'))); - $this->assertEquals($expected, $locator->getArgument(0)); - } - - public function provideBindings() - { - return array(array(ControllerDummy::class), array('$bar')); - } - - public function testDoNotBindScalarValueToControllerArgument() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('foo', ArgumentWithoutTypeController::class) - ->setBindings(array('$someArg' => '%foo%')) - ->addTag('controller.service_arguments'); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertEmpty($locator); - } -} - -class RegisterTestController -{ - public function __construct(ControllerDummy $bar) - { - } - - public function fooAction(ControllerDummy $bar) - { - } - - protected function barAction(ControllerDummy $bar) - { - } -} - -class ContainerAwareRegisterTestController implements ContainerAwareInterface -{ - use ContainerAwareTrait; - - public function fooAction(ControllerDummy $bar) - { - } -} - -class ControllerDummy -{ -} - -class NonExistentClassController -{ - public function fooAction(NonExistentClass $nonExistent) - { - } -} - -class NonExistentClassDifferentNamespaceController -{ - public function fooAction(\Acme\NonExistentClass $nonExistent) - { - } -} - -class NonExistentClassOptionalController -{ - public function fooAction(NonExistentClass $nonExistent = null) - { - } - - public function barAction(NonExistentClass $nonExistent = null, $bar) - { - } -} - -class ArgumentWithoutTypeController -{ - public function fooAction($someArg) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php deleted file mode 100644 index 9cac96818..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Compiler\ResolveInvalidReferencesPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass; -use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass; - -class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase -{ - public function testProcess() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('stdClass', 'stdClass'); - $container->register(parent::class, 'stdClass'); - $container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments'); - $container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments') - ->addMethodCall('setTestCase', array(new Reference('c1'))); - - $pass = new RegisterControllerArgumentLocatorsPass(); - $pass->process($container); - - $controllers = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - - $this->assertCount(2, $container->getDefinition((string) $controllers['c1:fooAction']->getValues()[0])->getArgument(0)); - $this->assertCount(1, $container->getDefinition((string) $controllers['c2:setTestCase']->getValues()[0])->getArgument(0)); - $this->assertCount(1, $container->getDefinition((string) $controllers['c2:fooAction']->getValues()[0])->getArgument(0)); - - (new ResolveInvalidReferencesPass())->process($container); - - $this->assertCount(1, $container->getDefinition((string) $controllers['c2:setTestCase']->getValues()[0])->getArgument(0)); - $this->assertSame(array(), $container->getDefinition((string) $controllers['c2:fooAction']->getValues()[0])->getArgument(0)); - - (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); - - $controllers = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - - $this->assertSame(array('c1:fooAction'), array_keys($controllers)); - $this->assertSame(array('bar'), array_keys($container->getDefinition((string) $controllers['c1:fooAction']->getValues()[0])->getArgument(0))); - - $expectedLog = array( - 'Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass: Removing service-argument resolver for controller "c2:fooAction": no corresponding services exist for the referenced types.', - 'Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass: Removing method "setTestCase" of service "c2" from controller candidates: the method is called at instantiation, thus cannot be an action.', - ); - - $this->assertSame($expectedLog, $container->getCompiler()->getLog()); - } - - public function testSameIdClass() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register(RegisterTestController::class, RegisterTestController::class) - ->addTag('controller.service_arguments') - ; - - (new RegisterControllerArgumentLocatorsPass())->process($container); - (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); - - $expected = array( - RegisterTestController::class.':fooAction', - RegisterTestController::class.'::fooAction', - ); - $this->assertEquals($expected, array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0))); - } - - public function testInvoke() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register('invokable', InvokableRegisterTestController::class) - ->addTag('controller.service_arguments') - ; - - (new RegisterControllerArgumentLocatorsPass())->process($container); - (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); - - $this->assertEquals( - array('invokable:__invoke', 'invokable'), - array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0)) - ); - } - - public function testInvokeSameIdClass() - { - $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); - - $container->register(InvokableRegisterTestController::class, InvokableRegisterTestController::class) - ->addTag('controller.service_arguments') - ; - - (new RegisterControllerArgumentLocatorsPass())->process($container); - (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); - - $expected = array( - InvokableRegisterTestController::class.':__invoke', - InvokableRegisterTestController::class.'::__invoke', - InvokableRegisterTestController::class, - ); - $this->assertEquals($expected, array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0))); - } -} - -class RemoveTestController1 -{ - public function fooAction(\stdClass $bar, ClassNotInContainer $baz) - { - } -} - -class RemoveTestController2 -{ - public function setTestCase(TestCase $test) - { - } - - public function fooAction(ClassNotInContainer $bar) - { - } -} - -class InvokableRegisterTestController -{ - public function __invoke(\stdClass $bar) - { - } -} - -class ClassNotInContainer -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ResettableServicePassTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ResettableServicePassTest.php deleted file mode 100644 index f7ea16dbf..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ResettableServicePassTest.php +++ /dev/null @@ -1,78 +0,0 @@ -register('one', ResettableService::class) - ->setPublic(true) - ->addTag('kernel.reset', array('method' => 'reset')); - $container->register('two', ClearableService::class) - ->setPublic(true) - ->addTag('kernel.reset', array('method' => 'clear')); - - $container->register('services_resetter', ServicesResetter::class) - ->setPublic(true) - ->setArguments(array(null, array())); - $container->addCompilerPass(new ResettableServicePass()); - - $container->compile(); - - $definition = $container->getDefinition('services_resetter'); - - $this->assertEquals( - array( - new IteratorArgument(array( - 'one' => new Reference('one', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE), - 'two' => new Reference('two', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE), - )), - array( - 'one' => 'reset', - 'two' => 'clear', - ), - ), - $definition->getArguments() - ); - } - - /** - * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException - * @expectedExceptionMessage Tag kernel.reset requires the "method" attribute to be set. - */ - public function testMissingMethod() - { - $container = new ContainerBuilder(); - $container->register(ResettableService::class) - ->addTag('kernel.reset'); - $container->register('services_resetter', ServicesResetter::class) - ->setArguments(array(null, array())); - $container->addCompilerPass(new ResettableServicePass()); - - $container->compile(); - } - - public function testCompilerPassWithoutResetters() - { - $container = new ContainerBuilder(); - $container->register('services_resetter', ServicesResetter::class) - ->setArguments(array(null, array())); - $container->addCompilerPass(new ResettableServicePass()); - - $container->compile(); - - $this->assertFalse($container->has('services_resetter')); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ServicesResetterTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ServicesResetterTest.php deleted file mode 100644 index 47c62abd0..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/DependencyInjection/ServicesResetterTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; -use Symfony\Component\HttpKernel\Tests\Fixtures\ClearableService; -use Symfony\Component\HttpKernel\Tests\Fixtures\ResettableService; - -class ServicesResetterTest extends TestCase -{ - protected function setUp() - { - ResettableService::$counter = 0; - ClearableService::$counter = 0; - } - - public function testResetServices() - { - $resetter = new ServicesResetter(new \ArrayIterator(array( - 'id1' => new ResettableService(), - 'id2' => new ClearableService(), - )), array( - 'id1' => 'reset', - 'id2' => 'clear', - )); - - $resetter->reset(); - - $this->assertEquals(1, ResettableService::$counter); - $this->assertEquals(1, ClearableService::$counter); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php deleted file mode 100644 index 9165d31f2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php +++ /dev/null @@ -1,17 +0,0 @@ -assertEquals($filterController->getArguments(), array('test')); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php deleted file mode 100644 index 724257930..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Event; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Tests\TestHttpKernel; - -class GetResponseForExceptionEventTest extends TestCase -{ - public function testAllowSuccessfulResponseIsFalseByDefault() - { - $event = new GetResponseForExceptionEvent(new TestHttpKernel(), new Request(), 1, new \Exception()); - - $this->assertFalse($event->isAllowingCustomResponseCode()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php deleted file mode 100644 index f4878f626..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * Test AddRequestFormatsListener class. - * - * @author Gildas Quemener - */ -class AddRequestFormatsListenerTest extends TestCase -{ - /** - * @var AddRequestFormatsListener - */ - private $listener; - - protected function setUp() - { - $this->listener = new AddRequestFormatsListener(array('csv' => array('text/csv', 'text/plain'))); - } - - protected function tearDown() - { - $this->listener = null; - } - - public function testIsAnEventSubscriber() - { - $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener); - } - - public function testRegisteredEvent() - { - $this->assertEquals( - array(KernelEvents::REQUEST => array('onKernelRequest', 1)), - AddRequestFormatsListener::getSubscribedEvents() - ); - } - - public function testSetAdditionalFormats() - { - $request = $this->getRequestMock(); - $event = $this->getGetResponseEventMock($request); - - $request->expects($this->once()) - ->method('setFormat') - ->with('csv', array('text/csv', 'text/plain')); - - $this->listener->onKernelRequest($event); - } - - protected function getRequestMock() - { - return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - } - - protected function getGetResponseEventMock(Request $request) - { - $event = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') - ->disableOriginalConstructor() - ->getMock(); - - $event->expects($this->any()) - ->method('getRequest') - ->will($this->returnValue($request)); - - return $event; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php deleted file mode 100644 index 467b8dde8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php +++ /dev/null @@ -1,155 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Psr\Log\LogLevel; -use Symfony\Component\Console\Event\ConsoleEvent; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\Console\Helper\HelperSet; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\KernelEvent; -use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\KernelEvents; - -/** - * @author Nicolas Grekas - */ -class DebugHandlersListenerTest extends TestCase -{ - public function testConfigure() - { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $userHandler = function () {}; - $listener = new DebugHandlersListener($userHandler, $logger); - $xHandler = new ExceptionHandler(); - $eHandler = new ErrorHandler(); - $eHandler->setExceptionHandler(array($xHandler, 'handle')); - - $exception = null; - set_error_handler(array($eHandler, 'handleError')); - set_exception_handler(array($eHandler, 'handleException')); - try { - $listener->configure(); - } catch (\Exception $exception) { - } - restore_exception_handler(); - restore_error_handler(); - - if (null !== $exception) { - throw $exception; - } - - $this->assertSame($userHandler, $xHandler->setHandler('var_dump')); - - $loggers = $eHandler->setLoggers(array()); - - $this->assertArrayHasKey(E_DEPRECATED, $loggers); - $this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]); - } - - public function testConfigureForHttpKernelWithNoTerminateWithException() - { - $listener = new DebugHandlersListener(null); - $eHandler = new ErrorHandler(); - $event = new KernelEvent( - $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), - Request::create('/'), - HttpKernelInterface::MASTER_REQUEST - ); - - $exception = null; - $h = set_exception_handler(array($eHandler, 'handleException')); - try { - $listener->configure($event); - } catch (\Exception $exception) { - } - restore_exception_handler(); - - if (null !== $exception) { - throw $exception; - } - - $this->assertNull($h); - } - - public function testConsoleEvent() - { - $dispatcher = new EventDispatcher(); - $listener = new DebugHandlersListener(null); - $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); - $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet())); - $command = new Command(__FUNCTION__); - $command->setApplication($app); - $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput()); - - $dispatcher->addSubscriber($listener); - - $xListeners = array( - KernelEvents::REQUEST => array(array($listener, 'configure')), - ConsoleEvents::COMMAND => array(array($listener, 'configure')), - ); - $this->assertSame($xListeners, $dispatcher->getListeners()); - - $exception = null; - $eHandler = new ErrorHandler(); - set_error_handler(array($eHandler, 'handleError')); - set_exception_handler(array($eHandler, 'handleException')); - try { - $dispatcher->dispatch(ConsoleEvents::COMMAND, $event); - } catch (\Exception $exception) { - } - restore_exception_handler(); - restore_error_handler(); - - if (null !== $exception) { - throw $exception; - } - - $xHandler = $eHandler->setExceptionHandler('var_dump'); - $this->assertInstanceOf('Closure', $xHandler); - - $app->expects($this->once()) - ->method('renderException'); - - $xHandler(new \Exception()); - } - - public function testReplaceExistingExceptionHandler() - { - $userHandler = function () {}; - $listener = new DebugHandlersListener($userHandler); - $eHandler = new ErrorHandler(); - $eHandler->setExceptionHandler('var_dump'); - - $exception = null; - set_exception_handler(array($eHandler, 'handleException')); - try { - $listener->configure(); - } catch (\Exception $exception) { - } - restore_exception_handler(); - - if (null !== $exception) { - throw $exception; - } - - $this->assertSame($userHandler, $eHandler->setExceptionHandler('var_dump')); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DumpListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DumpListenerTest.php deleted file mode 100644 index 509f44308..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/DumpListenerTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\HttpKernel\EventListener\DumpListener; -use Symfony\Component\VarDumper\Cloner\ClonerInterface; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Dumper\DataDumperInterface; -use Symfony\Component\VarDumper\VarDumper; - -/** - * DumpListenerTest. - * - * @author Nicolas Grekas - */ -class DumpListenerTest extends TestCase -{ - public function testSubscribedEvents() - { - $this->assertSame( - array(ConsoleEvents::COMMAND => array('configure', 1024)), - DumpListener::getSubscribedEvents() - ); - } - - public function testConfigure() - { - $prevDumper = VarDumper::setHandler('var_dump'); - VarDumper::setHandler($prevDumper); - - $cloner = new MockCloner(); - $dumper = new MockDumper(); - - ob_start(); - $exception = null; - $listener = new DumpListener($cloner, $dumper); - - try { - $listener->configure(); - - VarDumper::dump('foo'); - VarDumper::dump('bar'); - - $this->assertSame('+foo-+bar-', ob_get_clean()); - } catch (\Exception $exception) { - } - - VarDumper::setHandler($prevDumper); - - if (null !== $exception) { - throw $exception; - } - } -} - -class MockCloner implements ClonerInterface -{ - public function cloneVar($var) - { - return new Data(array(array($var.'-'))); - } -} - -class MockDumper implements DataDumperInterface -{ - public function dump(Data $data) - { - echo '+'.$data->getValue(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php deleted file mode 100644 index 3cb0b298b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php +++ /dev/null @@ -1,178 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\EventListener\ExceptionListener; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Logger; - -/** - * ExceptionListenerTest. - * - * @author Robert Schönthal - * - * @group time-sensitive - */ -class ExceptionListenerTest extends TestCase -{ - public function testConstruct() - { - $logger = new TestLogger(); - $l = new ExceptionListener('foo', $logger); - - $_logger = new \ReflectionProperty(get_class($l), 'logger'); - $_logger->setAccessible(true); - $_controller = new \ReflectionProperty(get_class($l), 'controller'); - $_controller->setAccessible(true); - - $this->assertSame($logger, $_logger->getValue($l)); - $this->assertSame('foo', $_controller->getValue($l)); - } - - /** - * @dataProvider provider - */ - public function testHandleWithoutLogger($event, $event2) - { - $this->iniSet('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul'); - - $l = new ExceptionListener('foo'); - $l->onKernelException($event); - - $this->assertEquals(new Response('foo'), $event->getResponse()); - - try { - $l->onKernelException($event2); - $this->fail('RuntimeException expected'); - } catch (\RuntimeException $e) { - $this->assertSame('bar', $e->getMessage()); - $this->assertSame('foo', $e->getPrevious()->getMessage()); - } - } - - /** - * @dataProvider provider - */ - public function testHandleWithLogger($event, $event2) - { - $logger = new TestLogger(); - - $l = new ExceptionListener('foo', $logger); - $l->onKernelException($event); - - $this->assertEquals(new Response('foo'), $event->getResponse()); - - try { - $l->onKernelException($event2); - $this->fail('RuntimeException expected'); - } catch (\RuntimeException $e) { - $this->assertSame('bar', $e->getMessage()); - $this->assertSame('foo', $e->getPrevious()->getMessage()); - } - - $this->assertEquals(3, $logger->countErrors()); - $this->assertCount(3, $logger->getLogs('critical')); - } - - public function provider() - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - return array(array(null, null)); - } - - $request = new Request(); - $exception = new \Exception('foo'); - $event = new GetResponseForExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MASTER_REQUEST, $exception); - $event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, HttpKernelInterface::MASTER_REQUEST, $exception); - - return array( - array($event, $event2), - ); - } - - public function testSubRequestFormat() - { - $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { - return new Response($request->getRequestFormat()); - })); - - $request = Request::create('/'); - $request->setRequestFormat('xml'); - - $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); - $listener->onKernelException($event); - - $response = $event->getResponse(); - $this->assertEquals('xml', $response->getContent()); - } - - public function testCSPHeaderIsRemoved() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { - return new Response($request->getRequestFormat()); - })); - - $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); - - $dispatcher->addSubscriber($listener); - - $request = Request::create('/'); - $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); - $dispatcher->dispatch(KernelEvents::EXCEPTION, $event); - - $response = new Response('', 200, array('content-security-policy' => "style-src 'self'")); - $this->assertTrue($response->headers->has('content-security-policy')); - - $event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response); - $dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed'); - $this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed'); - } -} - -class TestLogger extends Logger implements DebugLoggerInterface -{ - public function countErrors() - { - return count($this->logs['critical']); - } -} - -class TestKernel implements HttpKernelInterface -{ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - return new Response('foo'); - } -} - -class TestKernelThatThrowsException implements HttpKernelInterface -{ - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - throw new \RuntimeException('bar'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php deleted file mode 100644 index 464b2ab46..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\EventListener\FragmentListener; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\UriSigner; - -class FragmentListenerTest extends TestCase -{ - public function testOnlyTriggeredOnFragmentRoute() - { - $request = Request::create('http://example.com/foo?_path=foo%3Dbar%26_controller%3Dfoo'); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $expected = $request->attributes->all(); - - $listener->onKernelRequest($event); - - $this->assertEquals($expected, $request->attributes->all()); - $this->assertTrue($request->query->has('_path')); - } - - public function testOnlyTriggeredIfControllerWasNotDefinedYet() - { - $request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'); - $request->attributes->set('_controller', 'bar'); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST); - - $expected = $request->attributes->all(); - - $listener->onKernelRequest($event); - - $this->assertEquals($expected, $request->attributes->all()); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ - public function testAccessDeniedWithNonSafeMethods() - { - $request = Request::create('http://example.com/_fragment', 'POST'); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ - public function testAccessDeniedWithWrongSignature() - { - $request = Request::create('http://example.com/_fragment', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - } - - public function testWithSignature() - { - $signer = new UriSigner('foo'); - $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); - - $listener = new FragmentListener($signer); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - - $this->assertEquals(array('foo' => 'bar', '_controller' => 'foo'), $request->attributes->get('_route_params')); - $this->assertFalse($request->query->has('_path')); - } - - public function testRemovesPathWithControllerDefined() - { - $request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST); - - $listener->onKernelRequest($event); - - $this->assertFalse($request->query->has('_path')); - } - - public function testRemovesPathWithControllerNotDefined() - { - $signer = new UriSigner('foo'); - $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); - - $listener = new FragmentListener($signer); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - - $this->assertFalse($request->query->has('_path')); - } - - private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST) - { - return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, $requestType); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php deleted file mode 100644 index 332393eea..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\EventListener\LocaleListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; - -class LocaleListenerTest extends TestCase -{ - private $requestStack; - - protected function setUp() - { - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); - } - - public function testDefaultLocaleWithoutSession() - { - $listener = new LocaleListener($this->requestStack, 'fr'); - $event = $this->getEvent($request = Request::create('/')); - - $listener->onKernelRequest($event); - $this->assertEquals('fr', $request->getLocale()); - } - - public function testLocaleFromRequestAttribute() - { - $request = Request::create('/'); - $request->cookies->set(session_name(), 'value'); - - $request->attributes->set('_locale', 'es'); - $listener = new LocaleListener($this->requestStack, 'fr'); - $event = $this->getEvent($request); - - $listener->onKernelRequest($event); - $this->assertEquals('es', $request->getLocale()); - } - - public function testLocaleSetForRoutingContext() - { - // the request context is updated - $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); - $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock(); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); - - $request = Request::create('/'); - - $request->attributes->set('_locale', 'es'); - $listener = new LocaleListener($this->requestStack, 'fr', $router); - $listener->onKernelRequest($this->getEvent($request)); - } - - public function testRouterResetWithParentRequestOnKernelFinishRequest() - { - // the request context is updated - $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); - $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock(); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); - - $parentRequest = Request::create('/'); - $parentRequest->setLocale('es'); - - $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); - - $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock(); - - $listener = new LocaleListener($this->requestStack, 'fr', $router); - $listener->onKernelFinishRequest($event); - } - - public function testRequestLocaleIsNotOverridden() - { - $request = Request::create('/'); - $request->setLocale('de'); - $listener = new LocaleListener($this->requestStack, 'fr'); - $event = $this->getEvent($request); - - $listener->onKernelRequest($event); - $this->assertEquals('de', $request->getLocale()); - } - - private function getEvent(Request $request) - { - return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php deleted file mode 100644 index 751aee869..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\EventListener\ProfilerListener; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpKernel\Exception\HttpException; -use Symfony\Component\HttpKernel\Kernel; - -class ProfilerListenerTest extends TestCase -{ - /** - * Test a master and sub request with an exception and `onlyException` profiler option enabled. - */ - public function testKernelTerminate() - { - $profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile') - ->disableOriginalConstructor() - ->getMock(); - - $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') - ->disableOriginalConstructor() - ->getMock(); - - $profiler->expects($this->once()) - ->method('collect') - ->will($this->returnValue($profile)); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - - $masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') - ->disableOriginalConstructor() - ->getMock(); - - $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') - ->disableOriginalConstructor() - ->getMock(); - - $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') - ->disableOriginalConstructor() - ->getMock(); - - $requestStack = new RequestStack(); - $requestStack->push($masterRequest); - - $onlyException = true; - $listener = new ProfilerListener($profiler, $requestStack, null, $onlyException); - - // master request - $listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response)); - - // sub request - $listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404))); - $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response)); - - $listener->onKernelTerminate(new PostResponseEvent($kernel, $masterRequest, $response)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php deleted file mode 100644 index 12a31eb3e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\EventListener\ResponseListener; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class ResponseListenerTest extends TestCase -{ - private $dispatcher; - - private $kernel; - - protected function setUp() - { - $this->dispatcher = new EventDispatcher(); - $listener = new ResponseListener('UTF-8'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - - $this->kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->kernel = null; - } - - public function testFilterDoesNothingForSubRequests() - { - $response = new Response('foo'); - - $event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('', $event->getResponse()->headers->get('content-type')); - } - - public function testFilterSetsNonDefaultCharsetIfNotOverridden() - { - $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); - - $response = new Response('foo'); - - $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('ISO-8859-15', $response->getCharset()); - } - - public function testFilterDoesNothingIfCharsetIsOverridden() - { - $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); - - $response = new Response('foo'); - $response->setCharset('ISO-8859-1'); - - $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('ISO-8859-1', $response->getCharset()); - } - - public function testFiltersSetsNonDefaultCharsetIfNotOverriddenOnNonTextContentType() - { - $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); - - $response = new Response('foo'); - $request = Request::create('/'); - $request->setRequestFormat('application/json'); - - $event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response); - $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('ISO-8859-15', $response->getCharset()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php deleted file mode 100644 index 342dfc367..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php +++ /dev/null @@ -1,226 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver; -use Symfony\Component\HttpKernel\Controller\ControllerResolver; -use Symfony\Component\HttpKernel\EventListener\ExceptionListener; -use Symfony\Component\HttpKernel\EventListener\RouterListener; -use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\Routing\Exception\NoConfigurationException; -use Symfony\Component\Routing\RequestContext; - -class RouterListenerTest extends TestCase -{ - private $requestStack; - - protected function setUp() - { - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); - } - - /** - * @dataProvider getPortData - */ - public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHttpPort, $expectedHttpsPort) - { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface') - ->disableOriginalConstructor() - ->getMock(); - $context = new RequestContext(); - $context->setHttpPort($defaultHttpPort); - $context->setHttpsPort($defaultHttpsPort); - $urlMatcher->expects($this->any()) - ->method('getContext') - ->will($this->returnValue($context)); - - $listener = new RouterListener($urlMatcher, $this->requestStack); - $event = $this->createGetResponseEventForUri($uri); - $listener->onKernelRequest($event); - - $this->assertEquals($expectedHttpPort, $context->getHttpPort()); - $this->assertEquals($expectedHttpsPort, $context->getHttpsPort()); - $this->assertEquals(0 === strpos($uri, 'https') ? 'https' : 'http', $context->getScheme()); - } - - public function getPortData() - { - return array( - array(80, 443, 'http://localhost/', 80, 443), - array(80, 443, 'http://localhost:90/', 90, 443), - array(80, 443, 'https://localhost/', 80, 443), - array(80, 443, 'https://localhost:90/', 80, 90), - ); - } - - /** - * @param string $uri - * - * @return GetResponseEvent - */ - private function createGetResponseEventForUri($uri) - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create($uri); - $request->attributes->set('_controller', null); // Prevents going in to routing process - - return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidMatcher() - { - new RouterListener(new \stdClass(), $this->requestStack); - } - - public function testRequestMatcher() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('http://localhost/'); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - $requestMatcher->expects($this->once()) - ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue(array())); - - $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); - $listener->onKernelRequest($event); - } - - public function testSubRequestWithDifferentMethod() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('http://localhost/', 'post'); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - $requestMatcher->expects($this->any()) - ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue(array())); - - $context = new RequestContext(); - - $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); - $listener->onKernelRequest($event); - - // sub-request with another HTTP method - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('http://localhost/', 'get'); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST); - - $listener->onKernelRequest($event); - - $this->assertEquals('GET', $context->getMethod()); - } - - /** - * @dataProvider getLoggingParameterData - */ - public function testLoggingParameter($parameter, $log, $parameters) - { - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - $requestMatcher->expects($this->once()) - ->method('matchRequest') - ->will($this->returnValue($parameter)); - - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $logger->expects($this->once()) - ->method('info') - ->with($this->equalTo($log), $this->equalTo($parameters)); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('http://localhost/'); - - $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext(), $logger); - $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); - } - - public function getLoggingParameterData() - { - return array( - array(array('_route' => 'foo'), 'Matched route "{route}".', array('route' => 'foo', 'route_parameters' => array('_route' => 'foo'), 'request_uri' => 'http://localhost/', 'method' => 'GET')), - array(array(), 'Matched route "{route}".', array('route' => 'n/a', 'route_parameters' => array(), 'request_uri' => 'http://localhost/', 'method' => 'GET')), - ); - } - - public function testWithBadRequest() - { - $requestStack = new RequestStack(); - - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - $requestMatcher->expects($this->never())->method('matchRequest'); - - $dispatcher = new EventDispatcher(); - $dispatcher->addSubscriber(new ValidateRequestListener()); - $dispatcher->addSubscriber(new RouterListener($requestMatcher, $requestStack, new RequestContext())); - $dispatcher->addSubscriber(new ExceptionListener(function () { - return new Response('Exception handled', 400); - })); - - $kernel = new HttpKernel($dispatcher, new ControllerResolver(), $requestStack, new ArgumentResolver()); - - $request = Request::create('http://localhost/'); - $request->headers->set('host', '###'); - $response = $kernel->handle($request); - $this->assertSame(400, $response->getStatusCode()); - } - - public function testNoRoutingConfigurationResponse() - { - $requestStack = new RequestStack(); - - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - $requestMatcher - ->expects($this->once()) - ->method('matchRequest') - ->willThrowException(new NoConfigurationException()) - ; - - $dispatcher = new EventDispatcher(); - $dispatcher->addSubscriber(new RouterListener($requestMatcher, $requestStack, new RequestContext())); - - $kernel = new HttpKernel($dispatcher, new ControllerResolver(), $requestStack, new ArgumentResolver()); - - $request = Request::create('http://localhost/'); - $response = $kernel->handle($request); - $this->assertSame(404, $response->getStatusCode()); - $this->assertContains('Welcome', $response->getContent()); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException - */ - public function testRequestWithBadHost() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('http://bad host %22/'); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - - $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); - $listener->onKernelRequest($event); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php deleted file mode 100644 index 5492c3d78..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\EventListener\SaveSessionListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class SaveSessionListenerTest extends TestCase -{ - public function testOnlyTriggeredOnMasterRequest() - { - $listener = new SaveSessionListener(); - $event = $this->getMockBuilder(FilterResponseEvent::class)->disableOriginalConstructor()->getMock(); - $event->expects($this->once())->method('isMasterRequest')->willReturn(false); - $event->expects($this->never())->method('getRequest'); - - // sub request - $listener->onKernelResponse($event); - } - - public function testSessionSaved() - { - $listener = new SaveSessionListener(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); - - $session = $this->getMockBuilder(SessionInterface::class)->disableOriginalConstructor()->getMock(); - $session->expects($this->once())->method('isStarted')->willReturn(true); - $session->expects($this->once())->method('save'); - - $request = new Request(); - $request->setSession($session); - $response = new Response(); - $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php deleted file mode 100644 index 34598363c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; -use Symfony\Component\HttpKernel\EventListener\SessionListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class SessionListenerTest extends TestCase -{ - public function testOnlyTriggeredOnMasterRequest() - { - $listener = $this->getMockForAbstractClass(AbstractSessionListener::class); - $event = $this->getMockBuilder(GetResponseEvent::class)->disableOriginalConstructor()->getMock(); - $event->expects($this->once())->method('isMasterRequest')->willReturn(false); - $event->expects($this->never())->method('getRequest'); - - // sub request - $listener->onKernelRequest($event); - } - - public function testSessionIsSet() - { - $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); - - $container = new Container(); - $container->set('session', $session); - - $request = new Request(); - $listener = new SessionListener($container); - - $event = $this->getMockBuilder(GetResponseEvent::class)->disableOriginalConstructor()->getMock(); - $event->expects($this->once())->method('isMasterRequest')->willReturn(true); - $event->expects($this->once())->method('getRequest')->willReturn($request); - - $listener->onKernelRequest($event); - - $this->assertTrue($request->hasSession()); - $this->assertSame($session, $request->getSession()); - } - - public function testResponseIsPrivate() - { - $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); - $session->expects($this->once())->method('isStarted')->willReturn(false); - $session->expects($this->once())->method('hasBeenStarted')->willReturn(true); - - $container = new Container(); - $container->set('session', $session); - - $listener = new SessionListener($container); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); - - $request = new Request(); - $response = new Response(); - $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); - $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); - - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - $this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate')); - $this->assertSame('0', $response->headers->getCacheControlDirective('max-age')); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php deleted file mode 100644 index 1e79ebe05..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\EventListener\SurrogateListener; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class SurrogateListenerTest extends TestCase -{ - public function testFilterDoesNothingForSubRequests() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $response = new Response('foo '); - $listener = new SurrogateListener(new Esi()); - - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response); - $dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control')); - } - - public function testFilterWhenThereIsSomeEsiIncludes() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $response = new Response('foo '); - $listener = new SurrogateListener(new Esi()); - - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); - $dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('content="ESI/1.0"', $event->getResponse()->headers->get('Surrogate-Control')); - } - - public function testFilterWhenThereIsNoEsiIncludes() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $response = new Response('foo'); - $listener = new SurrogateListener(new Esi()); - - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); - $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); - $dispatcher->dispatch(KernelEvents::RESPONSE, $event); - - $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control')); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php deleted file mode 100644 index 4452f4877..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php +++ /dev/null @@ -1,164 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\EventListener\SessionListener; -use Symfony\Component\HttpKernel\EventListener\TestSessionListener; -use Symfony\Component\HttpFoundation\Session\SessionInterface; - -/** - * SessionListenerTest. - * - * Tests SessionListener. - * - * @author Bulat Shakirzyanov - */ -class TestSessionListenerTest extends TestCase -{ - /** - * @var TestSessionListener - */ - private $listener; - - /** - * @var SessionInterface - */ - private $session; - - protected function setUp() - { - $this->listener = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener'); - $this->session = $this->getSession(); - } - - public function testShouldSaveMasterRequestSession() - { - $this->sessionHasBeenStarted(); - $this->sessionMustBeSaved(); - - $this->filterResponse(new Request()); - } - - public function testShouldNotSaveSubRequestSession() - { - $this->sessionMustNotBeSaved(); - - $this->filterResponse(new Request(), HttpKernelInterface::SUB_REQUEST); - } - - public function testDoesNotDeleteCookieIfUsingSessionLifetime() - { - $this->sessionHasBeenStarted(); - - @ini_set('session.cookie_lifetime', 0); - - $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); - $cookies = $response->headers->getCookies(); - - $this->assertEquals(0, reset($cookies)->getExpiresTime()); - } - - /** - * @requires function \Symfony\Component\HttpFoundation\Session\Session::isEmpty - */ - public function testEmptySessionDoesNotSendCookie() - { - $this->sessionHasBeenStarted(); - $this->sessionIsEmpty(); - - $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); - - $this->assertSame(array(), $response->headers->getCookies()); - } - - public function testUnstartedSessionIsNotSave() - { - $this->sessionHasNotBeenStarted(); - $this->sessionMustNotBeSaved(); - - $this->filterResponse(new Request()); - } - - public function testDoesNotImplementServiceSubscriberInterface() - { - $this->assertTrue(interface_exists(ServiceSubscriberInterface::class)); - $this->assertTrue(class_exists(SessionListener::class)); - $this->assertTrue(class_exists(TestSessionListener::class)); - $this->assertFalse(is_subclass_of(SessionListener::class, ServiceSubscriberInterface::class), 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford'); - $this->assertFalse(is_subclass_of(TestSessionListener::class, ServiceSubscriberInterface::class, 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford')); - } - - private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST) - { - $request->setSession($this->session); - $response = new Response(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $event = new FilterResponseEvent($kernel, $request, $type, $response); - - $this->listener->onKernelResponse($event); - - $this->assertSame($response, $event->getResponse()); - - return $response; - } - - private function sessionMustNotBeSaved() - { - $this->session->expects($this->never()) - ->method('save'); - } - - private function sessionMustBeSaved() - { - $this->session->expects($this->once()) - ->method('save'); - } - - private function sessionHasBeenStarted() - { - $this->session->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(true)); - } - - private function sessionHasNotBeenStarted() - { - $this->session->expects($this->once()) - ->method('isStarted') - ->will($this->returnValue(false)); - } - - private function sessionIsEmpty() - { - $this->session->expects($this->once()) - ->method('isEmpty') - ->will($this->returnValue(true)); - } - - private function getSession() - { - $mock = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session') - ->disableOriginalConstructor() - ->getMock(); - - // set return value for getName() - $mock->expects($this->any())->method('getName')->will($this->returnValue('MOCKSESSID')); - - return $mock; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php deleted file mode 100644 index 23b833177..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\EventListener\TranslatorListener; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class TranslatorListenerTest extends TestCase -{ - private $listener; - private $translator; - private $requestStack; - - protected function setUp() - { - $this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock(); - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $this->listener = new TranslatorListener($this->translator, $this->requestStack); - } - - public function testLocaleIsSetInOnKernelRequest() - { - $this->translator - ->expects($this->once()) - ->method('setLocale') - ->with($this->equalTo('fr')); - - $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); - $this->listener->onKernelRequest($event); - } - - public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() - { - $this->translator - ->expects($this->at(0)) - ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->translator - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); - - $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); - $this->listener->onKernelRequest($event); - } - - public function testLocaleIsSetInOnKernelFinishRequestWhenParentRequestExists() - { - $this->translator - ->expects($this->once()) - ->method('setLocale') - ->with($this->equalTo('fr')); - - $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); - $this->listener->onKernelFinishRequest($event); - } - - public function testLocaleIsNotSetInOnKernelFinishRequestWhenParentRequestDoesNotExist() - { - $this->translator - ->expects($this->never()) - ->method('setLocale'); - - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); - $this->listener->onKernelFinishRequest($event); - } - - public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() - { - $this->translator - ->expects($this->at(0)) - ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->translator - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); - - $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); - $this->listener->onKernelFinishRequest($event); - } - - private function createHttpKernel() - { - return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - } - - private function createRequest($locale) - { - $request = new Request(); - $request->setLocale($locale); - - return $request; - } - - private function setMasterRequest($request) - { - $this->requestStack - ->expects($this->any()) - ->method('getParentRequest') - ->will($this->returnValue($request)); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php deleted file mode 100644 index d06094325..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\EventListener; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\KernelEvents; - -class ValidateRequestListenerTest extends TestCase -{ - /** - * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException - */ - public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - - $request = new Request(); - $request->setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $request->headers->set('FORWARDED', 'for=2.2.2.2'); - $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); - - $dispatcher->addListener(KernelEvents::REQUEST, array(new ValidateRequestListener(), 'onKernelRequest')); - $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - - $dispatcher->dispatch(KernelEvents::REQUEST, $event); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php deleted file mode 100644 index 2bfcb2bf8..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php +++ /dev/null @@ -1,13 +0,0 @@ - 'Test')), - array(array('X-Test' => 1)), - array( - array( - array('X-Test' => 'Test'), - array('X-Test-2' => 'Test-2'), - ), - ), - ); - } - - public function testHeadersDefault() - { - $exception = $this->createException(); - $this->assertSame(array(), $exception->getHeaders()); - } - - /** - * @dataProvider headerDataProvider - */ - public function testHeadersConstructor($headers) - { - $exception = new HttpException(200, null, null, $headers); - $this->assertSame($headers, $exception->getHeaders()); - } - - /** - * @dataProvider headerDataProvider - */ - public function testHeadersSetter($headers) - { - $exception = $this->createException(); - $exception->setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } - - protected function createException() - { - return new HttpException(200); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php deleted file mode 100644 index 462d3ca4f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php +++ /dev/null @@ -1,13 +0,0 @@ -assertSame(array('Allow' => 'GET, PUT'), $exception->getHeaders()); - } - - /** - * @dataProvider headerDataProvider - */ - public function testHeadersSetter($headers) - { - $exception = new MethodNotAllowedHttpException(array('GET')); - $exception->setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php deleted file mode 100644 index 4c0db7a3c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php +++ /dev/null @@ -1,13 +0,0 @@ -assertSame(array('Retry-After' => 10), $exception->getHeaders()); - } - - /** - * @dataProvider headerDataProvider - */ - public function testHeadersSetter($headers) - { - $exception = new ServiceUnavailableHttpException(10); - $exception->setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } - - protected function createException() - { - return new ServiceUnavailableHttpException(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php deleted file mode 100644 index 2079bb338..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php +++ /dev/null @@ -1,29 +0,0 @@ -assertSame(array('Retry-After' => 10), $exception->getHeaders()); - } - - /** - * @dataProvider headerDataProvider - */ - public function testHeadersSetter($headers) - { - $exception = new TooManyRequestsHttpException(10); - $exception->setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } - - protected function createException() - { - return new TooManyRequestsHttpException(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php deleted file mode 100644 index 37a0028dc..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php +++ /dev/null @@ -1,24 +0,0 @@ -assertSame(array('WWW-Authenticate' => 'Challenge'), $exception->getHeaders()); - } - - /** - * @dataProvider headerDataProvider - */ - public function testHeadersSetter($headers) - { - $exception = new UnauthorizedHttpException('Challenge'); - $exception->setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php deleted file mode 100644 index 760366c69..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php +++ /dev/null @@ -1,28 +0,0 @@ -setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } - - protected function createException() - { - return new UnprocessableEntityHttpException(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php deleted file mode 100644 index d47287a1f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php +++ /dev/null @@ -1,23 +0,0 @@ -setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } - - protected function createException($headers = array()) - { - return new UnsupportedMediaTypeHttpException(); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/123/Kernel123.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/123/Kernel123.php deleted file mode 100644 index b6cf1cba2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/123/Kernel123.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\_123; - -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Config\Loader\LoaderInterface; - -class Kernel123 extends Kernel -{ - public function registerBundles() - { - return array(); - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } - - public function getCacheDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/cache/'.$this->environment; - } - - public function getLogDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/logs'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/foo.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/hide.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/BaseBundle/Resources/hide.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/Resources/foo.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/Resources/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/bar.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/bar.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/foo.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle1Bundle/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle2Bundle/foo.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Bundle2Bundle/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/foo.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/foo.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/hide.txt b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ChildBundle/Resources/hide.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ClearableService.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ClearableService.php deleted file mode 100644 index 35acb419c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ClearableService.php +++ /dev/null @@ -1,13 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; - -class BasicTypesController -{ - public function action(string $foo, int $bar, float $baz) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingRequest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingRequest.php deleted file mode 100644 index 9b4754b46..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingRequest.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; - -use Symfony\Component\HttpFoundation\Request; - -class ExtendingRequest extends Request -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingSession.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingSession.php deleted file mode 100644 index 9fa54ee8b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/ExtendingSession.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; - -use Symfony\Component\HttpFoundation\Session\Session; - -class ExtendingSession extends Session -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/NullableController.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/NullableController.php deleted file mode 100644 index 9db4df7b4..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/NullableController.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; - -class NullableController -{ - public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/VariadicController.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/VariadicController.php deleted file mode 100644 index c39812453..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/Controller/VariadicController.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; - -class VariadicController -{ - public function action($foo, ...$bar) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php deleted file mode 100644 index 89dec36af..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/DataCollector/CloneVarDataCollector.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\DataCollector; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; - -class CloneVarDataCollector extends DataCollector -{ - private $varToClone; - - public function __construct($varToClone) - { - $this->varToClone = $varToClone; - } - - public function collect(Request $request, Response $response, \Exception $exception = null) - { - $this->data = $this->cloneVar($this->varToClone); - } - - public function reset() - { - $this->data = array(); - } - - public function getData() - { - return $this->data; - } - - public function getName() - { - return 'clone_var'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php deleted file mode 100644 index c8bfd36e6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionAbsentBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php deleted file mode 100644 index b43bc665a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionLoadedBundle\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\Extension; - -class ExtensionLoadedExtension extends Extension -{ - public function load(array $configs, ContainerBuilder $container) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php deleted file mode 100644 index 3af81cb07..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionLoadedBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionLoadedBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php deleted file mode 100644 index 0fd64316f..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/DependencyInjection/ExtensionNotValidExtension.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\DependencyInjection; - -class ExtensionNotValidExtension -{ - public function getAlias() - { - return 'extension_not_valid'; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php deleted file mode 100644 index 34e292039..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionNotValidBundle/ExtensionNotValidBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionNotValidBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php deleted file mode 100644 index 977976b75..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php +++ /dev/null @@ -1,17 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command; - -use Symfony\Component\Console\Command\Command; - -class FooCommand extends Command -{ - protected function configure() - { - $this->setName('foo'); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php deleted file mode 100644 index 108571718..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\Extension; - -class ExtensionPresentExtension extends Extension -{ - public function load(array $configs, ContainerBuilder $container) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php deleted file mode 100644 index 36a7ad404..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class ExtensionPresentBundle extends Bundle -{ -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForOverrideName.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForOverrideName.php deleted file mode 100644 index a1102ab78..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForOverrideName.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Config\Loader\LoaderInterface; - -class KernelForOverrideName extends Kernel -{ - protected $name = 'overridden'; - - public function registerBundles() - { - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForTest.php deleted file mode 100644 index 5fd61bbc7..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelForTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\Config\Loader\LoaderInterface; - -class KernelForTest extends Kernel -{ - public function getBundleMap() - { - return $this->bundleMap; - } - - public function registerBundles() - { - return array(); - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } - - public function isBooted() - { - return $this->booted; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelWithoutBundles.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelWithoutBundles.php deleted file mode 100644 index cee1b09fb..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/KernelWithoutBundles.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Kernel; - -class KernelWithoutBundles extends Kernel -{ - public function registerBundles() - { - return array(); - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } - - protected function build(ContainerBuilder $container) - { - $container->setParameter('test_executed', true); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ResettableService.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ResettableService.php deleted file mode 100644 index ffb72a35a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/ResettableService.php +++ /dev/null @@ -1,13 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Client; - -class TestClient extends Client -{ - protected function getScript($request) - { - $script = parent::getScript($request); - - $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/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/TestEventDispatcher.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/TestEventDispatcher.php deleted file mode 100644 index ca2e6a693..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fixtures/TestEventDispatcher.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fixtures; - -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestEventDispatcher extends EventDispatcher implements TraceableEventDispatcherInterface -{ - public function getCalledListeners() - { - return array('foo'); - } - - public function getNotCalledListeners() - { - return array('bar'); - } - - public function reset() - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/EsiFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/EsiFragmentRendererTest.php deleted file mode 100644 index 7099b4d7e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/EsiFragmentRendererTest.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\UriSigner; - -class EsiFragmentRendererTest extends TestCase -{ - public function testRenderFallbackToInlineStrategyIfEsiNotSupported() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true)); - $strategy->render('/', Request::create('/')); - } - - /** - * @group legacy - * @expectedDeprecation Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated %s. - */ - public function testRenderFallbackWithObjectAttributesIsDeprecated() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo')); - $request = Request::create('/'); - $reference = new ControllerReference('main_controller', array('foo' => new \stdClass()), array()); - $strategy->render($reference, $request); - } - - public function testRenderFallbackWithScalarIsNotDeprecated() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo')); - $request = Request::create('/'); - $reference = new ControllerReference('main_controller', array('foo' => array(true)), array()); - $strategy->render($reference, $request); - } - - public function testRender() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $this->assertEquals('', $strategy->render('/', $request)->getContent()); - $this->assertEquals("\n", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent()); - $this->assertEquals('', $strategy->render('/', $request, array('alt' => 'foo'))->getContent()); - } - - public function testRenderControllerReference() - { - $signer = new UriSigner('foo'); - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(), $signer); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $reference = new ControllerReference('main_controller', array(), array()); - $altReference = new ControllerReference('alt_controller', array(), array()); - - $this->assertEquals( - '', - $strategy->render($reference, $request, array('alt' => $altReference))->getContent() - ); - } - - /** - * @expectedException \LogicException - */ - public function testRenderControllerReferenceWithoutSignerThrowsException() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $strategy->render(new ControllerReference('main_controller'), $request); - } - - /** - * @expectedException \LogicException - */ - public function testRenderAltControllerReferenceWithoutSignerThrowsException() - { - $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - - $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); - } - - private function getInlineStrategy($called = false) - { - $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); - - if ($called) { - $inline->expects($this->once())->method('render'); - } - - return $inline; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/FragmentHandlerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/FragmentHandlerTest.php deleted file mode 100644 index 9c906b50a..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/FragmentHandlerTest.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Fragment\FragmentHandler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * @group time-sensitive - */ -class FragmentHandlerTest extends TestCase -{ - private $requestStack; - - protected function setUp() - { - $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') - ->disableOriginalConstructor() - ->getMock() - ; - $this->requestStack - ->expects($this->any()) - ->method('getCurrentRequest') - ->will($this->returnValue(Request::create('/'))) - ; - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRenderWhenRendererDoesNotExist() - { - $handler = new FragmentHandler($this->requestStack); - $handler->render('/', 'foo'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRenderWithUnknownRenderer() - { - $handler = $this->getHandler($this->returnValue(new Response('foo'))); - - $handler->render('/', 'bar'); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Error when rendering "http://localhost/" (Status code is 404). - */ - public function testDeliverWithUnsuccessfulResponse() - { - $handler = $this->getHandler($this->returnValue(new Response('foo', 404))); - - $handler->render('/', 'foo'); - } - - public function testRender() - { - $handler = $this->getHandler($this->returnValue(new Response('foo')), array('/', Request::create('/'), array('foo' => 'foo', 'ignore_errors' => true))); - - $this->assertEquals('foo', $handler->render('/', 'foo', array('foo' => 'foo'))); - } - - protected function getHandler($returnValue, $arguments = array()) - { - $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); - $renderer - ->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')) - ; - $e = $renderer - ->expects($this->any()) - ->method('render') - ->will($returnValue) - ; - - if ($arguments) { - call_user_func_array(array($e, 'with'), $arguments); - } - - $handler = new FragmentHandler($this->requestStack); - $handler->addRenderer($renderer); - - return $handler; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php deleted file mode 100644 index 1be052e5e..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; -use Symfony\Component\HttpKernel\UriSigner; -use Symfony\Component\HttpFoundation\Request; - -class HIncludeFragmentRendererTest extends TestCase -{ - /** - * @expectedException \LogicException - */ - public function testRenderExceptionWhenControllerAndNoSigner() - { - $strategy = new HIncludeFragmentRenderer(); - $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/')); - } - - public function testRenderWithControllerAndSigner() - { - $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); - } - - public function testRenderWithUri() - { - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('', $strategy->render('/foo', Request::create('/'))->getContent()); - - $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - $this->assertEquals('', $strategy->render('/foo', Request::create('/'))->getContent()); - } - - public function testRenderWithDefault() - { - // only default - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); - - // only global default - $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); - $this->assertEquals('global_default', $strategy->render('/foo', Request::create('/'), array())->getContent()); - - // global default and default - $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); - } - - public function testRenderWithAttributesOptions() - { - // with id - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar'))->getContent()); - - // with attributes - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); - - // with id & attributes - $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); - } - - public function testRenderWithDefaultText() - { - $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); - $engine->expects($this->once()) - ->method('exists') - ->with('default') - ->will($this->throwException(new \InvalidArgumentException())); - - // only default - $strategy = new HIncludeFragmentRenderer($engine); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php deleted file mode 100644 index 18e55a5be..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php +++ /dev/null @@ -1,250 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Controller\ArgumentResolver; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class InlineFragmentRendererTest extends TestCase -{ - public function testRender() - { - $strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo')))); - - $this->assertEquals('foo', $strategy->render('/', Request::create('/'))->getContent()); - } - - public function testRenderWithControllerReference() - { - $strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo')))); - - $this->assertEquals('foo', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); - } - - public function testRenderWithObjectsAsAttributes() - { - $object = new \stdClass(); - - $subRequest = Request::create('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller'); - $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); - $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); - - $this->assertSame('foo', $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'))->getContent()); - } - - /** - * @group legacy - */ - public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerLegacy() - { - $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver')->setMethods(array('getController'))->getMock(); - $resolver - ->expects($this->once()) - ->method('getController') - ->will($this->returnValue(function (\stdClass $object, Bar $object1) { - return new Response($object1->getBar()); - })) - ; - - $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack()); - $renderer = new InlineFragmentRenderer($kernel); - - $response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/')); - $this->assertEquals('bar', $response->getContent()); - } - - /** - * @group legacy - */ - public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController() - { - $resolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock(); - $resolver - ->expects($this->once()) - ->method('getController') - ->will($this->returnValue(function (\stdClass $object, Bar $object1) { - return new Response($object1->getBar()); - })) - ; - - $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack(), new ArgumentResolver()); - $renderer = new InlineFragmentRenderer($kernel); - - $response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/')); - $this->assertEquals('bar', $response->getContent()); - } - - public function testRenderWithTrustedHeaderDisabled() - { - Request::setTrustedProxies(array(), 0); - - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); - $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); - - Request::setTrustedProxies(array(), -1); - } - - /** - * @expectedException \RuntimeException - */ - public function testRenderExceptionNoIgnoreErrors() - { - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $dispatcher->expects($this->never())->method('dispatch'); - - $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); - - $this->assertEquals('foo', $strategy->render('/', Request::create('/'))->getContent()); - } - - public function testRenderExceptionIgnoreErrors() - { - $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $dispatcher->expects($this->once())->method('dispatch')->with(KernelEvents::EXCEPTION); - - $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); - - $this->assertEmpty($strategy->render('/', Request::create('/'), array('ignore_errors' => true))->getContent()); - } - - public function testRenderExceptionIgnoreErrorsWithAlt() - { - $strategy = new InlineFragmentRenderer($this->getKernel($this->onConsecutiveCalls( - $this->throwException(new \RuntimeException('foo')), - $this->returnValue(new Response('bar')) - ))); - - $this->assertEquals('bar', $strategy->render('/', Request::create('/'), array('ignore_errors' => true, 'alt' => '/foo'))->getContent()); - } - - private function getKernel($returnValue) - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel - ->expects($this->any()) - ->method('handle') - ->will($returnValue) - ; - - return $kernel; - } - - public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() - { - $controllerResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); - $controllerResolver - ->expects($this->once()) - ->method('getController') - ->will($this->returnValue(function () { - ob_start(); - echo 'bar'; - throw new \RuntimeException(); - })) - ; - - $argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock(); - $argumentResolver - ->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue(array())) - ; - - $kernel = new HttpKernel(new EventDispatcher(), $controllerResolver, new RequestStack(), $argumentResolver); - $renderer = new InlineFragmentRenderer($kernel); - - // simulate a main request with output buffering - ob_start(); - echo 'Foo'; - - // simulate a sub-request with output buffering and an exception - $renderer->render('/', Request::create('/'), array('ignore_errors' => true)); - - $this->assertEquals('Foo', ob_get_clean()); - } - - public function testESIHeaderIsKeptInSubrequest() - { - $expectedSubRequest = Request::create('/'); - $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - - if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - } - - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $strategy->render('/', $request); - } - - public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled() - { - Request::setTrustedProxies(array(), 0); - - $this->testESIHeaderIsKeptInSubrequest(); - - Request::setTrustedProxies(array(), -1); - } - - public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() - { - $expectedSubRequest = Request::create('/'); - if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - } - - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); - $request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*')); - $strategy->render('/', $request); - } - - /** - * Creates a Kernel expecting a request equals to $request - * Allows delta in comparison in case REQUEST_TIME changed by 1 second. - */ - private function getKernelExpectingRequest(Request $request, $strict = false) - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel - ->expects($this->once()) - ->method('handle') - ->with($this->equalTo($request, 1)) - ->willReturn(new Response('foo')); - - return $kernel; - } -} - -class Bar -{ - public $bar = 'bar'; - - public function getBar() - { - return $this->bar; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/RoutableFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/RoutableFragmentRendererTest.php deleted file mode 100644 index 3a040dedd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/RoutableFragmentRendererTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ControllerReference; - -class RoutableFragmentRendererTest extends TestCase -{ - /** - * @dataProvider getGenerateFragmentUriData - */ - public function testGenerateFragmentUri($uri, $controller) - { - $this->assertEquals($uri, $this->callGenerateFragmentUriMethod($controller, Request::create('/'))); - } - - /** - * @dataProvider getGenerateFragmentUriData - */ - public function testGenerateAbsoluteFragmentUri($uri, $controller) - { - $this->assertEquals('http://localhost'.$uri, $this->callGenerateFragmentUriMethod($controller, Request::create('/'), true)); - } - - public function getGenerateFragmentUriData() - { - return array( - array('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())), - array('/_fragment?_path=_format%3Dxml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())), - array('/_fragment?_path=foo%3Dfoo%26_format%3Djson%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())), - array('/_fragment?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))), - array('/_fragment?foo=foo&_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))), - array('/_fragment?_path=foo%255B0%255D%3Dfoo%26foo%255B1%255D%3Dbar%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => array('foo', 'bar')), array())), - ); - } - - public function testGenerateFragmentUriWithARequest() - { - $request = Request::create('/'); - $request->attributes->set('_format', 'json'); - $request->setLocale('fr'); - $controller = new ControllerReference('controller', array(), array()); - - $this->assertEquals('/_fragment?_path=_format%3Djson%26_locale%3Dfr%26_controller%3Dcontroller', $this->callGenerateFragmentUriMethod($controller, $request)); - } - - /** - * @expectedException \LogicException - * @dataProvider getGenerateFragmentUriDataWithNonScalar - */ - public function testGenerateFragmentUriWithNonScalar($controller) - { - $this->callGenerateFragmentUriMethod($controller, Request::create('/')); - } - - public function getGenerateFragmentUriDataWithNonScalar() - { - return array( - array(new ControllerReference('controller', array('foo' => new Foo(), 'bar' => 'bar'), array())), - array(new ControllerReference('controller', array('foo' => array('foo' => 'foo'), 'bar' => array('bar' => new Foo())), array())), - ); - } - - private function callGenerateFragmentUriMethod(ControllerReference $reference, Request $request, $absolute = false) - { - $renderer = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer'); - $r = new \ReflectionObject($renderer); - $m = $r->getMethod('generateFragmentUri'); - $m->setAccessible(true); - - return $m->invoke($renderer, $reference, $request, $absolute); - } -} - -class Foo -{ - public $foo; - - public function getFoo() - { - return $this->foo; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/SsiFragmentRendererTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/SsiFragmentRendererTest.php deleted file mode 100644 index b537625f2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Fragment/SsiFragmentRendererTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Fragment; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\Fragment\SsiFragmentRenderer; -use Symfony\Component\HttpKernel\HttpCache\Ssi; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\UriSigner; - -class SsiFragmentRendererTest extends TestCase -{ - public function testRenderFallbackToInlineStrategyIfSsiNotSupported() - { - $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy(true)); - $strategy->render('/', Request::create('/')); - } - - public function testRender() - { - $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'SSI/1.0'); - - $this->assertEquals('', $strategy->render('/', $request)->getContent()); - $this->assertEquals('', $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent(), 'Strategy options should not impact the ssi include tag'); - } - - public function testRenderControllerReference() - { - $signer = new UriSigner('foo'); - $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy(), $signer); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'SSI/1.0'); - - $reference = new ControllerReference('main_controller', array(), array()); - $altReference = new ControllerReference('alt_controller', array(), array()); - - $this->assertEquals( - '', - $strategy->render($reference, $request, array('alt' => $altReference))->getContent() - ); - } - - /** - * @expectedException \LogicException - */ - public function testRenderControllerReferenceWithoutSignerThrowsException() - { - $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'SSI/1.0'); - - $strategy->render(new ControllerReference('main_controller'), $request); - } - - /** - * @expectedException \LogicException - */ - public function testRenderAltControllerReferenceWithoutSignerThrowsException() - { - $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy()); - - $request = Request::create('/'); - $request->setLocale('fr'); - $request->headers->set('Surrogate-Capability', 'SSI/1.0'); - - $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); - } - - private function getInlineStrategy($called = false) - { - $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); - - if ($called) { - $inline->expects($this->once())->method('render'); - } - - return $inline; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/EsiTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/EsiTest.php deleted file mode 100644 index a8662b2a2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/EsiTest.php +++ /dev/null @@ -1,248 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class EsiTest extends TestCase -{ - public function testHasSurrogateEsiCapability() - { - $esi = new Esi(); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $this->assertTrue($esi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'foobar'); - $this->assertFalse($esi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $this->assertFalse($esi->hasSurrogateCapability($request)); - } - - public function testAddSurrogateEsiCapability() - { - $esi = new Esi(); - - $request = Request::create('/'); - $esi->addSurrogateCapability($request); - $this->assertEquals('symfony="ESI/1.0"', $request->headers->get('Surrogate-Capability')); - - $esi->addSurrogateCapability($request); - $this->assertEquals('symfony="ESI/1.0", symfony="ESI/1.0"', $request->headers->get('Surrogate-Capability')); - } - - public function testAddSurrogateControl() - { - $esi = new Esi(); - - $response = new Response('foo '); - $esi->addSurrogateControl($response); - $this->assertEquals('content="ESI/1.0"', $response->headers->get('Surrogate-Control')); - - $response = new Response('foo'); - $esi->addSurrogateControl($response); - $this->assertEquals('', $response->headers->get('Surrogate-Control')); - } - - public function testNeedsEsiParsing() - { - $esi = new Esi(); - - $response = new Response(); - $response->headers->set('Surrogate-Control', 'content="ESI/1.0"'); - $this->assertTrue($esi->needsParsing($response)); - - $response = new Response(); - $this->assertFalse($esi->needsParsing($response)); - } - - public function testRenderIncludeTag() - { - $esi = new Esi(); - - $this->assertEquals('', $esi->renderIncludeTag('/', '/alt', true)); - $this->assertEquals('', $esi->renderIncludeTag('/', '/alt', false)); - $this->assertEquals('', $esi->renderIncludeTag('/')); - $this->assertEquals(''."\n".'', $esi->renderIncludeTag('/', '/alt', true, 'some comment')); - } - - public function testProcessDoesNothingIfContentTypeIsNotHtml() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response(); - $response->headers->set('Content-Type', 'text/plain'); - $esi->process($request, $response); - - $this->assertFalse($response->headers->has('x-body-eval')); - } - - public function testMultilineEsiRemoveTagsAreRemoved() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response(' www.example.com Keep this'."\n www.example.com And this"); - $esi->process($request, $response); - - $this->assertEquals(' Keep this And this', $response->getContent()); - } - - public function testCommentTagsAreRemoved() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response(' Keep this'); - $esi->process($request, $response); - - $this->assertEquals(' Keep this', $response->getContent()); - } - - public function testProcess() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'alt\', true) ?>'."\n", $response->getContent()); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'foo\\\'\', \'bar\\\'\', true) ?>'."\n", $response->getContent()); - - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent()); - - $response = new Response('foo '); - $esi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent()); - } - - public function testProcessEscapesPhpTags() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response(''); - $esi->process($request, $response); - - $this->assertEquals('php cript language=php>', $response->getContent()); - } - - /** - * @expectedException \RuntimeException - */ - public function testProcessWhenNoSrcInAnEsi() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $esi->process($request, $response); - } - - public function testProcessRemoveSurrogateControlHeader() - { - $esi = new Esi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $response->headers->set('Surrogate-Control', 'content="ESI/1.0"'); - $esi->process($request, $response); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - - $response->headers->set('Surrogate-Control', 'no-store, content="ESI/1.0"'); - $esi->process($request, $response); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - - $response->headers->set('Surrogate-Control', 'content="ESI/1.0", no-store'); - $esi->process($request, $response); - $this->assertEquals('ESI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - } - - public function testHandle() - { - $esi = new Esi(); - $cache = $this->getCache(Request::create('/'), new Response('foo')); - $this->assertEquals('foo', $esi->handle($cache, '/', '/alt', true)); - } - - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenResponseIsNot200() - { - $esi = new Esi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $esi->handle($cache, '/', '/alt', false); - } - - public function testHandleWhenResponseIsNot200AndErrorsAreIgnored() - { - $esi = new Esi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $this->assertEquals('', $esi->handle($cache, '/', '/alt', true)); - } - - public function testHandleWhenResponseIsNot200AndAltIsPresent() - { - $esi = new Esi(); - $response1 = new Response('foo'); - $response1->setStatusCode(404); - $response2 = new Response('bar'); - $cache = $this->getCache(Request::create('/'), array($response1, $response2)); - $this->assertEquals('bar', $esi->handle($cache, '/', '/alt', false)); - } - - protected function getCache($request, $response) - { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock(); - $cache->expects($this->any()) - ->method('getRequest') - ->will($this->returnValue($request)) - ; - if (is_array($response)) { - $cache->expects($this->any()) - ->method('handle') - ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) - ; - } else { - $cache->expects($this->any()) - ->method('handle') - ->will($this->returnValue($response)) - ; - } - - return $cache; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php deleted file mode 100644 index 2a9a30d9c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php +++ /dev/null @@ -1,1482 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\HttpCache\HttpCache; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -/** - * @group time-sensitive - */ -class HttpCacheTest extends HttpCacheTestCase -{ - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() - { - $storeMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface') - ->disableOriginalConstructor() - ->getMock(); - - // does not implement TerminableInterface - $kernel = new TestKernel(); - $httpCache = new HttpCache($kernel, $storeMock); - $httpCache->terminate(Request::create('/'), new Response()); - - $this->assertFalse($kernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); - - // implements TerminableInterface - $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel') - ->disableOriginalConstructor() - ->setMethods(array('terminate', 'registerBundles', 'registerContainerConfiguration')) - ->getMock(); - - $kernelMock->expects($this->once()) - ->method('terminate'); - - $kernel = new HttpCache($kernelMock, $storeMock); - $kernel->terminate(Request::create('/'), new Response()); - } - - public function testPassesOnNonGetHeadRequests() - { - $this->setNextResponse(200); - $this->request('POST', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('pass'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testInvalidatesOnPostPutDeleteRequests() - { - foreach (array('post', 'put', 'delete') as $method) { - $this->setNextResponse(200); - $this->request($method, '/'); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('invalidate'); - $this->assertTraceContains('pass'); - } - } - - public function testDoesNotCacheWithAuthorizationRequestHeaderAndNonPublicResponse() - { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesCacheWithAuthorizationRequestHeaderAndPublicResponse() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - $this->assertEquals('public', $this->response->headers->get('Cache-Control')); - } - - public function testDoesNotCacheWithCookieHeaderAndNonPublicResponse() - { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array(), array('foo' => 'bar')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesNotCacheRequestsWithACookieHeader() - { - $this->setNextResponse(200); - $this->request('GET', '/', array(), array('foo' => 'bar')); - - $this->assertHttpKernelIsCalled(); - $this->assertResponseOk(); - $this->assertEquals('private', $this->response->headers->get('Cache-Control')); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() - { - $time = \DateTime::createFromFormat('U', time()); - - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822), 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->headers->get('Content-Type')); - $this->assertEmpty($this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testRespondsWith304WhenIfNoneMatchMatchesETag() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '12345', 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345')); - - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->headers->get('Content-Type')); - $this->assertTrue($this->response->headers->has('ETag')); - $this->assertEmpty($this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch() - { - $time = \DateTime::createFromFormat('U', time()); - - $this->setNextResponse(200, array(), '', function ($request, $response) use ($time) { - $response->setStatusCode(200); - $response->headers->set('ETag', '12345'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('Hello World'); - }); - - // only ETag matches - $t = \DateTime::createFromFormat('U', time() - 3600); - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - - // only Last-Modified matches - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - - // Both matches - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - } - - public function testIncrementsMaxAgeWhenNoDateIsSpecifiedEventWhenUsingETag() - { - $this->setNextResponse( - 200, - array( - 'ETag' => '1234', - 'Cache-Control' => 'public, s-maxage=60', - ) - ); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - sleep(2); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertEquals(2, $this->response->headers->get('Age')); - } - - public function testValidatesPrivateResponsesCachedOnTheClient() - { - $this->setNextResponse(200, array(), '', function ($request, $response) { - $etags = preg_split('/\s*,\s*/', $request->headers->get('IF_NONE_MATCH')); - if ($request->cookies->has('authenticated')) { - $response->headers->set('Cache-Control', 'private, no-store'); - $response->setETag('"private tag"'); - if (in_array('"private tag"', $etags)) { - $response->setStatusCode(304); - } else { - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('private data'); - } - } else { - $response->headers->set('Cache-Control', 'public'); - $response->setETag('"public tag"'); - if (in_array('"public tag"', $etags)) { - $response->setStatusCode(304); - } else { - $response->setStatusCode(200); - $response->headers->set('Content-Type', 'text/plain'); - $response->setContent('public data'); - } - } - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('"public tag"', $this->response->headers->get('ETag')); - $this->assertEquals('public data', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $this->request('GET', '/', array(), array('authenticated' => '')); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('"private tag"', $this->response->headers->get('ETag')); - $this->assertEquals('private data', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceNotContains('store'); - } - - public function testStoresResponsesWhenNoCacheRequestDirectivePresent() - { - $time = \DateTime::createFromFormat('U', time() + 5); - - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testReloadsResponsesWhenCacheHitsButNoCacheRequestDirectivePresentWhenAllowReloadIsSetTrue() - { - $count = 0; - - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) { - ++$count; - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_reload'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Goodbye World', $this->response->getContent()); - $this->assertTraceContains('reload'); - $this->assertTraceContains('store'); - } - - public function testDoesNotReloadResponsesWhenAllowReloadIsSetFalseDefault() - { - $count = 0; - - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) { - ++$count; - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_reload'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('reload'); - - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('reload'); - } - - public function testRevalidatesFreshCacheEntryWhenMaxAgeRequestDirectiveIsExceededWhenAllowRevalidateOptionIsSetTrue() - { - $count = 0; - - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) { - ++$count; - $response->headers->set('Cache-Control', 'public, max-age=10000'); - $response->setETag($count); - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_revalidate'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Goodbye World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - } - - public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIsSetFalseDefault() - { - $count = 0; - - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) { - ++$count; - $response->headers->set('Cache-Control', 'public, max-age=10000'); - $response->setETag($count); - $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); - }); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('store'); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - $this->cacheConfig['allow_revalidate'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('stale'); - $this->assertTraceNotContains('invalid'); - $this->assertTraceContains('fresh'); - - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceNotContains('stale'); - $this->assertTraceNotContains('invalid'); - $this->assertTraceContains('fresh'); - } - - public function testFetchesResponseFromBackendWhenCacheMisses() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testDoesNotCacheSomeStatusCodeResponses() - { - foreach (array_merge(range(201, 202), range(204, 206), range(303, 305), range(400, 403), range(405, 409), range(411, 417), range(500, 505)) as $code) { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse($code, array('Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals($code, $this->response->getStatusCode()); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - } - - public function testDoesNotCacheResponsesWithExplicitNoStoreDirective() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'no-store')); - - $this->request('GET', '/'); - $this->assertTraceNotContains('store'); - $this->assertFalse($this->response->headers->has('Age')); - } - - public function testDoesNotCacheResponsesWithoutFreshnessInformationOrAValidator() - { - $this->setNextResponse(); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceNotContains('store'); - } - - public function testCachesResponsesWithExplicitNoCacheDirective() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, no-cache')); - - $this->request('GET', '/'); - $this->assertTraceContains('store'); - $this->assertTrue($this->response->headers->has('Age')); - } - - public function testCachesResponsesWithAnExpirationHeader() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithAMaxAgeDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=5')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithASMaxAgeDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 's-maxage=5')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - } - - public function testCachesResponsesWithALastModifiedValidatorButNoFreshnessInformation() - { - $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testCachesResponsesWithAnETagValidatorButNoFreshnessInformation() - { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"123456"')); - - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - } - - public function testHitsCachedResponsesWithExpiresHeader() - { - $time1 = \DateTime::createFromFormat('U', time() - 5); - $time2 = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Date' => $time1->format(DATE_RFC2822), 'Expires' => $time2->format(DATE_RFC2822))); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertLessThan(2, strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date'))); - $this->assertGreaterThan(0, $this->response->headers->get('Age')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testHitsCachedResponseWithMaxAgeDirective() - { - $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, max-age=10')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertLessThan(2, strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date'))); - $this->assertGreaterThan(0, $this->response->headers->get('Age')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testDegradationWhenCacheLocked() - { - if ('\\' === DIRECTORY_SEPARATOR) { - $this->markTestSkipped('Skips on windows to avoid permissions issues.'); - } - - $this->cacheConfig['stale_while_revalidate'] = 10; - - // The prescence of Last-Modified makes this cacheable (because Response::isValidateable() then). - $this->setNextResponse(200, array('Cache-Control' => 'public, s-maxage=5', 'Last-Modified' => 'some while ago'), 'Old response'); - $this->request('GET', '/'); // warm the cache - - // Now, lock the cache - $concurrentRequest = Request::create('/', 'GET'); - $this->store->lock($concurrentRequest); - - /* - * After 10s, the cached response has become stale. Yet, we're still within the "stale_while_revalidate" - * timeout so we may serve the stale response. - */ - sleep(10); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('stale-while-revalidate'); - $this->assertEquals('Old response', $this->response->getContent()); - - /* - * Another 10s later, stale_while_revalidate is over. Resort to serving the old response, but - * do so with a "server unavailable" message. - */ - sleep(10); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(503, $this->response->getStatusCode()); - $this->assertEquals('Old response', $this->response->getContent()); - } - - public function testHitsCachedResponseWithSMaxAgeDirective() - { - $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 's-maxage=10, max-age=0')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertLessThan(2, strtotime($this->responses[0]->headers->get('Date')) - strtotime($this->response->headers->get('Date'))); - $this->assertGreaterThan(0, $this->response->headers->get('Age')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() - { - $this->setNextResponse(); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); - } - - public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpired() - { - $this->setNextResponse(); - - $this->cacheConfig['default_ttl'] = 2; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - // expires the cache - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - $tmp = unserialize($values[0]); - $time = \DateTime::createFromFormat('U', time() - 5); - $tmp[0][1]['date'] = $time->format(DATE_RFC2822); - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('save'); - $m->setAccessible(true); - $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - $this->setNextResponse(); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - } - - public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304() - { - $this->setNextResponse(); - - $this->cacheConfig['default_ttl'] = 2; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - // expires the cache - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - $tmp = unserialize($values[0]); - $time = \DateTime::createFromFormat('U', time() - 5); - $tmp[0][1]['date'] = $time->format(DATE_RFC2822); - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('save'); - $m->setAccessible(true); - $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - } - - public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() - { - $this->setNextResponse(200, array('Cache-Control' => 'must-revalidate')); - - $this->cacheConfig['default_ttl'] = 10; - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceNotContains('store'); - $this->assertNotRegExp('/s-maxage/', $this->response->headers->get('Cache-Control')); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() - { - $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Date')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertNotNull($this->response->headers->get('Age')); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - - // go in and play around with the cached metadata directly ... - $values = $this->getMetaStorageValues(); - $this->assertCount(1, $values); - $tmp = unserialize($values[0]); - $time = \DateTime::createFromFormat('U', time()); - $tmp[0][1]['expires'] = $time->format(DATE_RFC2822); - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('save'); - $m->setAccessible(true); - $m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp)); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertLessThanOrEqual(1, $this->response->headers->get('Age')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertTraceContains('stale'); - $this->assertTraceNotContains('fresh'); - $this->assertTraceNotContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Hello World', $this->response->getContent()); - } - - public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInformation() - { - $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time) { - $response->headers->set('Cache-Control', 'public'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - if ($time->format(DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) { - $response->setStatusCode(304); - $response->setContent(''); - } - }); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Last-Modified')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('stale'); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('Last-Modified')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertLessThanOrEqual(1, $this->response->headers->get('Age')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - } - - public function testValidatesCachedResponsesUseSameHttpMethod() - { - $test = $this; - - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($test) { - $test->assertSame('OPTIONS', $request->getMethod()); - }); - - // build initial request - $this->request('OPTIONS', '/'); - - // build subsequent request - $this->request('OPTIONS', '/'); - } - - public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { - $response->headers->set('Cache-Control', 'public'); - $response->headers->set('ETag', '"12345"'); - if ($response->getETag() == $request->headers->get('IF_NONE_MATCH')) { - $response->setStatusCode(304); - $response->setContent(''); - } - }); - - // build initial request - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('ETag')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - // build subsequent request; should be found but miss due to freshness - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertNotNull($this->response->headers->get('ETag')); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $this->assertLessThanOrEqual(1, $this->response->headers->get('Age')); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - $this->assertTraceContains('store'); - $this->assertTraceNotContains('miss'); - } - - public function testServesResponseWhileFreshAndRevalidatesWithLastModifiedInformation() - { - $time = \DateTime::createFromFormat('U', time()); - - $this->setNextResponse(200, array(), 'Hello World', function (Request $request, Response $response) use ($time) { - $response->setSharedMaxAge(10); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - }); - - // prime the cache - $this->request('GET', '/'); - - // next request before s-maxage has expired: Serve from cache - // without hitting the backend - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - sleep(15); // expire the cache - - $this->setNextResponse(304, array(), '', function (Request $request, Response $response) use ($time) { - $this->assertEquals($time->format(DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE')); - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('valid'); - } - - public function testReplacesCachedResponsesWhenValidationResultsInNon304Response() - { - $time = \DateTime::createFromFormat('U', time()); - $count = 0; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time, &$count) { - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - $response->headers->set('Cache-Control', 'public'); - switch (++$count) { - case 1: - $response->setContent('first response'); - break; - case 2: - $response->setContent('second response'); - break; - case 3: - $response->setContent(''); - $response->setStatusCode(304); - break; - } - }); - - // first request should fetch from backend and store in cache - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('first response', $this->response->getContent()); - - // second request is validated, is invalid, and replaces cached entry - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('second response', $this->response->getContent()); - - // third response is validated, valid, and returns cached entry - $this->request('GET', '/'); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('second response', $this->response->getContent()); - - $this->assertEquals(3, $count); - } - - public function testPassesHeadRequestsThroughDirectlyOnPass() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { - $response->setContent(''); - $response->setStatusCode(200); - $this->assertEquals('HEAD', $request->getMethod()); - }); - - $this->request('HEAD', '/', array('HTTP_EXPECT' => 'something ...')); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('', $this->response->getContent()); - } - - public function testUsesCacheToRespondToHeadRequestsWhenFresh() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->setContent('Hello World'); - $response->setStatusCode(200); - $this->assertNotEquals('HEAD', $request->getMethod()); - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('HEAD', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->getContent()); - $this->assertEquals(strlen('Hello World'), $this->response->headers->get('Content-Length')); - } - - public function testSendsNoContentWhenFresh() - { - $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time) { - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - }); - - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('Hello World', $this->response->getContent()); - - $this->request('GET', '/', array('HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822))); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(304, $this->response->getStatusCode()); - $this->assertEquals('', $this->response->getContent()); - } - - public function testInvalidatesCachedResponsesOnPost() - { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { - if ('GET' == $request->getMethod()) { - $response->setStatusCode(200); - $response->headers->set('Cache-Control', 'public, max-age=500'); - $response->setContent('Hello World'); - } elseif ('POST' == $request->getMethod()) { - $response->setStatusCode(303); - $response->headers->set('Location', '/'); - $response->headers->remove('Cache-Control'); - $response->setContent(''); - } - }); - - // build initial request to enter into the cache - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - // make sure it is valid - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('fresh'); - - // now POST to same URL - $this->request('POST', '/helloworld'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals('/', $this->response->headers->get('Location')); - $this->assertTraceContains('invalidate'); - $this->assertTraceContains('pass'); - $this->assertEquals('', $this->response->getContent()); - - // now make sure it was actually invalidated - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertTraceContains('stale'); - $this->assertTraceContains('invalid'); - $this->assertTraceContains('store'); - } - - public function testServesFromCacheWhenHeadersMatch() - { - $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) { - $response->headers->set('Vary', 'Accept User-Agent Foo'); - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('X-Response-Count', ++$count); - $response->setContent($request->headers->get('USER_AGENT')); - }); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertTraceContains('fresh'); - $this->assertTraceNotContains('store'); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - } - - public function testStoresMultipleResponsesWhenHeadersDiffer() - { - $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) { - $response->headers->set('Vary', 'Accept User-Agent Foo'); - $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('X-Response-Count', ++$count); - $response->setContent($request->headers->get('USER_AGENT')); - }); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertEquals(200, $this->response->getStatusCode()); - $this->assertTraceContains('miss'); - $this->assertTraceContains('store'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); - $this->assertTraceContains('fresh'); - $this->assertEquals('Bob/1.0', $this->response->getContent()); - $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertTraceContains('fresh'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - - $this->request('GET', '/', array('HTTP_USER_AGENT' => 'Bob/2.0')); - $this->assertTraceContains('miss'); - $this->assertEquals('Bob/2.0', $this->response->getContent()); - $this->assertEquals(3, $this->response->headers->get('X-Response-Count')); - } - - public function testShouldCatchExceptions() - { - $this->catchExceptions(); - - $this->setNextResponse(); - $this->request('GET', '/'); - - $this->assertExceptionsAreCaught(); - } - - public function testShouldCatchExceptionsWhenReloadingAndNoCacheRequest() - { - $this->catchExceptions(); - - $this->setNextResponse(); - $this->cacheConfig['allow_reload'] = true; - $this->request('GET', '/', array(), array(), false, array('Pragma' => 'no-cache')); - - $this->assertExceptionsAreCaught(); - } - - public function testShouldNotCatchExceptions() - { - $this->catchExceptions(false); - - $this->setNextResponse(); - $this->request('GET', '/'); - - $this->assertExceptionsAreNotCaught(); - } - - public function testEsiCacheSendsTheLowestTtl() - { - $responses = array( - array( - 'status' => 200, - 'body' => ' ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array('Cache-Control' => 's-maxage=200'), - ), - array( - 'status' => 200, - 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); - - $this->assertEquals(100, $this->response->getTtl()); - } - - public function testEsiCacheSendsTheLowestTtlForHeadRequests() - { - $responses = array( - array( - 'status' => 200, - 'body' => 'I am a long-lived master response, but I embed a short-lived resource: ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'I am a short-lived resource', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('HEAD', '/', array(), array(), true); - - $this->assertEmpty($this->response->getContent()); - $this->assertEquals(100, $this->response->getTtl()); - } - - public function testEsiCacheForceValidation() - { - $responses = array( - array( - 'status' => 200, - 'body' => ' ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array('ETag' => 'foobar'), - ), - array( - 'status' => 200, - 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); - $this->assertNull($this->response->getTtl()); - $this->assertTrue($this->response->mustRevalidate()); - $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); - $this->assertTrue($this->response->headers->hasCacheControlDirective('no-cache')); - } - - public function testEsiCacheForceValidationForHeadRequests() - { - $responses = array( - array( - 'status' => 200, - 'body' => 'I am the master response and use expiration caching, but I embed another resource: ', - 'headers' => array( - 'Cache-Control' => 's-maxage=300', - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'I am the embedded resource and use validation caching', - 'headers' => array('ETag' => 'foobar'), - ), - ); - - $this->setNextResponses($responses); - - $this->request('HEAD', '/', array(), array(), true); - - // The response has been assembled from expiration and validation based resources - // This can neither be cached nor revalidated, so it should be private/no cache - $this->assertEmpty($this->response->getContent()); - $this->assertNull($this->response->getTtl()); - $this->assertTrue($this->response->mustRevalidate()); - $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); - $this->assertTrue($this->response->headers->hasCacheControlDirective('no-cache')); - } - - public function testEsiRecalculateContentLengthHeader() - { - $responses = array( - array( - 'status' => 200, - 'body' => '', - 'headers' => array( - 'Content-Length' => 26, - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array(), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertEquals('Hello World!', $this->response->getContent()); - $this->assertEquals(12, $this->response->headers->get('Content-Length')); - } - - public function testEsiRecalculateContentLengthHeaderForHeadRequest() - { - $responses = array( - array( - 'status' => 200, - 'body' => '', - 'headers' => array( - 'Content-Length' => 26, - 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( - 'status' => 200, - 'body' => 'Hello World!', - 'headers' => array(), - ), - ); - - $this->setNextResponses($responses); - - $this->request('HEAD', '/', array(), array(), true); - - // https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13 - // "The Content-Length entity-header field indicates the size of the entity-body, - // in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD - // method, the size of the entity-body that would have been sent had the request - // been a GET." - $this->assertEmpty($this->response->getContent()); - $this->assertEquals(12, $this->response->headers->get('Content-Length')); - } - - public function testClientIpIsAlwaysLocalhostForForwardedRequests() - { - $this->setNextResponse(); - $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); - - $this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR')); - } - - /** - * @dataProvider getTrustedProxyData - */ - public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected) - { - Request::setTrustedProxies($existing, Request::HEADER_X_FORWARDED_ALL); - - $this->setNextResponse(); - $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); - - $this->assertEquals($expected, Request::getTrustedProxies()); - } - - public function getTrustedProxyData() - { - return array( - array(array(), array('127.0.0.1')), - array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')), - array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')), - ); - } - - /** - * @dataProvider getXForwardedForData - */ - public function testXForwarderForHeaderForForwardedRequests($xForwardedFor, $expected) - { - $this->setNextResponse(); - $server = array('REMOTE_ADDR' => '10.0.0.1'); - if (false !== $xForwardedFor) { - $server['HTTP_X_FORWARDED_FOR'] = $xForwardedFor; - } - $this->request('GET', '/', $server); - - $this->assertEquals($expected, $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For')); - } - - public function getXForwardedForData() - { - return array( - array(false, '10.0.0.1'), - array('10.0.0.2', '10.0.0.2, 10.0.0.1'), - array('10.0.0.2, 10.0.0.3', '10.0.0.2, 10.0.0.3, 10.0.0.1'), - ); - } - - public function testXForwarderForHeaderForPassRequests() - { - $this->setNextResponse(); - $server = array('REMOTE_ADDR' => '10.0.0.1'); - $this->request('POST', '/', $server); - - $this->assertEquals('10.0.0.1', $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For')); - } - - public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses() - { - $time = \DateTime::createFromFormat('U', time()); - - $responses = array( - array( - 'status' => 200, - 'body' => '', - 'headers' => array( - 'Surrogate-Control' => 'content="ESI/1.0"', - 'ETag' => 'hey', - 'Last-Modified' => $time->format(DATE_RFC2822), - ), - ), - array( - 'status' => 200, - 'body' => 'Hey!', - 'headers' => array(), - ), - ); - - $this->setNextResponses($responses); - - $this->request('GET', '/', array(), array(), true); - $this->assertNull($this->response->getETag()); - $this->assertNull($this->response->getLastModified()); - } - - public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponsesAndHeadRequest() - { - $time = \DateTime::createFromFormat('U', time()); - - $responses = array( - array( - 'status' => 200, - 'body' => '', - 'headers' => array( - 'Surrogate-Control' => 'content="ESI/1.0"', - 'ETag' => 'hey', - 'Last-Modified' => $time->format(DATE_RFC2822), - ), - ), - array( - 'status' => 200, - 'body' => 'Hey!', - 'headers' => array(), - ), - ); - - $this->setNextResponses($responses); - - $this->request('HEAD', '/', array(), array(), true); - $this->assertEmpty($this->response->getContent()); - $this->assertNull($this->response->getETag()); - $this->assertNull($this->response->getLastModified()); - } - - public function testDoesNotCacheOptionsRequest() - { - $this->setNextResponse(200, array('Cache-Control' => 'public, s-maxage=60'), 'get'); - $this->request('GET', '/'); - $this->assertHttpKernelIsCalled(); - - $this->setNextResponse(200, array('Cache-Control' => 'public, s-maxage=60'), 'options'); - $this->request('OPTIONS', '/'); - $this->assertHttpKernelIsCalled(); - - $this->request('GET', '/'); - $this->assertHttpKernelIsNotCalled(); - $this->assertSame('get', $this->response->getContent()); - } -} - -class TestKernel implements HttpKernelInterface -{ - public $terminateCalled = false; - - public function terminate(Request $request, Response $response) - { - $this->terminateCalled = true; - } - - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php deleted file mode 100644 index ed5c690d6..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\HttpCache\HttpCache; -use Symfony\Component\HttpKernel\HttpCache\Store; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class HttpCacheTestCase extends TestCase -{ - protected $kernel; - protected $cache; - protected $caches; - protected $cacheConfig; - protected $request; - protected $response; - protected $responses; - protected $catch; - protected $esi; - - /** - * @var Store - */ - protected $store; - - protected function setUp() - { - $this->kernel = null; - - $this->cache = null; - $this->esi = null; - $this->caches = array(); - $this->cacheConfig = array(); - - $this->request = null; - $this->response = null; - $this->responses = array(); - - $this->catch = false; - - $this->clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - protected function tearDown() - { - if ($this->cache) { - $this->cache->getStore()->cleanup(); - } - $this->kernel = null; - $this->cache = null; - $this->caches = null; - $this->request = null; - $this->response = null; - $this->responses = null; - $this->cacheConfig = null; - $this->catch = null; - $this->esi = null; - - $this->clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - public function assertHttpKernelIsCalled() - { - $this->assertTrue($this->kernel->hasBeenCalled()); - } - - public function assertHttpKernelIsNotCalled() - { - $this->assertFalse($this->kernel->hasBeenCalled()); - } - - public function assertResponseOk() - { - $this->assertEquals(200, $this->response->getStatusCode()); - } - - public function assertTraceContains($trace) - { - $traces = $this->cache->getTraces(); - $traces = current($traces); - - $this->assertRegExp('/'.$trace.'/', implode(', ', $traces)); - } - - public function assertTraceNotContains($trace) - { - $traces = $this->cache->getTraces(); - $traces = current($traces); - - $this->assertNotRegExp('/'.$trace.'/', implode(', ', $traces)); - } - - public function assertExceptionsAreCaught() - { - $this->assertTrue($this->kernel->isCatchingExceptions()); - } - - public function assertExceptionsAreNotCaught() - { - $this->assertFalse($this->kernel->isCatchingExceptions()); - } - - public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false, $headers = array()) - { - if (null === $this->kernel) { - throw new \LogicException('You must call setNextResponse() before calling request().'); - } - - $this->kernel->reset(); - - $this->store = new Store(sys_get_temp_dir().'/http_cache'); - - $this->cacheConfig['debug'] = true; - - $this->esi = $esi ? new Esi() : null; - $this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig); - $this->request = Request::create($uri, $method, array(), $cookies, array(), $server); - $this->request->headers->add($headers); - - $this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch); - - $this->responses[] = $this->response; - } - - public function getMetaStorageValues() - { - $values = array(); - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(sys_get_temp_dir().'/http_cache/md', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - $values[] = file_get_contents($file); - } - - return $values; - } - - // A basic response with 200 status code and a tiny body. - public function setNextResponse($statusCode = 200, array $headers = array(), $body = 'Hello World', \Closure $customizer = null) - { - $this->kernel = new TestHttpKernel($body, $statusCode, $headers, $customizer); - } - - public function setNextResponses($responses) - { - $this->kernel = new TestMultipleHttpKernel($responses); - } - - public function catchExceptions($catch = true) - { - $this->catch = $catch; - } - - public static function clearDirectory($directory) - { - if (!is_dir($directory)) { - return; - } - - $fp = opendir($directory); - while (false !== $file = readdir($fp)) { - if (!in_array($file, array('.', '..'))) { - if (is_link($directory.'/'.$file)) { - unlink($directory.'/'.$file); - } elseif (is_dir($directory.'/'.$file)) { - self::clearDirectory($directory.'/'.$file); - rmdir($directory.'/'.$file); - } else { - unlink($directory.'/'.$file); - } - } - } - - closedir($fp); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/ResponseCacheStrategyTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/ResponseCacheStrategyTest.php deleted file mode 100644 index 5e4c32222..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/ResponseCacheStrategyTest.php +++ /dev/null @@ -1,222 +0,0 @@ - - * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategy; - -class ResponseCacheStrategyTest extends TestCase -{ - public function testMinimumSharedMaxAgeWins() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $response1 = new Response(); - $response1->setSharedMaxAge(60); - $cacheStrategy->add($response1); - - $response2 = new Response(); - $response2->setSharedMaxAge(3600); - $cacheStrategy->add($response2); - - $response = new Response(); - $response->setSharedMaxAge(86400); - $cacheStrategy->update($response); - - $this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage')); - } - - public function testSharedMaxAgeNotSetIfNotSetInAnyEmbeddedRequest() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $response1 = new Response(); - $response1->setSharedMaxAge(60); - $cacheStrategy->add($response1); - - $response2 = new Response(); - $cacheStrategy->add($response2); - - $response = new Response(); - $response->setSharedMaxAge(86400); - $cacheStrategy->update($response); - - $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage')); - } - - public function testSharedMaxAgeNotSetIfNotSetInMasterRequest() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $response1 = new Response(); - $response1->setSharedMaxAge(60); - $cacheStrategy->add($response1); - - $response2 = new Response(); - $response2->setSharedMaxAge(3600); - $cacheStrategy->add($response2); - - $response = new Response(); - $cacheStrategy->update($response); - - $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage')); - } - - public function testMasterResponseNotCacheableWhenEmbeddedResponseRequiresValidation() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $embeddedResponse = new Response(); - $embeddedResponse->setLastModified(new \DateTime()); - $cacheStrategy->add($embeddedResponse); - - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - $cacheStrategy->update($masterResponse); - - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); - $this->assertFalse($masterResponse->isFresh()); - } - - public function testValidationOnMasterResponseIsNotPossibleWhenItContainsEmbeddedResponses() - { - $cacheStrategy = new ResponseCacheStrategy(); - - // This master response uses the "validation" model - $masterResponse = new Response(); - $masterResponse->setLastModified(new \DateTime()); - $masterResponse->setEtag('foo'); - - // Embedded response uses "expiry" model - $embeddedResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - $cacheStrategy->add($embeddedResponse); - - $cacheStrategy->update($masterResponse); - - $this->assertFalse($masterResponse->isValidateable()); - $this->assertFalse($masterResponse->headers->has('Last-Modified')); - $this->assertFalse($masterResponse->headers->has('ETag')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); - } - - public function testMasterResponseWithValidationIsUnchangedWhenThereIsNoEmbeddedResponse() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $masterResponse = new Response(); - $masterResponse->setLastModified(new \DateTime()); - $cacheStrategy->update($masterResponse); - - $this->assertTrue($masterResponse->isValidateable()); - } - - public function testMasterResponseWithExpirationIsUnchangedWhenThereIsNoEmbeddedResponse() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - $cacheStrategy->update($masterResponse); - - $this->assertTrue($masterResponse->isFresh()); - } - - public function testMasterResponseIsNotCacheableWhenEmbeddedResponseIsNotCacheable() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); // Public, cacheable - - /* This response has no validation or expiration information. - That makes it uncacheable, it is always stale. - (It does *not* make this private, though.) */ - $embeddedResponse = new Response(); - $this->assertFalse($embeddedResponse->isFresh()); // not fresh, as no lifetime is provided - - $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); - - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); - $this->assertFalse($masterResponse->isFresh()); - } - - public function testEmbeddingPrivateResponseMakesMainResponsePrivate() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); // public, cacheable - - // The embedded response might for example contain per-user data that remains valid for 60 seconds - $embeddedResponse = new Response(); - $embeddedResponse->setPrivate(); - $embeddedResponse->setMaxAge(60); // this would implicitly set "private" as well, but let's be explicit - - $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); - - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('private')); - // Not sure if we should pass "max-age: 60" in this case, as long as the response is private and - // that's the more conservative of both the master and embedded response...? - } - - public function testResponseIsExiprableWhenEmbeddedResponseCombinesExpiryAndValidation() - { - /* When "expiration wins over validation" (https://symfony.com/doc/current/http_cache/validation.html) - * and both the main and embedded response provide s-maxage, then the more restricting value of both - * should be fine, regardless of whether the embedded response can be validated later on or must be - * completely regenerated. - */ - $cacheStrategy = new ResponseCacheStrategy(); - - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - - $embeddedResponse = new Response(); - $embeddedResponse->setSharedMaxAge(60); - $embeddedResponse->setEtag('foo'); - - $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); - - $this->assertSame('60', $masterResponse->headers->getCacheControlDirective('s-maxage')); - } - - public function testResponseIsExpirableButNotValidateableWhenMasterResponseCombinesExpirationAndValidation() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(3600); - $masterResponse->setEtag('foo'); - $masterResponse->setLastModified(new \DateTime()); - - $embeddedResponse = new Response(); - $embeddedResponse->setSharedMaxAge(60); - - $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); - - $this->assertSame('60', $masterResponse->headers->getCacheControlDirective('s-maxage')); - $this->assertFalse($masterResponse->isValidateable()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/SsiTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/SsiTest.php deleted file mode 100644 index 1079d37a2..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/SsiTest.php +++ /dev/null @@ -1,215 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\Ssi; - -class SsiTest extends TestCase -{ - public function testHasSurrogateSsiCapability() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'abc="SSI/1.0"'); - $this->assertTrue($ssi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $request->headers->set('Surrogate-Capability', 'foobar'); - $this->assertFalse($ssi->hasSurrogateCapability($request)); - - $request = Request::create('/'); - $this->assertFalse($ssi->hasSurrogateCapability($request)); - } - - public function testAddSurrogateSsiCapability() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $ssi->addSurrogateCapability($request); - $this->assertEquals('symfony="SSI/1.0"', $request->headers->get('Surrogate-Capability')); - - $ssi->addSurrogateCapability($request); - $this->assertEquals('symfony="SSI/1.0", symfony="SSI/1.0"', $request->headers->get('Surrogate-Capability')); - } - - public function testAddSurrogateControl() - { - $ssi = new Ssi(); - - $response = new Response('foo '); - $ssi->addSurrogateControl($response); - $this->assertEquals('content="SSI/1.0"', $response->headers->get('Surrogate-Control')); - - $response = new Response('foo'); - $ssi->addSurrogateControl($response); - $this->assertEquals('', $response->headers->get('Surrogate-Control')); - } - - public function testNeedsSsiParsing() - { - $ssi = new Ssi(); - - $response = new Response(); - $response->headers->set('Surrogate-Control', 'content="SSI/1.0"'); - $this->assertTrue($ssi->needsParsing($response)); - - $response = new Response(); - $this->assertFalse($ssi->needsParsing($response)); - } - - public function testRenderIncludeTag() - { - $ssi = new Ssi(); - - $this->assertEquals('', $ssi->renderIncludeTag('/', '/alt', true)); - $this->assertEquals('', $ssi->renderIncludeTag('/', '/alt', false)); - $this->assertEquals('', $ssi->renderIncludeTag('/')); - } - - public function testProcessDoesNothingIfContentTypeIsNotHtml() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response(); - $response->headers->set('Content-Type', 'text/plain'); - $ssi->process($request, $response); - - $this->assertFalse($response->headers->has('x-body-eval')); - } - - public function testProcess() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $ssi->process($request, $response); - - $this->assertEquals('foo surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent()); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - - $response = new Response('foo '); - $ssi->process($request, $response); - - $this->assertEquals("foo surrogate->handle(\$this, 'foo\\'', '', false) ?>"."\n", $response->getContent()); - } - - public function testProcessEscapesPhpTags() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response(''); - $ssi->process($request, $response); - - $this->assertEquals('php cript language=php>', $response->getContent()); - } - - /** - * @expectedException \RuntimeException - */ - public function testProcessWhenNoSrcInAnSsi() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $ssi->process($request, $response); - } - - public function testProcessRemoveSurrogateControlHeader() - { - $ssi = new Ssi(); - - $request = Request::create('/'); - $response = new Response('foo '); - $response->headers->set('Surrogate-Control', 'content="SSI/1.0"'); - $ssi->process($request, $response); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - - $response->headers->set('Surrogate-Control', 'no-store, content="SSI/1.0"'); - $ssi->process($request, $response); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - - $response->headers->set('Surrogate-Control', 'content="SSI/1.0", no-store'); - $ssi->process($request, $response); - $this->assertEquals('SSI', $response->headers->get('x-body-eval')); - $this->assertEquals('no-store', $response->headers->get('surrogate-control')); - } - - public function testHandle() - { - $ssi = new Ssi(); - $cache = $this->getCache(Request::create('/'), new Response('foo')); - $this->assertEquals('foo', $ssi->handle($cache, '/', '/alt', true)); - } - - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenResponseIsNot200() - { - $ssi = new Ssi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $ssi->handle($cache, '/', '/alt', false); - } - - public function testHandleWhenResponseIsNot200AndErrorsAreIgnored() - { - $ssi = new Ssi(); - $response = new Response('foo'); - $response->setStatusCode(404); - $cache = $this->getCache(Request::create('/'), $response); - $this->assertEquals('', $ssi->handle($cache, '/', '/alt', true)); - } - - public function testHandleWhenResponseIsNot200AndAltIsPresent() - { - $ssi = new Ssi(); - $response1 = new Response('foo'); - $response1->setStatusCode(404); - $response2 = new Response('bar'); - $cache = $this->getCache(Request::create('/'), array($response1, $response2)); - $this->assertEquals('bar', $ssi->handle($cache, '/', '/alt', false)); - } - - protected function getCache($request, $response) - { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock(); - $cache->expects($this->any()) - ->method('getRequest') - ->will($this->returnValue($request)) - ; - if (is_array($response)) { - $cache->expects($this->any()) - ->method('handle') - ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) - ; - } else { - $cache->expects($this->any()) - ->method('handle') - ->will($this->returnValue($response)) - ; - } - - return $cache; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/StoreTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/StoreTest.php deleted file mode 100644 index cef019167..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/StoreTest.php +++ /dev/null @@ -1,301 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpCache\Store; - -class StoreTest extends TestCase -{ - protected $request; - protected $response; - - /** - * @var Store - */ - protected $store; - - protected function setUp() - { - $this->request = Request::create('/'); - $this->response = new Response('hello world', 200, array()); - - HttpCacheTestCase::clearDirectory(sys_get_temp_dir().'/http_cache'); - - $this->store = new Store(sys_get_temp_dir().'/http_cache'); - } - - protected function tearDown() - { - $this->store = null; - $this->request = null; - $this->response = null; - - HttpCacheTestCase::clearDirectory(sys_get_temp_dir().'/http_cache'); - } - - 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'); - $this->store->write($request, new Response('foo')); - - $metadata = $this->getStoreMetadata($request); - $this->assertNotEmpty($metadata); - - $this->assertTrue($this->store->purge('/foo')); - $this->assertEmpty($this->getStoreMetadata($request)); - - // cached content should be kept after purging - $path = $this->store->getPath($metadata[0][1]['x-content-digest'][0]); - $this->assertTrue(is_file($path)); - - $this->assertFalse($this->store->purge('/bar')); - } - - public function testStoresACacheEntry() - { - $cacheKey = $this->storeSimpleEntry(); - - $this->assertNotEmpty($this->getStoreMetadata($cacheKey)); - } - - public function testSetsTheXContentDigestResponseHeaderBeforeStoring() - { - $cacheKey = $this->storeSimpleEntry(); - $entries = $this->getStoreMetadata($cacheKey); - list($req, $res) = $entries[0]; - - $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); - } - - public function testFindsAStoredEntryWithLookup() - { - $this->storeSimpleEntry(); - $response = $this->store->lookup($this->request); - - $this->assertNotNull($response); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - } - - public function testDoesNotFindAnEntryWithLookupWhenNoneExists() - { - $request = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - - $this->assertNull($this->store->lookup($request)); - } - - public function testCanonizesUrlsForCacheKeys() - { - $this->storeSimpleEntry($path = '/test?x=y&p=q'); - $hitsReq = Request::create($path); - $missReq = Request::create('/test?p=x'); - - $this->assertNotNull($this->store->lookup($hitsReq)); - $this->assertNull($this->store->lookup($missReq)); - } - - public function testDoesNotFindAnEntryWithLookupWhenTheBodyDoesNotExist() - { - $this->storeSimpleEntry(); - $this->assertNotNull($this->response->headers->get('X-Content-Digest')); - $path = $this->getStorePath($this->response->headers->get('X-Content-Digest')); - @unlink($path); - $this->assertNull($this->store->lookup($this->request)); - } - - public function testRestoresResponseHeadersProperlyWithLookup() - { - $this->storeSimpleEntry(); - $response = $this->store->lookup($this->request); - - $this->assertEquals($response->headers->all(), array_merge(array('content-length' => 4, 'x-body-file' => array($this->getStorePath($response->headers->get('X-Content-Digest')))), $this->response->headers->all())); - } - - public function testRestoresResponseContentFromEntityStoreWithLookup() - { - $this->storeSimpleEntry(); - $response = $this->store->lookup($this->request); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test')), $response->getContent()); - } - - public function testInvalidatesMetaAndEntityStoreEntriesWithInvalidate() - { - $this->storeSimpleEntry(); - $this->store->invalidate($this->request); - $response = $this->store->lookup($this->request); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); - $this->assertFalse($response->isFresh()); - } - - public function testSucceedsQuietlyWhenInvalidateCalledWithNoMatchingEntries() - { - $req = Request::create('/test'); - $this->store->invalidate($req); - $this->assertNull($this->store->lookup($this->request)); - } - - public function testDoesNotReturnEntriesThatVaryWithLookup() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res = new Response('test', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req1, $res); - - $this->assertNull($this->store->lookup($req2)); - } - - public function testDoesNotReturnEntriesThatSlightlyVaryWithLookup() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bam')); - $res = new Response('test', 200, array('Vary' => array('Foo', 'Bar'))); - $this->store->write($req1, $res); - - $this->assertNull($this->store->lookup($req2)); - } - - public function testStoresMultipleResponsesForEachVaryCombination() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res1 = new Response('test 1', 200, array('Vary' => 'Foo Bar')); - $key = $this->store->write($req1, $res1); - - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res2 = new Response('test 2', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req2, $res2); - - $req3 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Baz', 'HTTP_BAR' => 'Boom')); - $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req3, $res3); - - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 2')), $this->store->lookup($req2)->getContent()); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent()); - - $this->assertCount(3, $this->getStoreMetadata($key)); - } - - public function testOverwritesNonVaryingResponseWithStore() - { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res1 = new Response('test 1', 200, array('Vary' => 'Foo Bar')); - $key = $this->store->write($req1, $res1); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent()); - - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res2 = new Response('test 2', 200, array('Vary' => 'Foo Bar')); - $this->store->write($req2, $res2); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 2')), $this->store->lookup($req2)->getContent()); - - $req3 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); - $key = $this->store->write($req3, $res3); - $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); - - $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)); - } - - public function testPurgeHttps() - { - $request = Request::create('https://example.com/foo'); - $this->store->write($request, new Response('foo')); - - $this->assertNotEmpty($this->getStoreMetadata($request)); - - $this->assertTrue($this->store->purge('https://example.com/foo')); - $this->assertEmpty($this->getStoreMetadata($request)); - } - - public function testPurgeHttpAndHttps() - { - $requestHttp = Request::create('https://example.com/foo'); - $this->store->write($requestHttp, new Response('foo')); - - $requestHttps = Request::create('http://example.com/foo'); - $this->store->write($requestHttps, new Response('foo')); - - $this->assertNotEmpty($this->getStoreMetadata($requestHttp)); - $this->assertNotEmpty($this->getStoreMetadata($requestHttps)); - - $this->assertTrue($this->store->purge('http://example.com/foo')); - $this->assertEmpty($this->getStoreMetadata($requestHttp)); - $this->assertEmpty($this->getStoreMetadata($requestHttps)); - } - - protected function storeSimpleEntry($path = null, $headers = array()) - { - if (null === $path) { - $path = '/test'; - } - - $this->request = Request::create($path, 'get', array(), array(), array(), $headers); - $this->response = new Response('test', 200, array('Cache-Control' => 'max-age=420')); - - return $this->store->write($this->request, $this->response); - } - - protected function getStoreMetadata($key) - { - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('getMetadata'); - $m->setAccessible(true); - - if ($key instanceof Request) { - $m1 = $r->getMethod('getCacheKey'); - $m1->setAccessible(true); - $key = $m1->invoke($this->store, $key); - } - - return $m->invoke($this->store, $key); - } - - protected function getStorePath($key) - { - $r = new \ReflectionObject($this->store); - $m = $r->getMethod('getPath'); - $m->setAccessible(true); - - return $m->invoke($this->store, $key); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestHttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestHttpKernel.php deleted file mode 100644 index 946c7a31c..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestHttpKernel.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestHttpKernel extends HttpKernel implements ControllerResolverInterface, ArgumentResolverInterface -{ - protected $body; - protected $status; - protected $headers; - protected $called = false; - protected $customizer; - protected $catch = false; - protected $backendRequest; - - public function __construct($body, $status, $headers, \Closure $customizer = null) - { - $this->body = $body; - $this->status = $status; - $this->headers = $headers; - $this->customizer = $customizer; - - parent::__construct(new EventDispatcher(), $this, null, $this); - } - - public function getBackendRequest() - { - return $this->backendRequest; - } - - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) - { - $this->catch = $catch; - $this->backendRequest = $request; - - return parent::handle($request, $type, $catch); - } - - public function isCatchingExceptions() - { - return $this->catch; - } - - public function getController(Request $request) - { - return array($this, 'callController'); - } - - public function getArguments(Request $request, $controller) - { - return array($request); - } - - public function callController(Request $request) - { - $this->called = true; - - $response = new Response($this->body, $this->status, $this->headers); - - if (null !== $customizer = $this->customizer) { - $customizer($request, $response); - } - - return $response; - } - - public function hasBeenCalled() - { - return $this->called; - } - - public function reset() - { - $this->called = false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestMultipleHttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestMultipleHttpKernel.php deleted file mode 100644 index 926d8daf5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpCache/TestMultipleHttpKernel.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\HttpCache; - -use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface, ArgumentResolverInterface -{ - protected $bodies = array(); - protected $statuses = array(); - protected $headers = array(); - protected $called = false; - protected $backendRequest; - - public function __construct($responses) - { - foreach ($responses as $response) { - $this->bodies[] = $response['body']; - $this->statuses[] = $response['status']; - $this->headers[] = $response['headers']; - } - - parent::__construct(new EventDispatcher(), $this, null, $this); - } - - public function getBackendRequest() - { - return $this->backendRequest; - } - - public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) - { - $this->backendRequest = $request; - - return parent::handle($request, $type, $catch); - } - - public function getController(Request $request) - { - return array($this, 'callController'); - } - - public function getArguments(Request $request, $controller) - { - return array($request); - } - - public function callController(Request $request) - { - $this->called = true; - - $response = new Response(array_shift($this->bodies), array_shift($this->statuses), array_shift($this->headers)); - - return $response; - } - - public function hasBeenCalled() - { - return $this->called; - } - - public function reset() - { - $this->called = false; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/HttpKernelTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/HttpKernelTest.php deleted file mode 100644 index 7aed26aa5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/HttpKernelTest.php +++ /dev/null @@ -1,403 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class HttpKernelTest extends TestCase -{ - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue() - { - $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); - - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); - } - - /** - * @expectedException \RuntimeException - */ - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered() - { - $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); - - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); - } - - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithAHandlingListener() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - $event->setResponse(new Response($event->getException()->getMessage())); - }); - - $kernel = $this->getHttpKernel($dispatcher, function () { throw new \RuntimeException('foo'); }); - $response = $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); - - $this->assertEquals('500', $response->getStatusCode()); - $this->assertEquals('foo', $response->getContent()); - } - - public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrueWithANonHandlingListener() - { - $exception = new \RuntimeException(); - - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - // should set a response, but does not - }); - - $kernel = $this->getHttpKernel($dispatcher, function () use ($exception) { throw $exception; }); - - try { - $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); - $this->fail('LogicException expected'); - } catch (\RuntimeException $e) { - $this->assertSame($exception, $e); - } - } - - public function testHandleExceptionWithARedirectionResponse() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - $event->setResponse(new RedirectResponse('/login', 301)); - }); - - $kernel = $this->getHttpKernel($dispatcher, function () { throw new AccessDeniedHttpException(); }); - $response = $kernel->handle(new Request()); - - $this->assertEquals('301', $response->getStatusCode()); - $this->assertEquals('/login', $response->headers->get('Location')); - } - - public function testHandleHttpException() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) { - $event->setResponse(new Response($event->getException()->getMessage())); - }); - - $kernel = $this->getHttpKernel($dispatcher, function () { throw new MethodNotAllowedHttpException(array('POST')); }); - $response = $kernel->handle(new Request()); - - $this->assertEquals('405', $response->getStatusCode()); - $this->assertEquals('POST', $response->headers->get('Allow')); - } - - /** - * @group legacy - * @dataProvider getStatusCodes - */ - public function testLegacyHandleWhenAnExceptionIsHandledWithASpecificStatusCode($responseStatusCode, $expectedStatusCode) - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($responseStatusCode, $expectedStatusCode) { - $event->setResponse(new Response('', $responseStatusCode, array('X-Status-Code' => $expectedStatusCode))); - }); - - $kernel = $this->getHttpKernel($dispatcher, function () { throw new \RuntimeException(); }); - $response = $kernel->handle(new Request()); - - $this->assertEquals($expectedStatusCode, $response->getStatusCode()); - $this->assertFalse($response->headers->has('X-Status-Code')); - } - - public function getStatusCodes() - { - return array( - array(200, 404), - array(404, 200), - array(301, 200), - array(500, 200), - ); - } - - /** - * @dataProvider getSpecificStatusCodes - */ - public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($expectedStatusCode) - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::EXCEPTION, function (GetResponseForExceptionEvent $event) use ($expectedStatusCode) { - $event->allowCustomResponseCode(); - $event->setResponse(new Response('', $expectedStatusCode)); - }); - - $kernel = $this->getHttpKernel($dispatcher, function () { throw new \RuntimeException(); }); - $response = $kernel->handle(new Request()); - - $this->assertEquals($expectedStatusCode, $response->getStatusCode()); - } - - public function getSpecificStatusCodes() - { - return array( - array(200), - array(302), - array(403), - ); - } - - public function testHandleWhenAListenerReturnsAResponse() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::REQUEST, function ($event) { - $event->setResponse(new Response('hello')); - }); - - $kernel = $this->getHttpKernel($dispatcher); - - $this->assertEquals('hello', $kernel->handle(new Request())->getContent()); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ - public function testHandleWhenNoControllerIsFound() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, false); - - $kernel->handle(new Request()); - } - - public function testHandleWhenTheControllerIsAClosure() - { - $response = new Response('foo'); - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, function () use ($response) { return $response; }); - - $this->assertSame($response, $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAnObjectWithInvoke() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, new Controller()); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAFunction() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, 'Symfony\Component\HttpKernel\Tests\controller_func'); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAnArray() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, array(new Controller(), 'controller')); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleWhenTheControllerIsAStaticArray() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\Controller', 'staticcontroller')); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - /** - * @expectedException \LogicException - */ - public function testHandleWhenTheControllerDoesNotReturnAResponse() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, function () { return 'foo'; }); - - $kernel->handle(new Request()); - } - - public function testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::VIEW, function ($event) { - $event->setResponse(new Response($event->getControllerResult())); - }); - - $kernel = $this->getHttpKernel($dispatcher, function () { return 'foo'; }); - - $this->assertEquals('foo', $kernel->handle(new Request())->getContent()); - } - - public function testHandleWithAResponseListener() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::RESPONSE, function ($event) { - $event->setResponse(new Response('foo')); - }); - $kernel = $this->getHttpKernel($dispatcher); - - $this->assertEquals('foo', $kernel->handle(new Request())->getContent()); - } - - public function testHandleAllowChangingControllerArguments() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::CONTROLLER_ARGUMENTS, function (FilterControllerArgumentsEvent $event) { - $event->setArguments(array('foo')); - }); - - $kernel = $this->getHttpKernel($dispatcher, function ($content) { return new Response($content); }); - - $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); - } - - public function testHandleAllowChangingControllerAndArguments() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::CONTROLLER_ARGUMENTS, function (FilterControllerArgumentsEvent $event) { - $oldController = $event->getController(); - $oldArguments = $event->getArguments(); - - $newController = function ($id) use ($oldController, $oldArguments) { - $response = call_user_func_array($oldController, $oldArguments); - - $response->headers->set('X-Id', $id); - - return $response; - }; - - $event->setController($newController); - $event->setArguments(array('bar')); - }); - - $kernel = $this->getHttpKernel($dispatcher, function ($content) { return new Response($content); }, null, array('foo')); - - $this->assertResponseEquals(new Response('foo', 200, array('X-Id' => 'bar')), $kernel->handle(new Request())); - } - - public function testTerminate() - { - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher); - $dispatcher->addListener(KernelEvents::TERMINATE, function ($event) use (&$called, &$capturedKernel, &$capturedRequest, &$capturedResponse) { - $called = true; - $capturedKernel = $event->getKernel(); - $capturedRequest = $event->getRequest(); - $capturedResponse = $event->getResponse(); - }); - - $kernel->terminate($request = Request::create('/'), $response = new Response()); - $this->assertTrue($called); - $this->assertEquals($kernel, $capturedKernel); - $this->assertEquals($request, $capturedRequest); - $this->assertEquals($response, $capturedResponse); - } - - public function testVerifyRequestStackPushPopDuringHandle() - { - $request = new Request(); - - $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('push', 'pop'))->getMock(); - $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); - $stack->expects($this->at(1))->method('pop'); - - $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, null, $stack); - - $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException - */ - public function testInconsistentClientIpsOnMasterRequests() - { - $request = new Request(); - $request->setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); - $request->server->set('REMOTE_ADDR', '1.1.1.1'); - $request->headers->set('FORWARDED', 'for=2.2.2.2'); - $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); - - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(KernelEvents::REQUEST, function ($event) { - $event->getRequest()->getClientIp(); - }); - - $kernel = $this->getHttpKernel($dispatcher); - $kernel->handle($request, $kernel::MASTER_REQUEST, false); - } - - private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, RequestStack $requestStack = null, array $arguments = array()) - { - if (null === $controller) { - $controller = function () { return new Response('Hello'); }; - } - - $controllerResolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock(); - $controllerResolver - ->expects($this->any()) - ->method('getController') - ->will($this->returnValue($controller)); - - $argumentResolver = $this->getMockBuilder(ArgumentResolverInterface::class)->getMock(); - $argumentResolver - ->expects($this->any()) - ->method('getArguments') - ->will($this->returnValue($arguments)); - - return new HttpKernel($eventDispatcher, $controllerResolver, $requestStack, $argumentResolver); - } - - private function assertResponseEquals(Response $expected, Response $actual) - { - $expected->setDate($actual->getDate()); - $this->assertEquals($expected, $actual); - } -} - -class Controller -{ - public function __invoke() - { - return new Response('foo'); - } - - public function controller() - { - return new Response('foo'); - } - - public static function staticController() - { - return new Response('foo'); - } -} - -function controller_func() -{ - return new Response('foo'); -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/KernelTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/KernelTest.php deleted file mode 100644 index 755e1db2b..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/KernelTest.php +++ /dev/null @@ -1,1060 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\HttpKernel\Config\EnvParametersResource; -use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; -use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelWithoutBundles; -use Symfony\Component\HttpKernel\Tests\Fixtures\ResettableService; - -class KernelTest extends TestCase -{ - public static function tearDownAfterClass() - { - $fs = new Filesystem(); - $fs->remove(__DIR__.'/Fixtures/cache'); - } - - public function testConstructor() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $this->assertEquals($env, $kernel->getEnvironment()); - $this->assertEquals($debug, $kernel->isDebug()); - $this->assertFalse($kernel->isBooted()); - $this->assertLessThanOrEqual(microtime(true), $kernel->getStartTime()); - $this->assertNull($kernel->getContainer()); - } - - public function testClone() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $clone = clone $kernel; - - $this->assertEquals($env, $clone->getEnvironment()); - $this->assertEquals($debug, $clone->isDebug()); - $this->assertFalse($clone->isBooted()); - $this->assertLessThanOrEqual(microtime(true), $clone->getStartTime()); - $this->assertNull($clone->getContainer()); - } - - public function testInitializeContainerClearsOldContainers() - { - $fs = new Filesystem(); - $legacyContainerDir = __DIR__.'/Fixtures/cache/custom/ContainerA123456'; - $fs->mkdir($legacyContainerDir); - touch($legacyContainerDir.'.legacy'); - - $kernel = new CustomProjectDirKernel(); - $kernel->boot(); - - $containerDir = __DIR__.'/Fixtures/cache/custom/'.substr(get_class($kernel->getContainer()), 0, 16); - $this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta')); - $this->assertFileExists($containerDir); - $this->assertFileNotExists($containerDir.'.legacy'); - - $kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); }); - $kernel->boot(); - - $this->assertFileExists($containerDir); - $this->assertFileExists($containerDir.'.legacy'); - - $this->assertFileNotExists($legacyContainerDir); - $this->assertFileNotExists($legacyContainerDir.'.legacy'); - } - - public function testBootInitializesBundlesAndContainer() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); - $kernel->expects($this->once()) - ->method('initializeBundles'); - $kernel->expects($this->once()) - ->method('initializeContainer'); - - $kernel->boot(); - } - - public function testBootSetsTheContainerToTheBundles() - { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); - $bundle->expects($this->once()) - ->method('setContainer'); - - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'getBundles')); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - $kernel->boot(); - } - - public function testBootSetsTheBootedFlagToTrue() - { - // use test kernel to access isBooted() - $kernel = $this->getKernelForTest(array('initializeBundles', 'initializeContainer')); - $kernel->boot(); - - $this->assertTrue($kernel->isBooted()); - } - - /** - * @group legacy - */ - public function testClassCacheIsLoaded() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); - $kernel->loadClassCache('name', '.extension'); - $kernel->expects($this->once()) - ->method('doLoadClassCache') - ->with('name', '.extension'); - - $kernel->boot(); - } - - public function testClassCacheIsNotLoadedByDefault() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); - $kernel->expects($this->never()) - ->method('doLoadClassCache'); - - $kernel->boot(); - } - - /** - * @group legacy - */ - public function testClassCacheIsNotLoadedWhenKernelIsNotBooted() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); - $kernel->loadClassCache(); - $kernel->expects($this->never()) - ->method('doLoadClassCache'); - } - - public function testEnvParametersResourceIsAdded() - { - $container = new ContainerBuilder(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getContainerBuilder', 'prepareContainer', 'getCacheDir', 'getLogDir')) - ->getMock(); - $kernel->expects($this->any()) - ->method('getContainerBuilder') - ->will($this->returnValue($container)); - $kernel->expects($this->any()) - ->method('prepareContainer') - ->will($this->returnValue(null)); - $kernel->expects($this->any()) - ->method('getCacheDir') - ->will($this->returnValue(sys_get_temp_dir())); - $kernel->expects($this->any()) - ->method('getLogDir') - ->will($this->returnValue(sys_get_temp_dir())); - - $reflection = new \ReflectionClass(get_class($kernel)); - $method = $reflection->getMethod('buildContainer'); - $method->setAccessible(true); - $method->invoke($kernel); - - $found = false; - foreach ($container->getResources() as $resource) { - if ($resource instanceof EnvParametersResource) { - $found = true; - break; - } - } - - $this->assertTrue($found); - } - - public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() - { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); - $kernel->expects($this->once()) - ->method('initializeBundles'); - - $kernel->boot(); - $kernel->boot(); - } - - public function testShutdownCallsShutdownOnAllBundles() - { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); - $bundle->expects($this->once()) - ->method('shutdown'); - - $kernel = $this->getKernel(array(), array($bundle)); - - $kernel->boot(); - $kernel->shutdown(); - } - - public function testShutdownGivesNullContainerToAllBundles() - { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); - $bundle->expects($this->at(3)) - ->method('setContainer') - ->with(null); - - $kernel = $this->getKernel(array('getBundles')); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); - - $kernel->boot(); - $kernel->shutdown(); - } - - public function testHandleCallsHandleOnHttpKernel() - { - $type = HttpKernelInterface::MASTER_REQUEST; - $catch = true; - $request = new Request(); - - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->getMock(); - $httpKernelMock - ->expects($this->once()) - ->method('handle') - ->with($request, $type, $catch); - - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->handle($request, $type, $catch); - } - - public function testHandleBootsTheKernel() - { - $type = HttpKernelInterface::MASTER_REQUEST; - $catch = true; - $request = new Request(); - - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->getMock(); - - $kernel = $this->getKernel(array('getHttpKernel', 'boot')); - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->expects($this->once()) - ->method('boot'); - - $kernel->handle($request, $type, $catch); - } - - public function testStripComments() - { - $source = <<<'EOF' -assertEquals($expected, $output); - } - - public function testGetRootDir() - { - $kernel = new KernelForTest('test', true); - - $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir())); - } - - public function testGetName() - { - $kernel = new KernelForTest('test', true); - - $this->assertEquals('Fixtures', $kernel->getName()); - } - - public function testOverrideGetName() - { - $kernel = new KernelForOverrideName('test', true); - - $this->assertEquals('overridden', $kernel->getName()); - } - - public function testSerialize() - { - $env = 'test_env'; - $debug = true; - $kernel = new KernelForTest($env, $debug); - - $expected = serialize(array($env, $debug)); - $this->assertEquals($expected, $kernel->serialize()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenNameIsNotValid() - { - $this->getKernel()->locateResource('Foo'); - } - - /** - * @expectedException \RuntimeException - */ - public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() - { - $this->getKernel()->locateResource('@FooBundle/../bar'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() - { - $this->getKernel()->locateResource('@FooBundle/config/routing.xml'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $kernel->locateResource('@Bundle1Bundle/config/routing.xml'); - } - - public function testLocateResourceReturnsTheFirstThatMatches() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt')); - } - - /** - * @group legacy - */ - public function testLocateResourceReturnsTheFirstThatMatchesWithParent() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(__DIR__.'/Fixtures/Bundle2Bundle/foo.txt', $kernel->locateResource('@ParentAABundle/foo.txt')); - $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/bar.txt', $kernel->locateResource('@ParentAABundle/bar.txt')); - } - - /** - * @group legacy - */ - public function testLocateResourceReturnsAllMatches() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Bundle2Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', ), - $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false)); - } - - /** - * @group legacy - */ - public function testLocateResourceReturnsAllMatchesBis() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array( - $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), - $this->getBundle(__DIR__.'/Foobar'), - ))) - ; - - $this->assertEquals( - array(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt'), - $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false) - ); - } - - public function testLocateResourceIgnoresDirOnNonResource() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', - $kernel->locateResource('@Bundle1Bundle/foo.txt', __DIR__.'/Fixtures') - ); - } - - public function testLocateResourceReturnsTheDirOneForResources() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle/foo.txt', - $kernel->locateResource('@FooBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources') - ); - } - - /** - * @group legacy - */ - public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->once()) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Resources/Bundle1Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt', ), - $kernel->locateResource('@Bundle1Bundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) - ); - } - - /** - * @group legacy - */ - public function testLocateResourceOverrideBundleAndResourcesFolders() - { - $parent = $this->getBundle(__DIR__.'/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle'); - $child = $this->getBundle(__DIR__.'/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle'); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(4)) - ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) - ; - - $this->assertEquals(array( - __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt', - __DIR__.'/Fixtures/ChildBundle/Resources/foo.txt', - __DIR__.'/Fixtures/BaseBundle/Resources/foo.txt', - ), - $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) - ); - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt', - $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources') - ); - - try { - $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', false); - $this->fail('Hidden resources should raise an exception when returning an array of matching paths'); - } catch (\RuntimeException $e) { - } - - try { - $kernel->locateResource('@BaseBundle/Resources/hide.txt', __DIR__.'/Fixtures/Resources', true); - $this->fail('Hidden resources should raise an exception when returning the first matching path'); - } catch (\RuntimeException $e) { - } - } - - public function testLocateResourceOnDirectories() - { - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle/', - $kernel->locateResource('@FooBundle/Resources/', __DIR__.'/Fixtures/Resources') - ); - $this->assertEquals( - __DIR__.'/Fixtures/Resources/FooBundle', - $kernel->locateResource('@FooBundle/Resources', __DIR__.'/Fixtures/Resources') - ); - - $kernel = $this->getKernel(array('getBundle')); - $kernel - ->expects($this->exactly(2)) - ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) - ; - - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/Resources/', - $kernel->locateResource('@Bundle1Bundle/Resources/') - ); - $this->assertEquals( - __DIR__.'/Fixtures/Bundle1Bundle/Resources', - $kernel->locateResource('@Bundle1Bundle/Resources') - ); - } - - /** - * @group legacy - */ - public function testInitializeBundles() - { - $parent = $this->getBundle(null, null, 'ParentABundle'); - $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle'); - - // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $child))) - ; - $kernel->boot(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent), $map['ParentABundle']); - } - - /** - * @group legacy - */ - public function testInitializeBundlesSupportInheritanceCascade() - { - $grandparent = $this->getBundle(null, null, 'GrandParentBBundle'); - $parent = $this->getBundle(null, 'GrandParentBBundle', 'ParentBBundle'); - $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle'); - - // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($grandparent, $parent, $child))) - ; - $kernel->boot(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentBBundle']); - $this->assertEquals(array($child, $parent), $map['ParentBBundle']); - $this->assertEquals(array($child), $map['ChildBBundle']); - } - - /** - * @group legacy - * @expectedException \LogicException - * @expectedExceptionMessage Bundle "ChildCBundle" extends bundle "FooBar", which is not registered. - */ - public function testInitializeBundlesThrowsExceptionWhenAParentDoesNotExists() - { - $child = $this->getBundle(null, 'FooBar', 'ChildCBundle'); - $kernel = $this->getKernel(array(), array($child)); - $kernel->boot(); - } - - /** - * @group legacy - */ - public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() - { - $grandparent = $this->getBundle(null, null, 'GrandParentCBundle'); - $parent = $this->getBundle(null, 'GrandParentCBundle', 'ParentCBundle'); - $child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle'); - - // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $grandparent, $child))) - ; - $kernel->boot(); - - $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCBundle']); - $this->assertEquals(array($child, $parent), $map['ParentCBundle']); - $this->assertEquals(array($child), $map['ChildCBundle']); - } - - /** - * @group legacy - * @expectedException \LogicException - * @expectedExceptionMessage Bundle "ParentCBundle" is directly extended by two bundles "ChildC2Bundle" and "ChildC1Bundle". - */ - public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtendedByTwoBundles() - { - $parent = $this->getBundle(null, null, 'ParentCBundle'); - $child1 = $this->getBundle(null, 'ParentCBundle', 'ChildC1Bundle'); - $child2 = $this->getBundle(null, 'ParentCBundle', 'ChildC2Bundle'); - - $kernel = $this->getKernel(array(), array($parent, $child1, $child2)); - $kernel->boot(); - } - - /** - * @group legacy - * @expectedException \LogicException - * @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName" - */ - public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName() - { - $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName'); - $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName'); - - $kernel = $this->getKernel(array(), array($fooBundle, $barBundle)); - $kernel->boot(); - } - - /** - * @group legacy - * @expectedException \LogicException - * @expectedExceptionMessage Bundle "CircularRefBundle" can not extend itself. - */ - public function testInitializeBundleThrowsExceptionWhenABundleExtendsItself() - { - $circularRef = $this->getBundle(null, 'CircularRefBundle', 'CircularRefBundle'); - - $kernel = $this->getKernel(array(), array($circularRef)); - $kernel->boot(); - } - - public function testTerminateReturnsSilentlyIfKernelIsNotBooted() - { - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->never()) - ->method('getHttpKernel'); - - $kernel->terminate(Request::create('/'), new Response()); - } - - public function testTerminateDelegatesTerminationOnlyForTerminableInterface() - { - // does not implement TerminableInterface - $httpKernel = new TestKernel(); - - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->once()) - ->method('getHttpKernel') - ->willReturn($httpKernel); - - $kernel->boot(); - $kernel->terminate(Request::create('/'), new Response()); - - $this->assertFalse($httpKernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); - - // implements TerminableInterface - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') - ->disableOriginalConstructor() - ->setMethods(array('terminate')) - ->getMock(); - - $httpKernelMock - ->expects($this->once()) - ->method('terminate'); - - $kernel = $this->getKernel(array('getHttpKernel')); - $kernel->expects($this->exactly(2)) - ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); - - $kernel->boot(); - $kernel->terminate(Request::create('/'), new Response()); - } - - public function testKernelWithoutBundles() - { - $kernel = new KernelWithoutBundles('test', true); - $kernel->boot(); - - $this->assertTrue($kernel->getContainer()->getParameter('test_executed')); - } - - public function testKernelRootDirNameStartingWithANumber() - { - $dir = __DIR__.'/Fixtures/123'; - require_once $dir.'/Kernel123.php'; - $kernel = new \Symfony\Component\HttpKernel\Tests\Fixtures\_123\Kernel123('dev', true); - $this->assertEquals('_123', $kernel->getName()); - } - - /** - * @group legacy - * @expectedDeprecation The Symfony\Component\HttpKernel\Kernel::getEnvParameters() method is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax to get the value of any environment variable from configuration files instead. - * @expectedDeprecation The support of special environment variables that start with SYMFONY__ (such as "SYMFONY__FOO__BAR") is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax instead to get the value of environment variables in configuration files. - */ - public function testSymfonyEnvironmentVariables() - { - $_SERVER['SYMFONY__FOO__BAR'] = 'baz'; - - $kernel = $this->getKernel(); - $method = new \ReflectionMethod($kernel, 'getEnvParameters'); - $method->setAccessible(true); - - $envParameters = $method->invoke($kernel); - $this->assertSame('baz', $envParameters['foo.bar']); - - unset($_SERVER['SYMFONY__FOO__BAR']); - } - - public function testProjectDirExtension() - { - $kernel = new CustomProjectDirKernel(); - $kernel->boot(); - - $this->assertSame('foo', $kernel->getProjectDir()); - $this->assertSame('foo', $kernel->getContainer()->getParameter('kernel.project_dir')); - } - - public function testKernelReset() - { - (new Filesystem())->remove(__DIR__.'/Fixtures/cache'); - - $kernel = new CustomProjectDirKernel(); - $kernel->boot(); - - $containerClass = get_class($kernel->getContainer()); - $containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName(); - unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta'); - - $kernel = new CustomProjectDirKernel(); - $kernel->boot(); - - $this->assertSame($containerClass, get_class($kernel->getContainer())); - $this->assertFileExists($containerFile); - unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta'); - - $kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); }); - $kernel->boot(); - - $this->assertTrue(get_class($kernel->getContainer()) !== $containerClass); - $this->assertFileExists($containerFile); - $this->assertFileExists(dirname($containerFile).'.legacy'); - } - - public function testKernelPass() - { - $kernel = new PassKernel(); - $kernel->boot(); - - $this->assertTrue($kernel->getContainer()->getParameter('test.processed')); - } - - public function testServicesResetter() - { - $httpKernelMock = $this->getMockBuilder(HttpKernelInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $httpKernelMock - ->expects($this->exactly(2)) - ->method('handle'); - - $kernel = new CustomProjectDirKernel(function ($container) { - $container->addCompilerPass(new ResettableServicePass()); - $container->register('one', ResettableService::class) - ->setPublic(true) - ->addTag('kernel.reset', array('method' => 'reset')); - $container->register('services_resetter', ServicesResetter::class)->setPublic(true); - }, $httpKernelMock, 'resetting'); - - ResettableService::$counter = 0; - - $request = new Request(); - - $kernel->handle($request); - $kernel->getContainer()->get('one'); - - $this->assertEquals(0, ResettableService::$counter); - $this->assertFalse($kernel->getContainer()->initialized('services_resetter')); - - $kernel->handle($request); - - $this->assertEquals(1, ResettableService::$counter); - } - - /** - * Returns a mock for the BundleInterface. - * - * @return BundleInterface - */ - protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null) - { - $bundle = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') - ->setMethods(array('getPath', 'getParent', 'getName')) - ->disableOriginalConstructor() - ; - - if ($className) { - $bundle->setMockClassName($className); - } - - $bundle = $bundle->getMockForAbstractClass(); - - $bundle - ->expects($this->any()) - ->method('getName') - ->will($this->returnValue(null === $bundleName ? get_class($bundle) : $bundleName)) - ; - - $bundle - ->expects($this->any()) - ->method('getPath') - ->will($this->returnValue($dir)) - ; - - $bundle - ->expects($this->any()) - ->method('getParent') - ->will($this->returnValue($parent)) - ; - - return $bundle; - } - - /** - * Returns a mock for the abstract kernel. - * - * @param array $methods Additional methods to mock (besides the abstract ones) - * @param array $bundles Bundles to register - * - * @return Kernel - */ - protected function getKernel(array $methods = array(), array $bundles = array()) - { - $methods[] = 'registerBundles'; - - $kernel = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') - ->setMethods($methods) - ->setConstructorArgs(array('test', false)) - ->getMockForAbstractClass() - ; - $kernel->expects($this->any()) - ->method('registerBundles') - ->will($this->returnValue($bundles)) - ; - $p = new \ReflectionProperty($kernel, 'rootDir'); - $p->setAccessible(true); - $p->setValue($kernel, __DIR__.'/Fixtures'); - - return $kernel; - } - - protected function getKernelForTest(array $methods = array()) - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setConstructorArgs(array('test', false)) - ->setMethods($methods) - ->getMock(); - $p = new \ReflectionProperty($kernel, 'rootDir'); - $p->setAccessible(true); - $p->setValue($kernel, __DIR__.'/Fixtures'); - - return $kernel; - } -} - -class TestKernel implements HttpKernelInterface -{ - public $terminateCalled = false; - - public function terminate() - { - $this->terminateCalled = true; - } - - public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) - { - } -} - -class CustomProjectDirKernel extends Kernel -{ - private $baseDir; - private $buildContainer; - private $httpKernel; - - public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $name = 'custom') - { - parent::__construct($name, true); - - $this->baseDir = 'foo'; - $this->buildContainer = $buildContainer; - $this->httpKernel = $httpKernel; - } - - public function registerBundles() - { - return array(); - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } - - public function getProjectDir() - { - return $this->baseDir; - } - - public function getRootDir() - { - return __DIR__.'/Fixtures'; - } - - protected function build(ContainerBuilder $container) - { - if ($build = $this->buildContainer) { - $build($container); - } - } - - protected function getHttpKernel() - { - return $this->httpKernel; - } -} - -class PassKernel extends CustomProjectDirKernel implements CompilerPassInterface -{ - public function __construct() - { - parent::__construct(); - Kernel::__construct('pass', true); - } - - public function process(ContainerBuilder $container) - { - $container->setParameter('test.processed', true); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php deleted file mode 100644 index ecf67af78..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php +++ /dev/null @@ -1,212 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Log; - -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; -use Psr\Log\LogLevel; -use Symfony\Component\HttpKernel\Log\Logger; - -/** - * @author Kévin Dunglas - * @author Jordi Boggiano - */ -class LoggerTest extends TestCase -{ - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var string - */ - private $tmpFile; - - protected function setUp() - { - $this->tmpFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.'log'; - $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile); - } - - protected function tearDown() - { - if (!@unlink($this->tmpFile)) { - file_put_contents($this->tmpFile, ''); - } - } - - public static function assertLogsMatch(array $expected, array $given) - { - foreach ($given as $k => $line) { - self::assertThat(1 === preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[\+-][0-9]{2}:[0-9]{2} '.preg_quote($expected[$k]).'/', $line), self::isTrue(), "\"$line\" do not match expected pattern \"$expected[$k]\""); - } - } - - /** - * Return the log messages in order. - * - * @return string[] - */ - public function getLogs() - { - return file($this->tmpFile, FILE_IGNORE_NEW_LINES); - } - - public function testImplements() - { - $this->assertInstanceOf(LoggerInterface::class, $this->logger); - } - - /** - * @dataProvider provideLevelsAndMessages - */ - public function testLogsAtAllLevels($level, $message) - { - $this->logger->{$level}($message, array('user' => 'Bob')); - $this->logger->log($level, $message, array('user' => 'Bob')); - - $expected = array( - "[$level] message of level $level with context: Bob", - "[$level] message of level $level with context: Bob", - ); - $this->assertLogsMatch($expected, $this->getLogs()); - } - - public function provideLevelsAndMessages() - { - return array( - LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), - LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), - LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), - LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), - LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), - LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), - LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), - LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), - ); - } - - public function testLogLevelDisabled() - { - $this->logger = new Logger(LogLevel::INFO, $this->tmpFile); - - $this->logger->debug('test', array('user' => 'Bob')); - $this->logger->log(LogLevel::DEBUG, 'test', array('user' => 'Bob')); - - // Will always be true, but asserts than an exception isn't thrown - $this->assertSame(array(), $this->getLogs()); - } - - /** - * @expectedException \Psr\Log\InvalidArgumentException - */ - public function testThrowsOnInvalidLevel() - { - $this->logger->log('invalid level', 'Foo'); - } - - /** - * @expectedException \Psr\Log\InvalidArgumentException - */ - public function testThrowsOnInvalidMinLevel() - { - new Logger('invalid'); - } - - /** - * @expectedException \Psr\Log\InvalidArgumentException - */ - public function testInvalidOutput() - { - new Logger(LogLevel::DEBUG, '/'); - } - - public function testContextReplacement() - { - $logger = $this->logger; - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); - - $expected = array('[info] {Message {nothing} Bob Bar a}'); - $this->assertLogsMatch($expected, $this->getLogs()); - } - - public function testObjectCastToString() - { - if (method_exists($this, 'createPartialMock')) { - $dummy = $this->createPartialMock(DummyTest::class, array('__toString')); - } else { - $dummy = $this->getMock(DummyTest::class, array('__toString')); - } - $dummy->expects($this->atLeastOnce()) - ->method('__toString') - ->will($this->returnValue('DUMMY')); - - $this->logger->warning($dummy); - - $expected = array('[warning] DUMMY'); - $this->assertLogsMatch($expected, $this->getLogs()); - } - - public function testContextCanContainAnything() - { - $context = array( - 'bool' => true, - 'null' => null, - 'string' => 'Foo', - 'int' => 0, - 'float' => 0.5, - 'nested' => array('with object' => new DummyTest()), - 'object' => new \DateTime(), - 'resource' => fopen('php://memory', 'r'), - ); - - $this->logger->warning('Crazy context data', $context); - - $expected = array('[warning] Crazy context data'); - $this->assertLogsMatch($expected, $this->getLogs()); - } - - public function testContextExceptionKeyCanBeExceptionOrOtherValues() - { - $logger = $this->logger; - $logger->warning('Random message', array('exception' => 'oops')); - $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); - - $expected = array( - '[warning] Random message', - '[critical] Uncaught Exception!', - ); - $this->assertLogsMatch($expected, $this->getLogs()); - } - - public function testFormatter() - { - $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile, function ($level, $message, $context) { - return json_encode(array('level' => $level, 'message' => $message, 'context' => $context)).\PHP_EOL; - }); - - $this->logger->error('An error', array('foo' => 'bar')); - $this->logger->warning('A warning', array('baz' => 'bar')); - $this->assertSame(array( - '{"level":"error","message":"An error","context":{"foo":"bar"}}', - '{"level":"warning","message":"A warning","context":{"baz":"bar"}}', - ), $this->getLogs()); - } -} - -class DummyTest -{ - public function __toString() - { - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Logger.php b/lib/silex/vendor/symfony/http-kernel/Tests/Logger.php deleted file mode 100644 index 63c70bf67..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Logger.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Psr\Log\LoggerInterface; - -class Logger implements LoggerInterface -{ - protected $logs; - - public function __construct() - { - $this->clear(); - } - - public function getLogs($level = false) - { - return false === $level ? $this->logs : $this->logs[$level]; - } - - public function clear() - { - $this->logs = array( - 'emergency' => array(), - 'alert' => array(), - 'critical' => array(), - 'error' => array(), - 'warning' => array(), - 'notice' => array(), - 'info' => array(), - 'debug' => array(), - ); - } - - public function log($level, $message, array $context = array()) - { - $this->logs[$level][] = $message; - } - - public function emergency($message, array $context = array()) - { - $this->log('emergency', $message, $context); - } - - public function alert($message, array $context = array()) - { - $this->log('alert', $message, $context); - } - - public function critical($message, array $context = array()) - { - $this->log('critical', $message, $context); - } - - public function error($message, array $context = array()) - { - $this->log('error', $message, $context); - } - - public function warning($message, array $context = array()) - { - $this->log('warning', $message, $context); - } - - public function notice($message, array $context = array()) - { - $this->log('notice', $message, $context); - } - - public function info($message, array $context = array()) - { - $this->log('info', $message, $context); - } - - public function debug($message, array $context = array()) - { - $this->log('debug', $message, $context); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Profiler/FileProfilerStorageTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Profiler/FileProfilerStorageTest.php deleted file mode 100644 index 99ff20756..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Profiler/FileProfilerStorageTest.php +++ /dev/null @@ -1,350 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage; -use Symfony\Component\HttpKernel\Profiler\Profile; - -class FileProfilerStorageTest extends TestCase -{ - private $tmpDir; - private $storage; - - protected function setUp() - { - $this->tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage'; - if (is_dir($this->tmpDir)) { - self::cleanDir(); - } - $this->storage = new FileProfilerStorage('file:'.$this->tmpDir); - $this->storage->purge(); - } - - protected function tearDown() - { - self::cleanDir(); - } - - public function testStore() - { - for ($i = 0; $i < 10; ++$i) { - $profile = new Profile('token_'.$i); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar'); - $profile->setMethod('GET'); - $this->storage->write($profile); - } - $this->assertCount(10, $this->storage->find('127.0.0.1', 'http://foo.bar', 20, 'GET'), '->write() stores data in the storage'); - } - - public function testChildren() - { - $parentProfile = new Profile('token_parent'); - $parentProfile->setIp('127.0.0.1'); - $parentProfile->setUrl('http://foo.bar/parent'); - - $childProfile = new Profile('token_child'); - $childProfile->setIp('127.0.0.1'); - $childProfile->setUrl('http://foo.bar/child'); - - $parentProfile->addChild($childProfile); - - $this->storage->write($parentProfile); - $this->storage->write($childProfile); - - // Load them from storage - $parentProfile = $this->storage->read('token_parent'); - $childProfile = $this->storage->read('token_child'); - - // Check child has link to parent - $this->assertNotNull($childProfile->getParent()); - $this->assertEquals($parentProfile->getToken(), $childProfile->getParentToken()); - - // Check parent has child - $children = $parentProfile->getChildren(); - $this->assertCount(1, $children); - $this->assertEquals($childProfile->getToken(), $children[0]->getToken()); - } - - public function testStoreSpecialCharsInUrl() - { - // The storage accepts special characters in URLs (Even though URLs are not - // supposed to contain them) - $profile = new Profile('simple_quote'); - $profile->setUrl('http://foo.bar/\''); - $this->storage->write($profile); - $this->assertTrue(false !== $this->storage->read('simple_quote'), '->write() accepts single quotes in URL'); - - $profile = new Profile('double_quote'); - $profile->setUrl('http://foo.bar/"'); - $this->storage->write($profile); - $this->assertTrue(false !== $this->storage->read('double_quote'), '->write() accepts double quotes in URL'); - - $profile = new Profile('backslash'); - $profile->setUrl('http://foo.bar/\\'); - $this->storage->write($profile); - $this->assertTrue(false !== $this->storage->read('backslash'), '->write() accepts backslash in URL'); - - $profile = new Profile('comma'); - $profile->setUrl('http://foo.bar/,'); - $this->storage->write($profile); - $this->assertTrue(false !== $this->storage->read('comma'), '->write() accepts comma in URL'); - } - - public function testStoreDuplicateToken() - { - $profile = new Profile('token'); - $profile->setUrl('http://example.com/'); - - $this->assertTrue($this->storage->write($profile), '->write() returns true when the token is unique'); - - $profile->setUrl('http://example.net/'); - - $this->assertTrue($this->storage->write($profile), '->write() returns true when the token is already present in the storage'); - $this->assertEquals('http://example.net/', $this->storage->read('token')->getUrl(), '->write() overwrites the current profile data'); - - $this->assertCount(1, $this->storage->find('', '', 1000, ''), '->find() does not return the same profile twice'); - } - - public function testRetrieveByIp() - { - $profile = new Profile('token'); - $profile->setIp('127.0.0.1'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $this->assertCount(1, $this->storage->find('127.0.0.1', '', 10, 'GET'), '->find() retrieve a record by IP'); - $this->assertCount(0, $this->storage->find('127.0.%.1', '', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the IP'); - $this->assertCount(0, $this->storage->find('127.0._.1', '', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the IP'); - } - - public function testRetrieveByStatusCode() - { - $profile200 = new Profile('statuscode200'); - $profile200->setStatusCode(200); - $this->storage->write($profile200); - - $profile404 = new Profile('statuscode404'); - $profile404->setStatusCode(404); - $this->storage->write($profile404); - - $this->assertCount(1, $this->storage->find(null, null, 10, null, null, null, '200'), '->find() retrieve a record by Status code 200'); - $this->assertCount(1, $this->storage->find(null, null, 10, null, null, null, '404'), '->find() retrieve a record by Status code 404'); - } - - public function testRetrieveByUrl() - { - $profile = new Profile('simple_quote'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/\''); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $profile = new Profile('double_quote'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/"'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $profile = new Profile('backslash'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo\\bar/'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $profile = new Profile('percent'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/%'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $profile = new Profile('underscore'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/_'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $profile = new Profile('semicolon'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar/;'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $this->assertCount(1, $this->storage->find('127.0.0.1', 'http://foo.bar/\'', 10, 'GET'), '->find() accepts single quotes in URLs'); - $this->assertCount(1, $this->storage->find('127.0.0.1', 'http://foo.bar/"', 10, 'GET'), '->find() accepts double quotes in URLs'); - $this->assertCount(1, $this->storage->find('127.0.0.1', 'http://foo\\bar/', 10, 'GET'), '->find() accepts backslash in URLs'); - $this->assertCount(1, $this->storage->find('127.0.0.1', 'http://foo.bar/;', 10, 'GET'), '->find() accepts semicolon in URLs'); - $this->assertCount(1, $this->storage->find('127.0.0.1', 'http://foo.bar/%', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the URL'); - $this->assertCount(1, $this->storage->find('127.0.0.1', 'http://foo.bar/_', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the URL'); - } - - public function testStoreTime() - { - $dt = new \DateTime('now'); - $start = $dt->getTimestamp(); - - for ($i = 0; $i < 3; ++$i) { - $dt->modify('+1 minute'); - $profile = new Profile('time_'.$i); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://foo.bar'); - $profile->setTime($dt->getTimestamp()); - $profile->setMethod('GET'); - $this->storage->write($profile); - } - - $records = $this->storage->find('', '', 3, 'GET', $start, time() + 3 * 60); - $this->assertCount(3, $records, '->find() returns all previously added records'); - $this->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[2]['token'], 'time_0', '->find() returns records ordered by time in descendant order'); - - $records = $this->storage->find('', '', 3, 'GET', $start, time() + 2 * 60); - $this->assertCount(2, $records, '->find() should return only first two of the previously added records'); - } - - public function testRetrieveByEmptyUrlAndIp() - { - for ($i = 0; $i < 5; ++$i) { - $profile = new Profile('token_'.$i); - $profile->setMethod('GET'); - $this->storage->write($profile); - } - $this->assertCount(5, $this->storage->find('', '', 10, 'GET'), '->find() returns all previously added records'); - $this->storage->purge(); - } - - public function testRetrieveByMethodAndLimit() - { - foreach (array('POST', 'GET') as $method) { - for ($i = 0; $i < 5; ++$i) { - $profile = new Profile('token_'.$i.$method); - $profile->setMethod($method); - $this->storage->write($profile); - } - } - - $this->assertCount(5, $this->storage->find('', '', 5, 'POST')); - - $this->storage->purge(); - } - - public function testPurge() - { - $profile = new Profile('token1'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://example.com/'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $this->assertTrue(false !== $this->storage->read('token1')); - $this->assertCount(1, $this->storage->find('127.0.0.1', '', 10, 'GET')); - - $profile = new Profile('token2'); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://example.net/'); - $profile->setMethod('GET'); - $this->storage->write($profile); - - $this->assertTrue(false !== $this->storage->read('token2')); - $this->assertCount(2, $this->storage->find('127.0.0.1', '', 10, 'GET')); - - $this->storage->purge(); - - $this->assertEmpty($this->storage->read('token'), '->purge() removes all data stored by profiler'); - $this->assertCount(0, $this->storage->find('127.0.0.1', '', 10, 'GET'), '->purge() removes all items from index'); - } - - public function testDuplicates() - { - for ($i = 1; $i <= 5; ++$i) { - $profile = new Profile('foo'.$i); - $profile->setIp('127.0.0.1'); - $profile->setUrl('http://example.net/'); - $profile->setMethod('GET'); - - ///three duplicates - $this->storage->write($profile); - $this->storage->write($profile); - $this->storage->write($profile); - } - $this->assertCount(3, $this->storage->find('127.0.0.1', 'http://example.net/', 3, 'GET'), '->find() method returns incorrect number of entries'); - } - - public function testStatusCode() - { - $profile = new Profile('token1'); - $profile->setStatusCode(200); - $this->storage->write($profile); - - $profile = new Profile('token2'); - $profile->setStatusCode(404); - $this->storage->write($profile); - - $tokens = $this->storage->find('', '', 10, ''); - $this->assertCount(2, $tokens); - $this->assertContains($tokens[0]['status_code'], array(200, 404)); - $this->assertContains($tokens[1]['status_code'], array(200, 404)); - } - - public function testMultiRowIndexFile() - { - $iteration = 3; - for ($i = 0; $i < $iteration; ++$i) { - $profile = new Profile('token'.$i); - $profile->setIp('127.0.0.'.$i); - $profile->setUrl('http://foo.bar/'.$i); - - $this->storage->write($profile); - $this->storage->write($profile); - $this->storage->write($profile); - } - - $handle = fopen($this->tmpDir.'/index.csv', 'r'); - for ($i = 0; $i < $iteration; ++$i) { - $row = fgetcsv($handle); - $this->assertEquals('token'.$i, $row[0]); - $this->assertEquals('127.0.0.'.$i, $row[1]); - $this->assertEquals('http://foo.bar/'.$i, $row[3]); - } - $this->assertFalse(fgetcsv($handle)); - } - - public function testReadLineFromFile() - { - $r = new \ReflectionMethod($this->storage, 'readLineFromFile'); - - $r->setAccessible(true); - - $h = tmpfile(); - - fwrite($h, "line1\n\n\nline2\n"); - fseek($h, 0, SEEK_END); - - $this->assertEquals('line2', $r->invoke($this->storage, $h)); - $this->assertEquals('line1', $r->invoke($this->storage, $h)); - } - - protected function cleanDir() - { - $flags = \FilesystemIterator::SKIP_DOTS; - $iterator = new \RecursiveDirectoryIterator($this->tmpDir, $flags); - $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST); - - foreach ($iterator as $file) { - if (is_file($file)) { - unlink($file); - } - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/Profiler/ProfilerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/Profiler/ProfilerTest.php deleted file mode 100644 index 243c3c5c5..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/Profiler/ProfilerTest.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests\Profiler; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; -use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; -use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class ProfilerTest extends TestCase -{ - private $tmp; - private $storage; - - public function testCollect() - { - $request = new Request(); - $request->query->set('foo', 'bar'); - $response = new Response('', 204); - $collector = new RequestDataCollector(); - - $profiler = new Profiler($this->storage); - $profiler->add($collector); - $profile = $profiler->collect($request, $response); - $profiler->saveProfile($profile); - - $this->assertSame(204, $profile->getStatusCode()); - $this->assertSame('GET', $profile->getMethod()); - $this->assertSame('bar', $profile->getCollector('request')->getRequestQuery()->all()['foo']->getValue()); - } - - public function testReset() - { - $collector = $this->getMockBuilder(DataCollectorInterface::class) - ->setMethods(['collect', 'getName', 'reset']) - ->getMock(); - $collector->expects($this->any())->method('getName')->willReturn('mock'); - $collector->expects($this->once())->method('reset'); - - $profiler = new Profiler($this->storage); - $profiler->add($collector); - $profiler->reset(); - } - - public function testFindWorksWithDates() - { - $profiler = new Profiler($this->storage); - - $this->assertCount(0, $profiler->find(null, null, null, null, '7th April 2014', '9th April 2014')); - } - - public function testFindWorksWithTimestamps() - { - $profiler = new Profiler($this->storage); - - $this->assertCount(0, $profiler->find(null, null, null, null, '1396828800', '1397001600')); - } - - public function testFindWorksWithInvalidDates() - { - $profiler = new Profiler($this->storage); - - $this->assertCount(0, $profiler->find(null, null, null, null, 'some string', '')); - } - - public function testFindWorksWithStatusCode() - { - $profiler = new Profiler($this->storage); - - $this->assertCount(0, $profiler->find(null, null, null, null, null, null, '204')); - } - - protected function setUp() - { - $this->tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler'); - if (file_exists($this->tmp)) { - @unlink($this->tmp); - } - - $this->storage = new FileProfilerStorage('file:'.$this->tmp); - $this->storage->purge(); - } - - protected function tearDown() - { - if (null !== $this->storage) { - $this->storage->purge(); - $this->storage = null; - - @unlink($this->tmp); - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/TestHttpKernel.php b/lib/silex/vendor/symfony/http-kernel/Tests/TestHttpKernel.php deleted file mode 100644 index 3ec592725..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/TestHttpKernel.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; - -class TestHttpKernel extends HttpKernel implements ControllerResolverInterface, ArgumentResolverInterface -{ - public function __construct() - { - parent::__construct(new EventDispatcher(), $this, null, $this); - } - - public function getController(Request $request) - { - return array($this, 'callController'); - } - - public function getArguments(Request $request, $controller) - { - return array($request); - } - - public function callController(Request $request) - { - return new Response('Request: '.$request->getRequestUri()); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/Tests/UriSignerTest.php b/lib/silex/vendor/symfony/http-kernel/Tests/UriSignerTest.php deleted file mode 100644 index 84ec19f70..000000000 --- a/lib/silex/vendor/symfony/http-kernel/Tests/UriSignerTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\UriSigner; - -class UriSignerTest extends TestCase -{ - public function testSign() - { - $signer = new UriSigner('foobar'); - - $this->assertContains('?_hash=', $signer->sign('http://example.com/foo')); - $this->assertContains('&_hash=', $signer->sign('http://example.com/foo?foo=bar')); - } - - public function testCheck() - { - $signer = new UriSigner('foobar'); - - $this->assertFalse($signer->check('http://example.com/foo?_hash=foo')); - $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo')); - $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo&bar=foo')); - - $this->assertTrue($signer->check($signer->sign('http://example.com/foo'))); - $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar'))); - $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&0=integer'))); - - $this->assertSame($signer->sign('http://example.com/foo?foo=bar&bar=foo'), $signer->sign('http://example.com/foo?bar=foo&foo=bar')); - } - - public function testCheckWithDifferentArgSeparator() - { - $this->iniSet('arg_separator.output', '&'); - $signer = new UriSigner('foobar'); - - $this->assertSame( - 'http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D', - $signer->sign('http://example.com/foo?foo=bar&baz=bay') - ); - $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); - } - - public function testCheckWithDifferentParameter() - { - $signer = new UriSigner('foobar', 'qux'); - - $this->assertSame( - 'http://example.com/foo?baz=bay&foo=bar&qux=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D', - $signer->sign('http://example.com/foo?foo=bar&baz=bay') - ); - $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/UriSigner.php b/lib/silex/vendor/symfony/http-kernel/UriSigner.php deleted file mode 100644 index 28459b4ec..000000000 --- a/lib/silex/vendor/symfony/http-kernel/UriSigner.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpKernel; - -/** - * Signs URIs. - * - * @author Fabien Potencier - */ -class UriSigner -{ - private $secret; - private $parameter; - - /** - * @param string $secret A secret - * @param string $parameter Query string parameter to use - */ - public function __construct($secret, $parameter = '_hash') - { - $this->secret = $secret; - $this->parameter = $parameter; - } - - /** - * Signs a URI. - * - * The given URI is signed by adding the query string parameter - * which value depends on the URI and the secret. - * - * @param string $uri A URI to sign - * - * @return string The signed URI - */ - public function sign($uri) - { - $url = parse_url($uri); - if (isset($url['query'])) { - parse_str($url['query'], $params); - } else { - $params = array(); - } - - $uri = $this->buildUrl($url, $params); - - return $uri.(false === strpos($uri, '?') ? '?' : '&').$this->parameter.'='.$this->computeHash($uri); - } - - /** - * Checks that a URI contains the correct hash. - * - * @param string $uri A signed URI - * - * @return bool True if the URI is signed correctly, false otherwise - */ - public function check($uri) - { - $url = parse_url($uri); - if (isset($url['query'])) { - parse_str($url['query'], $params); - } else { - $params = array(); - } - - if (empty($params[$this->parameter])) { - return false; - } - - $hash = urlencode($params[$this->parameter]); - unset($params[$this->parameter]); - - return $this->computeHash($this->buildUrl($url, $params)) === $hash; - } - - private function computeHash($uri) - { - return urlencode(base64_encode(hash_hmac('sha256', $uri, $this->secret, true))); - } - - private function buildUrl(array $url, array $params = array()) - { - ksort($params, SORT_STRING); - $url['query'] = http_build_query($params, '', '&'); - - $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; - $host = isset($url['host']) ? $url['host'] : ''; - $port = isset($url['port']) ? ':'.$url['port'] : ''; - $user = isset($url['user']) ? $url['user'] : ''; - $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; - $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($url['path']) ? $url['path'] : ''; - $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; - $fragment = isset($url['fragment']) ? '#'.$url['fragment'] : ''; - - return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/composer.json b/lib/silex/vendor/symfony/http-kernel/composer.json deleted file mode 100644 index b33675763..000000000 --- a/lib/silex/vendor/symfony/http-kernel/composer.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "symfony/http-kernel", - "type": "library", - "description": "Symfony HttpKernel Component", - "keywords": [], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "^3.4.4|^4.0.4", - "symfony/debug": "~2.8|~3.0|~4.0", - "psr/log": "~1.0" - }, - "require-dev": { - "symfony/browser-kit": "~2.8|~3.0|~4.0", - "symfony/class-loader": "~2.8|~3.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/console": "~2.8|~3.0|~4.0", - "symfony/css-selector": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/dom-crawler": "~2.8|~3.0|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/finder": "~2.8|~3.0|~4.0", - "symfony/process": "~2.8|~3.0|~4.0", - "symfony/routing": "~3.4|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0", - "symfony/templating": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/var-dumper": "~3.3|~4.0", - "psr/cache": "~1.0" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.4", - "symfony/var-dumper": "<3.3", - "twig/twig": "<1.34|<2.4,>=2" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\HttpKernel\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/http-kernel/phpunit.xml.dist b/lib/silex/vendor/symfony/http-kernel/phpunit.xml.dist deleted file mode 100644 index e0de769dd..000000000 --- a/lib/silex/vendor/symfony/http-kernel/phpunit.xml.dist +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Tests - ./vendor - - - - - - - - - Symfony\Component\HttpFoundation - - - - - diff --git a/lib/silex/vendor/symfony/polyfill-mbstring/LICENSE b/lib/silex/vendor/symfony/polyfill-mbstring/LICENSE deleted file mode 100644 index 39fa189d2..000000000 --- a/lib/silex/vendor/symfony/polyfill-mbstring/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014-2016 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/polyfill-mbstring/Mbstring.php b/lib/silex/vendor/symfony/polyfill-mbstring/Mbstring.php deleted file mode 100644 index 97e8c9b46..000000000 --- a/lib/silex/vendor/symfony/polyfill-mbstring/Mbstring.php +++ /dev/null @@ -1,664 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Mbstring; - -/** - * Partial mbstring implementation in PHP, iconv based, UTF-8 centric. - * - * Implemented: - * - mb_chr - Returns a specific character from its Unicode code point - * - mb_convert_encoding - Convert character encoding - * - mb_convert_variables - Convert character code in variable(s) - * - mb_decode_mimeheader - Decode string in MIME header field - * - mb_encode_mimeheader - Encode string for MIME header XXX NATIVE IMPLEMENTATION IS REALLY BUGGED - * - mb_convert_case - Perform case folding on a string - * - mb_get_info - Get internal settings of mbstring - * - mb_http_input - Detect HTTP input character encoding - * - mb_http_output - Set/Get HTTP output character encoding - * - mb_internal_encoding - Set/Get internal character encoding - * - mb_list_encodings - Returns an array of all supported encodings - * - mb_ord - Returns the Unicode code point of a character - * - mb_output_handler - Callback function converts character encoding in output buffer - * - mb_scrub - Replaces ill-formed byte sequences with substitute characters - * - mb_strlen - Get string length - * - mb_strpos - Find position of first occurrence of string in a string - * - mb_strrpos - Find position of last occurrence of a string in a string - * - mb_strtolower - Make a string lowercase - * - mb_strtoupper - Make a string uppercase - * - mb_substitute_character - Set/Get substitution character - * - mb_substr - Get part of string - * - mb_stripos - Finds position of first occurrence of a string within another, case insensitive - * - mb_stristr - Finds first occurrence of a string within another, case insensitive - * - mb_strrchr - Finds the last occurrence of a character in a string within another - * - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive - * - mb_strripos - Finds position of last occurrence of a string within another, case insensitive - * - mb_strstr - Finds first occurrence of a string within anothers - * - mb_strwidth - Return width of string - * - mb_substr_count - Count the number of substring occurrences - * - * Not implemented: - * - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more) - * - mb_decode_numericentity - Decode HTML numeric string reference to character - * - mb_encode_numericentity - Encode character to HTML numeric string reference - * - mb_ereg_* - Regular expression with multibyte support - * - mb_parse_str - Parse GET/POST/COOKIE data and set global variable - * - mb_preferred_mime_name - Get MIME charset string - * - mb_regex_encoding - Returns current encoding for multibyte regex as string - * - mb_regex_set_options - Set/Get the default options for mbregex functions - * - mb_send_mail - Send encoded mail - * - mb_split - Split multibyte string using regular expression - * - mb_strcut - Get part of string - * - mb_strimwidth - Get truncated string with specified width - * - * @author Nicolas Grekas - * - * @internal - */ -final class Mbstring -{ - const MB_CASE_FOLD = PHP_INT_MAX; - - private static $encodingList = array('ASCII', 'UTF-8'); - private static $language = 'neutral'; - private static $internalEncoding = 'UTF-8'; - private static $caseFold = array( - array('µ','ſ',"\xCD\x85",'ς',"\xCF\x90","\xCF\x91","\xCF\x95","\xCF\x96","\xCF\xB0","\xCF\xB1","\xCF\xB5","\xE1\xBA\x9B","\xE1\xBE\xBE"), - array('μ','s','ι', 'σ','β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1",'ι'), - ); - - public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null) - { - if (is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) { - $fromEncoding = self::mb_detect_encoding($s, $fromEncoding); - } else { - $fromEncoding = self::getEncoding($fromEncoding); - } - - $toEncoding = self::getEncoding($toEncoding); - - if ('BASE64' === $fromEncoding) { - $s = base64_decode($s); - $fromEncoding = $toEncoding; - } - - if ('BASE64' === $toEncoding) { - return base64_encode($s); - } - - if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) { - if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) { - $fromEncoding = 'Windows-1252'; - } - if ('UTF-8' !== $fromEncoding) { - $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s); - } - - return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s); - } - - if ('HTML-ENTITIES' === $fromEncoding) { - $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8'); - $fromEncoding = 'UTF-8'; - } - - return iconv($fromEncoding, $toEncoding.'//IGNORE', $s); - } - - public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null) - { - $vars = array(&$a, &$b, &$c, &$d, &$e, &$f); - - $ok = true; - array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) { - if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) { - $ok = false; - } - }); - - return $ok ? $fromEncoding : false; - } - - public static function mb_decode_mimeheader($s) - { - return iconv_mime_decode($s, 2, self::$internalEncoding); - } - - public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null) - { - trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING); - } - - public static function mb_convert_case($s, $mode, $encoding = null) - { - if ('' === $s .= '') { - return ''; - } - - $encoding = self::getEncoding($encoding); - - if ('UTF-8' === $encoding) { - $encoding = null; - if (!preg_match('//u', $s)) { - $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s); - } - } else { - $s = iconv($encoding, 'UTF-8//IGNORE', $s); - } - - if (MB_CASE_TITLE == $mode) { - $s = preg_replace_callback('/\b\p{Ll}/u', array(__CLASS__, 'title_case_upper'), $s); - $s = preg_replace_callback('/\B[\p{Lu}\p{Lt}]+/u', array(__CLASS__, 'title_case_lower'), $s); - } else { - if (MB_CASE_UPPER == $mode) { - static $upper = null; - if (null === $upper) { - $upper = self::getData('upperCase'); - } - $map = $upper; - } else { - if (self::MB_CASE_FOLD === $mode) { - $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s); - } - - static $lower = null; - if (null === $lower) { - $lower = self::getData('lowerCase'); - } - $map = $lower; - } - - static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4); - - $i = 0; - $len = strlen($s); - - while ($i < $len) { - $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"]; - $uchr = substr($s, $i, $ulen); - $i += $ulen; - - if (isset($map[$uchr])) { - $uchr = $map[$uchr]; - $nlen = strlen($uchr); - - if ($nlen == $ulen) { - $nlen = $i; - do { - $s[--$nlen] = $uchr[--$ulen]; - } while ($ulen); - } else { - $s = substr_replace($s, $uchr, $i - $ulen, $ulen); - $len += $nlen - $ulen; - $i += $nlen - $ulen; - } - } - } - } - - if (null === $encoding) { - return $s; - } - - return iconv('UTF-8', $encoding.'//IGNORE', $s); - } - - public static function mb_internal_encoding($encoding = null) - { - if (null === $encoding) { - return self::$internalEncoding; - } - - $encoding = self::getEncoding($encoding); - - if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) { - self::$internalEncoding = $encoding; - - return true; - } - - return false; - } - - public static function mb_language($lang = null) - { - if (null === $lang) { - return self::$language; - } - - switch ($lang = strtolower($lang)) { - case 'uni': - case 'neutral': - self::$language = $lang; - - return true; - } - - return false; - } - - public static function mb_list_encodings() - { - return array('UTF-8'); - } - - public static function mb_encoding_aliases($encoding) - { - switch (strtoupper($encoding)) { - case 'UTF8': - case 'UTF-8': - return array('utf8'); - } - - return false; - } - - public static function mb_check_encoding($var = null, $encoding = null) - { - if (null === $encoding) { - if (null === $var) { - return false; - } - $encoding = self::$internalEncoding; - } - - return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var); - } - - public static function mb_detect_encoding($str, $encodingList = null, $strict = false) - { - if (null === $encodingList) { - $encodingList = self::$encodingList; - } else { - if (!is_array($encodingList)) { - $encodingList = array_map('trim', explode(',', $encodingList)); - } - $encodingList = array_map('strtoupper', $encodingList); - } - - foreach ($encodingList as $enc) { - switch ($enc) { - case 'ASCII': - if (!preg_match('/[\x80-\xFF]/', $str)) { - return $enc; - } - break; - - case 'UTF8': - case 'UTF-8': - if (preg_match('//u', $str)) { - return 'UTF-8'; - } - break; - - default: - if (0 === strncmp($enc, 'ISO-8859-', 9)) { - return $enc; - } - } - } - - return false; - } - - public static function mb_detect_order($encodingList = null) - { - if (null === $encodingList) { - return self::$encodingList; - } - - if (!is_array($encodingList)) { - $encodingList = array_map('trim', explode(',', $encodingList)); - } - $encodingList = array_map('strtoupper', $encodingList); - - foreach ($encodingList as $enc) { - switch ($enc) { - default: - if (strncmp($enc, 'ISO-8859-', 9)) { - return false; - } - case 'ASCII': - case 'UTF8': - case 'UTF-8': - } - } - - self::$encodingList = $encodingList; - - return true; - } - - public static function mb_strlen($s, $encoding = null) - { - $encoding = self::getEncoding($encoding); - if ('CP850' === $encoding || 'ASCII' === $encoding) { - return strlen($s); - } - - return @iconv_strlen($s, $encoding); - } - - public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) - { - $encoding = self::getEncoding($encoding); - if ('CP850' === $encoding || 'ASCII' === $encoding) { - return strpos($haystack, $needle, $offset); - } - - if ('' === $needle .= '') { - trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING); - - return false; - } - - return iconv_strpos($haystack, $needle, $offset, $encoding); - } - - public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) - { - $encoding = self::getEncoding($encoding); - if ('CP850' === $encoding || 'ASCII' === $encoding) { - return strrpos($haystack, $needle, $offset); - } - - if ($offset != (int) $offset) { - $offset = 0; - } elseif ($offset = (int) $offset) { - if ($offset < 0) { - $haystack = self::mb_substr($haystack, 0, $offset, $encoding); - $offset = 0; - } else { - $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding); - } - } - - $pos = iconv_strrpos($haystack, $needle, $encoding); - - return false !== $pos ? $offset + $pos : false; - } - - public static function mb_strtolower($s, $encoding = null) - { - return self::mb_convert_case($s, MB_CASE_LOWER, $encoding); - } - - public static function mb_strtoupper($s, $encoding = null) - { - return self::mb_convert_case($s, MB_CASE_UPPER, $encoding); - } - - public static function mb_substitute_character($c = null) - { - if (0 === strcasecmp($c, 'none')) { - return true; - } - - return null !== $c ? false : 'none'; - } - - public static function mb_substr($s, $start, $length = null, $encoding = null) - { - $encoding = self::getEncoding($encoding); - if ('CP850' === $encoding || 'ASCII' === $encoding) { - return substr($s, $start, null === $length ? 2147483647 : $length); - } - - if ($start < 0) { - $start = iconv_strlen($s, $encoding) + $start; - if ($start < 0) { - $start = 0; - } - } - - if (null === $length) { - $length = 2147483647; - } elseif ($length < 0) { - $length = iconv_strlen($s, $encoding) + $length - $start; - if ($length < 0) { - return ''; - } - } - - return iconv_substr($s, $start, $length, $encoding).''; - } - - public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) - { - $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding); - $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding); - - return self::mb_strpos($haystack, $needle, $offset, $encoding); - } - - public static function mb_stristr($haystack, $needle, $part = false, $encoding = null) - { - $pos = self::mb_stripos($haystack, $needle, 0, $encoding); - - return self::getSubpart($pos, $part, $haystack, $encoding); - } - - public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null) - { - $encoding = self::getEncoding($encoding); - if ('CP850' === $encoding || 'ASCII' === $encoding) { - return strrchr($haystack, $needle, $part); - } - $needle = self::mb_substr($needle, 0, 1, $encoding); - $pos = iconv_strrpos($haystack, $needle, $encoding); - - return self::getSubpart($pos, $part, $haystack, $encoding); - } - - public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null) - { - $needle = self::mb_substr($needle, 0, 1, $encoding); - $pos = self::mb_strripos($haystack, $needle, $encoding); - - return self::getSubpart($pos, $part, $haystack, $encoding); - } - - public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) - { - $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding); - $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding); - - return self::mb_strrpos($haystack, $needle, $offset, $encoding); - } - - public static function mb_strstr($haystack, $needle, $part = false, $encoding = null) - { - $pos = strpos($haystack, $needle); - if (false === $pos) { - return false; - } - if ($part) { - return substr($haystack, 0, $pos); - } - - return substr($haystack, $pos); - } - - public static function mb_get_info($type = 'all') - { - $info = array( - 'internal_encoding' => self::$internalEncoding, - 'http_output' => 'pass', - 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)', - 'func_overload' => 0, - 'func_overload_list' => 'no overload', - 'mail_charset' => 'UTF-8', - 'mail_header_encoding' => 'BASE64', - 'mail_body_encoding' => 'BASE64', - 'illegal_chars' => 0, - 'encoding_translation' => 'Off', - 'language' => self::$language, - 'detect_order' => self::$encodingList, - 'substitute_character' => 'none', - 'strict_detection' => 'Off', - ); - - if ('all' === $type) { - return $info; - } - if (isset($info[$type])) { - return $info[$type]; - } - - return false; - } - - public static function mb_http_input($type = '') - { - return false; - } - - public static function mb_http_output($encoding = null) - { - return null !== $encoding ? 'pass' === $encoding : 'pass'; - } - - public static function mb_strwidth($s, $encoding = null) - { - $encoding = self::getEncoding($encoding); - - if ('UTF-8' !== $encoding) { - $s = iconv($encoding, 'UTF-8//IGNORE', $s); - } - - $s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide); - - return ($wide << 1) + iconv_strlen($s, 'UTF-8'); - } - - public static function mb_substr_count($haystack, $needle, $encoding = null) - { - return substr_count($haystack, $needle); - } - - public static function mb_output_handler($contents, $status) - { - return $contents; - } - - public static function mb_chr($code, $encoding = null) - { - if (0x80 > $code %= 0x200000) { - $s = chr($code); - } elseif (0x800 > $code) { - $s = chr(0xC0 | $code >> 6).chr(0x80 | $code & 0x3F); - } elseif (0x10000 > $code) { - $s = chr(0xE0 | $code >> 12).chr(0x80 | $code >> 6 & 0x3F).chr(0x80 | $code & 0x3F); - } else { - $s = chr(0xF0 | $code >> 18).chr(0x80 | $code >> 12 & 0x3F).chr(0x80 | $code >> 6 & 0x3F).chr(0x80 | $code & 0x3F); - } - - if ('UTF-8' !== $encoding = self::getEncoding($encoding)) { - $s = mb_convert_encoding($s, $encoding, 'UTF-8'); - } - - return $s; - } - - public static function mb_ord($s, $encoding = null) - { - if ('UTF-8' !== $encoding = self::getEncoding($encoding)) { - $s = mb_convert_encoding($s, 'UTF-8', $encoding); - } - - $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0; - if (0xF0 <= $code) { - return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80; - } - if (0xE0 <= $code) { - return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80; - } - if (0xC0 <= $code) { - return (($code - 0xC0) << 6) + $s[2] - 0x80; - } - - return $code; - } - - private static function getSubpart($pos, $part, $haystack, $encoding) - { - if (false === $pos) { - return false; - } - if ($part) { - return self::mb_substr($haystack, 0, $pos, $encoding); - } - - return self::mb_substr($haystack, $pos, null, $encoding); - } - - private static function html_encoding_callback($m) - { - $i = 1; - $entities = ''; - $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8')); - - while (isset($m[$i])) { - if (0x80 > $m[$i]) { - $entities .= chr($m[$i++]); - continue; - } - if (0xF0 <= $m[$i]) { - $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80; - } elseif (0xE0 <= $m[$i]) { - $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80; - } else { - $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80; - } - - $entities .= '&#'.$c.';'; - } - - return $entities; - } - - private static function title_case_lower($s) - { - return self::mb_convert_case($s[0], MB_CASE_LOWER, 'UTF-8'); - } - - private static function title_case_upper($s) - { - return self::mb_convert_case($s[0], MB_CASE_UPPER, 'UTF-8'); - } - - private static function getData($file) - { - if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) { - return require $file; - } - - return false; - } - - private static function getEncoding($encoding) - { - if (null === $encoding) { - return self::$internalEncoding; - } - - $encoding = strtoupper($encoding); - - if ('8BIT' === $encoding || 'BINARY' === $encoding) { - return 'CP850'; - } - if ('UTF8' === $encoding) { - return 'UTF-8'; - } - - return $encoding; - } -} diff --git a/lib/silex/vendor/symfony/polyfill-mbstring/README.md b/lib/silex/vendor/symfony/polyfill-mbstring/README.md deleted file mode 100644 index 342e8286d..000000000 --- a/lib/silex/vendor/symfony/polyfill-mbstring/README.md +++ /dev/null @@ -1,13 +0,0 @@ -Symfony Polyfill / Mbstring -=========================== - -This component provides a partial, native PHP implementation for the -[Mbstring](http://php.net/mbstring) extension. - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php b/lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php deleted file mode 100644 index 3ca16416a..000000000 --- a/lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +++ /dev/null @@ -1,1101 +0,0 @@ - 'a', - 'B' => 'b', - 'C' => 'c', - 'D' => 'd', - 'E' => 'e', - 'F' => 'f', - 'G' => 'g', - 'H' => 'h', - 'I' => 'i', - 'J' => 'j', - 'K' => 'k', - 'L' => 'l', - 'M' => 'm', - 'N' => 'n', - 'O' => 'o', - 'P' => 'p', - 'Q' => 'q', - 'R' => 'r', - 'S' => 's', - 'T' => 't', - 'U' => 'u', - 'V' => 'v', - 'W' => 'w', - 'X' => 'x', - 'Y' => 'y', - 'Z' => 'z', - 'À' => 'à', - 'Á' => 'á', - 'Â' => 'â', - 'Ã' => 'ã', - 'Ä' => 'ä', - 'Å' => 'å', - 'Æ' => 'æ', - 'Ç' => 'ç', - 'È' => 'è', - 'É' => 'é', - 'Ê' => 'ê', - 'Ë' => 'ë', - 'Ì' => 'ì', - 'Í' => 'í', - 'Î' => 'î', - 'Ï' => 'ï', - 'Ð' => 'ð', - 'Ñ' => 'ñ', - 'Ò' => 'ò', - 'Ó' => 'ó', - 'Ô' => 'ô', - 'Õ' => 'õ', - 'Ö' => 'ö', - 'Ø' => 'ø', - 'Ù' => 'ù', - 'Ú' => 'ú', - 'Û' => 'û', - 'Ü' => 'ü', - 'Ý' => 'ý', - 'Þ' => 'þ', - 'Ā' => 'ā', - 'Ă' => 'ă', - 'Ą' => 'ą', - 'Ć' => 'ć', - 'Ĉ' => 'ĉ', - 'Ċ' => 'ċ', - 'Č' => 'č', - 'Ď' => 'ď', - 'Đ' => 'đ', - 'Ē' => 'ē', - 'Ĕ' => 'ĕ', - 'Ė' => 'ė', - 'Ę' => 'ę', - 'Ě' => 'ě', - 'Ĝ' => 'ĝ', - 'Ğ' => 'ğ', - 'Ġ' => 'ġ', - 'Ģ' => 'ģ', - 'Ĥ' => 'ĥ', - 'Ħ' => 'ħ', - 'Ĩ' => 'ĩ', - 'Ī' => 'ī', - 'Ĭ' => 'ĭ', - 'Į' => 'į', - 'İ' => 'i', - 'IJ' => 'ij', - 'Ĵ' => 'ĵ', - 'Ķ' => 'ķ', - 'Ĺ' => 'ĺ', - 'Ļ' => 'ļ', - 'Ľ' => 'ľ', - 'Ŀ' => 'ŀ', - 'Ł' => 'ł', - 'Ń' => 'ń', - 'Ņ' => 'ņ', - 'Ň' => 'ň', - 'Ŋ' => 'ŋ', - 'Ō' => 'ō', - 'Ŏ' => 'ŏ', - 'Ő' => 'ő', - 'Œ' => 'œ', - 'Ŕ' => 'ŕ', - 'Ŗ' => 'ŗ', - 'Ř' => 'ř', - 'Ś' => 'ś', - 'Ŝ' => 'ŝ', - 'Ş' => 'ş', - 'Š' => 'š', - 'Ţ' => 'ţ', - 'Ť' => 'ť', - 'Ŧ' => 'ŧ', - 'Ũ' => 'ũ', - 'Ū' => 'ū', - 'Ŭ' => 'ŭ', - 'Ů' => 'ů', - 'Ű' => 'ű', - 'Ų' => 'ų', - 'Ŵ' => 'ŵ', - 'Ŷ' => 'ŷ', - 'Ÿ' => 'ÿ', - 'Ź' => 'ź', - 'Ż' => 'ż', - 'Ž' => 'ž', - 'Ɓ' => 'ɓ', - 'Ƃ' => 'ƃ', - 'Ƅ' => 'ƅ', - 'Ɔ' => 'ɔ', - 'Ƈ' => 'ƈ', - 'Ɖ' => 'ɖ', - 'Ɗ' => 'ɗ', - 'Ƌ' => 'ƌ', - 'Ǝ' => 'ǝ', - 'Ə' => 'ə', - 'Ɛ' => 'ɛ', - 'Ƒ' => 'ƒ', - 'Ɠ' => 'ɠ', - 'Ɣ' => 'ɣ', - 'Ɩ' => 'ɩ', - 'Ɨ' => 'ɨ', - 'Ƙ' => 'ƙ', - 'Ɯ' => 'ɯ', - 'Ɲ' => 'ɲ', - 'Ɵ' => 'ɵ', - 'Ơ' => 'ơ', - 'Ƣ' => 'ƣ', - 'Ƥ' => 'ƥ', - 'Ʀ' => 'ʀ', - 'Ƨ' => 'ƨ', - 'Ʃ' => 'ʃ', - 'Ƭ' => 'ƭ', - 'Ʈ' => 'ʈ', - 'Ư' => 'ư', - 'Ʊ' => 'ʊ', - 'Ʋ' => 'ʋ', - 'Ƴ' => 'ƴ', - 'Ƶ' => 'ƶ', - 'Ʒ' => 'ʒ', - 'Ƹ' => 'ƹ', - 'Ƽ' => 'ƽ', - 'DŽ' => 'dž', - 'Dž' => 'dž', - 'LJ' => 'lj', - 'Lj' => 'lj', - 'NJ' => 'nj', - 'Nj' => 'nj', - 'Ǎ' => 'ǎ', - 'Ǐ' => 'ǐ', - 'Ǒ' => 'ǒ', - 'Ǔ' => 'ǔ', - 'Ǖ' => 'ǖ', - 'Ǘ' => 'ǘ', - 'Ǚ' => 'ǚ', - 'Ǜ' => 'ǜ', - 'Ǟ' => 'ǟ', - 'Ǡ' => 'ǡ', - 'Ǣ' => 'ǣ', - 'Ǥ' => 'ǥ', - 'Ǧ' => 'ǧ', - 'Ǩ' => 'ǩ', - 'Ǫ' => 'ǫ', - 'Ǭ' => 'ǭ', - 'Ǯ' => 'ǯ', - 'DZ' => 'dz', - 'Dz' => 'dz', - 'Ǵ' => 'ǵ', - 'Ƕ' => 'ƕ', - 'Ƿ' => 'ƿ', - 'Ǹ' => 'ǹ', - 'Ǻ' => 'ǻ', - 'Ǽ' => 'ǽ', - 'Ǿ' => 'ǿ', - 'Ȁ' => 'ȁ', - 'Ȃ' => 'ȃ', - 'Ȅ' => 'ȅ', - 'Ȇ' => 'ȇ', - 'Ȉ' => 'ȉ', - 'Ȋ' => 'ȋ', - 'Ȍ' => 'ȍ', - 'Ȏ' => 'ȏ', - 'Ȑ' => 'ȑ', - 'Ȓ' => 'ȓ', - 'Ȕ' => 'ȕ', - 'Ȗ' => 'ȗ', - 'Ș' => 'ș', - 'Ț' => 'ț', - 'Ȝ' => 'ȝ', - 'Ȟ' => 'ȟ', - 'Ƞ' => 'ƞ', - 'Ȣ' => 'ȣ', - 'Ȥ' => 'ȥ', - 'Ȧ' => 'ȧ', - 'Ȩ' => 'ȩ', - 'Ȫ' => 'ȫ', - 'Ȭ' => 'ȭ', - 'Ȯ' => 'ȯ', - 'Ȱ' => 'ȱ', - 'Ȳ' => 'ȳ', - 'Ⱥ' => 'ⱥ', - 'Ȼ' => 'ȼ', - 'Ƚ' => 'ƚ', - 'Ⱦ' => 'ⱦ', - 'Ɂ' => 'ɂ', - 'Ƀ' => 'ƀ', - 'Ʉ' => 'ʉ', - 'Ʌ' => 'ʌ', - 'Ɇ' => 'ɇ', - 'Ɉ' => 'ɉ', - 'Ɋ' => 'ɋ', - 'Ɍ' => 'ɍ', - 'Ɏ' => 'ɏ', - 'Ͱ' => 'ͱ', - 'Ͳ' => 'ͳ', - 'Ͷ' => 'ͷ', - 'Ϳ' => 'ϳ', - 'Ά' => 'ά', - 'Έ' => 'έ', - 'Ή' => 'ή', - 'Ί' => 'ί', - 'Ό' => 'ό', - 'Ύ' => 'ύ', - 'Ώ' => 'ώ', - 'Α' => 'α', - 'Β' => 'β', - 'Γ' => 'γ', - 'Δ' => 'δ', - 'Ε' => 'ε', - 'Ζ' => 'ζ', - 'Η' => 'η', - 'Θ' => 'θ', - 'Ι' => 'ι', - 'Κ' => 'κ', - 'Λ' => 'λ', - 'Μ' => 'μ', - 'Ν' => 'ν', - 'Ξ' => 'ξ', - 'Ο' => 'ο', - 'Π' => 'π', - 'Ρ' => 'ρ', - 'Σ' => 'σ', - 'Τ' => 'τ', - 'Υ' => 'υ', - 'Φ' => 'φ', - 'Χ' => 'χ', - 'Ψ' => 'ψ', - 'Ω' => 'ω', - 'Ϊ' => 'ϊ', - 'Ϋ' => 'ϋ', - 'Ϗ' => 'ϗ', - 'Ϙ' => 'ϙ', - 'Ϛ' => 'ϛ', - 'Ϝ' => 'ϝ', - 'Ϟ' => 'ϟ', - 'Ϡ' => 'ϡ', - 'Ϣ' => 'ϣ', - 'Ϥ' => 'ϥ', - 'Ϧ' => 'ϧ', - 'Ϩ' => 'ϩ', - 'Ϫ' => 'ϫ', - 'Ϭ' => 'ϭ', - 'Ϯ' => 'ϯ', - 'ϴ' => 'θ', - 'Ϸ' => 'ϸ', - 'Ϲ' => 'ϲ', - 'Ϻ' => 'ϻ', - 'Ͻ' => 'ͻ', - 'Ͼ' => 'ͼ', - 'Ͽ' => 'ͽ', - 'Ѐ' => 'ѐ', - 'Ё' => 'ё', - 'Ђ' => 'ђ', - 'Ѓ' => 'ѓ', - 'Є' => 'є', - 'Ѕ' => 'ѕ', - 'І' => 'і', - 'Ї' => 'ї', - 'Ј' => 'ј', - 'Љ' => 'љ', - 'Њ' => 'њ', - 'Ћ' => 'ћ', - 'Ќ' => 'ќ', - 'Ѝ' => 'ѝ', - 'Ў' => 'ў', - 'Џ' => 'џ', - 'А' => 'а', - 'Б' => 'б', - 'В' => 'в', - 'Г' => 'г', - 'Д' => 'д', - 'Е' => 'е', - 'Ж' => 'ж', - 'З' => 'з', - 'И' => 'и', - 'Й' => 'й', - 'К' => 'к', - 'Л' => 'л', - 'М' => 'м', - 'Н' => 'н', - 'О' => 'о', - 'П' => 'п', - 'Р' => 'р', - 'С' => 'с', - 'Т' => 'т', - 'У' => 'у', - 'Ф' => 'ф', - 'Х' => 'х', - 'Ц' => 'ц', - 'Ч' => 'ч', - 'Ш' => 'ш', - 'Щ' => 'щ', - 'Ъ' => 'ъ', - 'Ы' => 'ы', - 'Ь' => 'ь', - 'Э' => 'э', - 'Ю' => 'ю', - 'Я' => 'я', - 'Ѡ' => 'ѡ', - 'Ѣ' => 'ѣ', - 'Ѥ' => 'ѥ', - 'Ѧ' => 'ѧ', - 'Ѩ' => 'ѩ', - 'Ѫ' => 'ѫ', - 'Ѭ' => 'ѭ', - 'Ѯ' => 'ѯ', - 'Ѱ' => 'ѱ', - 'Ѳ' => 'ѳ', - 'Ѵ' => 'ѵ', - 'Ѷ' => 'ѷ', - 'Ѹ' => 'ѹ', - 'Ѻ' => 'ѻ', - 'Ѽ' => 'ѽ', - 'Ѿ' => 'ѿ', - 'Ҁ' => 'ҁ', - 'Ҋ' => 'ҋ', - 'Ҍ' => 'ҍ', - 'Ҏ' => 'ҏ', - 'Ґ' => 'ґ', - 'Ғ' => 'ғ', - 'Ҕ' => 'ҕ', - 'Җ' => 'җ', - 'Ҙ' => 'ҙ', - 'Қ' => 'қ', - 'Ҝ' => 'ҝ', - 'Ҟ' => 'ҟ', - 'Ҡ' => 'ҡ', - 'Ң' => 'ң', - 'Ҥ' => 'ҥ', - 'Ҧ' => 'ҧ', - 'Ҩ' => 'ҩ', - 'Ҫ' => 'ҫ', - 'Ҭ' => 'ҭ', - 'Ү' => 'ү', - 'Ұ' => 'ұ', - 'Ҳ' => 'ҳ', - 'Ҵ' => 'ҵ', - 'Ҷ' => 'ҷ', - 'Ҹ' => 'ҹ', - 'Һ' => 'һ', - 'Ҽ' => 'ҽ', - 'Ҿ' => 'ҿ', - 'Ӏ' => 'ӏ', - 'Ӂ' => 'ӂ', - 'Ӄ' => 'ӄ', - 'Ӆ' => 'ӆ', - 'Ӈ' => 'ӈ', - 'Ӊ' => 'ӊ', - 'Ӌ' => 'ӌ', - 'Ӎ' => 'ӎ', - 'Ӑ' => 'ӑ', - 'Ӓ' => 'ӓ', - 'Ӕ' => 'ӕ', - 'Ӗ' => 'ӗ', - 'Ә' => 'ә', - 'Ӛ' => 'ӛ', - 'Ӝ' => 'ӝ', - 'Ӟ' => 'ӟ', - 'Ӡ' => 'ӡ', - 'Ӣ' => 'ӣ', - 'Ӥ' => 'ӥ', - 'Ӧ' => 'ӧ', - 'Ө' => 'ө', - 'Ӫ' => 'ӫ', - 'Ӭ' => 'ӭ', - 'Ӯ' => 'ӯ', - 'Ӱ' => 'ӱ', - 'Ӳ' => 'ӳ', - 'Ӵ' => 'ӵ', - 'Ӷ' => 'ӷ', - 'Ӹ' => 'ӹ', - 'Ӻ' => 'ӻ', - 'Ӽ' => 'ӽ', - 'Ӿ' => 'ӿ', - 'Ԁ' => 'ԁ', - 'Ԃ' => 'ԃ', - 'Ԅ' => 'ԅ', - 'Ԇ' => 'ԇ', - 'Ԉ' => 'ԉ', - 'Ԋ' => 'ԋ', - 'Ԍ' => 'ԍ', - 'Ԏ' => 'ԏ', - 'Ԑ' => 'ԑ', - 'Ԓ' => 'ԓ', - 'Ԕ' => 'ԕ', - 'Ԗ' => 'ԗ', - 'Ԙ' => 'ԙ', - 'Ԛ' => 'ԛ', - 'Ԝ' => 'ԝ', - 'Ԟ' => 'ԟ', - 'Ԡ' => 'ԡ', - 'Ԣ' => 'ԣ', - 'Ԥ' => 'ԥ', - 'Ԧ' => 'ԧ', - 'Ԩ' => 'ԩ', - 'Ԫ' => 'ԫ', - 'Ԭ' => 'ԭ', - 'Ԯ' => 'ԯ', - 'Ա' => 'ա', - 'Բ' => 'բ', - 'Գ' => 'գ', - 'Դ' => 'դ', - 'Ե' => 'ե', - 'Զ' => 'զ', - 'Է' => 'է', - 'Ը' => 'ը', - 'Թ' => 'թ', - 'Ժ' => 'ժ', - 'Ի' => 'ի', - 'Լ' => 'լ', - 'Խ' => 'խ', - 'Ծ' => 'ծ', - 'Կ' => 'կ', - 'Հ' => 'հ', - 'Ձ' => 'ձ', - 'Ղ' => 'ղ', - 'Ճ' => 'ճ', - 'Մ' => 'մ', - 'Յ' => 'յ', - 'Ն' => 'ն', - 'Շ' => 'շ', - 'Ո' => 'ո', - 'Չ' => 'չ', - 'Պ' => 'պ', - 'Ջ' => 'ջ', - 'Ռ' => 'ռ', - 'Ս' => 'ս', - 'Վ' => 'վ', - 'Տ' => 'տ', - 'Ր' => 'ր', - 'Ց' => 'ց', - 'Ւ' => 'ւ', - 'Փ' => 'փ', - 'Ք' => 'ք', - 'Օ' => 'օ', - 'Ֆ' => 'ֆ', - 'Ⴀ' => 'ⴀ', - 'Ⴁ' => 'ⴁ', - 'Ⴂ' => 'ⴂ', - 'Ⴃ' => 'ⴃ', - 'Ⴄ' => 'ⴄ', - 'Ⴅ' => 'ⴅ', - 'Ⴆ' => 'ⴆ', - 'Ⴇ' => 'ⴇ', - 'Ⴈ' => 'ⴈ', - 'Ⴉ' => 'ⴉ', - 'Ⴊ' => 'ⴊ', - 'Ⴋ' => 'ⴋ', - 'Ⴌ' => 'ⴌ', - 'Ⴍ' => 'ⴍ', - 'Ⴎ' => 'ⴎ', - 'Ⴏ' => 'ⴏ', - 'Ⴐ' => 'ⴐ', - 'Ⴑ' => 'ⴑ', - 'Ⴒ' => 'ⴒ', - 'Ⴓ' => 'ⴓ', - 'Ⴔ' => 'ⴔ', - 'Ⴕ' => 'ⴕ', - 'Ⴖ' => 'ⴖ', - 'Ⴗ' => 'ⴗ', - 'Ⴘ' => 'ⴘ', - 'Ⴙ' => 'ⴙ', - 'Ⴚ' => 'ⴚ', - 'Ⴛ' => 'ⴛ', - 'Ⴜ' => 'ⴜ', - 'Ⴝ' => 'ⴝ', - 'Ⴞ' => 'ⴞ', - 'Ⴟ' => 'ⴟ', - 'Ⴠ' => 'ⴠ', - 'Ⴡ' => 'ⴡ', - 'Ⴢ' => 'ⴢ', - 'Ⴣ' => 'ⴣ', - 'Ⴤ' => 'ⴤ', - 'Ⴥ' => 'ⴥ', - 'Ⴧ' => 'ⴧ', - 'Ⴭ' => 'ⴭ', - 'Ḁ' => 'ḁ', - 'Ḃ' => 'ḃ', - 'Ḅ' => 'ḅ', - 'Ḇ' => 'ḇ', - 'Ḉ' => 'ḉ', - 'Ḋ' => 'ḋ', - 'Ḍ' => 'ḍ', - 'Ḏ' => 'ḏ', - 'Ḑ' => 'ḑ', - 'Ḓ' => 'ḓ', - 'Ḕ' => 'ḕ', - 'Ḗ' => 'ḗ', - 'Ḙ' => 'ḙ', - 'Ḛ' => 'ḛ', - 'Ḝ' => 'ḝ', - 'Ḟ' => 'ḟ', - 'Ḡ' => 'ḡ', - 'Ḣ' => 'ḣ', - 'Ḥ' => 'ḥ', - 'Ḧ' => 'ḧ', - 'Ḩ' => 'ḩ', - 'Ḫ' => 'ḫ', - 'Ḭ' => 'ḭ', - 'Ḯ' => 'ḯ', - 'Ḱ' => 'ḱ', - 'Ḳ' => 'ḳ', - 'Ḵ' => 'ḵ', - 'Ḷ' => 'ḷ', - 'Ḹ' => 'ḹ', - 'Ḻ' => 'ḻ', - 'Ḽ' => 'ḽ', - 'Ḿ' => 'ḿ', - 'Ṁ' => 'ṁ', - 'Ṃ' => 'ṃ', - 'Ṅ' => 'ṅ', - 'Ṇ' => 'ṇ', - 'Ṉ' => 'ṉ', - 'Ṋ' => 'ṋ', - 'Ṍ' => 'ṍ', - 'Ṏ' => 'ṏ', - 'Ṑ' => 'ṑ', - 'Ṓ' => 'ṓ', - 'Ṕ' => 'ṕ', - 'Ṗ' => 'ṗ', - 'Ṙ' => 'ṙ', - 'Ṛ' => 'ṛ', - 'Ṝ' => 'ṝ', - 'Ṟ' => 'ṟ', - 'Ṡ' => 'ṡ', - 'Ṣ' => 'ṣ', - 'Ṥ' => 'ṥ', - 'Ṧ' => 'ṧ', - 'Ṩ' => 'ṩ', - 'Ṫ' => 'ṫ', - 'Ṭ' => 'ṭ', - 'Ṯ' => 'ṯ', - 'Ṱ' => 'ṱ', - 'Ṳ' => 'ṳ', - 'Ṵ' => 'ṵ', - 'Ṷ' => 'ṷ', - 'Ṹ' => 'ṹ', - 'Ṻ' => 'ṻ', - 'Ṽ' => 'ṽ', - 'Ṿ' => 'ṿ', - 'Ẁ' => 'ẁ', - 'Ẃ' => 'ẃ', - 'Ẅ' => 'ẅ', - 'Ẇ' => 'ẇ', - 'Ẉ' => 'ẉ', - 'Ẋ' => 'ẋ', - 'Ẍ' => 'ẍ', - 'Ẏ' => 'ẏ', - 'Ẑ' => 'ẑ', - 'Ẓ' => 'ẓ', - 'Ẕ' => 'ẕ', - 'ẞ' => 'ß', - 'Ạ' => 'ạ', - 'Ả' => 'ả', - 'Ấ' => 'ấ', - 'Ầ' => 'ầ', - 'Ẩ' => 'ẩ', - 'Ẫ' => 'ẫ', - 'Ậ' => 'ậ', - 'Ắ' => 'ắ', - 'Ằ' => 'ằ', - 'Ẳ' => 'ẳ', - 'Ẵ' => 'ẵ', - 'Ặ' => 'ặ', - 'Ẹ' => 'ẹ', - 'Ẻ' => 'ẻ', - 'Ẽ' => 'ẽ', - 'Ế' => 'ế', - 'Ề' => 'ề', - 'Ể' => 'ể', - 'Ễ' => 'ễ', - 'Ệ' => 'ệ', - 'Ỉ' => 'ỉ', - 'Ị' => 'ị', - 'Ọ' => 'ọ', - 'Ỏ' => 'ỏ', - 'Ố' => 'ố', - 'Ồ' => 'ồ', - 'Ổ' => 'ổ', - 'Ỗ' => 'ỗ', - 'Ộ' => 'ộ', - 'Ớ' => 'ớ', - 'Ờ' => 'ờ', - 'Ở' => 'ở', - 'Ỡ' => 'ỡ', - 'Ợ' => 'ợ', - 'Ụ' => 'ụ', - 'Ủ' => 'ủ', - 'Ứ' => 'ứ', - 'Ừ' => 'ừ', - 'Ử' => 'ử', - 'Ữ' => 'ữ', - 'Ự' => 'ự', - 'Ỳ' => 'ỳ', - 'Ỵ' => 'ỵ', - 'Ỷ' => 'ỷ', - 'Ỹ' => 'ỹ', - 'Ỻ' => 'ỻ', - 'Ỽ' => 'ỽ', - 'Ỿ' => 'ỿ', - 'Ἀ' => 'ἀ', - 'Ἁ' => 'ἁ', - 'Ἂ' => 'ἂ', - 'Ἃ' => 'ἃ', - 'Ἄ' => 'ἄ', - 'Ἅ' => 'ἅ', - 'Ἆ' => 'ἆ', - 'Ἇ' => 'ἇ', - 'Ἐ' => 'ἐ', - 'Ἑ' => 'ἑ', - 'Ἒ' => 'ἒ', - 'Ἓ' => 'ἓ', - 'Ἔ' => 'ἔ', - 'Ἕ' => 'ἕ', - 'Ἠ' => 'ἠ', - 'Ἡ' => 'ἡ', - 'Ἢ' => 'ἢ', - 'Ἣ' => 'ἣ', - 'Ἤ' => 'ἤ', - 'Ἥ' => 'ἥ', - 'Ἦ' => 'ἦ', - 'Ἧ' => 'ἧ', - 'Ἰ' => 'ἰ', - 'Ἱ' => 'ἱ', - 'Ἲ' => 'ἲ', - 'Ἳ' => 'ἳ', - 'Ἴ' => 'ἴ', - 'Ἵ' => 'ἵ', - 'Ἶ' => 'ἶ', - 'Ἷ' => 'ἷ', - 'Ὀ' => 'ὀ', - 'Ὁ' => 'ὁ', - 'Ὂ' => 'ὂ', - 'Ὃ' => 'ὃ', - 'Ὄ' => 'ὄ', - 'Ὅ' => 'ὅ', - 'Ὑ' => 'ὑ', - 'Ὓ' => 'ὓ', - 'Ὕ' => 'ὕ', - 'Ὗ' => 'ὗ', - 'Ὠ' => 'ὠ', - 'Ὡ' => 'ὡ', - 'Ὢ' => 'ὢ', - 'Ὣ' => 'ὣ', - 'Ὤ' => 'ὤ', - 'Ὥ' => 'ὥ', - 'Ὦ' => 'ὦ', - 'Ὧ' => 'ὧ', - 'ᾈ' => 'ᾀ', - 'ᾉ' => 'ᾁ', - 'ᾊ' => 'ᾂ', - 'ᾋ' => 'ᾃ', - 'ᾌ' => 'ᾄ', - 'ᾍ' => 'ᾅ', - 'ᾎ' => 'ᾆ', - 'ᾏ' => 'ᾇ', - 'ᾘ' => 'ᾐ', - 'ᾙ' => 'ᾑ', - 'ᾚ' => 'ᾒ', - 'ᾛ' => 'ᾓ', - 'ᾜ' => 'ᾔ', - 'ᾝ' => 'ᾕ', - 'ᾞ' => 'ᾖ', - 'ᾟ' => 'ᾗ', - 'ᾨ' => 'ᾠ', - 'ᾩ' => 'ᾡ', - 'ᾪ' => 'ᾢ', - 'ᾫ' => 'ᾣ', - 'ᾬ' => 'ᾤ', - 'ᾭ' => 'ᾥ', - 'ᾮ' => 'ᾦ', - 'ᾯ' => 'ᾧ', - 'Ᾰ' => 'ᾰ', - 'Ᾱ' => 'ᾱ', - 'Ὰ' => 'ὰ', - 'Ά' => 'ά', - 'ᾼ' => 'ᾳ', - 'Ὲ' => 'ὲ', - 'Έ' => 'έ', - 'Ὴ' => 'ὴ', - 'Ή' => 'ή', - 'ῌ' => 'ῃ', - 'Ῐ' => 'ῐ', - 'Ῑ' => 'ῑ', - 'Ὶ' => 'ὶ', - 'Ί' => 'ί', - 'Ῠ' => 'ῠ', - 'Ῡ' => 'ῡ', - 'Ὺ' => 'ὺ', - 'Ύ' => 'ύ', - 'Ῥ' => 'ῥ', - 'Ὸ' => 'ὸ', - 'Ό' => 'ό', - 'Ὼ' => 'ὼ', - 'Ώ' => 'ώ', - 'ῼ' => 'ῳ', - 'Ω' => 'ω', - 'K' => 'k', - 'Å' => 'å', - 'Ⅎ' => 'ⅎ', - 'Ⅰ' => 'ⅰ', - 'Ⅱ' => 'ⅱ', - 'Ⅲ' => 'ⅲ', - 'Ⅳ' => 'ⅳ', - 'Ⅴ' => 'ⅴ', - 'Ⅵ' => 'ⅵ', - 'Ⅶ' => 'ⅶ', - 'Ⅷ' => 'ⅷ', - 'Ⅸ' => 'ⅸ', - 'Ⅹ' => 'ⅹ', - 'Ⅺ' => 'ⅺ', - 'Ⅻ' => 'ⅻ', - 'Ⅼ' => 'ⅼ', - 'Ⅽ' => 'ⅽ', - 'Ⅾ' => 'ⅾ', - 'Ⅿ' => 'ⅿ', - 'Ↄ' => 'ↄ', - 'Ⓐ' => 'ⓐ', - 'Ⓑ' => 'ⓑ', - 'Ⓒ' => 'ⓒ', - 'Ⓓ' => 'ⓓ', - 'Ⓔ' => 'ⓔ', - 'Ⓕ' => 'ⓕ', - 'Ⓖ' => 'ⓖ', - 'Ⓗ' => 'ⓗ', - 'Ⓘ' => 'ⓘ', - 'Ⓙ' => 'ⓙ', - 'Ⓚ' => 'ⓚ', - 'Ⓛ' => 'ⓛ', - 'Ⓜ' => 'ⓜ', - 'Ⓝ' => 'ⓝ', - 'Ⓞ' => 'ⓞ', - 'Ⓟ' => 'ⓟ', - 'Ⓠ' => 'ⓠ', - 'Ⓡ' => 'ⓡ', - 'Ⓢ' => 'ⓢ', - 'Ⓣ' => 'ⓣ', - 'Ⓤ' => 'ⓤ', - 'Ⓥ' => 'ⓥ', - 'Ⓦ' => 'ⓦ', - 'Ⓧ' => 'ⓧ', - 'Ⓨ' => 'ⓨ', - 'Ⓩ' => 'ⓩ', - 'Ⰰ' => 'ⰰ', - 'Ⰱ' => 'ⰱ', - 'Ⰲ' => 'ⰲ', - 'Ⰳ' => 'ⰳ', - 'Ⰴ' => 'ⰴ', - 'Ⰵ' => 'ⰵ', - 'Ⰶ' => 'ⰶ', - 'Ⰷ' => 'ⰷ', - 'Ⰸ' => 'ⰸ', - 'Ⰹ' => 'ⰹ', - 'Ⰺ' => 'ⰺ', - 'Ⰻ' => 'ⰻ', - 'Ⰼ' => 'ⰼ', - 'Ⰽ' => 'ⰽ', - 'Ⰾ' => 'ⰾ', - 'Ⰿ' => 'ⰿ', - 'Ⱀ' => 'ⱀ', - 'Ⱁ' => 'ⱁ', - 'Ⱂ' => 'ⱂ', - 'Ⱃ' => 'ⱃ', - 'Ⱄ' => 'ⱄ', - 'Ⱅ' => 'ⱅ', - 'Ⱆ' => 'ⱆ', - 'Ⱇ' => 'ⱇ', - 'Ⱈ' => 'ⱈ', - 'Ⱉ' => 'ⱉ', - 'Ⱊ' => 'ⱊ', - 'Ⱋ' => 'ⱋ', - 'Ⱌ' => 'ⱌ', - 'Ⱍ' => 'ⱍ', - 'Ⱎ' => 'ⱎ', - 'Ⱏ' => 'ⱏ', - 'Ⱐ' => 'ⱐ', - 'Ⱑ' => 'ⱑ', - 'Ⱒ' => 'ⱒ', - 'Ⱓ' => 'ⱓ', - 'Ⱔ' => 'ⱔ', - 'Ⱕ' => 'ⱕ', - 'Ⱖ' => 'ⱖ', - 'Ⱗ' => 'ⱗ', - 'Ⱘ' => 'ⱘ', - 'Ⱙ' => 'ⱙ', - 'Ⱚ' => 'ⱚ', - 'Ⱛ' => 'ⱛ', - 'Ⱜ' => 'ⱜ', - 'Ⱝ' => 'ⱝ', - 'Ⱞ' => 'ⱞ', - 'Ⱡ' => 'ⱡ', - 'Ɫ' => 'ɫ', - 'Ᵽ' => 'ᵽ', - 'Ɽ' => 'ɽ', - 'Ⱨ' => 'ⱨ', - 'Ⱪ' => 'ⱪ', - 'Ⱬ' => 'ⱬ', - 'Ɑ' => 'ɑ', - 'Ɱ' => 'ɱ', - 'Ɐ' => 'ɐ', - 'Ɒ' => 'ɒ', - 'Ⱳ' => 'ⱳ', - 'Ⱶ' => 'ⱶ', - 'Ȿ' => 'ȿ', - 'Ɀ' => 'ɀ', - 'Ⲁ' => 'ⲁ', - 'Ⲃ' => 'ⲃ', - 'Ⲅ' => 'ⲅ', - 'Ⲇ' => 'ⲇ', - 'Ⲉ' => 'ⲉ', - 'Ⲋ' => 'ⲋ', - 'Ⲍ' => 'ⲍ', - 'Ⲏ' => 'ⲏ', - 'Ⲑ' => 'ⲑ', - 'Ⲓ' => 'ⲓ', - 'Ⲕ' => 'ⲕ', - 'Ⲗ' => 'ⲗ', - 'Ⲙ' => 'ⲙ', - 'Ⲛ' => 'ⲛ', - 'Ⲝ' => 'ⲝ', - 'Ⲟ' => 'ⲟ', - 'Ⲡ' => 'ⲡ', - 'Ⲣ' => 'ⲣ', - 'Ⲥ' => 'ⲥ', - 'Ⲧ' => 'ⲧ', - 'Ⲩ' => 'ⲩ', - 'Ⲫ' => 'ⲫ', - 'Ⲭ' => 'ⲭ', - 'Ⲯ' => 'ⲯ', - 'Ⲱ' => 'ⲱ', - 'Ⲳ' => 'ⲳ', - 'Ⲵ' => 'ⲵ', - 'Ⲷ' => 'ⲷ', - 'Ⲹ' => 'ⲹ', - 'Ⲻ' => 'ⲻ', - 'Ⲽ' => 'ⲽ', - 'Ⲿ' => 'ⲿ', - 'Ⳁ' => 'ⳁ', - 'Ⳃ' => 'ⳃ', - 'Ⳅ' => 'ⳅ', - 'Ⳇ' => 'ⳇ', - 'Ⳉ' => 'ⳉ', - 'Ⳋ' => 'ⳋ', - 'Ⳍ' => 'ⳍ', - 'Ⳏ' => 'ⳏ', - 'Ⳑ' => 'ⳑ', - 'Ⳓ' => 'ⳓ', - 'Ⳕ' => 'ⳕ', - 'Ⳗ' => 'ⳗ', - 'Ⳙ' => 'ⳙ', - 'Ⳛ' => 'ⳛ', - 'Ⳝ' => 'ⳝ', - 'Ⳟ' => 'ⳟ', - 'Ⳡ' => 'ⳡ', - 'Ⳣ' => 'ⳣ', - 'Ⳬ' => 'ⳬ', - 'Ⳮ' => 'ⳮ', - 'Ⳳ' => 'ⳳ', - 'Ꙁ' => 'ꙁ', - 'Ꙃ' => 'ꙃ', - 'Ꙅ' => 'ꙅ', - 'Ꙇ' => 'ꙇ', - 'Ꙉ' => 'ꙉ', - 'Ꙋ' => 'ꙋ', - 'Ꙍ' => 'ꙍ', - 'Ꙏ' => 'ꙏ', - 'Ꙑ' => 'ꙑ', - 'Ꙓ' => 'ꙓ', - 'Ꙕ' => 'ꙕ', - 'Ꙗ' => 'ꙗ', - 'Ꙙ' => 'ꙙ', - 'Ꙛ' => 'ꙛ', - 'Ꙝ' => 'ꙝ', - 'Ꙟ' => 'ꙟ', - 'Ꙡ' => 'ꙡ', - 'Ꙣ' => 'ꙣ', - 'Ꙥ' => 'ꙥ', - 'Ꙧ' => 'ꙧ', - 'Ꙩ' => 'ꙩ', - 'Ꙫ' => 'ꙫ', - 'Ꙭ' => 'ꙭ', - 'Ꚁ' => 'ꚁ', - 'Ꚃ' => 'ꚃ', - 'Ꚅ' => 'ꚅ', - 'Ꚇ' => 'ꚇ', - 'Ꚉ' => 'ꚉ', - 'Ꚋ' => 'ꚋ', - 'Ꚍ' => 'ꚍ', - 'Ꚏ' => 'ꚏ', - 'Ꚑ' => 'ꚑ', - 'Ꚓ' => 'ꚓ', - 'Ꚕ' => 'ꚕ', - 'Ꚗ' => 'ꚗ', - 'Ꚙ' => 'ꚙ', - 'Ꚛ' => 'ꚛ', - 'Ꜣ' => 'ꜣ', - 'Ꜥ' => 'ꜥ', - 'Ꜧ' => 'ꜧ', - 'Ꜩ' => 'ꜩ', - 'Ꜫ' => 'ꜫ', - 'Ꜭ' => 'ꜭ', - 'Ꜯ' => 'ꜯ', - 'Ꜳ' => 'ꜳ', - 'Ꜵ' => 'ꜵ', - 'Ꜷ' => 'ꜷ', - 'Ꜹ' => 'ꜹ', - 'Ꜻ' => 'ꜻ', - 'Ꜽ' => 'ꜽ', - 'Ꜿ' => 'ꜿ', - 'Ꝁ' => 'ꝁ', - 'Ꝃ' => 'ꝃ', - 'Ꝅ' => 'ꝅ', - 'Ꝇ' => 'ꝇ', - 'Ꝉ' => 'ꝉ', - 'Ꝋ' => 'ꝋ', - 'Ꝍ' => 'ꝍ', - 'Ꝏ' => 'ꝏ', - 'Ꝑ' => 'ꝑ', - 'Ꝓ' => 'ꝓ', - 'Ꝕ' => 'ꝕ', - 'Ꝗ' => 'ꝗ', - 'Ꝙ' => 'ꝙ', - 'Ꝛ' => 'ꝛ', - 'Ꝝ' => 'ꝝ', - 'Ꝟ' => 'ꝟ', - 'Ꝡ' => 'ꝡ', - 'Ꝣ' => 'ꝣ', - 'Ꝥ' => 'ꝥ', - 'Ꝧ' => 'ꝧ', - 'Ꝩ' => 'ꝩ', - 'Ꝫ' => 'ꝫ', - 'Ꝭ' => 'ꝭ', - 'Ꝯ' => 'ꝯ', - 'Ꝺ' => 'ꝺ', - 'Ꝼ' => 'ꝼ', - 'Ᵹ' => 'ᵹ', - 'Ꝿ' => 'ꝿ', - 'Ꞁ' => 'ꞁ', - 'Ꞃ' => 'ꞃ', - 'Ꞅ' => 'ꞅ', - 'Ꞇ' => 'ꞇ', - 'Ꞌ' => 'ꞌ', - 'Ɥ' => 'ɥ', - 'Ꞑ' => 'ꞑ', - 'Ꞓ' => 'ꞓ', - 'Ꞗ' => 'ꞗ', - 'Ꞙ' => 'ꞙ', - 'Ꞛ' => 'ꞛ', - 'Ꞝ' => 'ꞝ', - 'Ꞟ' => 'ꞟ', - 'Ꞡ' => 'ꞡ', - 'Ꞣ' => 'ꞣ', - 'Ꞥ' => 'ꞥ', - 'Ꞧ' => 'ꞧ', - 'Ꞩ' => 'ꞩ', - 'Ɦ' => 'ɦ', - 'Ɜ' => 'ɜ', - 'Ɡ' => 'ɡ', - 'Ɬ' => 'ɬ', - 'Ʞ' => 'ʞ', - 'Ʇ' => 'ʇ', - 'A' => 'a', - 'B' => 'b', - 'C' => 'c', - 'D' => 'd', - 'E' => 'e', - 'F' => 'f', - 'G' => 'g', - 'H' => 'h', - 'I' => 'i', - 'J' => 'j', - 'K' => 'k', - 'L' => 'l', - 'M' => 'm', - 'N' => 'n', - 'O' => 'o', - 'P' => 'p', - 'Q' => 'q', - 'R' => 'r', - 'S' => 's', - 'T' => 't', - 'U' => 'u', - 'V' => 'v', - 'W' => 'w', - 'X' => 'x', - 'Y' => 'y', - 'Z' => 'z', - '𐐀' => '𐐨', - '𐐁' => '𐐩', - '𐐂' => '𐐪', - '𐐃' => '𐐫', - '𐐄' => '𐐬', - '𐐅' => '𐐭', - '𐐆' => '𐐮', - '𐐇' => '𐐯', - '𐐈' => '𐐰', - '𐐉' => '𐐱', - '𐐊' => '𐐲', - '𐐋' => '𐐳', - '𐐌' => '𐐴', - '𐐍' => '𐐵', - '𐐎' => '𐐶', - '𐐏' => '𐐷', - '𐐐' => '𐐸', - '𐐑' => '𐐹', - '𐐒' => '𐐺', - '𐐓' => '𐐻', - '𐐔' => '𐐼', - '𐐕' => '𐐽', - '𐐖' => '𐐾', - '𐐗' => '𐐿', - '𐐘' => '𐑀', - '𐐙' => '𐑁', - '𐐚' => '𐑂', - '𐐛' => '𐑃', - '𐐜' => '𐑄', - '𐐝' => '𐑅', - '𐐞' => '𐑆', - '𐐟' => '𐑇', - '𐐠' => '𐑈', - '𐐡' => '𐑉', - '𐐢' => '𐑊', - '𐐣' => '𐑋', - '𐐤' => '𐑌', - '𐐥' => '𐑍', - '𐐦' => '𐑎', - '𐐧' => '𐑏', - '𑢠' => '𑣀', - '𑢡' => '𑣁', - '𑢢' => '𑣂', - '𑢣' => '𑣃', - '𑢤' => '𑣄', - '𑢥' => '𑣅', - '𑢦' => '𑣆', - '𑢧' => '𑣇', - '𑢨' => '𑣈', - '𑢩' => '𑣉', - '𑢪' => '𑣊', - '𑢫' => '𑣋', - '𑢬' => '𑣌', - '𑢭' => '𑣍', - '𑢮' => '𑣎', - '𑢯' => '𑣏', - '𑢰' => '𑣐', - '𑢱' => '𑣑', - '𑢲' => '𑣒', - '𑢳' => '𑣓', - '𑢴' => '𑣔', - '𑢵' => '𑣕', - '𑢶' => '𑣖', - '𑢷' => '𑣗', - '𑢸' => '𑣘', - '𑢹' => '𑣙', - '𑢺' => '𑣚', - '𑢻' => '𑣛', - '𑢼' => '𑣜', - '𑢽' => '𑣝', - '𑢾' => '𑣞', - '𑢿' => '𑣟', -); - -$result =& $data; -unset($data); - -return $result; diff --git a/lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php b/lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php deleted file mode 100644 index ec9422121..000000000 --- a/lib/silex/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +++ /dev/null @@ -1,1109 +0,0 @@ - 'A', - 'b' => 'B', - 'c' => 'C', - 'd' => 'D', - 'e' => 'E', - 'f' => 'F', - 'g' => 'G', - 'h' => 'H', - 'i' => 'I', - 'j' => 'J', - 'k' => 'K', - 'l' => 'L', - 'm' => 'M', - 'n' => 'N', - 'o' => 'O', - 'p' => 'P', - 'q' => 'Q', - 'r' => 'R', - 's' => 'S', - 't' => 'T', - 'u' => 'U', - 'v' => 'V', - 'w' => 'W', - 'x' => 'X', - 'y' => 'Y', - 'z' => 'Z', - 'µ' => 'Μ', - 'à' => 'À', - 'á' => 'Á', - 'â' => 'Â', - 'ã' => 'Ã', - 'ä' => 'Ä', - 'å' => 'Å', - 'æ' => 'Æ', - 'ç' => 'Ç', - 'è' => 'È', - 'é' => 'É', - 'ê' => 'Ê', - 'ë' => 'Ë', - 'ì' => 'Ì', - 'í' => 'Í', - 'î' => 'Î', - 'ï' => 'Ï', - 'ð' => 'Ð', - 'ñ' => 'Ñ', - 'ò' => 'Ò', - 'ó' => 'Ó', - 'ô' => 'Ô', - 'õ' => 'Õ', - 'ö' => 'Ö', - 'ø' => 'Ø', - 'ù' => 'Ù', - 'ú' => 'Ú', - 'û' => 'Û', - 'ü' => 'Ü', - 'ý' => 'Ý', - 'þ' => 'Þ', - 'ÿ' => 'Ÿ', - 'ā' => 'Ā', - 'ă' => 'Ă', - 'ą' => 'Ą', - 'ć' => 'Ć', - 'ĉ' => 'Ĉ', - 'ċ' => 'Ċ', - 'č' => 'Č', - 'ď' => 'Ď', - 'đ' => 'Đ', - 'ē' => 'Ē', - 'ĕ' => 'Ĕ', - 'ė' => 'Ė', - 'ę' => 'Ę', - 'ě' => 'Ě', - 'ĝ' => 'Ĝ', - 'ğ' => 'Ğ', - 'ġ' => 'Ġ', - 'ģ' => 'Ģ', - 'ĥ' => 'Ĥ', - 'ħ' => 'Ħ', - 'ĩ' => 'Ĩ', - 'ī' => 'Ī', - 'ĭ' => 'Ĭ', - 'į' => 'Į', - 'ı' => 'I', - 'ij' => 'IJ', - 'ĵ' => 'Ĵ', - 'ķ' => 'Ķ', - 'ĺ' => 'Ĺ', - 'ļ' => 'Ļ', - 'ľ' => 'Ľ', - 'ŀ' => 'Ŀ', - 'ł' => 'Ł', - 'ń' => 'Ń', - 'ņ' => 'Ņ', - 'ň' => 'Ň', - 'ŋ' => 'Ŋ', - 'ō' => 'Ō', - 'ŏ' => 'Ŏ', - 'ő' => 'Ő', - 'œ' => 'Œ', - 'ŕ' => 'Ŕ', - 'ŗ' => 'Ŗ', - 'ř' => 'Ř', - 'ś' => 'Ś', - 'ŝ' => 'Ŝ', - 'ş' => 'Ş', - 'š' => 'Š', - 'ţ' => 'Ţ', - 'ť' => 'Ť', - 'ŧ' => 'Ŧ', - 'ũ' => 'Ũ', - 'ū' => 'Ū', - 'ŭ' => 'Ŭ', - 'ů' => 'Ů', - 'ű' => 'Ű', - 'ų' => 'Ų', - 'ŵ' => 'Ŵ', - 'ŷ' => 'Ŷ', - 'ź' => 'Ź', - 'ż' => 'Ż', - 'ž' => 'Ž', - 'ſ' => 'S', - 'ƀ' => 'Ƀ', - 'ƃ' => 'Ƃ', - 'ƅ' => 'Ƅ', - 'ƈ' => 'Ƈ', - 'ƌ' => 'Ƌ', - 'ƒ' => 'Ƒ', - 'ƕ' => 'Ƕ', - 'ƙ' => 'Ƙ', - 'ƚ' => 'Ƚ', - 'ƞ' => 'Ƞ', - 'ơ' => 'Ơ', - 'ƣ' => 'Ƣ', - 'ƥ' => 'Ƥ', - 'ƨ' => 'Ƨ', - 'ƭ' => 'Ƭ', - 'ư' => 'Ư', - 'ƴ' => 'Ƴ', - 'ƶ' => 'Ƶ', - 'ƹ' => 'Ƹ', - 'ƽ' => 'Ƽ', - 'ƿ' => 'Ƿ', - 'Dž' => 'DŽ', - 'dž' => 'DŽ', - 'Lj' => 'LJ', - 'lj' => 'LJ', - 'Nj' => 'NJ', - 'nj' => 'NJ', - 'ǎ' => 'Ǎ', - 'ǐ' => 'Ǐ', - 'ǒ' => 'Ǒ', - 'ǔ' => 'Ǔ', - 'ǖ' => 'Ǖ', - 'ǘ' => 'Ǘ', - 'ǚ' => 'Ǚ', - 'ǜ' => 'Ǜ', - 'ǝ' => 'Ǝ', - 'ǟ' => 'Ǟ', - 'ǡ' => 'Ǡ', - 'ǣ' => 'Ǣ', - 'ǥ' => 'Ǥ', - 'ǧ' => 'Ǧ', - 'ǩ' => 'Ǩ', - 'ǫ' => 'Ǫ', - 'ǭ' => 'Ǭ', - 'ǯ' => 'Ǯ', - 'Dz' => 'DZ', - 'dz' => 'DZ', - 'ǵ' => 'Ǵ', - 'ǹ' => 'Ǹ', - 'ǻ' => 'Ǻ', - 'ǽ' => 'Ǽ', - 'ǿ' => 'Ǿ', - 'ȁ' => 'Ȁ', - 'ȃ' => 'Ȃ', - 'ȅ' => 'Ȅ', - 'ȇ' => 'Ȇ', - 'ȉ' => 'Ȉ', - 'ȋ' => 'Ȋ', - 'ȍ' => 'Ȍ', - 'ȏ' => 'Ȏ', - 'ȑ' => 'Ȑ', - 'ȓ' => 'Ȓ', - 'ȕ' => 'Ȕ', - 'ȗ' => 'Ȗ', - 'ș' => 'Ș', - 'ț' => 'Ț', - 'ȝ' => 'Ȝ', - 'ȟ' => 'Ȟ', - 'ȣ' => 'Ȣ', - 'ȥ' => 'Ȥ', - 'ȧ' => 'Ȧ', - 'ȩ' => 'Ȩ', - 'ȫ' => 'Ȫ', - 'ȭ' => 'Ȭ', - 'ȯ' => 'Ȯ', - 'ȱ' => 'Ȱ', - 'ȳ' => 'Ȳ', - 'ȼ' => 'Ȼ', - 'ȿ' => 'Ȿ', - 'ɀ' => 'Ɀ', - 'ɂ' => 'Ɂ', - 'ɇ' => 'Ɇ', - 'ɉ' => 'Ɉ', - 'ɋ' => 'Ɋ', - 'ɍ' => 'Ɍ', - 'ɏ' => 'Ɏ', - 'ɐ' => 'Ɐ', - 'ɑ' => 'Ɑ', - 'ɒ' => 'Ɒ', - 'ɓ' => 'Ɓ', - 'ɔ' => 'Ɔ', - 'ɖ' => 'Ɖ', - 'ɗ' => 'Ɗ', - 'ə' => 'Ə', - 'ɛ' => 'Ɛ', - 'ɜ' => 'Ɜ', - 'ɠ' => 'Ɠ', - 'ɡ' => 'Ɡ', - 'ɣ' => 'Ɣ', - 'ɥ' => 'Ɥ', - 'ɦ' => 'Ɦ', - 'ɨ' => 'Ɨ', - 'ɩ' => 'Ɩ', - 'ɫ' => 'Ɫ', - 'ɬ' => 'Ɬ', - 'ɯ' => 'Ɯ', - 'ɱ' => 'Ɱ', - 'ɲ' => 'Ɲ', - 'ɵ' => 'Ɵ', - 'ɽ' => 'Ɽ', - 'ʀ' => 'Ʀ', - 'ʃ' => 'Ʃ', - 'ʇ' => 'Ʇ', - 'ʈ' => 'Ʈ', - 'ʉ' => 'Ʉ', - 'ʊ' => 'Ʊ', - 'ʋ' => 'Ʋ', - 'ʌ' => 'Ʌ', - 'ʒ' => 'Ʒ', - 'ʞ' => 'Ʞ', - 'ͅ' => 'Ι', - 'ͱ' => 'Ͱ', - 'ͳ' => 'Ͳ', - 'ͷ' => 'Ͷ', - 'ͻ' => 'Ͻ', - 'ͼ' => 'Ͼ', - 'ͽ' => 'Ͽ', - 'ά' => 'Ά', - 'έ' => 'Έ', - 'ή' => 'Ή', - 'ί' => 'Ί', - 'α' => 'Α', - 'β' => 'Β', - 'γ' => 'Γ', - 'δ' => 'Δ', - 'ε' => 'Ε', - 'ζ' => 'Ζ', - 'η' => 'Η', - 'θ' => 'Θ', - 'ι' => 'Ι', - 'κ' => 'Κ', - 'λ' => 'Λ', - 'μ' => 'Μ', - 'ν' => 'Ν', - 'ξ' => 'Ξ', - 'ο' => 'Ο', - 'π' => 'Π', - 'ρ' => 'Ρ', - 'ς' => 'Σ', - 'σ' => 'Σ', - 'τ' => 'Τ', - 'υ' => 'Υ', - 'φ' => 'Φ', - 'χ' => 'Χ', - 'ψ' => 'Ψ', - 'ω' => 'Ω', - 'ϊ' => 'Ϊ', - 'ϋ' => 'Ϋ', - 'ό' => 'Ό', - 'ύ' => 'Ύ', - 'ώ' => 'Ώ', - 'ϐ' => 'Β', - 'ϑ' => 'Θ', - 'ϕ' => 'Φ', - 'ϖ' => 'Π', - 'ϗ' => 'Ϗ', - 'ϙ' => 'Ϙ', - 'ϛ' => 'Ϛ', - 'ϝ' => 'Ϝ', - 'ϟ' => 'Ϟ', - 'ϡ' => 'Ϡ', - 'ϣ' => 'Ϣ', - 'ϥ' => 'Ϥ', - 'ϧ' => 'Ϧ', - 'ϩ' => 'Ϩ', - 'ϫ' => 'Ϫ', - 'ϭ' => 'Ϭ', - 'ϯ' => 'Ϯ', - 'ϰ' => 'Κ', - 'ϱ' => 'Ρ', - 'ϲ' => 'Ϲ', - 'ϳ' => 'Ϳ', - 'ϵ' => 'Ε', - 'ϸ' => 'Ϸ', - 'ϻ' => 'Ϻ', - 'а' => 'А', - 'б' => 'Б', - 'в' => 'В', - 'г' => 'Г', - 'д' => 'Д', - 'е' => 'Е', - 'ж' => 'Ж', - 'з' => 'З', - 'и' => 'И', - 'й' => 'Й', - 'к' => 'К', - 'л' => 'Л', - 'м' => 'М', - 'н' => 'Н', - 'о' => 'О', - 'п' => 'П', - 'р' => 'Р', - 'с' => 'С', - 'т' => 'Т', - 'у' => 'У', - 'ф' => 'Ф', - 'х' => 'Х', - 'ц' => 'Ц', - 'ч' => 'Ч', - 'ш' => 'Ш', - 'щ' => 'Щ', - 'ъ' => 'Ъ', - 'ы' => 'Ы', - 'ь' => 'Ь', - 'э' => 'Э', - 'ю' => 'Ю', - 'я' => 'Я', - 'ѐ' => 'Ѐ', - 'ё' => 'Ё', - 'ђ' => 'Ђ', - 'ѓ' => 'Ѓ', - 'є' => 'Є', - 'ѕ' => 'Ѕ', - 'і' => 'І', - 'ї' => 'Ї', - 'ј' => 'Ј', - 'љ' => 'Љ', - 'њ' => 'Њ', - 'ћ' => 'Ћ', - 'ќ' => 'Ќ', - 'ѝ' => 'Ѝ', - 'ў' => 'Ў', - 'џ' => 'Џ', - 'ѡ' => 'Ѡ', - 'ѣ' => 'Ѣ', - 'ѥ' => 'Ѥ', - 'ѧ' => 'Ѧ', - 'ѩ' => 'Ѩ', - 'ѫ' => 'Ѫ', - 'ѭ' => 'Ѭ', - 'ѯ' => 'Ѯ', - 'ѱ' => 'Ѱ', - 'ѳ' => 'Ѳ', - 'ѵ' => 'Ѵ', - 'ѷ' => 'Ѷ', - 'ѹ' => 'Ѹ', - 'ѻ' => 'Ѻ', - 'ѽ' => 'Ѽ', - 'ѿ' => 'Ѿ', - 'ҁ' => 'Ҁ', - 'ҋ' => 'Ҋ', - 'ҍ' => 'Ҍ', - 'ҏ' => 'Ҏ', - 'ґ' => 'Ґ', - 'ғ' => 'Ғ', - 'ҕ' => 'Ҕ', - 'җ' => 'Җ', - 'ҙ' => 'Ҙ', - 'қ' => 'Қ', - 'ҝ' => 'Ҝ', - 'ҟ' => 'Ҟ', - 'ҡ' => 'Ҡ', - 'ң' => 'Ң', - 'ҥ' => 'Ҥ', - 'ҧ' => 'Ҧ', - 'ҩ' => 'Ҩ', - 'ҫ' => 'Ҫ', - 'ҭ' => 'Ҭ', - 'ү' => 'Ү', - 'ұ' => 'Ұ', - 'ҳ' => 'Ҳ', - 'ҵ' => 'Ҵ', - 'ҷ' => 'Ҷ', - 'ҹ' => 'Ҹ', - 'һ' => 'Һ', - 'ҽ' => 'Ҽ', - 'ҿ' => 'Ҿ', - 'ӂ' => 'Ӂ', - 'ӄ' => 'Ӄ', - 'ӆ' => 'Ӆ', - 'ӈ' => 'Ӈ', - 'ӊ' => 'Ӊ', - 'ӌ' => 'Ӌ', - 'ӎ' => 'Ӎ', - 'ӏ' => 'Ӏ', - 'ӑ' => 'Ӑ', - 'ӓ' => 'Ӓ', - 'ӕ' => 'Ӕ', - 'ӗ' => 'Ӗ', - 'ә' => 'Ә', - 'ӛ' => 'Ӛ', - 'ӝ' => 'Ӝ', - 'ӟ' => 'Ӟ', - 'ӡ' => 'Ӡ', - 'ӣ' => 'Ӣ', - 'ӥ' => 'Ӥ', - 'ӧ' => 'Ӧ', - 'ө' => 'Ө', - 'ӫ' => 'Ӫ', - 'ӭ' => 'Ӭ', - 'ӯ' => 'Ӯ', - 'ӱ' => 'Ӱ', - 'ӳ' => 'Ӳ', - 'ӵ' => 'Ӵ', - 'ӷ' => 'Ӷ', - 'ӹ' => 'Ӹ', - 'ӻ' => 'Ӻ', - 'ӽ' => 'Ӽ', - 'ӿ' => 'Ӿ', - 'ԁ' => 'Ԁ', - 'ԃ' => 'Ԃ', - 'ԅ' => 'Ԅ', - 'ԇ' => 'Ԇ', - 'ԉ' => 'Ԉ', - 'ԋ' => 'Ԋ', - 'ԍ' => 'Ԍ', - 'ԏ' => 'Ԏ', - 'ԑ' => 'Ԑ', - 'ԓ' => 'Ԓ', - 'ԕ' => 'Ԕ', - 'ԗ' => 'Ԗ', - 'ԙ' => 'Ԙ', - 'ԛ' => 'Ԛ', - 'ԝ' => 'Ԝ', - 'ԟ' => 'Ԟ', - 'ԡ' => 'Ԡ', - 'ԣ' => 'Ԣ', - 'ԥ' => 'Ԥ', - 'ԧ' => 'Ԧ', - 'ԩ' => 'Ԩ', - 'ԫ' => 'Ԫ', - 'ԭ' => 'Ԭ', - 'ԯ' => 'Ԯ', - 'ա' => 'Ա', - 'բ' => 'Բ', - 'գ' => 'Գ', - 'դ' => 'Դ', - 'ե' => 'Ե', - 'զ' => 'Զ', - 'է' => 'Է', - 'ը' => 'Ը', - 'թ' => 'Թ', - 'ժ' => 'Ժ', - 'ի' => 'Ի', - 'լ' => 'Լ', - 'խ' => 'Խ', - 'ծ' => 'Ծ', - 'կ' => 'Կ', - 'հ' => 'Հ', - 'ձ' => 'Ձ', - 'ղ' => 'Ղ', - 'ճ' => 'Ճ', - 'մ' => 'Մ', - 'յ' => 'Յ', - 'ն' => 'Ն', - 'շ' => 'Շ', - 'ո' => 'Ո', - 'չ' => 'Չ', - 'պ' => 'Պ', - 'ջ' => 'Ջ', - 'ռ' => 'Ռ', - 'ս' => 'Ս', - 'վ' => 'Վ', - 'տ' => 'Տ', - 'ր' => 'Ր', - 'ց' => 'Ց', - 'ւ' => 'Ւ', - 'փ' => 'Փ', - 'ք' => 'Ք', - 'օ' => 'Օ', - 'ֆ' => 'Ֆ', - 'ᵹ' => 'Ᵹ', - 'ᵽ' => 'Ᵽ', - 'ḁ' => 'Ḁ', - 'ḃ' => 'Ḃ', - 'ḅ' => 'Ḅ', - 'ḇ' => 'Ḇ', - 'ḉ' => 'Ḉ', - 'ḋ' => 'Ḋ', - 'ḍ' => 'Ḍ', - 'ḏ' => 'Ḏ', - 'ḑ' => 'Ḑ', - 'ḓ' => 'Ḓ', - 'ḕ' => 'Ḕ', - 'ḗ' => 'Ḗ', - 'ḙ' => 'Ḙ', - 'ḛ' => 'Ḛ', - 'ḝ' => 'Ḝ', - 'ḟ' => 'Ḟ', - 'ḡ' => 'Ḡ', - 'ḣ' => 'Ḣ', - 'ḥ' => 'Ḥ', - 'ḧ' => 'Ḧ', - 'ḩ' => 'Ḩ', - 'ḫ' => 'Ḫ', - 'ḭ' => 'Ḭ', - 'ḯ' => 'Ḯ', - 'ḱ' => 'Ḱ', - 'ḳ' => 'Ḳ', - 'ḵ' => 'Ḵ', - 'ḷ' => 'Ḷ', - 'ḹ' => 'Ḹ', - 'ḻ' => 'Ḻ', - 'ḽ' => 'Ḽ', - 'ḿ' => 'Ḿ', - 'ṁ' => 'Ṁ', - 'ṃ' => 'Ṃ', - 'ṅ' => 'Ṅ', - 'ṇ' => 'Ṇ', - 'ṉ' => 'Ṉ', - 'ṋ' => 'Ṋ', - 'ṍ' => 'Ṍ', - 'ṏ' => 'Ṏ', - 'ṑ' => 'Ṑ', - 'ṓ' => 'Ṓ', - 'ṕ' => 'Ṕ', - 'ṗ' => 'Ṗ', - 'ṙ' => 'Ṙ', - 'ṛ' => 'Ṛ', - 'ṝ' => 'Ṝ', - 'ṟ' => 'Ṟ', - 'ṡ' => 'Ṡ', - 'ṣ' => 'Ṣ', - 'ṥ' => 'Ṥ', - 'ṧ' => 'Ṧ', - 'ṩ' => 'Ṩ', - 'ṫ' => 'Ṫ', - 'ṭ' => 'Ṭ', - 'ṯ' => 'Ṯ', - 'ṱ' => 'Ṱ', - 'ṳ' => 'Ṳ', - 'ṵ' => 'Ṵ', - 'ṷ' => 'Ṷ', - 'ṹ' => 'Ṹ', - 'ṻ' => 'Ṻ', - 'ṽ' => 'Ṽ', - 'ṿ' => 'Ṿ', - 'ẁ' => 'Ẁ', - 'ẃ' => 'Ẃ', - 'ẅ' => 'Ẅ', - 'ẇ' => 'Ẇ', - 'ẉ' => 'Ẉ', - 'ẋ' => 'Ẋ', - 'ẍ' => 'Ẍ', - 'ẏ' => 'Ẏ', - 'ẑ' => 'Ẑ', - 'ẓ' => 'Ẓ', - 'ẕ' => 'Ẕ', - 'ẛ' => 'Ṡ', - 'ạ' => 'Ạ', - 'ả' => 'Ả', - 'ấ' => 'Ấ', - 'ầ' => 'Ầ', - 'ẩ' => 'Ẩ', - 'ẫ' => 'Ẫ', - 'ậ' => 'Ậ', - 'ắ' => 'Ắ', - 'ằ' => 'Ằ', - 'ẳ' => 'Ẳ', - 'ẵ' => 'Ẵ', - 'ặ' => 'Ặ', - 'ẹ' => 'Ẹ', - 'ẻ' => 'Ẻ', - 'ẽ' => 'Ẽ', - 'ế' => 'Ế', - 'ề' => 'Ề', - 'ể' => 'Ể', - 'ễ' => 'Ễ', - 'ệ' => 'Ệ', - 'ỉ' => 'Ỉ', - 'ị' => 'Ị', - 'ọ' => 'Ọ', - 'ỏ' => 'Ỏ', - 'ố' => 'Ố', - 'ồ' => 'Ồ', - 'ổ' => 'Ổ', - 'ỗ' => 'Ỗ', - 'ộ' => 'Ộ', - 'ớ' => 'Ớ', - 'ờ' => 'Ờ', - 'ở' => 'Ở', - 'ỡ' => 'Ỡ', - 'ợ' => 'Ợ', - 'ụ' => 'Ụ', - 'ủ' => 'Ủ', - 'ứ' => 'Ứ', - 'ừ' => 'Ừ', - 'ử' => 'Ử', - 'ữ' => 'Ữ', - 'ự' => 'Ự', - 'ỳ' => 'Ỳ', - 'ỵ' => 'Ỵ', - 'ỷ' => 'Ỷ', - 'ỹ' => 'Ỹ', - 'ỻ' => 'Ỻ', - 'ỽ' => 'Ỽ', - 'ỿ' => 'Ỿ', - 'ἀ' => 'Ἀ', - 'ἁ' => 'Ἁ', - 'ἂ' => 'Ἂ', - 'ἃ' => 'Ἃ', - 'ἄ' => 'Ἄ', - 'ἅ' => 'Ἅ', - 'ἆ' => 'Ἆ', - 'ἇ' => 'Ἇ', - 'ἐ' => 'Ἐ', - 'ἑ' => 'Ἑ', - 'ἒ' => 'Ἒ', - 'ἓ' => 'Ἓ', - 'ἔ' => 'Ἔ', - 'ἕ' => 'Ἕ', - 'ἠ' => 'Ἠ', - 'ἡ' => 'Ἡ', - 'ἢ' => 'Ἢ', - 'ἣ' => 'Ἣ', - 'ἤ' => 'Ἤ', - 'ἥ' => 'Ἥ', - 'ἦ' => 'Ἦ', - 'ἧ' => 'Ἧ', - 'ἰ' => 'Ἰ', - 'ἱ' => 'Ἱ', - 'ἲ' => 'Ἲ', - 'ἳ' => 'Ἳ', - 'ἴ' => 'Ἴ', - 'ἵ' => 'Ἵ', - 'ἶ' => 'Ἶ', - 'ἷ' => 'Ἷ', - 'ὀ' => 'Ὀ', - 'ὁ' => 'Ὁ', - 'ὂ' => 'Ὂ', - 'ὃ' => 'Ὃ', - 'ὄ' => 'Ὄ', - 'ὅ' => 'Ὅ', - 'ὑ' => 'Ὑ', - 'ὓ' => 'Ὓ', - 'ὕ' => 'Ὕ', - 'ὗ' => 'Ὗ', - 'ὠ' => 'Ὠ', - 'ὡ' => 'Ὡ', - 'ὢ' => 'Ὢ', - 'ὣ' => 'Ὣ', - 'ὤ' => 'Ὤ', - 'ὥ' => 'Ὥ', - 'ὦ' => 'Ὦ', - 'ὧ' => 'Ὧ', - 'ὰ' => 'Ὰ', - 'ά' => 'Ά', - 'ὲ' => 'Ὲ', - 'έ' => 'Έ', - 'ὴ' => 'Ὴ', - 'ή' => 'Ή', - 'ὶ' => 'Ὶ', - 'ί' => 'Ί', - 'ὸ' => 'Ὸ', - 'ό' => 'Ό', - 'ὺ' => 'Ὺ', - 'ύ' => 'Ύ', - 'ὼ' => 'Ὼ', - 'ώ' => 'Ώ', - 'ᾀ' => 'ᾈ', - 'ᾁ' => 'ᾉ', - 'ᾂ' => 'ᾊ', - 'ᾃ' => 'ᾋ', - 'ᾄ' => 'ᾌ', - 'ᾅ' => 'ᾍ', - 'ᾆ' => 'ᾎ', - 'ᾇ' => 'ᾏ', - 'ᾐ' => 'ᾘ', - 'ᾑ' => 'ᾙ', - 'ᾒ' => 'ᾚ', - 'ᾓ' => 'ᾛ', - 'ᾔ' => 'ᾜ', - 'ᾕ' => 'ᾝ', - 'ᾖ' => 'ᾞ', - 'ᾗ' => 'ᾟ', - 'ᾠ' => 'ᾨ', - 'ᾡ' => 'ᾩ', - 'ᾢ' => 'ᾪ', - 'ᾣ' => 'ᾫ', - 'ᾤ' => 'ᾬ', - 'ᾥ' => 'ᾭ', - 'ᾦ' => 'ᾮ', - 'ᾧ' => 'ᾯ', - 'ᾰ' => 'Ᾰ', - 'ᾱ' => 'Ᾱ', - 'ᾳ' => 'ᾼ', - 'ι' => 'Ι', - 'ῃ' => 'ῌ', - 'ῐ' => 'Ῐ', - 'ῑ' => 'Ῑ', - 'ῠ' => 'Ῠ', - 'ῡ' => 'Ῡ', - 'ῥ' => 'Ῥ', - 'ῳ' => 'ῼ', - 'ⅎ' => 'Ⅎ', - 'ⅰ' => 'Ⅰ', - 'ⅱ' => 'Ⅱ', - 'ⅲ' => 'Ⅲ', - 'ⅳ' => 'Ⅳ', - 'ⅴ' => 'Ⅴ', - 'ⅵ' => 'Ⅵ', - 'ⅶ' => 'Ⅶ', - 'ⅷ' => 'Ⅷ', - 'ⅸ' => 'Ⅸ', - 'ⅹ' => 'Ⅹ', - 'ⅺ' => 'Ⅺ', - 'ⅻ' => 'Ⅻ', - 'ⅼ' => 'Ⅼ', - 'ⅽ' => 'Ⅽ', - 'ⅾ' => 'Ⅾ', - 'ⅿ' => 'Ⅿ', - 'ↄ' => 'Ↄ', - 'ⓐ' => 'Ⓐ', - 'ⓑ' => 'Ⓑ', - 'ⓒ' => 'Ⓒ', - 'ⓓ' => 'Ⓓ', - 'ⓔ' => 'Ⓔ', - 'ⓕ' => 'Ⓕ', - 'ⓖ' => 'Ⓖ', - 'ⓗ' => 'Ⓗ', - 'ⓘ' => 'Ⓘ', - 'ⓙ' => 'Ⓙ', - 'ⓚ' => 'Ⓚ', - 'ⓛ' => 'Ⓛ', - 'ⓜ' => 'Ⓜ', - 'ⓝ' => 'Ⓝ', - 'ⓞ' => 'Ⓞ', - 'ⓟ' => 'Ⓟ', - 'ⓠ' => 'Ⓠ', - 'ⓡ' => 'Ⓡ', - 'ⓢ' => 'Ⓢ', - 'ⓣ' => 'Ⓣ', - 'ⓤ' => 'Ⓤ', - 'ⓥ' => 'Ⓥ', - 'ⓦ' => 'Ⓦ', - 'ⓧ' => 'Ⓧ', - 'ⓨ' => 'Ⓨ', - 'ⓩ' => 'Ⓩ', - 'ⰰ' => 'Ⰰ', - 'ⰱ' => 'Ⰱ', - 'ⰲ' => 'Ⰲ', - 'ⰳ' => 'Ⰳ', - 'ⰴ' => 'Ⰴ', - 'ⰵ' => 'Ⰵ', - 'ⰶ' => 'Ⰶ', - 'ⰷ' => 'Ⰷ', - 'ⰸ' => 'Ⰸ', - 'ⰹ' => 'Ⰹ', - 'ⰺ' => 'Ⰺ', - 'ⰻ' => 'Ⰻ', - 'ⰼ' => 'Ⰼ', - 'ⰽ' => 'Ⰽ', - 'ⰾ' => 'Ⰾ', - 'ⰿ' => 'Ⰿ', - 'ⱀ' => 'Ⱀ', - 'ⱁ' => 'Ⱁ', - 'ⱂ' => 'Ⱂ', - 'ⱃ' => 'Ⱃ', - 'ⱄ' => 'Ⱄ', - 'ⱅ' => 'Ⱅ', - 'ⱆ' => 'Ⱆ', - 'ⱇ' => 'Ⱇ', - 'ⱈ' => 'Ⱈ', - 'ⱉ' => 'Ⱉ', - 'ⱊ' => 'Ⱊ', - 'ⱋ' => 'Ⱋ', - 'ⱌ' => 'Ⱌ', - 'ⱍ' => 'Ⱍ', - 'ⱎ' => 'Ⱎ', - 'ⱏ' => 'Ⱏ', - 'ⱐ' => 'Ⱐ', - 'ⱑ' => 'Ⱑ', - 'ⱒ' => 'Ⱒ', - 'ⱓ' => 'Ⱓ', - 'ⱔ' => 'Ⱔ', - 'ⱕ' => 'Ⱕ', - 'ⱖ' => 'Ⱖ', - 'ⱗ' => 'Ⱗ', - 'ⱘ' => 'Ⱘ', - 'ⱙ' => 'Ⱙ', - 'ⱚ' => 'Ⱚ', - 'ⱛ' => 'Ⱛ', - 'ⱜ' => 'Ⱜ', - 'ⱝ' => 'Ⱝ', - 'ⱞ' => 'Ⱞ', - 'ⱡ' => 'Ⱡ', - 'ⱥ' => 'Ⱥ', - 'ⱦ' => 'Ⱦ', - 'ⱨ' => 'Ⱨ', - 'ⱪ' => 'Ⱪ', - 'ⱬ' => 'Ⱬ', - 'ⱳ' => 'Ⱳ', - 'ⱶ' => 'Ⱶ', - 'ⲁ' => 'Ⲁ', - 'ⲃ' => 'Ⲃ', - 'ⲅ' => 'Ⲅ', - 'ⲇ' => 'Ⲇ', - 'ⲉ' => 'Ⲉ', - 'ⲋ' => 'Ⲋ', - 'ⲍ' => 'Ⲍ', - 'ⲏ' => 'Ⲏ', - 'ⲑ' => 'Ⲑ', - 'ⲓ' => 'Ⲓ', - 'ⲕ' => 'Ⲕ', - 'ⲗ' => 'Ⲗ', - 'ⲙ' => 'Ⲙ', - 'ⲛ' => 'Ⲛ', - 'ⲝ' => 'Ⲝ', - 'ⲟ' => 'Ⲟ', - 'ⲡ' => 'Ⲡ', - 'ⲣ' => 'Ⲣ', - 'ⲥ' => 'Ⲥ', - 'ⲧ' => 'Ⲧ', - 'ⲩ' => 'Ⲩ', - 'ⲫ' => 'Ⲫ', - 'ⲭ' => 'Ⲭ', - 'ⲯ' => 'Ⲯ', - 'ⲱ' => 'Ⲱ', - 'ⲳ' => 'Ⲳ', - 'ⲵ' => 'Ⲵ', - 'ⲷ' => 'Ⲷ', - 'ⲹ' => 'Ⲹ', - 'ⲻ' => 'Ⲻ', - 'ⲽ' => 'Ⲽ', - 'ⲿ' => 'Ⲿ', - 'ⳁ' => 'Ⳁ', - 'ⳃ' => 'Ⳃ', - 'ⳅ' => 'Ⳅ', - 'ⳇ' => 'Ⳇ', - 'ⳉ' => 'Ⳉ', - 'ⳋ' => 'Ⳋ', - 'ⳍ' => 'Ⳍ', - 'ⳏ' => 'Ⳏ', - 'ⳑ' => 'Ⳑ', - 'ⳓ' => 'Ⳓ', - 'ⳕ' => 'Ⳕ', - 'ⳗ' => 'Ⳗ', - 'ⳙ' => 'Ⳙ', - 'ⳛ' => 'Ⳛ', - 'ⳝ' => 'Ⳝ', - 'ⳟ' => 'Ⳟ', - 'ⳡ' => 'Ⳡ', - 'ⳣ' => 'Ⳣ', - 'ⳬ' => 'Ⳬ', - 'ⳮ' => 'Ⳮ', - 'ⳳ' => 'Ⳳ', - 'ⴀ' => 'Ⴀ', - 'ⴁ' => 'Ⴁ', - 'ⴂ' => 'Ⴂ', - 'ⴃ' => 'Ⴃ', - 'ⴄ' => 'Ⴄ', - 'ⴅ' => 'Ⴅ', - 'ⴆ' => 'Ⴆ', - 'ⴇ' => 'Ⴇ', - 'ⴈ' => 'Ⴈ', - 'ⴉ' => 'Ⴉ', - 'ⴊ' => 'Ⴊ', - 'ⴋ' => 'Ⴋ', - 'ⴌ' => 'Ⴌ', - 'ⴍ' => 'Ⴍ', - 'ⴎ' => 'Ⴎ', - 'ⴏ' => 'Ⴏ', - 'ⴐ' => 'Ⴐ', - 'ⴑ' => 'Ⴑ', - 'ⴒ' => 'Ⴒ', - 'ⴓ' => 'Ⴓ', - 'ⴔ' => 'Ⴔ', - 'ⴕ' => 'Ⴕ', - 'ⴖ' => 'Ⴖ', - 'ⴗ' => 'Ⴗ', - 'ⴘ' => 'Ⴘ', - 'ⴙ' => 'Ⴙ', - 'ⴚ' => 'Ⴚ', - 'ⴛ' => 'Ⴛ', - 'ⴜ' => 'Ⴜ', - 'ⴝ' => 'Ⴝ', - 'ⴞ' => 'Ⴞ', - 'ⴟ' => 'Ⴟ', - 'ⴠ' => 'Ⴠ', - 'ⴡ' => 'Ⴡ', - 'ⴢ' => 'Ⴢ', - 'ⴣ' => 'Ⴣ', - 'ⴤ' => 'Ⴤ', - 'ⴥ' => 'Ⴥ', - 'ⴧ' => 'Ⴧ', - 'ⴭ' => 'Ⴭ', - 'ꙁ' => 'Ꙁ', - 'ꙃ' => 'Ꙃ', - 'ꙅ' => 'Ꙅ', - 'ꙇ' => 'Ꙇ', - 'ꙉ' => 'Ꙉ', - 'ꙋ' => 'Ꙋ', - 'ꙍ' => 'Ꙍ', - 'ꙏ' => 'Ꙏ', - 'ꙑ' => 'Ꙑ', - 'ꙓ' => 'Ꙓ', - 'ꙕ' => 'Ꙕ', - 'ꙗ' => 'Ꙗ', - 'ꙙ' => 'Ꙙ', - 'ꙛ' => 'Ꙛ', - 'ꙝ' => 'Ꙝ', - 'ꙟ' => 'Ꙟ', - 'ꙡ' => 'Ꙡ', - 'ꙣ' => 'Ꙣ', - 'ꙥ' => 'Ꙥ', - 'ꙧ' => 'Ꙧ', - 'ꙩ' => 'Ꙩ', - 'ꙫ' => 'Ꙫ', - 'ꙭ' => 'Ꙭ', - 'ꚁ' => 'Ꚁ', - 'ꚃ' => 'Ꚃ', - 'ꚅ' => 'Ꚅ', - 'ꚇ' => 'Ꚇ', - 'ꚉ' => 'Ꚉ', - 'ꚋ' => 'Ꚋ', - 'ꚍ' => 'Ꚍ', - 'ꚏ' => 'Ꚏ', - 'ꚑ' => 'Ꚑ', - 'ꚓ' => 'Ꚓ', - 'ꚕ' => 'Ꚕ', - 'ꚗ' => 'Ꚗ', - 'ꚙ' => 'Ꚙ', - 'ꚛ' => 'Ꚛ', - 'ꜣ' => 'Ꜣ', - 'ꜥ' => 'Ꜥ', - 'ꜧ' => 'Ꜧ', - 'ꜩ' => 'Ꜩ', - 'ꜫ' => 'Ꜫ', - 'ꜭ' => 'Ꜭ', - 'ꜯ' => 'Ꜯ', - 'ꜳ' => 'Ꜳ', - 'ꜵ' => 'Ꜵ', - 'ꜷ' => 'Ꜷ', - 'ꜹ' => 'Ꜹ', - 'ꜻ' => 'Ꜻ', - 'ꜽ' => 'Ꜽ', - 'ꜿ' => 'Ꜿ', - 'ꝁ' => 'Ꝁ', - 'ꝃ' => 'Ꝃ', - 'ꝅ' => 'Ꝅ', - 'ꝇ' => 'Ꝇ', - 'ꝉ' => 'Ꝉ', - 'ꝋ' => 'Ꝋ', - 'ꝍ' => 'Ꝍ', - 'ꝏ' => 'Ꝏ', - 'ꝑ' => 'Ꝑ', - 'ꝓ' => 'Ꝓ', - 'ꝕ' => 'Ꝕ', - 'ꝗ' => 'Ꝗ', - 'ꝙ' => 'Ꝙ', - 'ꝛ' => 'Ꝛ', - 'ꝝ' => 'Ꝝ', - 'ꝟ' => 'Ꝟ', - 'ꝡ' => 'Ꝡ', - 'ꝣ' => 'Ꝣ', - 'ꝥ' => 'Ꝥ', - 'ꝧ' => 'Ꝧ', - 'ꝩ' => 'Ꝩ', - 'ꝫ' => 'Ꝫ', - 'ꝭ' => 'Ꝭ', - 'ꝯ' => 'Ꝯ', - 'ꝺ' => 'Ꝺ', - 'ꝼ' => 'Ꝼ', - 'ꝿ' => 'Ꝿ', - 'ꞁ' => 'Ꞁ', - 'ꞃ' => 'Ꞃ', - 'ꞅ' => 'Ꞅ', - 'ꞇ' => 'Ꞇ', - 'ꞌ' => 'Ꞌ', - 'ꞑ' => 'Ꞑ', - 'ꞓ' => 'Ꞓ', - 'ꞗ' => 'Ꞗ', - 'ꞙ' => 'Ꞙ', - 'ꞛ' => 'Ꞛ', - 'ꞝ' => 'Ꞝ', - 'ꞟ' => 'Ꞟ', - 'ꞡ' => 'Ꞡ', - 'ꞣ' => 'Ꞣ', - 'ꞥ' => 'Ꞥ', - 'ꞧ' => 'Ꞧ', - 'ꞩ' => 'Ꞩ', - 'a' => 'A', - 'b' => 'B', - 'c' => 'C', - 'd' => 'D', - 'e' => 'E', - 'f' => 'F', - 'g' => 'G', - 'h' => 'H', - 'i' => 'I', - 'j' => 'J', - 'k' => 'K', - 'l' => 'L', - 'm' => 'M', - 'n' => 'N', - 'o' => 'O', - 'p' => 'P', - 'q' => 'Q', - 'r' => 'R', - 's' => 'S', - 't' => 'T', - 'u' => 'U', - 'v' => 'V', - 'w' => 'W', - 'x' => 'X', - 'y' => 'Y', - 'z' => 'Z', - '𐐨' => '𐐀', - '𐐩' => '𐐁', - '𐐪' => '𐐂', - '𐐫' => '𐐃', - '𐐬' => '𐐄', - '𐐭' => '𐐅', - '𐐮' => '𐐆', - '𐐯' => '𐐇', - '𐐰' => '𐐈', - '𐐱' => '𐐉', - '𐐲' => '𐐊', - '𐐳' => '𐐋', - '𐐴' => '𐐌', - '𐐵' => '𐐍', - '𐐶' => '𐐎', - '𐐷' => '𐐏', - '𐐸' => '𐐐', - '𐐹' => '𐐑', - '𐐺' => '𐐒', - '𐐻' => '𐐓', - '𐐼' => '𐐔', - '𐐽' => '𐐕', - '𐐾' => '𐐖', - '𐐿' => '𐐗', - '𐑀' => '𐐘', - '𐑁' => '𐐙', - '𐑂' => '𐐚', - '𐑃' => '𐐛', - '𐑄' => '𐐜', - '𐑅' => '𐐝', - '𐑆' => '𐐞', - '𐑇' => '𐐟', - '𐑈' => '𐐠', - '𐑉' => '𐐡', - '𐑊' => '𐐢', - '𐑋' => '𐐣', - '𐑌' => '𐐤', - '𐑍' => '𐐥', - '𐑎' => '𐐦', - '𐑏' => '𐐧', - '𑣀' => '𑢠', - '𑣁' => '𑢡', - '𑣂' => '𑢢', - '𑣃' => '𑢣', - '𑣄' => '𑢤', - '𑣅' => '𑢥', - '𑣆' => '𑢦', - '𑣇' => '𑢧', - '𑣈' => '𑢨', - '𑣉' => '𑢩', - '𑣊' => '𑢪', - '𑣋' => '𑢫', - '𑣌' => '𑢬', - '𑣍' => '𑢭', - '𑣎' => '𑢮', - '𑣏' => '𑢯', - '𑣐' => '𑢰', - '𑣑' => '𑢱', - '𑣒' => '𑢲', - '𑣓' => '𑢳', - '𑣔' => '𑢴', - '𑣕' => '𑢵', - '𑣖' => '𑢶', - '𑣗' => '𑢷', - '𑣘' => '𑢸', - '𑣙' => '𑢹', - '𑣚' => '𑢺', - '𑣛' => '𑢻', - '𑣜' => '𑢼', - '𑣝' => '𑢽', - '𑣞' => '𑢾', - '𑣟' => '𑢿', -); - -$result =& $data; -unset($data); - -return $result; diff --git a/lib/silex/vendor/symfony/polyfill-mbstring/bootstrap.php b/lib/silex/vendor/symfony/polyfill-mbstring/bootstrap.php deleted file mode 100644 index 337229106..000000000 --- a/lib/silex/vendor/symfony/polyfill-mbstring/bootstrap.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Polyfill\Mbstring as p; - -if (!function_exists('mb_strlen')) { - define('MB_CASE_UPPER', 0); - define('MB_CASE_LOWER', 1); - define('MB_CASE_TITLE', 2); - - function mb_convert_encoding($s, $to, $from = null) { return p\Mbstring::mb_convert_encoding($s, $to, $from); } - function mb_decode_mimeheader($s) { return p\Mbstring::mb_decode_mimeheader($s); } - function mb_encode_mimeheader($s, $charset = null, $transferEnc = null, $lf = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($s, $charset, $transferEnc, $lf, $indent); } - function mb_convert_case($s, $mode, $enc = null) { return p\Mbstring::mb_convert_case($s, $mode, $enc); } - function mb_internal_encoding($enc = null) { return p\Mbstring::mb_internal_encoding($enc); } - function mb_language($lang = null) { return p\Mbstring::mb_language($lang); } - function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); } - function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); } - function mb_check_encoding($var = null, $encoding = null) { return p\Mbstring::mb_check_encoding($var, $encoding); } - function mb_detect_encoding($str, $encodingList = null, $strict = false) { return p\Mbstring::mb_detect_encoding($str, $encodingList, $strict); } - function mb_detect_order($encodingList = null) { return p\Mbstring::mb_detect_order($encodingList); } - function mb_parse_str($s, &$result = array()) { parse_str($s, $result); } - function mb_strlen($s, $enc = null) { return p\Mbstring::mb_strlen($s, $enc); } - function mb_strpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strpos($s, $needle, $offset, $enc); } - function mb_strtolower($s, $enc = null) { return p\Mbstring::mb_strtolower($s, $enc); } - function mb_strtoupper($s, $enc = null) { return p\Mbstring::mb_strtoupper($s, $enc); } - function mb_substitute_character($char = null) { return p\Mbstring::mb_substitute_character($char); } - function mb_substr($s, $start, $length = 2147483647, $enc = null) { return p\Mbstring::mb_substr($s, $start, $length, $enc); } - function mb_stripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_stripos($s, $needle, $offset, $enc); } - function mb_stristr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_stristr($s, $needle, $part, $enc); } - function mb_strrchr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrchr($s, $needle, $part, $enc); } - function mb_strrichr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrichr($s, $needle, $part, $enc); } - function mb_strripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strripos($s, $needle, $offset, $enc); } - function mb_strrpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strrpos($s, $needle, $offset, $enc); } - function mb_strstr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strstr($s, $needle, $part, $enc); } - function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); } - function mb_http_output($enc = null) { return p\Mbstring::mb_http_output($enc); } - function mb_strwidth($s, $enc = null) { return p\Mbstring::mb_strwidth($s, $enc); } - function mb_substr_count($haystack, $needle, $enc = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $enc); } - function mb_output_handler($contents, $status) { return p\Mbstring::mb_output_handler($contents, $status); } - function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); } - function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null) { return p\Mbstring::mb_convert_variables($toEncoding, $fromEncoding, $a, $b, $c, $d, $e, $f); } -} -if (!function_exists('mb_chr')) { - function mb_ord($s, $enc = null) { return p\Mbstring::mb_ord($s, $enc); } - function mb_chr($code, $enc = null) { return p\Mbstring::mb_chr($code, $enc); } - function mb_scrub($s, $enc = null) { $enc = null === $enc ? mb_internal_encoding() : $enc; return mb_convert_encoding($s, $enc, $enc); } -} diff --git a/lib/silex/vendor/symfony/polyfill-mbstring/composer.json b/lib/silex/vendor/symfony/polyfill-mbstring/composer.json deleted file mode 100644 index 5946b5d82..000000000 --- a/lib/silex/vendor/symfony/polyfill-mbstring/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "symfony/polyfill-mbstring", - "type": "library", - "description": "Symfony polyfill for the Mbstring extension", - "keywords": ["polyfill", "shim", "compatibility", "portable", "mbstring"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3" - }, - "autoload": { - "psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" }, - "files": [ "bootstrap.php" ] - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/polyfill-php70/LICENSE b/lib/silex/vendor/symfony/polyfill-php70/LICENSE deleted file mode 100644 index 39fa189d2..000000000 --- a/lib/silex/vendor/symfony/polyfill-php70/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014-2016 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/polyfill-php70/Php70.php b/lib/silex/vendor/symfony/polyfill-php70/Php70.php deleted file mode 100644 index e7ff0b26d..000000000 --- a/lib/silex/vendor/symfony/polyfill-php70/Php70.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Php70; - -/** - * @author Nicolas Grekas - * - * @internal - */ -final class Php70 -{ - public static function intdiv($dividend, $divisor) - { - $dividend = self::intArg($dividend, __FUNCTION__, 1); - $divisor = self::intArg($divisor, __FUNCTION__, 2); - - if (0 === $divisor) { - throw new \DivisionByZeroError('Division by zero'); - } - if (-1 === $divisor && ~PHP_INT_MAX === $dividend) { - throw new \ArithmeticError('Division of PHP_INT_MIN by -1 is not an integer'); - } - - return ($dividend - ($dividend % $divisor)) / $divisor; - } - - public static function preg_replace_callback_array(array $patterns, $subject, $limit = -1, &$count = 0) - { - $count = 0; - $result = ''.$subject; - if (0 === $limit = self::intArg($limit, __FUNCTION__, 3)) { - return $result; - } - - foreach ($patterns as $pattern => $callback) { - $result = preg_replace_callback($pattern, $callback, $result, $limit, $c); - $count += $c; - } - - return $result; - } - - public static function error_clear_last() - { - static $handler; - if (!$handler) { - $handler = function() { return false; }; - } - set_error_handler($handler); - @trigger_error(''); - restore_error_handler(); - } - - public static function intArg($value, $caller, $pos) - { - if (is_int($value)) { - return $value; - } - if (!is_numeric($value) || PHP_INT_MAX <= ($value += 0) || ~PHP_INT_MAX >= $value) { - throw new \TypeError(sprintf('%s() expects parameter %d to be integer, %s given', $caller, $pos, gettype($value))); - } - - return (int) $value; - } -} diff --git a/lib/silex/vendor/symfony/polyfill-php70/README.md b/lib/silex/vendor/symfony/polyfill-php70/README.md deleted file mode 100644 index 04988c6f9..000000000 --- a/lib/silex/vendor/symfony/polyfill-php70/README.md +++ /dev/null @@ -1,28 +0,0 @@ -Symfony Polyfill / Php70 -======================== - -This component provides features unavailable in releases prior to PHP 7.0: - -- [`intdiv`](http://php.net/intdiv) -- [`preg_replace_callback_array`](http://php.net/preg_replace_callback_array) -- [`error_clear_last`](http://php.net/error_clear_last) -- `random_bytes` and `random_int` (from [paragonie/random_compat](https://github.com/paragonie/random_compat)) -- [`*Error` throwable classes](http://php.net/Error) -- [`PHP_INT_MIN`](http://php.net/manual/en/reserved.constants.php#constant.php-int-min) -- `SessionUpdateTimestampHandlerInterface` - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). - -Compatibility notes -=================== - -To write portable code between PHP5 and PHP7, some care must be taken: -- `\*Error` exceptions must be caught before `\Exception`; -- after calling `error_clear_last()`, the result of `$e = error_get_last()` must be - verified using `isset($e['message'][0])` instead of `null !== $e`. - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php b/lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php deleted file mode 100644 index 681912446..000000000 --- a/lib/silex/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php +++ /dev/null @@ -1,5 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Polyfill\Php70 as p; - -if (PHP_VERSION_ID < 70000) { - if (!defined('PHP_INT_MIN')) { - define('PHP_INT_MIN', ~PHP_INT_MAX); - } - if (!function_exists('intdiv')) { - function intdiv($dividend, $divisor) { return p\Php70::intdiv($dividend, $divisor); } - } - if (!function_exists('preg_replace_callback_array')) { - function preg_replace_callback_array(array $patterns, $subject, $limit = -1, &$count = 0) { return p\Php70::preg_replace_callback_array($patterns, $subject, $limit, $count); } - } - if (!function_exists('error_clear_last')) { - function error_clear_last() { return p\Php70::error_clear_last(); } - } -} diff --git a/lib/silex/vendor/symfony/polyfill-php70/composer.json b/lib/silex/vendor/symfony/polyfill-php70/composer.json deleted file mode 100644 index 1d0b8fe20..000000000 --- a/lib/silex/vendor/symfony/polyfill-php70/composer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "symfony/polyfill-php70", - "type": "library", - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "keywords": ["polyfill", "shim", "compatibility", "portable"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3", - "paragonie/random_compat": "~1.0|~2.0" - }, - "autoload": { - "psr-4": { "Symfony\\Polyfill\\Php70\\": "" }, - "files": [ "bootstrap.php" ], - "classmap": [ "Resources/stubs" ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/routing/.gitignore b/lib/silex/vendor/symfony/routing/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/routing/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/routing/Annotation/Route.php b/lib/silex/vendor/symfony/routing/Annotation/Route.php deleted file mode 100644 index 5b3cbeaab..000000000 --- a/lib/silex/vendor/symfony/routing/Annotation/Route.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Annotation; - -/** - * Annotation class for @Route(). - * - * @Annotation - * @Target({"CLASS", "METHOD"}) - * - * @author Fabien Potencier - */ -class Route -{ - private $path; - private $name; - private $requirements = array(); - private $options = array(); - private $defaults = array(); - private $host; - private $methods = array(); - private $schemes = array(); - private $condition; - - /** - * @param array $data An array of key/value parameters - * - * @throws \BadMethodCallException - */ - public function __construct(array $data) - { - if (isset($data['value'])) { - $data['path'] = $data['value']; - unset($data['value']); - } - - foreach ($data as $key => $value) { - $method = 'set'.str_replace('_', '', $key); - if (!method_exists($this, $method)) { - throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, get_class($this))); - } - $this->$method($value); - } - } - - public function setPath($path) - { - $this->path = $path; - } - - public function getPath() - { - return $this->path; - } - - public function setHost($pattern) - { - $this->host = $pattern; - } - - public function getHost() - { - return $this->host; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getName() - { - return $this->name; - } - - public function setRequirements($requirements) - { - $this->requirements = $requirements; - } - - public function getRequirements() - { - return $this->requirements; - } - - public function setOptions($options) - { - $this->options = $options; - } - - public function getOptions() - { - return $this->options; - } - - public function setDefaults($defaults) - { - $this->defaults = $defaults; - } - - public function getDefaults() - { - return $this->defaults; - } - - public function setSchemes($schemes) - { - $this->schemes = is_array($schemes) ? $schemes : array($schemes); - } - - public function getSchemes() - { - return $this->schemes; - } - - public function setMethods($methods) - { - $this->methods = is_array($methods) ? $methods : array($methods); - } - - public function getMethods() - { - return $this->methods; - } - - public function setCondition($condition) - { - $this->condition = $condition; - } - - public function getCondition() - { - return $this->condition; - } -} diff --git a/lib/silex/vendor/symfony/routing/CHANGELOG.md b/lib/silex/vendor/symfony/routing/CHANGELOG.md deleted file mode 100644 index e278f8b1e..000000000 --- a/lib/silex/vendor/symfony/routing/CHANGELOG.md +++ /dev/null @@ -1,228 +0,0 @@ -CHANGELOG -========= - -3.4.0 ------ - - * Added `NoConfigurationException`. - * Added the possibility to define a prefix for all routes of a controller via @Route(name="prefix_") - * Added support for prioritized routing loaders. - * Add matched and default parameters to redirect responses - * Added support for a `controller` keyword for configuring route controllers in YAML and XML configurations. - -3.3.0 ------ - - * [DEPRECATION] Class parameters have been deprecated and will be removed in 4.0. - * router.options.generator_class - * router.options.generator_base_class - * router.options.generator_dumper_class - * router.options.matcher_class - * router.options.matcher_base_class - * router.options.matcher_dumper_class - * router.options.matcher.cache_class - * router.options.generator.cache_class - -3.2.0 ------ - - * Added support for `bool`, `int`, `float`, `string`, `list` and `map` defaults in XML configurations. - * Added support for UTF-8 requirements - -2.8.0 ------ - - * allowed specifying a directory to recursively load all routing configuration files it contains - * Added ObjectRouteLoader and ServiceRouteLoader that allow routes to be loaded - by calling a method on an object/service. - * [DEPRECATION] Deprecated the hardcoded value for the `$referenceType` argument of the `UrlGeneratorInterface::generate` method. - Use the constants defined in the `UrlGeneratorInterface` instead. - - Before: - - ```php - $router->generate('blog_show', array('slug' => 'my-blog-post'), true); - ``` - - After: - - ```php - use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - - $router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL); - ``` - -2.5.0 ------ - - * [DEPRECATION] The `ApacheMatcherDumper` and `ApacheUrlMatcher` were deprecated and - will be removed in Symfony 3.0, since the performance gains were minimal and - it's hard to replicate the behaviour of PHP implementation. - -2.3.0 ------ - - * added RequestContext::getQueryString() - -2.2.0 ------ - - * [DEPRECATION] Several route settings have been renamed (the old ones will be removed in 3.0): - - * The `pattern` setting for a route has been deprecated in favor of `path` - * The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings - - Before: - - ```yaml - article_edit: - pattern: /article/{id} - requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' } - ``` - - ```xml - - POST|PUT - https - \d+ - - ``` - - ```php - $route = new Route(); - $route->setPattern('/article/{id}'); - $route->setRequirement('_method', 'POST|PUT'); - $route->setRequirement('_scheme', 'https'); - ``` - - After: - - ```yaml - article_edit: - path: /article/{id} - methods: [POST, PUT] - schemes: https - requirements: { 'id': '\d+' } - ``` - - ```xml - - \d+ - - ``` - - ```php - $route = new Route(); - $route->setPath('/article/{id}'); - $route->setMethods(array('POST', 'PUT')); - $route->setSchemes('https'); - ``` - - * [BC BREAK] RouteCollection does not behave like a tree structure anymore but as - a flat array of Routes. So when using PHP to build the RouteCollection, you must - make sure to add routes to the sub-collection before adding it to the parent - collection (this is not relevant when using YAML or XML for Route definitions). - - Before: - - ```php - $rootCollection = new RouteCollection(); - $subCollection = new RouteCollection(); - $rootCollection->addCollection($subCollection); - $subCollection->add('foo', new Route('/foo')); - ``` - - After: - - ```php - $rootCollection = new RouteCollection(); - $subCollection = new RouteCollection(); - $subCollection->add('foo', new Route('/foo')); - $rootCollection->addCollection($subCollection); - ``` - - Also one must call `addCollection` from the bottom to the top hierarchy. - So the correct sequence is the following (and not the reverse): - - ```php - $childCollection->addCollection($grandchildCollection); - $rootCollection->addCollection($childCollection); - ``` - - * [DEPRECATION] The methods `RouteCollection::getParent()` and `RouteCollection::getRoot()` - have been deprecated and will be removed in Symfony 2.3. - * [BC BREAK] Misusing the `RouteCollection::addPrefix` method to add defaults, requirements - or options without adding a prefix is not supported anymore. So if you called `addPrefix` - with an empty prefix or `/` only (both have no relevance), like - `addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)` - you need to use the new dedicated methods `addDefaults($defaultsArray)`, - `addRequirements($requirementsArray)` or `addOptions($optionsArray)` instead. - * [DEPRECATION] The `$options` parameter to `RouteCollection::addPrefix()` has been deprecated - because adding options has nothing to do with adding a path prefix. If you want to add options - to all child routes of a RouteCollection, you can use `addOptions()`. - * [DEPRECATION] The method `RouteCollection::getPrefix()` has been deprecated - because it suggested that all routes in the collection would have this prefix, which is - not necessarily true. On top of that, since there is no tree structure anymore, this method - is also useless. Don't worry about performance, prefix optimization for matching is still done - in the dumper, which was also improved in 2.2.0 to find even more grouping possibilities. - * [DEPRECATION] `RouteCollection::addCollection(RouteCollection $collection)` should now only be - used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options` - will still work, but have been deprecated. The `addPrefix` method should be used for this - use-case instead. - Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))` - After: - ```php - $collection->addPrefix('/prefix', array(...), array(...)); - $parentCollection->addCollection($collection); - ``` - * 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 possessive 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. - * [BC BREAK] `RouteCompilerInterface::compile(Route $route)` was made static - (only relevant if you implemented your own RouteCompiler). - * Added possibility to generate relative paths and network paths in the UrlGenerator, e.g. - "../parent-file" and "//example.com/dir/file". The third parameter in - `UrlGeneratorInterface::generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)` - now accepts more values and you should use the constants defined in `UrlGeneratorInterface` for - claritiy. The old method calls with a Boolean parameter will continue to work because they - equal the signature using the constants. - -2.1.0 ------ - - * added RequestMatcherInterface - * added RequestContext::fromRequest() - * the UrlMatcher does not throw a \LogicException anymore when the required - scheme is not the current one - * added TraceableUrlMatcher - * added the possibility to define options, default values and requirements - for placeholders in prefix, including imported routes - * added RouterInterface::getRouteCollection - * [BC BREAK] the UrlMatcher urldecodes the route parameters only once, they - were decoded twice before. Note that the `urldecode()` calls have been - changed for a single `rawurldecode()` in order to support `+` for input - paths. - * added RouteCollection::getRoot method to retrieve the root of a - RouteCollection tree - * [BC BREAK] made RouteCollection::setParent private which could not have - been used anyway without creating inconsistencies - * [BC BREAK] RouteCollection::remove also removes a route from parent - collections (not only from its children) - * added ConfigurableRequirementsInterface that allows to disable exceptions - (and generate empty URLs instead) when generating a route with an invalid - parameter value diff --git a/lib/silex/vendor/symfony/routing/CompiledRoute.php b/lib/silex/vendor/symfony/routing/CompiledRoute.php deleted file mode 100644 index 8ecf5153c..000000000 --- a/lib/silex/vendor/symfony/routing/CompiledRoute.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * CompiledRoutes are returned by the RouteCompiler class. - * - * @author Fabien Potencier - */ -class CompiledRoute implements \Serializable -{ - private $variables; - private $tokens; - private $staticPrefix; - private $regex; - private $pathVariables; - private $hostVariables; - private $hostRegex; - private $hostTokens; - - /** - * @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 $hostRegex Host regex - * @param array $hostTokens Host tokens - * @param array $hostVariables An array of host variables - * @param array $variables An array of variables (variables defined in the path and in the host patterns) - */ - public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) - { - $this->staticPrefix = (string) $staticPrefix; - $this->regex = $regex; - $this->tokens = $tokens; - $this->pathVariables = $pathVariables; - $this->hostRegex = $hostRegex; - $this->hostTokens = $hostTokens; - $this->hostVariables = $hostVariables; - $this->variables = $variables; - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - return serialize(array( - 'vars' => $this->variables, - 'path_prefix' => $this->staticPrefix, - 'path_regex' => $this->regex, - 'path_tokens' => $this->tokens, - 'path_vars' => $this->pathVariables, - 'host_regex' => $this->hostRegex, - 'host_tokens' => $this->hostTokens, - 'host_vars' => $this->hostVariables, - )); - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - if (\PHP_VERSION_ID >= 70000) { - $data = unserialize($serialized, array('allowed_classes' => false)); - } else { - $data = unserialize($serialized); - } - - $this->variables = $data['vars']; - $this->staticPrefix = $data['path_prefix']; - $this->regex = $data['path_regex']; - $this->tokens = $data['path_tokens']; - $this->pathVariables = $data['path_vars']; - $this->hostRegex = $data['host_regex']; - $this->hostTokens = $data['host_tokens']; - $this->hostVariables = $data['host_vars']; - } - - /** - * Returns the static prefix. - * - * @return string The static prefix - */ - public function getStaticPrefix() - { - return $this->staticPrefix; - } - - /** - * Returns the regex. - * - * @return string The regex - */ - public function getRegex() - { - return $this->regex; - } - - /** - * Returns the host regex. - * - * @return string|null The host regex or null - */ - public function getHostRegex() - { - return $this->hostRegex; - } - - /** - * Returns the tokens. - * - * @return array The tokens - */ - public function getTokens() - { - return $this->tokens; - } - - /** - * Returns the host tokens. - * - * @return array The tokens - */ - public function getHostTokens() - { - return $this->hostTokens; - } - - /** - * Returns the variables. - * - * @return array The variables - */ - public function getVariables() - { - return $this->variables; - } - - /** - * Returns the path variables. - * - * @return array The variables - */ - public function getPathVariables() - { - return $this->pathVariables; - } - - /** - * Returns the host variables. - * - * @return array The variables - */ - public function getHostVariables() - { - return $this->hostVariables; - } -} diff --git a/lib/silex/vendor/symfony/routing/DependencyInjection/RoutingResolverPass.php b/lib/silex/vendor/symfony/routing/DependencyInjection/RoutingResolverPass.php deleted file mode 100644 index 4af0a5a28..000000000 --- a/lib/silex/vendor/symfony/routing/DependencyInjection/RoutingResolverPass.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\DependencyInjection; - -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; - -/** - * Adds tagged routing.loader services to routing.resolver service. - * - * @author Fabien Potencier - */ -class RoutingResolverPass implements CompilerPassInterface -{ - use PriorityTaggedServiceTrait; - - private $resolverServiceId; - private $loaderTag; - - public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader') - { - $this->resolverServiceId = $resolverServiceId; - $this->loaderTag = $loaderTag; - } - - public function process(ContainerBuilder $container) - { - if (false === $container->hasDefinition($this->resolverServiceId)) { - return; - } - - $definition = $container->getDefinition($this->resolverServiceId); - - foreach ($this->findAndSortTaggedServices($this->loaderTag, $container) as $id) { - $definition->addMethodCall('addLoader', array(new Reference($id))); - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Exception/ExceptionInterface.php b/lib/silex/vendor/symfony/routing/Exception/ExceptionInterface.php deleted file mode 100644 index db7636211..000000000 --- a/lib/silex/vendor/symfony/routing/Exception/ExceptionInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * ExceptionInterface. - * - * @author Alexandre Salomé - */ -interface ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Exception/InvalidParameterException.php b/lib/silex/vendor/symfony/routing/Exception/InvalidParameterException.php deleted file mode 100644 index 94d841f4c..000000000 --- a/lib/silex/vendor/symfony/routing/Exception/InvalidParameterException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * Exception thrown when a parameter is not valid. - * - * @author Alexandre Salomé - */ -class InvalidParameterException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Exception/MethodNotAllowedException.php b/lib/silex/vendor/symfony/routing/Exception/MethodNotAllowedException.php deleted file mode 100644 index 712412fec..000000000 --- a/lib/silex/vendor/symfony/routing/Exception/MethodNotAllowedException.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * The resource was found but the request method is not allowed. - * - * This exception should trigger an HTTP 405 response in your application code. - * - * @author Kris Wallsmith - */ -class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface -{ - protected $allowedMethods = array(); - - public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null) - { - $this->allowedMethods = array_map('strtoupper', $allowedMethods); - - parent::__construct($message, $code, $previous); - } - - /** - * Gets the allowed HTTP methods. - * - * @return array - */ - public function getAllowedMethods() - { - return $this->allowedMethods; - } -} diff --git a/lib/silex/vendor/symfony/routing/Exception/MissingMandatoryParametersException.php b/lib/silex/vendor/symfony/routing/Exception/MissingMandatoryParametersException.php deleted file mode 100644 index 57f3a40df..000000000 --- a/lib/silex/vendor/symfony/routing/Exception/MissingMandatoryParametersException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * Exception thrown when a route cannot be generated because of missing - * mandatory parameters. - * - * @author Alexandre Salomé - */ -class MissingMandatoryParametersException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Exception/NoConfigurationException.php b/lib/silex/vendor/symfony/routing/Exception/NoConfigurationException.php deleted file mode 100644 index 333bc7433..000000000 --- a/lib/silex/vendor/symfony/routing/Exception/NoConfigurationException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * Exception thrown when no routes are configured. - * - * @author Yonel Ceruto - */ -class NoConfigurationException extends ResourceNotFoundException -{ -} diff --git a/lib/silex/vendor/symfony/routing/Exception/ResourceNotFoundException.php b/lib/silex/vendor/symfony/routing/Exception/ResourceNotFoundException.php deleted file mode 100644 index ccbca1527..000000000 --- a/lib/silex/vendor/symfony/routing/Exception/ResourceNotFoundException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * The resource was not found. - * - * This exception should trigger an HTTP 404 response in your application code. - * - * @author Kris Wallsmith - */ -class ResourceNotFoundException extends \RuntimeException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Exception/RouteNotFoundException.php b/lib/silex/vendor/symfony/routing/Exception/RouteNotFoundException.php deleted file mode 100644 index 24ab0b44a..000000000 --- a/lib/silex/vendor/symfony/routing/Exception/RouteNotFoundException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * Exception thrown when a route does not exist. - * - * @author Alexandre Salomé - */ -class RouteNotFoundException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Generator/ConfigurableRequirementsInterface.php b/lib/silex/vendor/symfony/routing/Generator/ConfigurableRequirementsInterface.php deleted file mode 100644 index dc97b7e72..000000000 --- a/lib/silex/vendor/symfony/routing/Generator/ConfigurableRequirementsInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator; - -/** - * 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 a 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 - * @author Tobias Schultze - */ -interface ConfigurableRequirementsInterface -{ - /** - * Enables or disables the exception on incorrect parameters. - * Passing null will deactivate the requirements check completely. - * - * @param bool|null $enabled - */ - public function setStrictRequirements($enabled); - - /** - * Returns whether to throw an exception on incorrect parameters. - * Null means the requirements check is deactivated completely. - * - * @return bool|null - */ - public function isStrictRequirements(); -} diff --git a/lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumper.php b/lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumper.php deleted file mode 100644 index 659c5ba1c..000000000 --- a/lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumper.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -use Symfony\Component\Routing\RouteCollection; - -/** - * GeneratorDumper is the base class for all built-in generator dumpers. - * - * @author Fabien Potencier - */ -abstract class GeneratorDumper implements GeneratorDumperInterface -{ - private $routes; - - public function __construct(RouteCollection $routes) - { - $this->routes = $routes; - } - - /** - * {@inheritdoc} - */ - public function getRoutes() - { - return $this->routes; - } -} diff --git a/lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumperInterface.php b/lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumperInterface.php deleted file mode 100644 index fed347239..000000000 --- a/lib/silex/vendor/symfony/routing/Generator/Dumper/GeneratorDumperInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -use Symfony\Component\Routing\RouteCollection; - -/** - * GeneratorDumperInterface is the interface that all generator dumper classes must implement. - * - * @author Fabien Potencier - */ -interface GeneratorDumperInterface -{ - /** - * Dumps a set of routes to a string representation of executable code - * that can then be used to generate a URL of such a route. - * - * @param array $options An array of options - * - * @return string Executable code - */ - public function dump(array $options = array()); - - /** - * Gets the routes to dump. - * - * @return RouteCollection A RouteCollection instance - */ - public function getRoutes(); -} diff --git a/lib/silex/vendor/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php b/lib/silex/vendor/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php deleted file mode 100644 index 60bdf1da3..000000000 --- a/lib/silex/vendor/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -/** - * PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class PhpGeneratorDumper extends GeneratorDumper -{ - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the generator class - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'class' => 'ProjectUrlGenerator', - 'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', - ), $options); - - return <<context = \$context; - \$this->logger = \$logger; - if (null === self::\$declaredRoutes) { - self::\$declaredRoutes = {$this->generateDeclaredRoutes()}; - } - } - -{$this->generateGenerateMethod()} -} - -EOF; - } - - /** - * Generates PHP code representing an array of defined routes - * together with the routes properties (e.g. requirements). - * - * @return string PHP code - */ - private function generateDeclaredRoutes() - { - $routes = "array(\n"; - foreach ($this->getRoutes()->all() as $name => $route) { - $compiledRoute = $route->compile(); - - $properties = array(); - $properties[] = $compiledRoute->getVariables(); - $properties[] = $route->getDefaults(); - $properties[] = $route->getRequirements(); - $properties[] = $compiledRoute->getTokens(); - $properties[] = $compiledRoute->getHostTokens(); - $properties[] = $route->getSchemes(); - - $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); - } - $routes .= ' )'; - - return $routes; - } - - /** - * Generates PHP code representing the `generate` method that implements the UrlGeneratorInterface. - * - * @return string PHP code - */ - private function generateGenerateMethod() - { - return <<<'EOF' - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) - { - if (!isset(self::$declaredRoutes[$name])) { - throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name)); - } - - list($variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes) = self::$declaredRoutes[$name]; - - return $this->doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes); - } -EOF; - } -} diff --git a/lib/silex/vendor/symfony/routing/Generator/UrlGenerator.php b/lib/silex/vendor/symfony/routing/Generator/UrlGenerator.php deleted file mode 100644 index 02a59a925..000000000 --- a/lib/silex/vendor/symfony/routing/Generator/UrlGenerator.php +++ /dev/null @@ -1,321 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Exception\InvalidParameterException; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; -use Psr\Log\LoggerInterface; - -/** - * UrlGenerator can generate a URL or a path for any route in the RouteCollection - * based on the passed parameters. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface -{ - protected $routes; - protected $context; - - /** - * @var bool|null - */ - protected $strictRequirements = true; - - protected $logger; - - /** - * This array defines the characters (besides alphanumeric ones) that will not be percent-encoded in the path segment of the generated URL. - * - * PHP's rawurlencode() encodes all chars except "a-zA-Z0-9-._~" according to RFC 3986. But we want to allow some chars - * to be used in their literal form (reasons below). Other chars inside the path must of course be encoded, e.g. - * "?" and "#" (would be interpreted wrongly as query and fragment identifier), - * "'" and """ (are used as delimiters in HTML). - */ - protected $decodedChars = array( - // the slash can be used to designate a hierarchical structure and we want allow using it with this meaning - // some webservers don't allow the slash in encoded form in the path for security reasons anyway - // see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss - '%2F' => '/', - // the following chars are general delimiters in the URI specification but have only special meaning in the authority component - // so they can safely be used in the path in unencoded form - '%40' => '@', - '%3A' => ':', - // these chars are only sub-delimiters that have no predefined meaning and can therefore be used literally - // so URI producing applications can use these chars to delimit subcomponents in a path segment without being encoded for better readability - '%3B' => ';', - '%2C' => ',', - '%3D' => '=', - '%2B' => '+', - '%21' => '!', - '%2A' => '*', - '%7C' => '|', - ); - - public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null) - { - $this->routes = $routes; - $this->context = $context; - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - return $this->context; - } - - /** - * {@inheritdoc} - */ - public function setStrictRequirements($enabled) - { - $this->strictRequirements = null === $enabled ? null : (bool) $enabled; - } - - /** - * {@inheritdoc} - */ - public function isStrictRequirements() - { - return $this->strictRequirements; - } - - /** - * {@inheritdoc} - */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) - { - if (null === $route = $this->routes->get($name)) { - throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name)); - } - - // 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, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes()); - } - - /** - * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route - * @throws InvalidParameterException When a parameter value for a placeholder is not correct because - * it does not match the requirement - */ - protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array()) - { - $variables = array_flip($variables); - $mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters); - - // all params must be given - if ($diff = array_diff_key($variables, $mergedParams)) { - throw new MissingMandatoryParametersException(sprintf('Some mandatory parameters are missing ("%s") to generate a URL for route "%s".', implode('", "', array_keys($diff)), $name)); - } - - $url = ''; - $optional = true; - $message = 'Parameter "{parameter}" for route "{route}" must match "{expected}" ("{given}" given) to generate a corresponding URL.'; - foreach ($tokens as $token) { - if ('variable' === $token[0]) { - if (!$optional || !array_key_exists($token[3], $defaults) || null !== $mergedParams[$token[3]] && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) { - // check requirement - if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) { - if ($this->strictRequirements) { - throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]))); - } - - if ($this->logger) { - $this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]])); - } - - return; - } - - $url = $token[1].$mergedParams[$token[3]].$url; - $optional = false; - } - } else { - // static text - $url = $token[1].$url; - $optional = false; - } - } - - if ('' === $url) { - $url = '/'; - } - - // the contexts base URL is already encoded (see Symfony\Component\HttpFoundation\Request) - $url = strtr(rawurlencode($url), $this->decodedChars); - - // the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3 - // so we need to encode them as they are not used for this purpose here - // otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route - $url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/')); - if ('/..' === substr($url, -3)) { - $url = substr($url, 0, -2).'%2E%2E'; - } elseif ('/.' === substr($url, -2)) { - $url = substr($url, 0, -1).'%2E'; - } - - $schemeAuthority = ''; - $host = $this->context->getHost(); - $scheme = $this->context->getScheme(); - - if ($requiredSchemes) { - if (!in_array($scheme, $requiredSchemes, true)) { - $referenceType = self::ABSOLUTE_URL; - $scheme = current($requiredSchemes); - } - } - - if ($hostTokens) { - $routeHost = ''; - foreach ($hostTokens as $token) { - if ('variable' === $token[0]) { - if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) { - if ($this->strictRequirements) { - throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]))); - } - - if ($this->logger) { - $this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]])); - } - - return; - } - - $routeHost = $token[1].$mergedParams[$token[3]].$routeHost; - } else { - $routeHost = $token[1].$routeHost; - } - } - - if ($routeHost !== $host) { - $host = $routeHost; - if (self::ABSOLUTE_URL !== $referenceType) { - $referenceType = self::NETWORK_PATH; - } - } - } - - if ((self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) && !empty($host)) { - $port = ''; - if ('http' === $scheme && 80 != $this->context->getHttpPort()) { - $port = ':'.$this->context->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) { - $port = ':'.$this->context->getHttpsPort(); - } - - $schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://"; - $schemeAuthority .= $host.$port; - } - - if (self::RELATIVE_PATH === $referenceType) { - $url = self::getRelativePath($this->context->getPathInfo(), $url); - } else { - $url = $schemeAuthority.$this->context->getBaseUrl().$url; - } - - // add a query string if needed - $extra = array_udiff_assoc(array_diff_key($parameters, $variables), $defaults, function ($a, $b) { - return $a == $b ? 0 : 1; - }); - - // extract fragment - $fragment = ''; - if (isset($defaults['_fragment'])) { - $fragment = $defaults['_fragment']; - } - - if (isset($extra['_fragment'])) { - $fragment = $extra['_fragment']; - unset($extra['_fragment']); - } - - if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) { - // "/" and "?" can be left decoded for better user experience, see - // http://tools.ietf.org/html/rfc3986#section-3.4 - $url .= '?'.strtr($query, array('%2F' => '/')); - } - - if ('' !== $fragment) { - $url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?')); - } - - return $url; - } - - /** - * Returns the target path as relative reference from the base path. - * - * Only the URIs path component (no schema, host etc.) is relevant and must be given, starting with a slash. - * Both paths must be absolute and not contain relative parts. - * Relative URLs from one resource to another are useful when generating self-contained downloadable document archives. - * Furthermore, they can be used to reduce the link size in documents. - * - * Example target paths, given a base path of "/a/b/c/d": - * - "/a/b/c/d" -> "" - * - "/a/b/c/" -> "./" - * - "/a/b/" -> "../" - * - "/a/b/c/other" -> "other" - * - "/a/x/y" -> "../../x/y" - * - * @param string $basePath The base path - * @param string $targetPath The target path - * - * @return string The relative target path - */ - public static function getRelativePath($basePath, $targetPath) - { - if ($basePath === $targetPath) { - return ''; - } - - $sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath); - $targetDirs = explode('/', isset($targetPath[0]) && '/' === $targetPath[0] ? substr($targetPath, 1) : $targetPath); - array_pop($sourceDirs); - $targetFile = array_pop($targetDirs); - - foreach ($sourceDirs as $i => $dir) { - if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) { - unset($sourceDirs[$i], $targetDirs[$i]); - } else { - break; - } - } - - $targetDirs[] = $targetFile; - $path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs); - - // A reference to the same base directory or an empty subdirectory must be prefixed with "./". - // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used - // as the first segment of a relative-path reference, as it would be mistaken for a scheme name - // (see http://tools.ietf.org/html/rfc3986#section-4.2). - return '' === $path || '/' === $path[0] - || false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos) - ? "./$path" : $path; - } -} diff --git a/lib/silex/vendor/symfony/routing/Generator/UrlGeneratorInterface.php b/lib/silex/vendor/symfony/routing/Generator/UrlGeneratorInterface.php deleted file mode 100644 index d6e7938e5..000000000 --- a/lib/silex/vendor/symfony/routing/Generator/UrlGeneratorInterface.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator; - -use Symfony\Component\Routing\Exception\InvalidParameterException; -use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\RequestContextAwareInterface; - -/** - * UrlGeneratorInterface is the interface that all URL generator classes must implement. - * - * The constants in this interface define the different types of resource references that - * are declared in RFC 3986: http://tools.ietf.org/html/rfc3986 - * We are using the term "URL" instead of "URI" as this is more common in web applications - * and we do not need to distinguish them as the difference is mostly semantical and - * less technical. Generating URIs, i.e. representation-independent resource identifiers, - * is also possible. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -interface UrlGeneratorInterface extends RequestContextAwareInterface -{ - /** - * Generates an absolute URL, e.g. "http://example.com/dir/file". - */ - const ABSOLUTE_URL = 0; - - /** - * Generates an absolute path, e.g. "/dir/file". - */ - const ABSOLUTE_PATH = 1; - - /** - * Generates a relative path based on the current request path, e.g. "../parent-file". - * - * @see UrlGenerator::getRelativePath() - */ - const RELATIVE_PATH = 2; - - /** - * Generates a network path, e.g. "//example.com/dir/file". - * Such reference reuses the current scheme but specifies the host. - */ - const NETWORK_PATH = 3; - - /** - * Generates a URL or path for a specific route based on the given parameters. - * - * Parameters that reference placeholders in the route pattern will substitute them in the - * path or host. Extra params are added as query string to the URL. - * - * When the passed reference type cannot be generated for the route because it requires a different - * host or scheme than the current one, the method will return a more comprehensive reference - * that includes the required params. For example, when you call this method with $referenceType = ABSOLUTE_PATH - * but the route requires the https scheme whereas the current scheme is http, it will instead return an - * ABSOLUTE_URL with the https scheme and the current host. This makes sure the generated URL matches - * the route in any case. - * - * If there is no route with the given name, the generator must throw the RouteNotFoundException. - * - * The special parameter _fragment will be used as the document fragment suffixed to the final URL. - * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters - * @param int $referenceType The type of reference to be generated (one of the constants) - * - * @return string The generated URL - * - * @throws RouteNotFoundException If the named route doesn't exist - * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route - * @throws InvalidParameterException When a parameter value for a placeholder is not correct because - * it does not match the requirement - */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH); -} diff --git a/lib/silex/vendor/symfony/routing/LICENSE b/lib/silex/vendor/symfony/routing/LICENSE deleted file mode 100644 index 21d7fb9e2..000000000 --- a/lib/silex/vendor/symfony/routing/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2018 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/routing/Loader/AnnotationClassLoader.php b/lib/silex/vendor/symfony/routing/Loader/AnnotationClassLoader.php deleted file mode 100644 index 2fe6fb596..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/AnnotationClassLoader.php +++ /dev/null @@ -1,269 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Doctrine\Common\Annotations\Reader; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Loader\LoaderResolverInterface; - -/** - * AnnotationClassLoader loads routing information from a PHP class and its methods. - * - * You need to define an implementation for the getRouteDefaults() method. Most of the - * time, this method should define some PHP callable to be called for the route - * (a controller in MVC speak). - * - * The @Route annotation can be set on the class (for global parameters), - * and on each method. - * - * The @Route annotation main value is the route path. The annotation also - * recognizes several parameters: requirements, options, defaults, schemes, - * methods, host, and name. The name parameter is mandatory. - * Here is an example of how you should be able to use it: - * - * /** - * * @Route("/Blog") - * * / - * class Blog - * { - * /** - * * @Route("/", name="blog_index") - * * / - * public function index() - * { - * } - * - * /** - * * @Route("/{id}", name="blog_post", requirements = {"id" = "\d+"}) - * * / - * public function show() - * { - * } - * } - * - * @author Fabien Potencier - */ -abstract class AnnotationClassLoader implements LoaderInterface -{ - protected $reader; - - /** - * @var string - */ - protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route'; - - /** - * @var int - */ - protected $defaultRouteIndex = 0; - - public function __construct(Reader $reader) - { - $this->reader = $reader; - } - - /** - * Sets the annotation class to read route properties from. - * - * @param string $class A fully-qualified class name - */ - public function setRouteAnnotationClass($class) - { - $this->routeAnnotationClass = $class; - } - - /** - * Loads from annotations from a class. - * - * @param string $class A class name - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When route can't be parsed - */ - public function load($class, $type = null) - { - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); - } - - $class = new \ReflectionClass($class); - if ($class->isAbstract()) { - throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName())); - } - - $globals = $this->getGlobals($class); - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($class->getFileName())); - - foreach ($class->getMethods() as $method) { - $this->defaultRouteIndex = 0; - foreach ($this->reader->getMethodAnnotations($method) as $annot) { - if ($annot instanceof $this->routeAnnotationClass) { - $this->addRoute($collection, $annot, $globals, $class, $method); - } - } - } - - if (0 === $collection->count() && $class->hasMethod('__invoke') && $annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { - $globals['path'] = ''; - $globals['name'] = ''; - $this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke')); - } - - return $collection; - } - - protected function addRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method) - { - $name = $annot->getName(); - if (null === $name) { - $name = $this->getDefaultRouteName($class, $method); - } - $name = $globals['name'].$name; - - $defaults = array_replace($globals['defaults'], $annot->getDefaults()); - foreach ($method->getParameters() as $param) { - if (false !== strpos($globals['path'].$annot->getPath(), sprintf('{%s}', $param->getName())) && !isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) { - $defaults[$param->getName()] = $param->getDefaultValue(); - } - } - $requirements = array_replace($globals['requirements'], $annot->getRequirements()); - $options = array_replace($globals['options'], $annot->getOptions()); - $schemes = array_merge($globals['schemes'], $annot->getSchemes()); - $methods = array_merge($globals['methods'], $annot->getMethods()); - - $host = $annot->getHost(); - if (null === $host) { - $host = $globals['host']; - } - - $condition = $annot->getCondition(); - if (null === $condition) { - $condition = $globals['condition']; - } - - $route = $this->createRoute($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $host, $schemes, $methods, $condition); - - $this->configureRoute($route, $class, $method, $annot); - - $collection->add($name, $route); - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type); - } - - /** - * {@inheritdoc} - */ - public function setResolver(LoaderResolverInterface $resolver) - { - } - - /** - * {@inheritdoc} - */ - public function getResolver() - { - } - - /** - * Gets the default route name for a class method. - * - * @param \ReflectionClass $class - * @param \ReflectionMethod $method - * - * @return string - */ - protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) - { - $name = strtolower(str_replace('\\', '_', $class->name).'_'.$method->name); - if ($this->defaultRouteIndex > 0) { - $name .= '_'.$this->defaultRouteIndex; - } - ++$this->defaultRouteIndex; - - return $name; - } - - protected function getGlobals(\ReflectionClass $class) - { - $globals = array( - 'path' => '', - 'requirements' => array(), - 'options' => array(), - 'defaults' => array(), - 'schemes' => array(), - 'methods' => array(), - 'host' => '', - 'condition' => '', - 'name' => '', - ); - - if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { - if (null !== $annot->getName()) { - $globals['name'] = $annot->getName(); - } - - if (null !== $annot->getPath()) { - $globals['path'] = $annot->getPath(); - } - - if (null !== $annot->getRequirements()) { - $globals['requirements'] = $annot->getRequirements(); - } - - if (null !== $annot->getOptions()) { - $globals['options'] = $annot->getOptions(); - } - - if (null !== $annot->getDefaults()) { - $globals['defaults'] = $annot->getDefaults(); - } - - if (null !== $annot->getSchemes()) { - $globals['schemes'] = $annot->getSchemes(); - } - - if (null !== $annot->getMethods()) { - $globals['methods'] = $annot->getMethods(); - } - - if (null !== $annot->getHost()) { - $globals['host'] = $annot->getHost(); - } - - if (null !== $annot->getCondition()) { - $globals['condition'] = $annot->getCondition(); - } - } - - return $globals; - } - - protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition) - { - return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition); - } - - abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot); -} diff --git a/lib/silex/vendor/symfony/routing/Loader/AnnotationDirectoryLoader.php b/lib/silex/vendor/symfony/routing/Loader/AnnotationDirectoryLoader.php deleted file mode 100644 index 4574a0201..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/AnnotationDirectoryLoader.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Resource\DirectoryResource; - -/** - * AnnotationDirectoryLoader loads routing information from annotations set - * on PHP classes and methods. - * - * @author Fabien Potencier - */ -class AnnotationDirectoryLoader extends AnnotationFileLoader -{ - /** - * Loads from annotations from a directory. - * - * @param string $path A directory path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed - */ - public function load($path, $type = null) - { - if (!is_dir($dir = $this->locator->locate($path))) { - return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection(); - } - - $collection = new RouteCollection(); - $collection->addResource(new DirectoryResource($dir, '/\.php$/')); - $files = iterator_to_array(new \RecursiveIteratorIterator( - new \RecursiveCallbackFilterIterator( - new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS), - function (\SplFileInfo $current) { - return '.' !== substr($current->getBasename(), 0, 1); - } - ), - \RecursiveIteratorIterator::LEAVES_ONLY - )); - usort($files, function (\SplFileInfo $a, \SplFileInfo $b) { - return (string) $a > (string) $b ? 1 : -1; - }); - - foreach ($files as $file) { - if (!$file->isFile() || '.php' !== substr($file->getFilename(), -4)) { - continue; - } - - if ($class = $this->findClass($file)) { - $refl = new \ReflectionClass($class); - if ($refl->isAbstract()) { - continue; - } - - $collection->addCollection($this->loader->load($class, $type)); - } - } - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - if ('annotation' === $type) { - return true; - } - - if ($type || !is_string($resource)) { - return false; - } - - try { - return is_dir($this->locator->locate($resource)); - } catch (\Exception $e) { - return false; - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/AnnotationFileLoader.php b/lib/silex/vendor/symfony/routing/Loader/AnnotationFileLoader.php deleted file mode 100644 index cf9f0704c..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/AnnotationFileLoader.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\FileLocatorInterface; - -/** - * AnnotationFileLoader loads routing information from annotations set - * on a PHP class and its methods. - * - * @author Fabien Potencier - */ -class AnnotationFileLoader extends FileLoader -{ - protected $loader; - - /** - * @throws \RuntimeException - */ - public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader) - { - if (!function_exists('token_get_all')) { - throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.'); - } - - parent::__construct($locator); - - $this->loader = $loader; - } - - /** - * Loads from annotations from a file. - * - * @param string $file A PHP file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $collection = new RouteCollection(); - if ($class = $this->findClass($path)) { - $collection->addResource(new FileResource($path)); - $collection->addCollection($this->loader->load($class, $type)); - } - if (\PHP_VERSION_ID >= 70000) { - // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 - gc_mem_caches(); - } - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type); - } - - /** - * Returns the full class name for the first class in the file. - * - * @param string $file A PHP file path - * - * @return string|false Full class name if found, false otherwise - */ - protected function findClass($file) - { - $class = false; - $namespace = false; - $tokens = token_get_all(file_get_contents($file)); - - if (1 === count($tokens) && T_INLINE_HTML === $tokens[0][0]) { - throw new \InvalidArgumentException(sprintf('The file "%s" does not contain PHP code. Did you forgot to add the " 0; --$j) { - if (!isset($tokens[$j][1])) { - break; - } - - if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) { - $skipClassToken = true; - break; - } elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) { - break; - } - } - - if (!$skipClassToken) { - $class = true; - } - } - - if (T_NAMESPACE === $token[0]) { - $namespace = true; - } - } - - return false; - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/ClosureLoader.php b/lib/silex/vendor/symfony/routing/Loader/ClosureLoader.php deleted file mode 100644 index 5df9f6ae8..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/ClosureLoader.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Config\Loader\Loader; -use Symfony\Component\Routing\RouteCollection; - -/** - * ClosureLoader loads routes from a PHP closure. - * - * The Closure must return a RouteCollection instance. - * - * @author Fabien Potencier - */ -class ClosureLoader extends Loader -{ - /** - * Loads a Closure. - * - * @param \Closure $closure A Closure - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - */ - public function load($closure, $type = null) - { - return $closure(); - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return $resource instanceof \Closure && (!$type || 'closure' === $type); - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php b/lib/silex/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php deleted file mode 100644 index 38d86cb89..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/Configurator/CollectionConfigurator.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\Configurator; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -/** - * @author Nicolas Grekas - */ -class CollectionConfigurator -{ - use Traits\AddTrait; - use Traits\RouteTrait; - - private $parent; - - public function __construct(RouteCollection $parent, $name) - { - $this->parent = $parent; - $this->name = $name; - $this->collection = new RouteCollection(); - $this->route = new Route(''); - } - - public function __destruct() - { - $this->collection->addPrefix(rtrim($this->route->getPath(), '/')); - $this->parent->addCollection($this->collection); - } - - /** - * Adds a route. - * - * @param string $name - * @param string $path - * - * @return RouteConfigurator - */ - final public function add($name, $path) - { - $this->collection->add($this->name.$name, $route = clone $this->route); - - return new RouteConfigurator($this->collection, $route->setPath($path), $this->name); - } - - /** - * Creates a sub-collection. - * - * @return self - */ - final public function collection($name = '') - { - return new self($this->collection, $this->name.$name); - } - - /** - * Sets the prefix to add to the path of all child routes. - * - * @param string $prefix - * - * @return $this - */ - final public function prefix($prefix) - { - $this->route->setPath($prefix); - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php b/lib/silex/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php deleted file mode 100644 index d0a3c373f..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/Configurator/ImportConfigurator.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\Configurator; - -use Symfony\Component\Routing\RouteCollection; - -/** - * @author Nicolas Grekas - */ -class ImportConfigurator -{ - use Traits\RouteTrait; - - private $parent; - - public function __construct(RouteCollection $parent, RouteCollection $route) - { - $this->parent = $parent; - $this->route = $route; - } - - public function __destruct() - { - $this->parent->addCollection($this->route); - } - - /** - * Sets the prefix to add to the path of all child routes. - * - * @param string $prefix - * - * @return $this - */ - final public function prefix($prefix) - { - $this->route->addPrefix($prefix); - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php b/lib/silex/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php deleted file mode 100644 index b8d870254..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/Configurator/RouteConfigurator.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\Configurator; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -/** - * @author Nicolas Grekas - */ -class RouteConfigurator -{ - use Traits\AddTrait; - use Traits\RouteTrait; - - public function __construct(RouteCollection $collection, Route $route, $name = '') - { - $this->collection = $collection; - $this->route = $route; - $this->name = $name; - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php b/lib/silex/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php deleted file mode 100644 index 4591a86ba..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/Configurator/RoutingConfigurator.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\Configurator; - -use Symfony\Component\Routing\Loader\PhpFileLoader; -use Symfony\Component\Routing\RouteCollection; - -/** - * @author Nicolas Grekas - */ -class RoutingConfigurator -{ - use Traits\AddTrait; - - private $loader; - private $path; - private $file; - - public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file) - { - $this->collection = $collection; - $this->loader = $loader; - $this->path = $path; - $this->file = $file; - } - - /** - * @return ImportConfigurator - */ - final public function import($resource, $type = null, $ignoreErrors = false) - { - $this->loader->setCurrentDir(dirname($this->path)); - $subCollection = $this->loader->import($resource, $type, $ignoreErrors, $this->file); - - return new ImportConfigurator($this->collection, $subCollection); - } - - /** - * @return CollectionConfigurator - */ - final public function collection($name = '') - { - return new CollectionConfigurator($this->collection, $name); - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php b/lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php deleted file mode 100644 index 7171fd241..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/AddTrait.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\Configurator\Traits; - -use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -trait AddTrait -{ - /** - * @var RouteCollection - */ - private $collection; - - private $name = ''; - - /** - * Adds a route. - * - * @param string $name - * @param string $path - * - * @return RouteConfigurator - */ - final public function add($name, $path) - { - $this->collection->add($this->name.$name, $route = new Route($path)); - - return new RouteConfigurator($this->collection, $route); - } - - /** - * Adds a route. - * - * @param string $name - * @param string $path - * - * @return RouteConfigurator - */ - final public function __invoke($name, $path) - { - return $this->add($name, $path); - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php b/lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php deleted file mode 100644 index 4d2e255b1..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/Configurator/Traits/RouteTrait.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\Configurator\Traits; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -trait RouteTrait -{ - /** - * @var RouteCollection|Route - */ - private $route; - - /** - * Adds defaults. - * - * @return $this - */ - final public function defaults(array $defaults) - { - $this->route->addDefaults($defaults); - - return $this; - } - - /** - * Adds requirements. - * - * @return $this - */ - final public function requirements(array $requirements) - { - $this->route->addRequirements($requirements); - - return $this; - } - - /** - * Adds options. - * - * @return $this - */ - final public function options(array $options) - { - $this->route->addOptions($options); - - return $this; - } - - /** - * Sets the condition. - * - * @param string $condition - * - * @return $this - */ - final public function condition($condition) - { - $this->route->setCondition($condition); - - return $this; - } - - /** - * Sets the pattern for the host. - * - * @param string $pattern - * - * @return $this - */ - final public function host($pattern) - { - $this->route->setHost($pattern); - - return $this; - } - - /** - * Sets the schemes (e.g. 'https') this route is restricted to. - * So an empty array means that any scheme is allowed. - * - * @param string[] $schemes - * - * @return $this - */ - final public function schemes(array $schemes) - { - $this->route->setSchemes($schemes); - - return $this; - } - - /** - * Sets the HTTP methods (e.g. 'POST') this route is restricted to. - * So an empty array means that any method is allowed. - * - * @param string[] $methods - * - * @return $this - */ - final public function methods(array $methods) - { - $this->route->setMethods($methods); - - return $this; - } - - /** - * Adds the "_controller" entry to defaults. - * - * @param callable|string $controller a callable or parseable pseudo-callable - * - * @return $this - */ - final public function controller($controller) - { - $this->route->addDefaults(array('_controller' => $controller)); - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php b/lib/silex/vendor/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php deleted file mode 100644 index 6c1621635..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/DependencyInjection/ServiceRouterLoader.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\DependencyInjection; - -use Psr\Container\ContainerInterface; -use Symfony\Component\Routing\Loader\ObjectRouteLoader; - -/** - * A route loader that executes a service to load the routes. - * - * This depends on the DependencyInjection component. - * - * @author Ryan Weaver - */ -class ServiceRouterLoader extends ObjectRouteLoader -{ - /** - * @var ContainerInterface - */ - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - protected function getServiceObject($id) - { - return $this->container->get($id); - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/DirectoryLoader.php b/lib/silex/vendor/symfony/routing/Loader/DirectoryLoader.php deleted file mode 100644 index 4bb5b31b6..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/DirectoryLoader.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Resource\DirectoryResource; - -class DirectoryLoader extends FileLoader -{ - /** - * {@inheritdoc} - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $collection = new RouteCollection(); - $collection->addResource(new DirectoryResource($path)); - - foreach (scandir($path) as $dir) { - if ('.' !== $dir[0]) { - $this->setCurrentDir($path); - $subPath = $path.'/'.$dir; - $subType = null; - - if (is_dir($subPath)) { - $subPath .= '/'; - $subType = 'directory'; - } - - $subCollection = $this->import($subPath, $subType, false, $path); - $collection->addCollection($subCollection); - } - } - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - // only when type is forced to directory, not to conflict with AnnotationLoader - - return 'directory' === $type; - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/ObjectRouteLoader.php b/lib/silex/vendor/symfony/routing/Loader/ObjectRouteLoader.php deleted file mode 100644 index 0899a8181..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/ObjectRouteLoader.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Config\Loader\Loader; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\RouteCollection; - -/** - * A route loader that calls a method on an object to load the routes. - * - * @author Ryan Weaver - */ -abstract class ObjectRouteLoader extends Loader -{ - /** - * Returns the object that the method will be called on to load routes. - * - * For example, if your application uses a service container, - * the $id may be a service id. - * - * @param string $id - * - * @return object - */ - abstract protected function getServiceObject($id); - - /** - * Calls the service that will load the routes. - * - * @param mixed $resource Some value that will resolve to a callable - * @param string|null $type The resource type - * - * @return RouteCollection - */ - public function load($resource, $type = null) - { - $parts = explode(':', $resource); - if (2 != count($parts)) { - throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service_name:methodName"', $resource)); - } - - $serviceString = $parts[0]; - $method = $parts[1]; - - $loaderObject = $this->getServiceObject($serviceString); - - if (!is_object($loaderObject)) { - throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', get_class($this), gettype($loaderObject))); - } - - if (!method_exists($loaderObject, $method)) { - throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, get_class($loaderObject), $resource)); - } - - $routeCollection = call_user_func(array($loaderObject, $method), $this); - - if (!$routeCollection instanceof RouteCollection) { - $type = is_object($routeCollection) ? get_class($routeCollection) : gettype($routeCollection); - - throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', get_class($loaderObject), $method, $type)); - } - - // make the service file tracked so that if it changes, the cache rebuilds - $this->addClassResource(new \ReflectionClass($loaderObject), $routeCollection); - - return $routeCollection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return 'service' === $type; - } - - private function addClassResource(\ReflectionClass $class, RouteCollection $collection) - { - do { - if (is_file($class->getFileName())) { - $collection->addResource(new FileResource($class->getFileName())); - } - } while ($class = $class->getParentClass()); - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/PhpFileLoader.php b/lib/silex/vendor/symfony/routing/Loader/PhpFileLoader.php deleted file mode 100644 index 3fcd692f9..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/PhpFileLoader.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -use Symfony\Component\Routing\RouteCollection; - -/** - * PhpFileLoader loads routes from a PHP file. - * - * The file must return a RouteCollection instance. - * - * @author Fabien Potencier - */ -class PhpFileLoader extends FileLoader -{ - /** - * Loads a PHP file. - * - * @param string $file A PHP file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - $this->setCurrentDir(dirname($path)); - - // the closure forbids access to the private scope in the included file - $loader = $this; - $load = \Closure::bind(function ($file) use ($loader) { - return include $file; - }, null, ProtectedPhpFileLoader::class); - - $result = $load($path); - - if ($result instanceof \Closure) { - $collection = new RouteCollection(); - $result(new RoutingConfigurator($collection, $this, $path, $file), $this); - } else { - $collection = $result; - } - - $collection->addResource(new FileResource($path)); - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type); - } -} - -/** - * @internal - */ -final class ProtectedPhpFileLoader extends PhpFileLoader -{ -} diff --git a/lib/silex/vendor/symfony/routing/Loader/XmlFileLoader.php b/lib/silex/vendor/symfony/routing/Loader/XmlFileLoader.php deleted file mode 100644 index 3a7789070..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/XmlFileLoader.php +++ /dev/null @@ -1,352 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\Util\XmlUtils; - -/** - * XmlFileLoader loads XML routing files. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class XmlFileLoader extends FileLoader -{ - const NAMESPACE_URI = 'http://symfony.com/schema/routing'; - const SCHEME_PATH = '/schema/routing/routing-1.0.xsd'; - - /** - * Loads an XML file. - * - * @param string $file An XML file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be - * parsed because it does not validate against the scheme - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $xml = $this->loadFile($path); - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($path)); - - // process routes and imports - foreach ($xml->documentElement->childNodes as $node) { - if (!$node instanceof \DOMElement) { - continue; - } - - $this->parseNode($collection, $node, $path, $file); - } - - return $collection; - } - - /** - * Parses a node from a loaded XML file. - * - * @param RouteCollection $collection Collection to associate with the node - * @param \DOMElement $node Element to parse - * @param string $path Full path of the XML file being processed - * @param string $file Loaded file name - * - * @throws \InvalidArgumentException When the XML is invalid - */ - protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file) - { - if (self::NAMESPACE_URI !== $node->namespaceURI) { - return; - } - - switch ($node->localName) { - case 'route': - $this->parseRoute($collection, $node, $path); - break; - case 'import': - $this->parseImport($collection, $node, $path, $file); - break; - default: - throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "route" or "import".', $node->localName, $path)); - } - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type); - } - - /** - * Parses a route and adds it to the RouteCollection. - * - * @param RouteCollection $collection RouteCollection instance - * @param \DOMElement $node Element to parse that represents a Route - * @param string $path Full path of the XML file being processed - * - * @throws \InvalidArgumentException When the XML is invalid - */ - protected function parseRoute(RouteCollection $collection, \DOMElement $node, $path) - { - if ('' === ($id = $node->getAttribute('id')) || !$node->hasAttribute('path')) { - throw new \InvalidArgumentException(sprintf('The element in file "%s" must have an "id" and a "path" attribute.', $path)); - } - - $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY); - $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY); - - list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); - - $route = new Route($node->getAttribute('path'), $defaults, $requirements, $options, $node->getAttribute('host'), $schemes, $methods, $condition); - $collection->add($id, $route); - } - - /** - * Parses an import and adds the routes in the resource to the RouteCollection. - * - * @param RouteCollection $collection RouteCollection instance - * @param \DOMElement $node Element to parse that represents a Route - * @param string $path Full path of the XML file being processed - * @param string $file Loaded file name - * - * @throws \InvalidArgumentException When the XML is invalid - */ - protected function parseImport(RouteCollection $collection, \DOMElement $node, $path, $file) - { - if ('' === $resource = $node->getAttribute('resource')) { - throw new \InvalidArgumentException(sprintf('The element in file "%s" must have a "resource" attribute.', $path)); - } - - $type = $node->getAttribute('type'); - $prefix = $node->getAttribute('prefix'); - $host = $node->hasAttribute('host') ? $node->getAttribute('host') : null; - $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null; - $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null; - - list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); - - $this->setCurrentDir(dirname($path)); - - $subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file); - /* @var $subCollection RouteCollection */ - $subCollection->addPrefix($prefix); - if (null !== $host) { - $subCollection->setHost($host); - } - if (null !== $condition) { - $subCollection->setCondition($condition); - } - if (null !== $schemes) { - $subCollection->setSchemes($schemes); - } - if (null !== $methods) { - $subCollection->setMethods($methods); - } - $subCollection->addDefaults($defaults); - $subCollection->addRequirements($requirements); - $subCollection->addOptions($options); - - $collection->addCollection($subCollection); - } - - /** - * Loads an XML file. - * - * @param string $file An XML file path - * - * @return \DOMDocument - * - * @throws \InvalidArgumentException When loading of XML file fails because of syntax errors - * or when the XML structure is not as expected by the scheme - - * see validate() - */ - protected function loadFile($file) - { - return XmlUtils::loadFile($file, __DIR__.static::SCHEME_PATH); - } - - /** - * Parses the config elements (default, requirement, option). - * - * @param \DOMElement $node Element to parse that contains the configs - * @param string $path Full path of the XML file being processed - * - * @return array An array with the defaults as first item, requirements as second and options as third - * - * @throws \InvalidArgumentException When the XML is invalid - */ - private function parseConfigs(\DOMElement $node, $path) - { - $defaults = array(); - $requirements = array(); - $options = array(); - $condition = null; - - foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { - if ($node !== $n->parentNode) { - continue; - } - - switch ($n->localName) { - case 'default': - if ($this->isElementValueNull($n)) { - $defaults[$n->getAttribute('key')] = null; - } else { - $defaults[$n->getAttribute('key')] = $this->parseDefaultsConfig($n, $path); - } - - break; - case 'requirement': - $requirements[$n->getAttribute('key')] = trim($n->textContent); - break; - case 'option': - $options[$n->getAttribute('key')] = trim($n->textContent); - break; - case 'condition': - $condition = trim($n->textContent); - break; - default: - throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "default", "requirement", "option" or "condition".', $n->localName, $path)); - } - } - - if ($controller = $node->getAttribute('controller')) { - if (isset($defaults['_controller'])) { - $name = $node->hasAttribute('id') ? sprintf('"%s"', $node->getAttribute('id')) : sprintf('the "%s" tag', $node->tagName); - - throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" attribute and the defaults key "_controller" for %s.', $path, $name)); - } - - $defaults['_controller'] = $controller; - } - - return array($defaults, $requirements, $options, $condition); - } - - /** - * Parses the "default" elements. - * - * @param \DOMElement $element The "default" element to parse - * @param string $path Full path of the XML file being processed - * - * @return array|bool|float|int|string|null The parsed value of the "default" element - */ - private function parseDefaultsConfig(\DOMElement $element, $path) - { - if ($this->isElementValueNull($element)) { - return; - } - - // Check for existing element nodes in the default element. There can - // only be a single element inside a default element. So this element - // (if one was found) can safely be returned. - foreach ($element->childNodes as $child) { - if (!$child instanceof \DOMElement) { - continue; - } - - if (self::NAMESPACE_URI !== $child->namespaceURI) { - continue; - } - - return $this->parseDefaultNode($child, $path); - } - - // If the default element doesn't contain a nested "bool", "int", "float", - // "string", "list", or "map" element, the element contents will be treated - // as the string value of the associated default option. - return trim($element->textContent); - } - - /** - * Recursively parses the value of a "default" element. - * - * @param \DOMElement $node The node value - * @param string $path Full path of the XML file being processed - * - * @return array|bool|float|int|string The parsed value - * - * @throws \InvalidArgumentException when the XML is invalid - */ - private function parseDefaultNode(\DOMElement $node, $path) - { - if ($this->isElementValueNull($node)) { - return; - } - - switch ($node->localName) { - case 'bool': - return 'true' === trim($node->nodeValue) || '1' === trim($node->nodeValue); - case 'int': - return (int) trim($node->nodeValue); - case 'float': - return (float) trim($node->nodeValue); - case 'string': - return trim($node->nodeValue); - case 'list': - $list = array(); - - foreach ($node->childNodes as $element) { - if (!$element instanceof \DOMElement) { - continue; - } - - if (self::NAMESPACE_URI !== $element->namespaceURI) { - continue; - } - - $list[] = $this->parseDefaultNode($element, $path); - } - - return $list; - case 'map': - $map = array(); - - foreach ($node->childNodes as $element) { - if (!$element instanceof \DOMElement) { - continue; - } - - if (self::NAMESPACE_URI !== $element->namespaceURI) { - continue; - } - - $map[$element->getAttribute('key')] = $this->parseDefaultNode($element, $path); - } - - return $map; - default: - throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "bool", "int", "float", "string", "list", or "map".', $node->localName, $path)); - } - } - - private function isElementValueNull(\DOMElement $element) - { - $namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance'; - - if (!$element->hasAttributeNS($namespaceUri, 'nil')) { - return false; - } - - return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/YamlFileLoader.php b/lib/silex/vendor/symfony/routing/Loader/YamlFileLoader.php deleted file mode 100644 index 037d581d0..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/YamlFileLoader.php +++ /dev/null @@ -1,226 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Yaml\Exception\ParseException; -use Symfony\Component\Yaml\Parser as YamlParser; -use Symfony\Component\Config\Loader\FileLoader; - -/** - * YamlFileLoader loads Yaml routing files. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class YamlFileLoader extends FileLoader -{ - private static $availableKeys = array( - 'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', - ); - private $yamlParser; - - /** - * Loads a Yaml file. - * - * @param string $file A Yaml file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - if (!stream_is_local($path)) { - throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path)); - } - - if (!file_exists($path)) { - throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path)); - } - - if (null === $this->yamlParser) { - $this->yamlParser = new YamlParser(); - } - - $prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($file, &$prevErrorHandler) { - $message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message; - - return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false; - }); - - try { - $parsedConfig = $this->yamlParser->parseFile($path); - } catch (ParseException $e) { - throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e); - } finally { - restore_error_handler(); - } - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($path)); - - // empty file - if (null === $parsedConfig) { - return $collection; - } - - // not an array - if (!is_array($parsedConfig)) { - throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path)); - } - - foreach ($parsedConfig as $name => $config) { - $this->validate($config, $name, $path); - - if (isset($config['resource'])) { - $this->parseImport($collection, $config, $path, $file); - } else { - $this->parseRoute($collection, $name, $config, $path); - } - } - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type); - } - - /** - * Parses a route and adds it to the RouteCollection. - * - * @param RouteCollection $collection A RouteCollection instance - * @param string $name Route name - * @param array $config Route definition - * @param string $path Full path of the YAML file being processed - */ - protected function parseRoute(RouteCollection $collection, $name, array $config, $path) - { - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); - $host = isset($config['host']) ? $config['host'] : ''; - $schemes = isset($config['schemes']) ? $config['schemes'] : array(); - $methods = isset($config['methods']) ? $config['methods'] : array(); - $condition = isset($config['condition']) ? $config['condition'] : null; - - if (isset($config['controller'])) { - $defaults['_controller'] = $config['controller']; - } - - $route = new Route($config['path'], $defaults, $requirements, $options, $host, $schemes, $methods, $condition); - - $collection->add($name, $route); - } - - /** - * Parses an import and adds the routes in the resource to the RouteCollection. - * - * @param RouteCollection $collection A RouteCollection instance - * @param array $config Route definition - * @param string $path Full path of the YAML file being processed - * @param string $file Loaded file name - */ - protected function parseImport(RouteCollection $collection, array $config, $path, $file) - { - $type = isset($config['type']) ? $config['type'] : null; - $prefix = isset($config['prefix']) ? $config['prefix'] : ''; - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); - $host = isset($config['host']) ? $config['host'] : null; - $condition = isset($config['condition']) ? $config['condition'] : null; - $schemes = isset($config['schemes']) ? $config['schemes'] : null; - $methods = isset($config['methods']) ? $config['methods'] : null; - - if (isset($config['controller'])) { - $defaults['_controller'] = $config['controller']; - } - - $this->setCurrentDir(dirname($path)); - - $subCollection = $this->import($config['resource'], $type, false, $file); - /* @var $subCollection RouteCollection */ - $subCollection->addPrefix($prefix); - if (null !== $host) { - $subCollection->setHost($host); - } - if (null !== $condition) { - $subCollection->setCondition($condition); - } - if (null !== $schemes) { - $subCollection->setSchemes($schemes); - } - if (null !== $methods) { - $subCollection->setMethods($methods); - } - $subCollection->addDefaults($defaults); - $subCollection->addRequirements($requirements); - $subCollection->addOptions($options); - - $collection->addCollection($subCollection); - } - - /** - * Validates the route configuration. - * - * @param array $config A resource config - * @param string $name The config key - * @param string $path The loaded file path - * - * @throws \InvalidArgumentException If one of the provided config keys is not supported, - * something is missing or the combination is nonsense - */ - protected function validate($config, $name, $path) - { - if (!is_array($config)) { - throw new \InvalidArgumentException(sprintf('The definition of "%s" in "%s" must be a YAML array.', $name, $path)); - } - if ($extraKeys = array_diff(array_keys($config), self::$availableKeys)) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".', - $path, $name, implode('", "', $extraKeys), implode('", "', self::$availableKeys) - )); - } - if (isset($config['resource']) && isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" must not specify both the "resource" key and the "path" key for "%s". Choose between an import and a route definition.', - $path, $name - )); - } - if (!isset($config['resource']) && isset($config['type'])) { - throw new \InvalidArgumentException(sprintf( - 'The "type" key for the route definition "%s" in "%s" is unsupported. It is only available for imports in combination with the "resource" key.', - $name, $path - )); - } - if (!isset($config['resource']) && !isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'You must define a "path" for the route "%s" in file "%s".', - $name, $path - )); - } - if (isset($config['controller']) && isset($config['defaults']['_controller'])) { - throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" key and the defaults key "_controller" for "%s".', $path, $name)); - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Loader/schema/routing/routing-1.0.xsd b/lib/silex/vendor/symfony/routing/Loader/schema/routing/routing-1.0.xsd deleted file mode 100644 index a97111aaa..000000000 --- a/lib/silex/vendor/symfony/routing/Loader/schema/routing/routing-1.0.xsd +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperCollection.php b/lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperCollection.php deleted file mode 100644 index 6916297b8..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperCollection.php +++ /dev/null @@ -1,159 +0,0 @@ - - * - * 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 - * - * @internal - */ -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 self[]|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 self) { - $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 self) { - $child->setParent($this); - } - } - $this->children = $children; - } - - /** - * Returns an iterator over the children. - * - * @return \Iterator|DumperCollection[]|DumperRoute[] The iterator - */ - public function getIterator() - { - return new \ArrayIterator($this->children); - } - - /** - * Returns the root of the collection. - * - * @return self The root collection - */ - public function getRoot() - { - return (null !== $this->parent) ? $this->parent->getRoot() : $this; - } - - /** - * Returns the parent collection. - * - * @return self|null The parent collection or null if the collection has no parent - */ - protected function getParent() - { - return $this->parent; - } - - /** - * Sets 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 bool 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/lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperRoute.php b/lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperRoute.php deleted file mode 100644 index c71989a3a..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/Dumper/DumperRoute.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * 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 - * - * @internal - */ -class DumperRoute -{ - private $name; - private $route; - - /** - * @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/lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumper.php b/lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumper.php deleted file mode 100644 index ea51ab406..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumper.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * 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\RouteCollection; - -/** - * MatcherDumper is the abstract class for all built-in matcher dumpers. - * - * @author Fabien Potencier - */ -abstract class MatcherDumper implements MatcherDumperInterface -{ - private $routes; - - public function __construct(RouteCollection $routes) - { - $this->routes = $routes; - } - - /** - * {@inheritdoc} - */ - public function getRoutes() - { - return $this->routes; - } -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumperInterface.php b/lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumperInterface.php deleted file mode 100644 index 5e7c134b9..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/Dumper/MatcherDumperInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * 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\RouteCollection; - -/** - * MatcherDumperInterface is the interface that all matcher dumper classes must implement. - * - * @author Fabien Potencier - */ -interface MatcherDumperInterface -{ - /** - * Dumps a set of routes to a string representation of executable code - * that can then be used to match a request against these routes. - * - * @param array $options An array of options - * - * @return string Executable code - */ - public function dump(array $options = array()); - - /** - * Gets the routes to dump. - * - * @return RouteCollection A RouteCollection instance - */ - public function getRoutes(); -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php b/lib/silex/vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php deleted file mode 100644 index acb9eddb3..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php +++ /dev/null @@ -1,441 +0,0 @@ - - * - * 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; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; - -/** - * PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes. - * - * @author Fabien Potencier - * @author Tobias Schultze - * @author Arnaud Le Blanc - */ -class PhpMatcherDumper extends MatcherDumper -{ - private $expressionLanguage; - - /** - * @var ExpressionFunctionProviderInterface[] - */ - private $expressionLanguageProviders = array(); - - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the matcher class - */ - public function dump(array $options = array()) - { - $options = array_replace(array( - 'class' => 'ProjectUrlMatcher', - 'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', - ), $options); - - // trailing slash support is only enabled if we know how to redirect the user - $interfaces = class_implements($options['base_class']); - $supportsRedirections = isset($interfaces['Symfony\\Component\\Routing\\Matcher\\RedirectableUrlMatcherInterface']); - - return <<context = \$context; - } - -{$this->generateMatchMethod($supportsRedirections)} -} - -EOF; - } - - public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) - { - $this->expressionLanguageProviders[] = $provider; - } - - /** - * Generates the code for the match method implementing UrlMatcherInterface. - * - * @param bool $supportsRedirections Whether redirections are supported by the base class - * - * @return string Match method as PHP code - */ - private function generateMatchMethod($supportsRedirections) - { - $code = rtrim($this->compileRoutes($this->getRoutes(), $supportsRedirections), "\n"); - - return <<context; - \$request = \$this->request; - \$requestMethod = \$canonicalMethod = \$context->getMethod(); - \$scheme = \$context->getScheme(); - - if ('HEAD' === \$requestMethod) { - \$canonicalMethod = 'GET'; - } - - -$code - - throw 0 < count(\$allow) ? new MethodNotAllowedException(array_unique(\$allow)) : new ResourceNotFoundException(); - } -EOF; - } - - /** - * Generates PHP code to match a RouteCollection with all its routes. - * - * @param RouteCollection $routes A RouteCollection instance - * @param bool $supportsRedirections Whether redirections are supported by the base class - * - * @return string PHP code - */ - private function compileRoutes(RouteCollection $routes, $supportsRedirections) - { - $fetchedHost = false; - $groups = $this->groupRoutesByHostRegex($routes); - $code = ''; - - foreach ($groups as $collection) { - if (null !== $regex = $collection->getAttribute('host_regex')) { - if (!$fetchedHost) { - $code .= " \$host = \$context->getHost();\n\n"; - $fetchedHost = true; - } - - $code .= sprintf(" if (preg_match(%s, \$host, \$hostMatches)) {\n", var_export($regex, true)); - } - - $tree = $this->buildStaticPrefixCollection($collection); - $groupCode = $this->compileStaticPrefixRoutes($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; - } - } - - if ('' === $code) { - $code .= " if ('/' === \$pathinfo) {\n"; - $code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n"; - $code .= " }\n"; - } - - return $code; - } - - private function buildStaticPrefixCollection(DumperCollection $collection) - { - $prefixCollection = new StaticPrefixCollection(); - - foreach ($collection as $dumperRoute) { - $prefix = $dumperRoute->getRoute()->compile()->getStaticPrefix(); - $prefixCollection->addRoute($prefix, $dumperRoute); - } - - $prefixCollection->optimizeGroups(); - - return $prefixCollection; - } - - /** - * Generates PHP code to match a tree of routes. - * - * @param StaticPrefixCollection $collection A StaticPrefixCollection instance - * @param bool $supportsRedirections Whether redirections are supported by the base class - * @param string $ifOrElseIf either "if" or "elseif" to influence chaining - * - * @return string PHP code - */ - private function compileStaticPrefixRoutes(StaticPrefixCollection $collection, $supportsRedirections, $ifOrElseIf = 'if') - { - $code = ''; - $prefix = $collection->getPrefix(); - - if (!empty($prefix) && '/' !== $prefix) { - $code .= sprintf(" %s (0 === strpos(\$pathinfo, %s)) {\n", $ifOrElseIf, var_export($prefix, true)); - } - - $ifOrElseIf = 'if'; - - foreach ($collection->getItems() as $route) { - if ($route instanceof StaticPrefixCollection) { - $code .= $this->compileStaticPrefixRoutes($route, $supportsRedirections, $ifOrElseIf); - $ifOrElseIf = 'elseif'; - } else { - $code .= $this->compileRoute($route[1]->getRoute(), $route[1]->getName(), $supportsRedirections, $prefix)."\n"; - $ifOrElseIf = 'if'; - } - } - - if (!empty($prefix) && '/' !== $prefix) { - $code .= " }\n\n"; - // apply extra indention at each line (except empty ones) - $code = preg_replace('/^.{2,}$/m', ' $0', $code); - } - - return $code; - } - - /** - * Compiles a single Route to PHP code used to match it against the path info. - * - * @param Route $route A Route instance - * @param string $name The name of the Route - * @param bool $supportsRedirections Whether redirections are supported by the base class - * @param string|null $parentPrefix The prefix of the parent collection used to optimize the code - * - * @return string PHP code - * - * @throws \LogicException - */ - private function compileRoute(Route $route, $name, $supportsRedirections, $parentPrefix = null) - { - $code = ''; - $compiledRoute = $route->compile(); - $conditions = array(); - $hasTrailingSlash = false; - $matches = false; - $hostMatches = false; - $methods = $route->getMethods(); - - $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods) || in_array('GET', $methods)); - $regex = $compiledRoute->getRegex(); - - if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P.*?)\$\1#'.('u' === substr($regex, -1) ? 'u' : ''), $regex, $m)) { - if ($supportsTrailingSlash && '/' === substr($m['url'], -1)) { - $conditions[] = sprintf('%s === $trimmedPathinfo', var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true)); - $hasTrailingSlash = true; - } else { - $conditions[] = sprintf('%s === $pathinfo', var_export(str_replace('\\', '', $m['url']), true)); - } - } else { - if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) { - $conditions[] = sprintf('0 === strpos($pathinfo, %s)', var_export($compiledRoute->getStaticPrefix(), true)); - } - - if ($supportsTrailingSlash && $pos = strpos($regex, '/$')) { - $regex = substr($regex, 0, $pos).'/?$'.substr($regex, $pos + 2); - $hasTrailingSlash = true; - } - $conditions[] = sprintf('preg_match(%s, $pathinfo, $matches)', var_export($regex, true)); - - $matches = true; - } - - if ($compiledRoute->getHostVariables()) { - $hostMatches = true; - } - - if ($route->getCondition()) { - $conditions[] = $this->getExpressionLanguage()->compile($route->getCondition(), array('context', 'request')); - } - - $conditions = implode(' && ', $conditions); - - $code .= <<mergeDefaults(array_replace(%s), %s);\n", - implode(', ', $vars), - str_replace("\n", '', var_export($route->getDefaults(), true)) - ); - } elseif ($route->getDefaults()) { - $code .= sprintf(" \$ret = %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true))); - } else { - $code .= sprintf(" \$ret = array('_route' => '%s');\n", $name); - } - - if ($hasTrailingSlash) { - $code .= <<redirect(\$rawPathinfo.'/', '$name')); - } - - -EOF; - } - - if ($schemes = $route->getSchemes()) { - if (!$supportsRedirections) { - throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); - } - $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); - $code .= <<redirect(\$rawPathinfo, '$name', key(\$requiredSchemes))); - } - - -EOF; - } - - if ($hasTrailingSlash || $schemes) { - $code .= " return \$ret;\n"; - } else { - $code = substr_replace($code, 'return', $retOffset, 6); - } - $code .= " }\n"; - - if ($methods) { - $code .= " $gotoname:\n"; - } - - return $code; - } - - /** - * Groups consecutive routes having the same host regex. - * - * The result is a collection of collections of routes having the same host regex. - * - * @param RouteCollection $routes A flat RouteCollection - * - * @return DumperCollection A collection with routes grouped by host regex in sub-collections - */ - private function groupRoutesByHostRegex(RouteCollection $routes) - { - $groups = new DumperCollection(); - $currentGroup = new DumperCollection(); - $currentGroup->setAttribute('host_regex', null); - $groups->add($currentGroup); - - foreach ($routes as $name => $route) { - $hostRegex = $route->compile()->getHostRegex(); - if ($currentGroup->getAttribute('host_regex') !== $hostRegex) { - $currentGroup = new DumperCollection(); - $currentGroup->setAttribute('host_regex', $hostRegex); - $groups->add($currentGroup); - } - $currentGroup->add(new DumperRoute($name, $route)); - } - - return $groups; - } - - private function getExpressionLanguage() - { - if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { - throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); - } - $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); - } - - return $this->expressionLanguage; - } -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php b/lib/silex/vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php deleted file mode 100644 index 736580861..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/Dumper/StaticPrefixCollection.php +++ /dev/null @@ -1,238 +0,0 @@ - - * - * 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 Frank de Jonge - * - * @internal - */ -class StaticPrefixCollection -{ - /** - * @var string - */ - private $prefix; - - /** - * @var array[]|StaticPrefixCollection[] - */ - private $items = array(); - - /** - * @var int - */ - private $matchStart = 0; - - public function __construct($prefix = '') - { - $this->prefix = $prefix; - } - - public function getPrefix() - { - return $this->prefix; - } - - /** - * @return mixed[]|StaticPrefixCollection[] - */ - public function getItems() - { - return $this->items; - } - - /** - * Adds a route to a group. - * - * @param string $prefix - * @param mixed $route - */ - public function addRoute($prefix, $route) - { - $prefix = '/' === $prefix ? $prefix : rtrim($prefix, '/'); - $this->guardAgainstAddingNotAcceptedRoutes($prefix); - - if ($this->prefix === $prefix) { - // When a prefix is exactly the same as the base we move up the match start position. - // This is needed because otherwise routes that come afterwards have higher precedence - // than a possible regular expression, which goes against the input order sorting. - $this->items[] = array($prefix, $route); - $this->matchStart = count($this->items); - - return; - } - - foreach ($this->items as $i => $item) { - if ($i < $this->matchStart) { - continue; - } - - if ($item instanceof self && $item->accepts($prefix)) { - $item->addRoute($prefix, $route); - - return; - } - - $group = $this->groupWithItem($item, $prefix, $route); - - if ($group instanceof self) { - $this->items[$i] = $group; - - return; - } - } - - // No optimised case was found, in this case we simple add the route for possible - // grouping when new routes are added. - $this->items[] = array($prefix, $route); - } - - /** - * Tries to combine a route with another route or group. - * - * @param StaticPrefixCollection|array $item - * @param string $prefix - * @param mixed $route - * - * @return null|StaticPrefixCollection - */ - private function groupWithItem($item, $prefix, $route) - { - $itemPrefix = $item instanceof self ? $item->prefix : $item[0]; - $commonPrefix = $this->detectCommonPrefix($prefix, $itemPrefix); - - if (!$commonPrefix) { - return; - } - - $child = new self($commonPrefix); - - if ($item instanceof self) { - $child->items = array($item); - } else { - $child->addRoute($item[0], $item[1]); - } - - $child->addRoute($prefix, $route); - - return $child; - } - - /** - * Checks whether a prefix can be contained within the group. - * - * @param string $prefix - * - * @return bool Whether a prefix could belong in a given group - */ - private function accepts($prefix) - { - return '' === $this->prefix || 0 === strpos($prefix, $this->prefix); - } - - /** - * Detects whether there's a common prefix relative to the group prefix and returns it. - * - * @param string $prefix - * @param string $anotherPrefix - * - * @return false|string A common prefix, longer than the base/group prefix, or false when none available - */ - private function detectCommonPrefix($prefix, $anotherPrefix) - { - $baseLength = strlen($this->prefix); - $commonLength = $baseLength; - $end = min(strlen($prefix), strlen($anotherPrefix)); - - for ($i = $baseLength; $i <= $end; ++$i) { - if (substr($prefix, 0, $i) !== substr($anotherPrefix, 0, $i)) { - break; - } - - $commonLength = $i; - } - - $commonPrefix = rtrim(substr($prefix, 0, $commonLength), '/'); - - if (strlen($commonPrefix) > $baseLength) { - return $commonPrefix; - } - - return false; - } - - /** - * Optimizes the tree by inlining items from groups with less than 3 items. - */ - public function optimizeGroups() - { - $index = -1; - - while (isset($this->items[++$index])) { - $item = $this->items[$index]; - - if ($item instanceof self) { - $item->optimizeGroups(); - - // When a group contains only two items there's no reason to optimize because at minimum - // the amount of prefix check is 2. In this case inline the group. - if ($item->shouldBeInlined()) { - array_splice($this->items, $index, 1, $item->items); - - // Lower index to pass through the same index again after optimizing. - // The first item of the replacements might be a group needing optimization. - --$index; - } - } - } - } - - private function shouldBeInlined() - { - if (count($this->items) >= 3) { - return false; - } - - foreach ($this->items as $item) { - if ($item instanceof self) { - return true; - } - } - - foreach ($this->items as $item) { - if (is_array($item) && $item[0] === $this->prefix) { - return false; - } - } - - return true; - } - - /** - * Guards against adding incompatible prefixes in a group. - * - * @param string $prefix - * - * @throws \LogicException when a prefix does not belong in a group - */ - private function guardAgainstAddingNotAcceptedRoutes($prefix) - { - if (!$this->accepts($prefix)) { - $message = sprintf('Could not add route with prefix %s to collection with prefix %s', $prefix, $this->prefix); - - throw new \LogicException($message); - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcher.php b/lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcher.php deleted file mode 100644 index 3770a9c24..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcher.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Route; - -/** - * @author Fabien Potencier - */ -abstract class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface -{ - /** - * {@inheritdoc} - */ - public function match($pathinfo) - { - try { - $parameters = parent::match($pathinfo); - } catch (ResourceNotFoundException $e) { - if ('/' === substr($pathinfo, -1) || !in_array($this->context->getMethod(), array('HEAD', 'GET'))) { - throw $e; - } - - try { - $parameters = parent::match($pathinfo.'/'); - - return array_replace($parameters, $this->redirect($pathinfo.'/', isset($parameters['_route']) ? $parameters['_route'] : null)); - } catch (ResourceNotFoundException $e2) { - throw $e; - } - } - - return $parameters; - } - - /** - * {@inheritdoc} - */ - protected function handleRouteRequirements($pathinfo, $name, Route $route) - { - // expression condition - if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)))) { - return array(self::REQUIREMENT_MISMATCH, null); - } - - // check HTTP scheme requirement - $scheme = $this->context->getScheme(); - $schemes = $route->getSchemes(); - if ($schemes && !$route->hasScheme($scheme)) { - return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, current($schemes))); - } - - return array(self::REQUIREMENT_MATCH, null); - } -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcherInterface.php b/lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcherInterface.php deleted file mode 100644 index 7c27bc879..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/RedirectableUrlMatcherInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -/** - * RedirectableUrlMatcherInterface knows how to redirect the user. - * - * @author Fabien Potencier - */ -interface RedirectableUrlMatcherInterface -{ - /** - * Redirects the user to another URL. - * - * @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 - */ - public function redirect($path, $route, $scheme = null); -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/RequestMatcherInterface.php b/lib/silex/vendor/symfony/routing/Matcher/RequestMatcherInterface.php deleted file mode 100644 index 1eef778a5..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/RequestMatcherInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Exception\NoConfigurationException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * RequestMatcherInterface is the interface that all request matcher classes must implement. - * - * @author Fabien Potencier - */ -interface RequestMatcherInterface -{ - /** - * Tries to match a request with a set of routes. - * - * If the matcher can not find information, it must throw one of the exceptions documented - * below. - * - * @return array An array of parameters - * - * @throws NoConfigurationException If no routing configuration could be found - * @throws ResourceNotFoundException If no matching resource could be found - * @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed - */ - public function matchRequest(Request $request); -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/TraceableUrlMatcher.php b/lib/silex/vendor/symfony/routing/Matcher/TraceableUrlMatcher.php deleted file mode 100644 index 9085be042..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/TraceableUrlMatcher.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Exception\ExceptionInterface; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -/** - * TraceableUrlMatcher helps debug path info matching by tracing the match. - * - * @author Fabien Potencier - */ -class TraceableUrlMatcher extends UrlMatcher -{ - const ROUTE_DOES_NOT_MATCH = 0; - const ROUTE_ALMOST_MATCHES = 1; - const ROUTE_MATCHES = 2; - - protected $traces; - - public function getTraces($pathinfo) - { - $this->traces = array(); - - try { - $this->match($pathinfo); - } catch (ExceptionInterface $e) { - } - - return $this->traces; - } - - public function getTracesForRequest(Request $request) - { - $this->request = $request; - $traces = $this->getTraces($request->getPathInfo()); - $this->request = null; - - return $traces; - } - - protected function matchCollection($pathinfo, RouteCollection $routes) - { - foreach ($routes as $name => $route) { - $compiledRoute = $route->compile(); - - if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) { - // does it match without any requirements? - $r = new Route($route->getPath(), $route->getDefaults(), array(), $route->getOptions()); - $cr = $r->compile(); - if (!preg_match($cr->getRegex(), $pathinfo)) { - $this->addTrace(sprintf('Path "%s" does not match', $route->getPath()), self::ROUTE_DOES_NOT_MATCH, $name, $route); - - continue; - } - - foreach ($route->getRequirements() as $n => $regex) { - $r = new Route($route->getPath(), $route->getDefaults(), array($n => $regex), $route->getOptions()); - $cr = $r->compile(); - - if (in_array($n, $cr->getVariables()) && !preg_match($cr->getRegex(), $pathinfo)) { - $this->addTrace(sprintf('Requirement for "%s" does not match (%s)', $n, $regex), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue 2; - } - } - - continue; - } - - // check host requirement - $hostMatches = array(); - if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { - $this->addTrace(sprintf('Host "%s" does not match the requirement ("%s")', $this->context->getHost(), $route->getHost()), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue; - } - - // check HTTP method requirement - if ($requiredMethods = $route->getMethods()) { - // HEAD and GET are equivalent as per RFC - if ('HEAD' === $method = $this->context->getMethod()) { - $method = 'GET'; - } - - if (!in_array($method, $requiredMethods)) { - $this->allow = array_merge($this->allow, $requiredMethods); - - $this->addTrace(sprintf('Method "%s" does not match any of the required methods (%s)', $this->context->getMethod(), implode(', ', $requiredMethods)), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue; - } - } - - // check condition - if ($condition = $route->getCondition()) { - if (!$this->getExpressionLanguage()->evaluate($condition, array('context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)))) { - $this->addTrace(sprintf('Condition "%s" does not evaluate to "true"', $condition), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue; - } - } - - // check HTTP scheme requirement - if ($requiredSchemes = $route->getSchemes()) { - $scheme = $this->context->getScheme(); - - if (!$route->hasScheme($scheme)) { - $this->addTrace(sprintf('Scheme "%s" does not match any of the required schemes (%s); the user will be redirected to first required scheme', $scheme, implode(', ', $requiredSchemes)), self::ROUTE_ALMOST_MATCHES, $name, $route); - - return true; - } - } - - $this->addTrace('Route matches!', self::ROUTE_MATCHES, $name, $route); - - return true; - } - } - - private function addTrace($log, $level = self::ROUTE_DOES_NOT_MATCH, $name = null, $route = null) - { - $this->traces[] = array( - 'log' => $log, - 'name' => $name, - 'level' => $level, - 'path' => null !== $route ? $route->getPath() : null, - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/UrlMatcher.php b/lib/silex/vendor/symfony/routing/Matcher/UrlMatcher.php deleted file mode 100644 index 3cba7e66f..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/UrlMatcher.php +++ /dev/null @@ -1,250 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\NoConfigurationException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Route; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; - -/** - * UrlMatcher matches URL based on a set of routes. - * - * @author Fabien Potencier - */ -class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface -{ - const REQUIREMENT_MATCH = 0; - const REQUIREMENT_MISMATCH = 1; - const ROUTE_MATCH = 2; - - protected $context; - protected $allow = array(); - protected $routes; - protected $request; - protected $expressionLanguage; - - /** - * @var ExpressionFunctionProviderInterface[] - */ - protected $expressionLanguageProviders = array(); - - public function __construct(RouteCollection $routes, RequestContext $context) - { - $this->routes = $routes; - $this->context = $context; - } - - /** - * {@inheritdoc} - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - return $this->context; - } - - /** - * {@inheritdoc} - */ - public function match($pathinfo) - { - $this->allow = array(); - - if ($ret = $this->matchCollection(rawurldecode($pathinfo), $this->routes)) { - return $ret; - } - - if (0 === count($this->routes) && '/' === $pathinfo) { - throw new NoConfigurationException(); - } - - throw 0 < count($this->allow) - ? new MethodNotAllowedException(array_unique($this->allow)) - : new ResourceNotFoundException(sprintf('No routes found for "%s".', $pathinfo)); - } - - /** - * {@inheritdoc} - */ - public function matchRequest(Request $request) - { - $this->request = $request; - - $ret = $this->match($request->getPathInfo()); - - $this->request = null; - - return $ret; - } - - public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) - { - $this->expressionLanguageProviders[] = $provider; - } - - /** - * Tries to match a URL with a set of routes. - * - * @param string $pathinfo The path info to be parsed - * @param RouteCollection $routes The set of routes - * - * @return array An array of parameters - * - * @throws NoConfigurationException If no routing configuration could be found - * @throws ResourceNotFoundException If the resource could not be found - * @throws MethodNotAllowedException If the resource was found but the request method is not allowed - */ - protected function matchCollection($pathinfo, RouteCollection $routes) - { - foreach ($routes as $name => $route) { - $compiledRoute = $route->compile(); - - // check the static prefix of the URL first. Only use the more expensive preg_match when it matches - if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) { - continue; - } - - if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) { - continue; - } - - $hostMatches = array(); - if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { - continue; - } - - // check HTTP method requirement - if ($requiredMethods = $route->getMethods()) { - // HEAD and GET are equivalent as per RFC - if ('HEAD' === $method = $this->context->getMethod()) { - $method = 'GET'; - } - - if (!in_array($method, $requiredMethods)) { - $this->allow = array_merge($this->allow, $requiredMethods); - - continue; - } - } - - $status = $this->handleRouteRequirements($pathinfo, $name, $route); - - if (self::REQUIREMENT_MISMATCH === $status[0]) { - continue; - } - - return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, isset($status[1]) ? $status[1] : array())); - } - } - - /** - * 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. - * - * @param string $pathinfo The path - * @param string $name The route name - * @param Route $route The route - * - * @return array The first element represents the status, the second contains additional information - */ - protected function handleRouteRequirements($pathinfo, $name, Route $route) - { - // expression condition - if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request ?: $this->createRequest($pathinfo)))) { - return array(self::REQUIREMENT_MISMATCH, null); - } - - // check HTTP scheme requirement - $scheme = $this->context->getScheme(); - $status = $route->getSchemes() && !$route->hasScheme($scheme) ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH; - - return array($status, null); - } - - /** - * Get merged default parameters. - * - * @param array $params The parameters - * @param array $defaults The defaults - * - * @return array Merged default parameters - */ - protected function mergeDefaults($params, $defaults) - { - foreach ($params as $key => $value) { - if (!is_int($key)) { - $defaults[$key] = $value; - } - } - - return $defaults; - } - - protected function getExpressionLanguage() - { - if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { - throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); - } - $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); - } - - return $this->expressionLanguage; - } - - /** - * @internal - */ - protected function createRequest($pathinfo) - { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - return null; - } - - return Request::create($this->context->getScheme().'://'.$this->context->getHost().$this->context->getBaseUrl().$pathinfo, $this->context->getMethod(), $this->context->getParameters(), array(), array(), array( - 'SCRIPT_FILENAME' => $this->context->getBaseUrl(), - 'SCRIPT_NAME' => $this->context->getBaseUrl(), - )); - } -} diff --git a/lib/silex/vendor/symfony/routing/Matcher/UrlMatcherInterface.php b/lib/silex/vendor/symfony/routing/Matcher/UrlMatcherInterface.php deleted file mode 100644 index 2c7c3135b..000000000 --- a/lib/silex/vendor/symfony/routing/Matcher/UrlMatcherInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\NoConfigurationException; -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * UrlMatcherInterface is the interface that all URL matcher classes must implement. - * - * @author Fabien Potencier - */ -interface UrlMatcherInterface extends RequestContextAwareInterface -{ - /** - * Tries to match a URL path with a set of routes. - * - * If the matcher can not find information, it must throw one of the exceptions documented - * below. - * - * @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded) - * - * @return array An array of parameters - * - * @throws NoConfigurationException If no routing configuration could be found - * @throws ResourceNotFoundException If the resource could not be found - * @throws MethodNotAllowedException If the resource was found but the request method is not allowed - */ - public function match($pathinfo); -} diff --git a/lib/silex/vendor/symfony/routing/README.md b/lib/silex/vendor/symfony/routing/README.md deleted file mode 100644 index 88fb1fde5..000000000 --- a/lib/silex/vendor/symfony/routing/README.md +++ /dev/null @@ -1,13 +0,0 @@ -Routing Component -================= - -The Routing component maps an HTTP request to a set of configuration variables. - -Resources ---------- - - * [Documentation](https://symfony.com/doc/current/components/routing/index.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/lib/silex/vendor/symfony/routing/RequestContext.php b/lib/silex/vendor/symfony/routing/RequestContext.php deleted file mode 100644 index d62a7766e..000000000 --- a/lib/silex/vendor/symfony/routing/RequestContext.php +++ /dev/null @@ -1,336 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Holds information about the current request. - * - * This class implements a fluent interface. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class RequestContext -{ - private $baseUrl; - private $pathInfo; - private $method; - private $host; - private $scheme; - private $httpPort; - private $httpsPort; - private $queryString; - private $parameters = array(); - - /** - * @param string $baseUrl The base URL - * @param string $method The HTTP method - * @param string $host The HTTP host name - * @param string $scheme The HTTP scheme - * @param int $httpPort The HTTP port - * @param int $httpsPort The HTTPS port - * @param string $path The path - * @param string $queryString The query string - */ - public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '') - { - $this->setBaseUrl($baseUrl); - $this->setMethod($method); - $this->setHost($host); - $this->setScheme($scheme); - $this->setHttpPort($httpPort); - $this->setHttpsPort($httpsPort); - $this->setPathInfo($path); - $this->setQueryString($queryString); - } - - /** - * Updates the RequestContext information based on a HttpFoundation Request. - * - * @return $this - */ - public function fromRequest(Request $request) - { - $this->setBaseUrl($request->getBaseUrl()); - $this->setPathInfo($request->getPathInfo()); - $this->setMethod($request->getMethod()); - $this->setHost($request->getHost()); - $this->setScheme($request->getScheme()); - $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort()); - $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort); - $this->setQueryString($request->server->get('QUERY_STRING', '')); - - return $this; - } - - /** - * Gets the base URL. - * - * @return string The base URL - */ - public function getBaseUrl() - { - return $this->baseUrl; - } - - /** - * Sets the base URL. - * - * @param string $baseUrl The base URL - * - * @return $this - */ - public function setBaseUrl($baseUrl) - { - $this->baseUrl = $baseUrl; - - return $this; - } - - /** - * Gets the path info. - * - * @return string The path info - */ - public function getPathInfo() - { - return $this->pathInfo; - } - - /** - * Sets the path info. - * - * @param string $pathInfo The path info - * - * @return $this - */ - public function setPathInfo($pathInfo) - { - $this->pathInfo = $pathInfo; - - return $this; - } - - /** - * Gets the HTTP method. - * - * The method is always an uppercased string. - * - * @return string The HTTP method - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the HTTP method. - * - * @param string $method The HTTP method - * - * @return $this - */ - public function setMethod($method) - { - $this->method = strtoupper($method); - - return $this; - } - - /** - * Gets the HTTP host. - * - * The host is always lowercased because it must be treated case-insensitive. - * - * @return string The HTTP host - */ - public function getHost() - { - return $this->host; - } - - /** - * Sets the HTTP host. - * - * @param string $host The HTTP host - * - * @return $this - */ - public function setHost($host) - { - $this->host = strtolower($host); - - return $this; - } - - /** - * Gets the HTTP scheme. - * - * @return string The HTTP scheme - */ - public function getScheme() - { - return $this->scheme; - } - - /** - * Sets the HTTP scheme. - * - * @param string $scheme The HTTP scheme - * - * @return $this - */ - public function setScheme($scheme) - { - $this->scheme = strtolower($scheme); - - return $this; - } - - /** - * Gets the HTTP port. - * - * @return int The HTTP port - */ - public function getHttpPort() - { - return $this->httpPort; - } - - /** - * Sets the HTTP port. - * - * @param int $httpPort The HTTP port - * - * @return $this - */ - public function setHttpPort($httpPort) - { - $this->httpPort = (int) $httpPort; - - return $this; - } - - /** - * Gets the HTTPS port. - * - * @return int The HTTPS port - */ - public function getHttpsPort() - { - return $this->httpsPort; - } - - /** - * Sets the HTTPS port. - * - * @param int $httpsPort The HTTPS port - * - * @return $this - */ - public function setHttpsPort($httpsPort) - { - $this->httpsPort = (int) $httpsPort; - - return $this; - } - - /** - * Gets the query string. - * - * @return string The query string without the "?" - */ - public function getQueryString() - { - return $this->queryString; - } - - /** - * Sets the query string. - * - * @param string $queryString The query string (after "?") - * - * @return $this - */ - public function setQueryString($queryString) - { - // string cast to be fault-tolerant, accepting null - $this->queryString = (string) $queryString; - - return $this; - } - - /** - * Returns the parameters. - * - * @return array The parameters - */ - public function getParameters() - { - return $this->parameters; - } - - /** - * Sets the parameters. - * - * @param array $parameters The parameters - * - * @return $this - */ - public function setParameters(array $parameters) - { - $this->parameters = $parameters; - - return $this; - } - - /** - * Gets a parameter value. - * - * @param string $name A parameter name - * - * @return mixed The parameter value or null if nonexistent - */ - public function getParameter($name) - { - return isset($this->parameters[$name]) ? $this->parameters[$name] : null; - } - - /** - * Checks if a parameter value is set for the given parameter. - * - * @param string $name A parameter name - * - * @return bool True if the parameter value is set, false otherwise - */ - public function hasParameter($name) - { - return array_key_exists($name, $this->parameters); - } - - /** - * Sets a parameter value. - * - * @param string $name A parameter name - * @param mixed $parameter The parameter value - * - * @return $this - */ - public function setParameter($name, $parameter) - { - $this->parameters[$name] = $parameter; - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/routing/RequestContextAwareInterface.php b/lib/silex/vendor/symfony/routing/RequestContextAwareInterface.php deleted file mode 100644 index df5b9fcd4..000000000 --- a/lib/silex/vendor/symfony/routing/RequestContextAwareInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -interface RequestContextAwareInterface -{ - /** - * Sets the request context. - */ - public function setContext(RequestContext $context); - - /** - * Gets the request context. - * - * @return RequestContext The context - */ - public function getContext(); -} diff --git a/lib/silex/vendor/symfony/routing/Route.php b/lib/silex/vendor/symfony/routing/Route.php deleted file mode 100644 index cd50ac827..000000000 --- a/lib/silex/vendor/symfony/routing/Route.php +++ /dev/null @@ -1,558 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * A Route describes a route and its parameters. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class Route implements \Serializable -{ - private $path = '/'; - private $host = ''; - private $schemes = array(); - private $methods = array(); - private $defaults = array(); - private $requirements = array(); - private $options = array(); - private $condition = ''; - - /** - * @var null|CompiledRoute - */ - private $compiled; - - /** - * Constructor. - * - * Available options: - * - * * compiler_class: A class name able to compile this route instance (RouteCompiler by default) - * * utf8: Whether UTF-8 matching is enforced ot not - * - * @param string $path 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 $host The host pattern to match - * @param string|string[] $schemes A required URI scheme or an array of restricted schemes - * @param string|string[] $methods A required HTTP method or an array of restricted methods - * @param string $condition A condition that should evaluate to true for the route to match - */ - public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '') - { - $this->setPath($path); - $this->setDefaults($defaults); - $this->setRequirements($requirements); - $this->setOptions($options); - $this->setHost($host); - $this->setSchemes($schemes); - $this->setMethods($methods); - $this->setCondition($condition); - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - return serialize(array( - 'path' => $this->path, - 'host' => $this->host, - 'defaults' => $this->defaults, - 'requirements' => $this->requirements, - 'options' => $this->options, - 'schemes' => $this->schemes, - 'methods' => $this->methods, - 'condition' => $this->condition, - 'compiled' => $this->compiled, - )); - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - $this->path = $data['path']; - $this->host = $data['host']; - $this->defaults = $data['defaults']; - $this->requirements = $data['requirements']; - $this->options = $data['options']; - $this->schemes = $data['schemes']; - $this->methods = $data['methods']; - - if (isset($data['condition'])) { - $this->condition = $data['condition']; - } - if (isset($data['compiled'])) { - $this->compiled = $data['compiled']; - } - } - - /** - * Returns the pattern for the path. - * - * @return string The path pattern - */ - public function getPath() - { - return $this->path; - } - - /** - * Sets the pattern for the path. - * - * This method implements a fluent interface. - * - * @param string $pattern The path pattern - * - * @return $this - */ - public function setPath($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->path = '/'.ltrim(trim($pattern), '/'); - $this->compiled = null; - - return $this; - } - - /** - * Returns the pattern for the host. - * - * @return string The host pattern - */ - public function getHost() - { - return $this->host; - } - - /** - * Sets the pattern for the host. - * - * This method implements a fluent interface. - * - * @param string $pattern The host pattern - * - * @return $this - */ - public function setHost($pattern) - { - $this->host = (string) $pattern; - $this->compiled = null; - - return $this; - } - - /** - * Returns the lowercased schemes this route is restricted to. - * So an empty array means that any scheme is allowed. - * - * @return string[] The schemes - */ - public function getSchemes() - { - return $this->schemes; - } - - /** - * Sets the schemes (e.g. 'https') this route is restricted to. - * So an empty array means that any scheme is allowed. - * - * This method implements a fluent interface. - * - * @param string|string[] $schemes The scheme or an array of schemes - * - * @return $this - */ - public function setSchemes($schemes) - { - $this->schemes = array_map('strtolower', (array) $schemes); - $this->compiled = null; - - return $this; - } - - /** - * Checks if a scheme requirement has been set. - * - * @param string $scheme - * - * @return bool true if the scheme requirement exists, otherwise false - */ - public function hasScheme($scheme) - { - return in_array(strtolower($scheme), $this->schemes, true); - } - - /** - * Returns the uppercased HTTP methods this route is restricted to. - * So an empty array means that any method is allowed. - * - * @return string[] The methods - */ - public function getMethods() - { - return $this->methods; - } - - /** - * Sets the HTTP methods (e.g. 'POST') this route is restricted to. - * So an empty array means that any method is allowed. - * - * This method implements a fluent interface. - * - * @param string|string[] $methods The method or an array of methods - * - * @return $this - */ - public function setMethods($methods) - { - $this->methods = array_map('strtoupper', (array) $methods); - $this->compiled = null; - - return $this; - } - - /** - * Returns the options. - * - * @return array The options - */ - public function getOptions() - { - return $this->options; - } - - /** - * Sets the options. - * - * This method implements a fluent interface. - * - * @param array $options The options - * - * @return $this - */ - public function setOptions(array $options) - { - $this->options = array( - 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler', - ); - - return $this->addOptions($options); - } - - /** - * Adds options. - * - * This method implements a fluent interface. - * - * @param array $options The options - * - * @return $this - */ - public function addOptions(array $options) - { - foreach ($options as $name => $option) { - $this->options[$name] = $option; - } - $this->compiled = null; - - return $this; - } - - /** - * Sets an option value. - * - * This method implements a fluent interface. - * - * @param string $name An option name - * @param mixed $value The option value - * - * @return $this - */ - public function setOption($name, $value) - { - $this->options[$name] = $value; - $this->compiled = null; - - return $this; - } - - /** - * Get an option value. - * - * @param string $name An option name - * - * @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 an option has been set. - * - * @param string $name An option name - * - * @return bool true if the option is set, false otherwise - */ - public function hasOption($name) - { - return array_key_exists($name, $this->options); - } - - /** - * Returns the defaults. - * - * @return array The defaults - */ - public function getDefaults() - { - return $this->defaults; - } - - /** - * Sets the defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * - * @return $this - */ - public function setDefaults(array $defaults) - { - $this->defaults = array(); - - return $this->addDefaults($defaults); - } - - /** - * Adds defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * - * @return $this - */ - public function addDefaults(array $defaults) - { - foreach ($defaults as $name => $default) { - $this->defaults[$name] = $default; - } - $this->compiled = null; - - return $this; - } - - /** - * Gets a default value. - * - * @param string $name A variable name - * - * @return mixed The default value or null when not given - */ - public function getDefault($name) - { - return isset($this->defaults[$name]) ? $this->defaults[$name] : null; - } - - /** - * Checks if a default value is set for the given variable. - * - * @param string $name A variable name - * - * @return bool true if the default value is set, false otherwise - */ - public function hasDefault($name) - { - return array_key_exists($name, $this->defaults); - } - - /** - * Sets a default value. - * - * @param string $name A variable name - * @param mixed $default The default value - * - * @return $this - */ - public function setDefault($name, $default) - { - $this->defaults[$name] = $default; - $this->compiled = null; - - return $this; - } - - /** - * Returns the requirements. - * - * @return array The requirements - */ - public function getRequirements() - { - return $this->requirements; - } - - /** - * Sets the requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * - * @return $this - */ - public function setRequirements(array $requirements) - { - $this->requirements = array(); - - return $this->addRequirements($requirements); - } - - /** - * Adds requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * - * @return $this - */ - public function addRequirements(array $requirements) - { - foreach ($requirements as $key => $regex) { - $this->requirements[$key] = $this->sanitizeRequirement($key, $regex); - } - $this->compiled = null; - - return $this; - } - - /** - * Returns the requirement for the given key. - * - * @param string $key The key - * - * @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 $key A variable name - * - * @return bool 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. - * - * @param string $key The key - * @param string $regex The regex - * - * @return $this - */ - public function setRequirement($key, $regex) - { - $this->requirements[$key] = $this->sanitizeRequirement($key, $regex); - $this->compiled = null; - - return $this; - } - - /** - * Returns the condition. - * - * @return string The condition - */ - public function getCondition() - { - return $this->condition; - } - - /** - * Sets the condition. - * - * This method implements a fluent interface. - * - * @param string $condition The condition - * - * @return $this - */ - public function setCondition($condition) - { - $this->condition = (string) $condition; - $this->compiled = null; - - return $this; - } - - /** - * Compiles the route. - * - * @return CompiledRoute A CompiledRoute instance - * - * @throws \LogicException If the Route cannot be compiled because the - * path or host pattern is invalid - * - * @see RouteCompiler which is responsible for the compilation process - */ - public function compile() - { - if (null !== $this->compiled) { - return $this->compiled; - } - - $class = $this->getOption('compiler_class'); - - return $this->compiled = $class::compile($this); - } - - private function sanitizeRequirement($key, $regex) - { - if (!is_string($regex)) { - throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key)); - } - - 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/lib/silex/vendor/symfony/routing/RouteCollection.php b/lib/silex/vendor/symfony/routing/RouteCollection.php deleted file mode 100644 index feabf234b..000000000 --- a/lib/silex/vendor/symfony/routing/RouteCollection.php +++ /dev/null @@ -1,280 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\Config\Resource\ResourceInterface; - -/** - * A RouteCollection represents a set of Route instances. - * - * When adding a route at the end of the collection, an existing route - * with the same name is removed first. So there can only be one route - * with a given name. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -class RouteCollection implements \IteratorAggregate, \Countable -{ - /** - * @var Route[] - */ - private $routes = array(); - - /** - * @var array - */ - private $resources = array(); - - public function __clone() - { - foreach ($this->routes as $name => $route) { - $this->routes[$name] = clone $route; - } - } - - /** - * Gets the current RouteCollection as an Iterator that includes all routes. - * - * It implements \IteratorAggregate. - * - * @see all() - * - * @return \ArrayIterator|Route[] An \ArrayIterator object for iterating over routes - */ - public function getIterator() - { - return new \ArrayIterator($this->routes); - } - - /** - * Gets the number of Routes in this collection. - * - * @return int The number of routes - */ - public function count() - { - return count($this->routes); - } - - /** - * Adds a route. - * - * @param string $name The route name - * @param Route $route A Route instance - */ - public function add($name, Route $route) - { - unset($this->routes[$name]); - - $this->routes[$name] = $route; - } - - /** - * Returns all routes in this collection. - * - * @return Route[] An array of routes - */ - public function all() - { - return $this->routes; - } - - /** - * Gets a route by name. - * - * @param string $name The route name - * - * @return Route|null A Route instance or null when not found - */ - public function get($name) - { - return isset($this->routes[$name]) ? $this->routes[$name] : null; - } - - /** - * Removes a route or an array of routes by name from the collection. - * - * @param string|string[] $name The route name or an array of route names - */ - public function remove($name) - { - foreach ((array) $name as $n) { - unset($this->routes[$n]); - } - } - - /** - * Adds a route collection at the end of the current set by appending all - * routes of the added collection. - */ - public function addCollection(RouteCollection $collection) - { - // we need to remove all routes with the same names first because just replacing them - // would not place the new route at the end of the merged array - foreach ($collection->all() as $name => $route) { - unset($this->routes[$name]); - $this->routes[$name] = $route; - } - - foreach ($collection->getResources() as $resource) { - $this->addResource($resource); - } - } - - /** - * Adds a prefix to the path of all child routes. - * - * @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 - */ - public function addPrefix($prefix, array $defaults = array(), array $requirements = array()) - { - $prefix = trim(trim($prefix), '/'); - - if ('' === $prefix) { - return; - } - - foreach ($this->routes as $route) { - $route->setPath('/'.$prefix.$route->getPath()); - $route->addDefaults($defaults); - $route->addRequirements($requirements); - } - } - - /** - * Sets the host pattern on all routes. - * - * @param string $pattern The pattern - * @param array $defaults An array of default values - * @param array $requirements An array of requirements - */ - public function setHost($pattern, array $defaults = array(), array $requirements = array()) - { - foreach ($this->routes as $route) { - $route->setHost($pattern); - $route->addDefaults($defaults); - $route->addRequirements($requirements); - } - } - - /** - * Sets a condition on all routes. - * - * Existing conditions will be overridden. - * - * @param string $condition The condition - */ - public function setCondition($condition) - { - foreach ($this->routes as $route) { - $route->setCondition($condition); - } - } - - /** - * Adds defaults to all routes. - * - * An existing default value under the same name in a route will be overridden. - * - * @param array $defaults An array of default values - */ - public function addDefaults(array $defaults) - { - if ($defaults) { - foreach ($this->routes as $route) { - $route->addDefaults($defaults); - } - } - } - - /** - * Adds requirements to all routes. - * - * An existing requirement under the same name in a route will be overridden. - * - * @param array $requirements An array of requirements - */ - public function addRequirements(array $requirements) - { - if ($requirements) { - foreach ($this->routes as $route) { - $route->addRequirements($requirements); - } - } - } - - /** - * Adds options to all routes. - * - * An existing option value under the same name in a route will be overridden. - * - * @param array $options An array of options - */ - public function addOptions(array $options) - { - if ($options) { - foreach ($this->routes as $route) { - $route->addOptions($options); - } - } - } - - /** - * Sets the schemes (e.g. 'https') all child routes are restricted to. - * - * @param string|string[] $schemes The scheme or an array of schemes - */ - public function setSchemes($schemes) - { - foreach ($this->routes as $route) { - $route->setSchemes($schemes); - } - } - - /** - * Sets the HTTP methods (e.g. 'POST') all child routes are restricted to. - * - * @param string|string[] $methods The method or an array of methods - */ - public function setMethods($methods) - { - foreach ($this->routes as $route) { - $route->setMethods($methods); - } - } - - /** - * Returns an array of resources loaded to build this collection. - * - * @return ResourceInterface[] An array of resources - */ - public function getResources() - { - return array_values($this->resources); - } - - /** - * Adds a resource for this collection. If the resource already exists - * it is not added. - */ - public function addResource(ResourceInterface $resource) - { - $key = (string) $resource; - - if (!isset($this->resources[$key])) { - $this->resources[$key] = $resource; - } - } -} diff --git a/lib/silex/vendor/symfony/routing/RouteCollectionBuilder.php b/lib/silex/vendor/symfony/routing/RouteCollectionBuilder.php deleted file mode 100644 index e8a9a165d..000000000 --- a/lib/silex/vendor/symfony/routing/RouteCollectionBuilder.php +++ /dev/null @@ -1,380 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\Config\Exception\FileLoaderLoadException; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Resource\ResourceInterface; - -/** - * Helps add and import routes into a RouteCollection. - * - * @author Ryan Weaver - */ -class RouteCollectionBuilder -{ - /** - * @var Route[]|RouteCollectionBuilder[] - */ - private $routes = array(); - - private $loader; - private $defaults = array(); - private $prefix; - private $host; - private $condition; - private $requirements = array(); - private $options = array(); - private $schemes; - private $methods; - private $resources = array(); - - public function __construct(LoaderInterface $loader = null) - { - $this->loader = $loader; - } - - /** - * Import an external routing resource and returns the RouteCollectionBuilder. - * - * $routes->import('blog.yml', '/blog'); - * - * @param mixed $resource - * @param string|null $prefix - * @param string $type - * - * @return self - * - * @throws FileLoaderLoadException - */ - public function import($resource, $prefix = '/', $type = null) - { - /** @var RouteCollection[] $collection */ - $collections = $this->load($resource, $type); - - // create a builder from the RouteCollection - $builder = $this->createBuilder(); - - foreach ($collections as $collection) { - if (null === $collection) { - continue; - } - - foreach ($collection->all() as $name => $route) { - $builder->addRoute($route, $name); - } - - foreach ($collection->getResources() as $resource) { - $builder->addResource($resource); - } - } - - // mount into this builder - $this->mount($prefix, $builder); - - return $builder; - } - - /** - * Adds a route and returns it for future modification. - * - * @param string $path The route path - * @param string $controller The route's controller - * @param string|null $name The name to give this route - * - * @return Route - */ - public function add($path, $controller, $name = null) - { - $route = new Route($path); - $route->setDefault('_controller', $controller); - $this->addRoute($route, $name); - - return $route; - } - - /** - * Returns a RouteCollectionBuilder that can be configured and then added with mount(). - * - * @return self - */ - public function createBuilder() - { - return new self($this->loader); - } - - /** - * Add a RouteCollectionBuilder. - * - * @param string $prefix - * @param RouteCollectionBuilder $builder - */ - public function mount($prefix, RouteCollectionBuilder $builder) - { - $builder->prefix = trim(trim($prefix), '/'); - $this->routes[] = $builder; - } - - /** - * Adds a Route object to the builder. - * - * @param Route $route - * @param string|null $name - * - * @return $this - */ - public function addRoute(Route $route, $name = null) - { - if (null === $name) { - // used as a flag to know which routes will need a name later - $name = '_unnamed_route_'.spl_object_hash($route); - } - - $this->routes[$name] = $route; - - return $this; - } - - /** - * Sets the host on all embedded routes (unless already set). - * - * @param string $pattern - * - * @return $this - */ - public function setHost($pattern) - { - $this->host = $pattern; - - return $this; - } - - /** - * Sets a condition on all embedded routes (unless already set). - * - * @param string $condition - * - * @return $this - */ - public function setCondition($condition) - { - $this->condition = $condition; - - return $this; - } - - /** - * Sets a default value that will be added to all embedded routes (unless that - * default value is already set). - * - * @param string $key - * @param mixed $value - * - * @return $this - */ - public function setDefault($key, $value) - { - $this->defaults[$key] = $value; - - return $this; - } - - /** - * Sets a requirement that will be added to all embedded routes (unless that - * requirement is already set). - * - * @param string $key - * @param mixed $regex - * - * @return $this - */ - public function setRequirement($key, $regex) - { - $this->requirements[$key] = $regex; - - return $this; - } - - /** - * Sets an option that will be added to all embedded routes (unless that - * option is already set). - * - * @param string $key - * @param mixed $value - * - * @return $this - */ - public function setOption($key, $value) - { - $this->options[$key] = $value; - - return $this; - } - - /** - * Sets the schemes on all embedded routes (unless already set). - * - * @param array|string $schemes - * - * @return $this - */ - public function setSchemes($schemes) - { - $this->schemes = $schemes; - - return $this; - } - - /** - * Sets the methods on all embedded routes (unless already set). - * - * @param array|string $methods - * - * @return $this - */ - public function setMethods($methods) - { - $this->methods = $methods; - - return $this; - } - - /** - * Adds a resource for this collection. - * - * @param ResourceInterface $resource - * - * @return $this - */ - private function addResource(ResourceInterface $resource) - { - $this->resources[] = $resource; - - return $this; - } - - /** - * Creates the final RouteCollection and returns it. - * - * @return RouteCollection - */ - public function build() - { - $routeCollection = new RouteCollection(); - - foreach ($this->routes as $name => $route) { - if ($route instanceof Route) { - $route->setDefaults(array_merge($this->defaults, $route->getDefaults())); - $route->setOptions(array_merge($this->options, $route->getOptions())); - - foreach ($this->requirements as $key => $val) { - if (!$route->hasRequirement($key)) { - $route->setRequirement($key, $val); - } - } - - if (null !== $this->prefix) { - $route->setPath('/'.$this->prefix.$route->getPath()); - } - - if (!$route->getHost()) { - $route->setHost($this->host); - } - - if (!$route->getCondition()) { - $route->setCondition($this->condition); - } - - if (!$route->getSchemes()) { - $route->setSchemes($this->schemes); - } - - if (!$route->getMethods()) { - $route->setMethods($this->methods); - } - - // auto-generate the route name if it's been marked - if ('_unnamed_route_' === substr($name, 0, 15)) { - $name = $this->generateRouteName($route); - } - - $routeCollection->add($name, $route); - } else { - /* @var self $route */ - $subCollection = $route->build(); - $subCollection->addPrefix($this->prefix); - - $routeCollection->addCollection($subCollection); - } - } - - foreach ($this->resources as $resource) { - $routeCollection->addResource($resource); - } - - return $routeCollection; - } - - /** - * Generates a route name based on details of this route. - * - * @return string - */ - private function generateRouteName(Route $route) - { - $methods = implode('_', $route->getMethods()).'_'; - - $routeName = $methods.$route->getPath(); - $routeName = str_replace(array('/', ':', '|', '-'), '_', $routeName); - $routeName = preg_replace('/[^a-z0-9A-Z_.]+/', '', $routeName); - - // Collapse consecutive underscores down into a single underscore. - $routeName = preg_replace('/_+/', '_', $routeName); - - return $routeName; - } - - /** - * Finds a loader able to load an imported resource and loads it. - * - * @param mixed $resource A resource - * @param string|null $type The resource type or null if unknown - * - * @return RouteCollection[] - * - * @throws FileLoaderLoadException If no loader is found - */ - private function load($resource, $type = null) - { - if (null === $this->loader) { - throw new \BadMethodCallException('Cannot import other routing resources: you must pass a LoaderInterface when constructing RouteCollectionBuilder.'); - } - - if ($this->loader->supports($resource, $type)) { - $collections = $this->loader->load($resource, $type); - - return is_array($collections) ? $collections : array($collections); - } - - if (null === $resolver = $this->loader->getResolver()) { - throw new FileLoaderLoadException($resource, null, null, null, $type); - } - - if (false === $loader = $resolver->resolve($resource, $type)) { - throw new FileLoaderLoadException($resource, null, null, null, $type); - } - - $collections = $loader->load($resource, $type); - - return is_array($collections) ? $collections : array($collections); - } -} diff --git a/lib/silex/vendor/symfony/routing/RouteCompiler.php b/lib/silex/vendor/symfony/routing/RouteCompiler.php deleted file mode 100644 index 9b5526f31..000000000 --- a/lib/silex/vendor/symfony/routing/RouteCompiler.php +++ /dev/null @@ -1,316 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * RouteCompiler compiles Route instances to CompiledRoute instances. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -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 = '/,;.:-_~+*=@|'; - - /** - * The maximum supported length of a PCRE subpattern name - * http://pcre.org/current/doc/html/pcre2pattern.html#SEC16. - * - * @internal - */ - const VARIABLE_MAXIMUM_LENGTH = 32; - - /** - * {@inheritdoc} - * - * @throws \InvalidArgumentException if a path variable is named _fragment - * @throws \LogicException if a variable is referenced more than once - * @throws \DomainException if a variable name starts with a digit or if it is too long to be successfully used as - * a PCRE subpattern - */ - public static function compile(Route $route) - { - $hostVariables = array(); - $variables = array(); - $hostRegex = null; - $hostTokens = array(); - - if ('' !== $host = $route->getHost()) { - $result = self::compilePattern($route, $host, true); - - $hostVariables = $result['variables']; - $variables = $hostVariables; - - $hostTokens = $result['tokens']; - $hostRegex = $result['regex']; - } - - $path = $route->getPath(); - - $result = self::compilePattern($route, $path, false); - - $staticPrefix = $result['staticPrefix']; - - $pathVariables = $result['variables']; - - foreach ($pathVariables as $pathParam) { - if ('_fragment' === $pathParam) { - throw new \InvalidArgumentException(sprintf('Route pattern "%s" cannot contain "_fragment" as a path parameter.', $route->getPath())); - } - } - - $variables = array_merge($variables, $pathVariables); - - $tokens = $result['tokens']; - $regex = $result['regex']; - - return new CompiledRoute( - $staticPrefix, - $regex, - $tokens, - $pathVariables, - $hostRegex, - $hostTokens, - $hostVariables, - array_unique($variables) - ); - } - - private static function compilePattern(Route $route, $pattern, $isHost) - { - $tokens = array(); - $variables = array(); - $matches = array(); - $pos = 0; - $defaultSeparator = $isHost ? '.' : '/'; - $useUtf8 = preg_match('//u', $pattern); - $needsUtf8 = $route->getOption('utf8'); - - if (!$needsUtf8 && $useUtf8 && preg_match('/[\x80-\xFF]/', $pattern)) { - $needsUtf8 = true; - @trigger_error(sprintf('Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "%s".', $pattern), E_USER_DEPRECATED); - } - if (!$useUtf8 && $needsUtf8) { - throw new \LogicException(sprintf('Cannot mix UTF-8 requirements with non-UTF-8 pattern "%s".', $pattern)); - } - - // 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]); - - if (!strlen($precedingText)) { - $precedingChar = ''; - } elseif ($useUtf8) { - preg_match('/.$/u', $precedingText, $precedingChar); - $precedingChar = $precedingChar[0]; - } else { - $precedingChar = substr($precedingText, -1); - } - $isSeparator = '' !== $precedingChar && false !== strpos(static::SEPARATORS, $precedingChar); - - // A PCRE subpattern name must start with a non-digit. Also a PHP variable cannot start with a digit so the - // variable would not be usable as a Controller action argument. - if (preg_match('/^\d/', $varName)) { - throw new \DomainException(sprintf('Variable name "%s" cannot start with a digit 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)); - } - - if (strlen($varName) > self::VARIABLE_MAXIMUM_LENGTH) { - throw new \DomainException(sprintf('Variable name "%s" cannot be longer than %s characters in route pattern "%s". Please use a shorter name.', $varName, self::VARIABLE_MAXIMUM_LENGTH, $pattern)); - } - - if ($isSeparator && $precedingText !== $precedingChar) { - $tokens[] = array('text', substr($precedingText, 0, -strlen($precedingChar))); - } elseif (!$isSeparator && strlen($precedingText) > 0) { - $tokens[] = array('text', $precedingText); - } - - $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 = self::findNextSeparator($followingPattern, $useUtf8); - $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 .= '+'; - } - } else { - if (!preg_match('//u', $regexp)) { - $useUtf8 = false; - } elseif (!$needsUtf8 && preg_match('/[\x80-\xFF]|(?= 0; --$i) { - $token = $tokens[$i]; - if ('variable' === $token[0] && $route->hasDefault($token[3])) { - $firstOptional = $i; - } else { - break; - } - } - } - - // compute the matching regexp - $regexp = ''; - for ($i = 0, $nbToken = count($tokens); $i < $nbToken; ++$i) { - $regexp .= self::computeRegexp($tokens, $i, $firstOptional); - } - $regexp = self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : ''); - - // enable Utf8 matching if really required - if ($needsUtf8) { - $regexp .= 'u'; - for ($i = 0, $nbToken = count($tokens); $i < $nbToken; ++$i) { - if ('variable' === $tokens[$i][0]) { - $tokens[$i][] = true; - } - } - } - - return array( - 'staticPrefix' => self::determineStaticPrefix($route, $tokens), - 'regex' => $regexp, - 'tokens' => array_reverse($tokens), - 'variables' => $variables, - ); - } - - /** - * Determines the longest static prefix possible for a route. - * - * @return string The leading static part of a route's path - */ - private static function determineStaticPrefix(Route $route, array $tokens) - { - if ('text' !== $tokens[0][0]) { - return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1]; - } - - $prefix = $tokens[0][1]; - - if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) { - $prefix .= $tokens[1][1]; - } - - return $prefix; - } - - /** - * Returns the next static character in the Route pattern that will serve as a separator. - * - * @param string $pattern The route pattern - * @param bool $useUtf8 Whether the character is encoded in UTF-8 or not - * - * @return string The next static character that functions as separator (or empty string when none available) - */ - private static function findNextSeparator($pattern, $useUtf8) - { - 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 - if ('' === $pattern = preg_replace('#\{\w+\}#', '', $pattern)) { - return ''; - } - if ($useUtf8) { - preg_match('/^./u', $pattern, $pattern); - } - - return 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. - * - * @param array $tokens The route tokens - * @param int $index The index of the current token - * @param int $firstOptional The index of the first optional token - * - * @return string The regexp pattern for a single token - */ - private static function computeRegexp(array $tokens, $index, $firstOptional) - { - $token = $tokens[$index]; - if ('text' === $token[0]) { - // Text tokens - return preg_quote($token[1], self::REGEX_DELIMITER); - } else { - // Variable tokens - if (0 === $index && 0 === $firstOptional) { - // When the only token is an optional variable token, the separator is required - return sprintf('%s(?P<%s>%s)?', preg_quote($token[1], self::REGEX_DELIMITER), $token[3], $token[2]); - } else { - $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 - // matched the optional subpattern is not passed back. - $regexp = "(?:$regexp"; - $nbTokens = count($tokens); - if ($nbTokens - 1 == $index) { - // Close the optional subpatterns - $regexp .= str_repeat(')?', $nbTokens - $firstOptional - (0 === $firstOptional ? 1 : 0)); - } - } - - return $regexp; - } - } - } -} diff --git a/lib/silex/vendor/symfony/routing/RouteCompilerInterface.php b/lib/silex/vendor/symfony/routing/RouteCompilerInterface.php deleted file mode 100644 index ddfa7ca49..000000000 --- a/lib/silex/vendor/symfony/routing/RouteCompilerInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * RouteCompilerInterface is the interface that all RouteCompiler classes must implement. - * - * @author Fabien Potencier - */ -interface RouteCompilerInterface -{ - /** - * Compiles the current route instance. - * - * @return CompiledRoute A CompiledRoute instance - * - * @throws \LogicException If the Route cannot be compiled because the - * path or host pattern is invalid - */ - public static function compile(Route $route); -} diff --git a/lib/silex/vendor/symfony/routing/Router.php b/lib/silex/vendor/symfony/routing/Router.php deleted file mode 100644 index 0de921853..000000000 --- a/lib/silex/vendor/symfony/routing/Router.php +++ /dev/null @@ -1,384 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\ConfigCacheInterface; -use Symfony\Component\Config\ConfigCacheFactoryInterface; -use Symfony\Component\Config\ConfigCacheFactory; -use Psr\Log\LoggerInterface; -use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\Generator\Dumper\GeneratorDumperInterface; -use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; -use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; - -/** - * The Router class is an example of the integration of all pieces of the - * routing system for easier use. - * - * @author Fabien Potencier - */ -class Router implements RouterInterface, RequestMatcherInterface -{ - /** - * @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; - - /** - * @var array - */ - protected $options = array(); - - /** - * @var LoggerInterface|null - */ - protected $logger; - - /** - * @var ConfigCacheFactoryInterface|null - */ - private $configCacheFactory; - - /** - * @var ExpressionFunctionProviderInterface[] - */ - private $expressionLanguageProviders = array(); - - /** - * @param LoaderInterface $loader A LoaderInterface instance - * @param mixed $resource The main resource to load - * @param array $options An array of options - * @param RequestContext $context The context - * @param LoggerInterface $logger A logger instance - */ - public function __construct(LoaderInterface $loader, $resource, array $options = array(), RequestContext $context = null, LoggerInterface $logger = null) - { - $this->loader = $loader; - $this->resource = $resource; - $this->logger = $logger; - $this->context = $context ?: new RequestContext(); - $this->setOptions($options); - } - - /** - * Sets options. - * - * Available options: - * - * * cache_dir: The cache directory (or null to disable caching) - * * debug: Whether to enable debugging or not (false by default) - * * generator_class: The name of a UrlGeneratorInterface implementation - * * generator_base_class: The base class for the dumped generator class - * * generator_cache_class: The class name for the dumped generator class - * * generator_dumper_class: The name of a GeneratorDumperInterface implementation - * * matcher_class: The name of a UrlMatcherInterface implementation - * * matcher_base_class: The base class for the dumped matcher class - * * matcher_dumper_class: The class name for the dumped matcher class - * * matcher_cache_class: The name of a MatcherDumperInterface implementation - * * resource_type: Type hint for the main resource (optional) - * * strict_requirements: Configure strict requirement checking for generators - * implementing ConfigurableRequirementsInterface (default is true) - * - * @param array $options An array of options - * - * @throws \InvalidArgumentException When unsupported option is provided - */ - public function setOptions(array $options) - { - $this->options = array( - 'cache_dir' => null, - 'debug' => false, - 'generator_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', - 'generator_base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', - 'generator_dumper_class' => 'Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper', - 'generator_cache_class' => 'ProjectUrlGenerator', - 'matcher_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', - 'matcher_base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', - 'matcher_dumper_class' => 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper', - 'matcher_cache_class' => 'ProjectUrlMatcher', - 'resource_type' => null, - 'strict_requirements' => true, - ); - - // check option names and live merge, if errors are encountered Exception will be thrown - $invalid = array(); - foreach ($options as $key => $value) { - if (array_key_exists($key, $this->options)) { - $this->options[$key] = $value; - } else { - $invalid[] = $key; - } - } - - if ($invalid) { - throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('", "', $invalid))); - } - } - - /** - * Sets an option. - * - * @param string $key The key - * @param mixed $value The value - * - * @throws \InvalidArgumentException - */ - public function setOption($key, $value) - { - if (!array_key_exists($key, $this->options)) { - throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key)); - } - - $this->options[$key] = $value; - } - - /** - * Gets an option value. - * - * @param string $key The key - * - * @return mixed The value - * - * @throws \InvalidArgumentException - */ - public function getOption($key) - { - if (!array_key_exists($key, $this->options)) { - throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key)); - } - - return $this->options[$key]; - } - - /** - * {@inheritdoc} - */ - public function getRouteCollection() - { - if (null === $this->collection) { - $this->collection = $this->loader->load($this->resource, $this->options['resource_type']); - } - - return $this->collection; - } - - /** - * {@inheritdoc} - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - - if (null !== $this->matcher) { - $this->getMatcher()->setContext($context); - } - if (null !== $this->generator) { - $this->getGenerator()->setContext($context); - } - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - return $this->context; - } - - /** - * Sets the ConfigCache factory to use. - */ - public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory) - { - $this->configCacheFactory = $configCacheFactory; - } - - /** - * {@inheritdoc} - */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) - { - return $this->getGenerator()->generate($name, $parameters, $referenceType); - } - - /** - * {@inheritdoc} - */ - public function match($pathinfo) - { - return $this->getMatcher()->match($pathinfo); - } - - /** - * {@inheritdoc} - */ - public function matchRequest(Request $request) - { - $matcher = $this->getMatcher(); - if (!$matcher instanceof RequestMatcherInterface) { - // fallback to the default UrlMatcherInterface - return $matcher->match($request->getPathInfo()); - } - - return $matcher->matchRequest($request); - } - - /** - * Gets the UrlMatcher instance associated with this Router. - * - * @return UrlMatcherInterface A UrlMatcherInterface instance - */ - public function getMatcher() - { - if (null !== $this->matcher) { - return $this->matcher; - } - - if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) { - $this->matcher = new $this->options['matcher_class']($this->getRouteCollection(), $this->context); - if (method_exists($this->matcher, 'addExpressionLanguageProvider')) { - foreach ($this->expressionLanguageProviders as $provider) { - $this->matcher->addExpressionLanguageProvider($provider); - } - } - - return $this->matcher; - } - - $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/'.$this->options['matcher_cache_class'].'.php', - function (ConfigCacheInterface $cache) { - $dumper = $this->getMatcherDumperInstance(); - if (method_exists($dumper, 'addExpressionLanguageProvider')) { - foreach ($this->expressionLanguageProviders as $provider) { - $dumper->addExpressionLanguageProvider($provider); - } - } - - $options = array( - 'class' => $this->options['matcher_cache_class'], - 'base_class' => $this->options['matcher_base_class'], - ); - - $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources()); - } - ); - - require_once $cache->getPath(); - - return $this->matcher = new $this->options['matcher_cache_class']($this->context); - } - - /** - * Gets the UrlGenerator instance associated with this Router. - * - * @return UrlGeneratorInterface A UrlGeneratorInterface instance - */ - public function getGenerator() - { - if (null !== $this->generator) { - return $this->generator; - } - - if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) { - $this->generator = new $this->options['generator_class']($this->getRouteCollection(), $this->context, $this->logger); - } else { - $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/'.$this->options['generator_cache_class'].'.php', - function (ConfigCacheInterface $cache) { - $dumper = $this->getGeneratorDumperInstance(); - - $options = array( - 'class' => $this->options['generator_cache_class'], - 'base_class' => $this->options['generator_base_class'], - ); - - $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources()); - } - ); - - require_once $cache->getPath(); - - $this->generator = new $this->options['generator_cache_class']($this->context, $this->logger); - } - - if ($this->generator instanceof ConfigurableRequirementsInterface) { - $this->generator->setStrictRequirements($this->options['strict_requirements']); - } - - return $this->generator; - } - - public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) - { - $this->expressionLanguageProviders[] = $provider; - } - - /** - * @return GeneratorDumperInterface - */ - protected function getGeneratorDumperInstance() - { - return new $this->options['generator_dumper_class']($this->getRouteCollection()); - } - - /** - * @return MatcherDumperInterface - */ - protected function getMatcherDumperInstance() - { - return new $this->options['matcher_dumper_class']($this->getRouteCollection()); - } - - /** - * Provides the ConfigCache factory implementation, falling back to a - * default implementation if necessary. - * - * @return ConfigCacheFactoryInterface $configCacheFactory - */ - private function getConfigCacheFactory() - { - if (null === $this->configCacheFactory) { - $this->configCacheFactory = new ConfigCacheFactory($this->options['debug']); - } - - return $this->configCacheFactory; - } -} diff --git a/lib/silex/vendor/symfony/routing/RouterInterface.php b/lib/silex/vendor/symfony/routing/RouterInterface.php deleted file mode 100644 index a10ae34e0..000000000 --- a/lib/silex/vendor/symfony/routing/RouterInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; - -/** - * RouterInterface is the interface that all Router classes must implement. - * - * This interface is the concatenation of UrlMatcherInterface and UrlGeneratorInterface. - * - * @author Fabien Potencier - */ -interface RouterInterface extends UrlMatcherInterface, UrlGeneratorInterface -{ - /** - * Gets the RouteCollection instance associated with this Router. - * - * @return RouteCollection A RouteCollection instance - */ - public function getRouteCollection(); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/.gitignore b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php deleted file mode 100644 index bea53a7cf..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php +++ /dev/null @@ -1,162 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Annotation; - -/** - * Annotation class for @Route(). - * - * @Annotation - * @Target({"CLASS", "METHOD"}) - * - * @author Fabien Potencier - */ -class Route -{ - private $path; - private $name; - private $requirements = array(); - private $options = array(); - private $defaults = array(); - private $host; - private $methods = array(); - private $schemes = array(); - private $condition; - - /** - * Constructor. - * - * @param array $data An array of key/value parameters. - * - * @throws \BadMethodCallException - */ - public function __construct(array $data) - { - if (isset($data['value'])) { - $data['path'] = $data['value']; - unset($data['value']); - } - - foreach ($data as $key => $value) { - $method = 'set'.str_replace('_', '', $key); - if (!method_exists($this, $method)) { - throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, get_class($this))); - } - $this->$method($value); - } - } - - /** - * @deprecated Deprecated in 2.2, to be removed in 3.0. Use setPath instead. - */ - public function setPattern($pattern) - { - $this->path = $pattern; - } - - /** - * @deprecated Deprecated in 2.2, to be removed in 3.0. Use getPath instead. - */ - public function getPattern() - { - return $this->path; - } - - public function setPath($path) - { - $this->path = $path; - } - - public function getPath() - { - return $this->path; - } - - public function setHost($pattern) - { - $this->host = $pattern; - } - - public function getHost() - { - return $this->host; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getName() - { - return $this->name; - } - - public function setRequirements($requirements) - { - $this->requirements = $requirements; - } - - public function getRequirements() - { - return $this->requirements; - } - - public function setOptions($options) - { - $this->options = $options; - } - - public function getOptions() - { - return $this->options; - } - - public function setDefaults($defaults) - { - $this->defaults = $defaults; - } - - public function getDefaults() - { - return $this->defaults; - } - - public function setSchemes($schemes) - { - $this->schemes = is_array($schemes) ? $schemes : array($schemes); - } - - public function getSchemes() - { - return $this->schemes; - } - - public function setMethods($methods) - { - $this->methods = is_array($methods) ? $methods : array($methods); - } - - public function getMethods() - { - return $this->methods; - } - - public function setCondition($condition) - { - $this->condition = $condition; - } - - public function getCondition() - { - return $this->condition; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md deleted file mode 100644 index b5fd9db94..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md +++ /dev/null @@ -1,177 +0,0 @@ -CHANGELOG -========= - -2.5.0 ------ - - * [DEPRECATION] The `ApacheMatcherDumper` and `ApacheUrlMatcher` were deprecated and - will be removed in Symfony 3.0, since the performance gains were minimal and - it's hard to replicate the behaviour of PHP implementation. - -2.3.0 ------ - - * added RequestContext::getQueryString() - -2.2.0 ------ - - * [DEPRECATION] Several route settings have been renamed (the old ones will be removed in 3.0): - - * The `pattern` setting for a route has been deprecated in favor of `path` - * The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings - - Before: - - ```yaml - article_edit: - pattern: /article/{id} - requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' } - ``` - - ```xml - - POST|PUT - https - \d+ - - ``` - - ```php - $route = new Route(); - $route->setPattern('/article/{id}'); - $route->setRequirement('_method', 'POST|PUT'); - $route->setRequirement('_scheme', 'https'); - ``` - - After: - - ```yaml - article_edit: - path: /article/{id} - methods: [POST, PUT] - schemes: https - requirements: { 'id': '\d+' } - ``` - - ```xml - - \d+ - - ``` - - ```php - $route = new Route(); - $route->setPath('/article/{id}'); - $route->setMethods(array('POST', 'PUT')); - $route->setSchemes('https'); - ``` - - * [BC BREAK] RouteCollection does not behave like a tree structure anymore but as - a flat array of Routes. So when using PHP to build the RouteCollection, you must - make sure to add routes to the sub-collection before adding it to the parent - collection (this is not relevant when using YAML or XML for Route definitions). - - Before: - - ```php - $rootCollection = new RouteCollection(); - $subCollection = new RouteCollection(); - $rootCollection->addCollection($subCollection); - $subCollection->add('foo', new Route('/foo')); - ``` - - After: - - ```php - $rootCollection = new RouteCollection(); - $subCollection = new RouteCollection(); - $subCollection->add('foo', new Route('/foo')); - $rootCollection->addCollection($subCollection); - ``` - - Also one must call `addCollection` from the bottom to the top hierarchy. - So the correct sequence is the following (and not the reverse): - - ```php - $childCollection->addCollection($grandchildCollection); - $rootCollection->addCollection($childCollection); - ``` - - * [DEPRECATION] The methods `RouteCollection::getParent()` and `RouteCollection::getRoot()` - have been deprecated and will be removed in Symfony 2.3. - * [BC BREAK] Misusing the `RouteCollection::addPrefix` method to add defaults, requirements - or options without adding a prefix is not supported anymore. So if you called `addPrefix` - with an empty prefix or `/` only (both have no relevance), like - `addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)` - you need to use the new dedicated methods `addDefaults($defaultsArray)`, - `addRequirements($requirementsArray)` or `addOptions($optionsArray)` instead. - * [DEPRECATION] The `$options` parameter to `RouteCollection::addPrefix()` has been deprecated - because adding options has nothing to do with adding a path prefix. If you want to add options - to all child routes of a RouteCollection, you can use `addOptions()`. - * [DEPRECATION] The method `RouteCollection::getPrefix()` has been deprecated - because it suggested that all routes in the collection would have this prefix, which is - not necessarily true. On top of that, since there is no tree structure anymore, this method - is also useless. Don't worry about performance, prefix optimization for matching is still done - in the dumper, which was also improved in 2.2.0 to find even more grouping possibilities. - * [DEPRECATION] `RouteCollection::addCollection(RouteCollection $collection)` should now only be - used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options` - will still work, but have been deprecated. The `addPrefix` method should be used for this - use-case instead. - Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))` - After: - ```php - $collection->addPrefix('/prefix', array(...), array(...)); - $parentCollection->addCollection($collection); - ``` - * 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 possessive 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. - * [BC BREAK] `RouteCompilerInterface::compile(Route $route)` was made static - (only relevant if you implemented your own RouteCompiler). - * Added possibility to generate relative paths and network paths in the UrlGenerator, e.g. - "../parent-file" and "//example.com/dir/file". The third parameter in - `UrlGeneratorInterface::generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)` - now accepts more values and you should use the constants defined in `UrlGeneratorInterface` for - claritiy. The old method calls with a Boolean parameter will continue to work because they - equal the signature using the constants. - -2.1.0 ------ - - * added RequestMatcherInterface - * added RequestContext::fromRequest() - * the UrlMatcher does not throw a \LogicException anymore when the required - scheme is not the current one - * added TraceableUrlMatcher - * added the possibility to define options, default values and requirements - for placeholders in prefix, including imported routes - * added RouterInterface::getRouteCollection - * [BC BREAK] the UrlMatcher urldecodes the route parameters only once, they - were decoded twice before. Note that the `urldecode()` calls have been - changed for a single `rawurldecode()` in order to support `+` for input - paths. - * added RouteCollection::getRoot method to retrieve the root of a - RouteCollection tree - * [BC BREAK] made RouteCollection::setParent private which could not have - been used anyway without creating inconsistencies - * [BC BREAK] RouteCollection::remove also removes a route from parent - collections (not only from its children) - * added ConfigurableRequirementsInterface that allows to disable exceptions - (and generate empty URLs instead) when generating a route with an invalid - parameter value diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php deleted file mode 100644 index 3eca9ecd8..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php +++ /dev/null @@ -1,166 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * CompiledRoutes are returned by the RouteCompiler class. - * - * @author Fabien Potencier - */ -class CompiledRoute implements \Serializable -{ - private $variables; - private $tokens; - private $staticPrefix; - private $regex; - private $pathVariables; - private $hostVariables; - private $hostRegex; - private $hostTokens; - - /** - * 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 $pathVariables An array of path variables - * @param string|null $hostRegex Host regex - * @param array $hostTokens Host tokens - * @param array $hostVariables An array of host variables - * @param array $variables An array of variables (variables defined in the path and in the host patterns) - */ - public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) - { - $this->staticPrefix = (string) $staticPrefix; - $this->regex = $regex; - $this->tokens = $tokens; - $this->pathVariables = $pathVariables; - $this->hostRegex = $hostRegex; - $this->hostTokens = $hostTokens; - $this->hostVariables = $hostVariables; - $this->variables = $variables; - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - return serialize(array( - 'vars' => $this->variables, - 'path_prefix' => $this->staticPrefix, - 'path_regex' => $this->regex, - 'path_tokens' => $this->tokens, - 'path_vars' => $this->pathVariables, - 'host_regex' => $this->hostRegex, - 'host_tokens' => $this->hostTokens, - 'host_vars' => $this->hostVariables, - )); - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - $this->variables = $data['vars']; - $this->staticPrefix = $data['path_prefix']; - $this->regex = $data['path_regex']; - $this->tokens = $data['path_tokens']; - $this->pathVariables = $data['path_vars']; - $this->hostRegex = $data['host_regex']; - $this->hostTokens = $data['host_tokens']; - $this->hostVariables = $data['host_vars']; - } - - /** - * Returns the static prefix. - * - * @return string The static prefix - */ - public function getStaticPrefix() - { - return $this->staticPrefix; - } - - /** - * Returns the regex. - * - * @return string The regex - */ - public function getRegex() - { - return $this->regex; - } - - /** - * Returns the host regex. - * - * @return string|null The host regex or null - */ - public function getHostRegex() - { - return $this->hostRegex; - } - - /** - * Returns the tokens. - * - * @return array The tokens - */ - public function getTokens() - { - return $this->tokens; - } - - /** - * Returns the host tokens. - * - * @return array The tokens - */ - public function getHostTokens() - { - return $this->hostTokens; - } - - /** - * Returns the variables. - * - * @return array The variables - */ - public function getVariables() - { - return $this->variables; - } - - /** - * Returns the path variables. - * - * @return array The variables - */ - public function getPathVariables() - { - return $this->pathVariables; - } - - /** - * Returns the host variables. - * - * @return array The variables - */ - public function getHostVariables() - { - return $this->hostVariables; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ExceptionInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ExceptionInterface.php deleted file mode 100644 index 9fcd2249b..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ExceptionInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * ExceptionInterface. - * - * @author Alexandre Salomé - * - * @api - */ -interface ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/InvalidParameterException.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/InvalidParameterException.php deleted file mode 100644 index ae37c343b..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/InvalidParameterException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * Exception thrown when a parameter is not valid. - * - * @author Alexandre Salomé - * - * @api - */ -class InvalidParameterException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php deleted file mode 100644 index 32f109137..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * The resource was found but the request method is not allowed. - * - * This exception should trigger an HTTP 405 response in your application code. - * - * @author Kris Wallsmith - * - * @api - */ -class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface -{ - /** - * @var array - */ - protected $allowedMethods = array(); - - public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null) - { - $this->allowedMethods = array_map('strtoupper', $allowedMethods); - - parent::__construct($message, $code, $previous); - } - - /** - * Gets the allowed HTTP methods. - * - * @return array - */ - public function getAllowedMethods() - { - return $this->allowedMethods; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php deleted file mode 100644 index 5a523fa55..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * Exception thrown when a route cannot be generated because of missing - * mandatory parameters. - * - * @author Alexandre Salomé - * - * @api - */ -class MissingMandatoryParametersException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ResourceNotFoundException.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ResourceNotFoundException.php deleted file mode 100644 index 362a0d61f..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/ResourceNotFoundException.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * The resource was not found. - * - * This exception should trigger an HTTP 404 response in your application code. - * - * @author Kris Wallsmith - * - * @api - */ -class ResourceNotFoundException extends \RuntimeException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/RouteNotFoundException.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/RouteNotFoundException.php deleted file mode 100644 index 8059e4579..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Exception/RouteNotFoundException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Exception; - -/** - * Exception thrown when a route does not exist. - * - * @author Alexandre Salomé - * - * @api - */ -class RouteNotFoundException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php deleted file mode 100644 index dc97b7e72..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator; - -/** - * 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 a 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 - * @author Tobias Schultze - */ -interface ConfigurableRequirementsInterface -{ - /** - * Enables or disables the exception on incorrect parameters. - * Passing null will deactivate the requirements check completely. - * - * @param bool|null $enabled - */ - public function setStrictRequirements($enabled); - - /** - * Returns whether to throw an exception on incorrect parameters. - * Null means the requirements check is deactivated completely. - * - * @return bool|null - */ - public function isStrictRequirements(); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php deleted file mode 100644 index 4739bd836..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -use Symfony\Component\Routing\RouteCollection; - -/** - * GeneratorDumper is the base class for all built-in generator dumpers. - * - * @author Fabien Potencier - */ -abstract class GeneratorDumper implements GeneratorDumperInterface -{ - /** - * @var RouteCollection - */ - private $routes; - - /** - * Constructor. - * - * @param RouteCollection $routes The RouteCollection to dump - */ - public function __construct(RouteCollection $routes) - { - $this->routes = $routes; - } - - /** - * {@inheritdoc} - */ - public function getRoutes() - { - return $this->routes; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php deleted file mode 100644 index deb0c0a2d..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -use Symfony\Component\Routing\RouteCollection; - -/** - * GeneratorDumperInterface is the interface that all generator dumper classes must implement. - * - * @author Fabien Potencier - * - * @api - */ -interface GeneratorDumperInterface -{ - /** - * Dumps a set of routes to a string representation of executable code - * that can then be used to generate a URL of such a route. - * - * @param array $options An array of options - * - * @return string Executable code - */ - public function dump(array $options = array()); - - /** - * Gets the routes to dump. - * - * @return RouteCollection A RouteCollection instance - */ - public function getRoutes(); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php deleted file mode 100644 index 9b7e4830c..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator\Dumper; - -/** - * PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class PhpGeneratorDumper extends GeneratorDumper -{ - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the generator class - * - * @api - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'class' => 'ProjectUrlGenerator', - 'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', - ), $options); - - return <<generateDeclaredRoutes()}; - - /** - * Constructor. - */ - public function __construct(RequestContext \$context, LoggerInterface \$logger = null) - { - \$this->context = \$context; - \$this->logger = \$logger; - } - -{$this->generateGenerateMethod()} -} - -EOF; - } - - /** - * Generates PHP code representing an array of defined routes - * together with the routes properties (e.g. requirements). - * - * @return string PHP code - */ - private function generateDeclaredRoutes() - { - $routes = "array(\n"; - foreach ($this->getRoutes()->all() as $name => $route) { - $compiledRoute = $route->compile(); - - $properties = array(); - $properties[] = $compiledRoute->getVariables(); - $properties[] = $route->getDefaults(); - $properties[] = $route->getRequirements(); - $properties[] = $compiledRoute->getTokens(); - $properties[] = $compiledRoute->getHostTokens(); - $properties[] = $route->getSchemes(); - - $routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true))); - } - $routes .= ' )'; - - return $routes; - } - - /** - * Generates PHP code representing the `generate` method that implements the UrlGeneratorInterface. - * - * @return string PHP code - */ - private function generateGenerateMethod() - { - return <<doGenerate(\$variables, \$defaults, \$requirements, \$tokens, \$parameters, \$name, \$referenceType, \$hostTokens, \$requiredSchemes); - } -EOF; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php deleted file mode 100644 index 5fe943bdb..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php +++ /dev/null @@ -1,340 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Exception\InvalidParameterException; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; -use Psr\Log\LoggerInterface; - -/** - * UrlGenerator can generate a URL or a path for any route in the RouteCollection - * based on the passed parameters. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface -{ - /** - * @var RouteCollection - */ - protected $routes; - - /** - * @var RequestContext - */ - protected $context; - - /** - * @var bool|null - */ - protected $strictRequirements = true; - - /** - * @var LoggerInterface|null - */ - protected $logger; - - /** - * This array defines the characters (besides alphanumeric ones) that will not be percent-encoded in the path segment of the generated URL. - * - * PHP's rawurlencode() encodes all chars except "a-zA-Z0-9-._~" according to RFC 3986. But we want to allow some chars - * to be used in their literal form (reasons below). Other chars inside the path must of course be encoded, e.g. - * "?" and "#" (would be interpreted wrongly as query and fragment identifier), - * "'" and """ (are used as delimiters in HTML). - */ - protected $decodedChars = array( - // the slash can be used to designate a hierarchical structure and we want allow using it with this meaning - // some webservers don't allow the slash in encoded form in the path for security reasons anyway - // see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss - '%2F' => '/', - // the following chars are general delimiters in the URI specification but have only special meaning in the authority component - // so they can safely be used in the path in unencoded form - '%40' => '@', - '%3A' => ':', - // these chars are only sub-delimiters that have no predefined meaning and can therefore be used literally - // so URI producing applications can use these chars to delimit subcomponents in a path segment without being encoded for better readability - '%3B' => ';', - '%2C' => ',', - '%3D' => '=', - '%2B' => '+', - '%21' => '!', - '%2A' => '*', - '%7C' => '|', - ); - - /** - * Constructor. - * - * @param RouteCollection $routes A RouteCollection instance - * @param RequestContext $context The context - * @param LoggerInterface|null $logger A logger instance - * - * @api - */ - public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null) - { - $this->routes = $routes; - $this->context = $context; - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - return $this->context; - } - - /** - * {@inheritdoc} - */ - public function setStrictRequirements($enabled) - { - $this->strictRequirements = null === $enabled ? null : (bool) $enabled; - } - - /** - * {@inheritdoc} - */ - public function isStrictRequirements() - { - return $this->strictRequirements; - } - - /** - * {@inheritdoc} - */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) - { - if (null === $route = $this->routes->get($name)) { - throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name)); - } - - // 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, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes()); - } - - /** - * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route - * @throws InvalidParameterException When a parameter value for a placeholder is not correct because - * it does not match the requirement - */ - protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array()) - { - $variables = array_flip($variables); - $mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters); - - // all params must be given - if ($diff = array_diff_key($variables, $mergedParams)) { - throw new MissingMandatoryParametersException(sprintf('Some mandatory parameters are missing ("%s") to generate a URL for route "%s".', implode('", "', array_keys($diff)), $name)); - } - - $url = ''; - $optional = true; - foreach ($tokens as $token) { - if ('variable' === $token[0]) { - if (!$optional || !array_key_exists($token[3], $defaults) || null !== $mergedParams[$token[3]] && (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) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]); - if ($this->strictRequirements) { - throw new InvalidParameterException($message); - } - - if ($this->logger) { - $this->logger->error($message); - } - - return; - } - - $url = $token[1].$mergedParams[$token[3]].$url; - $optional = false; - } - } else { - // static text - $url = $token[1].$url; - $optional = false; - } - } - - if ('' === $url) { - $url = '/'; - } - - // the contexts base URL is already encoded (see Symfony\Component\HttpFoundation\Request) - $url = strtr(rawurlencode($url), $this->decodedChars); - - // the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3 - // so we need to encode them as they are not used for this purpose here - // otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route - $url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/')); - if ('/..' === substr($url, -3)) { - $url = substr($url, 0, -2).'%2E%2E'; - } elseif ('/.' === substr($url, -2)) { - $url = substr($url, 0, -1).'%2E'; - } - - $schemeAuthority = ''; - if ($host = $this->context->getHost()) { - $scheme = $this->context->getScheme(); - - if ($requiredSchemes) { - $schemeMatched = false; - foreach ($requiredSchemes as $requiredScheme) { - if ($scheme === $requiredScheme) { - $schemeMatched = true; - - break; - } - } - - if (!$schemeMatched) { - $referenceType = self::ABSOLUTE_URL; - $scheme = current($requiredSchemes); - } - } elseif (isset($requirements['_scheme']) && ($req = strtolower($requirements['_scheme'])) && $scheme !== $req) { - // We do this for BC; to be removed if _scheme is not supported anymore - $referenceType = self::ABSOLUTE_URL; - $scheme = $req; - } - - if ($hostTokens) { - $routeHost = ''; - foreach ($hostTokens as $token) { - if ('variable' === $token[0]) { - if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i', $mergedParams[$token[3]])) { - $message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]); - - if ($this->strictRequirements) { - throw new InvalidParameterException($message); - } - - if ($this->logger) { - $this->logger->error($message); - } - - return; - } - - $routeHost = $token[1].$mergedParams[$token[3]].$routeHost; - } else { - $routeHost = $token[1].$routeHost; - } - } - - if ($routeHost !== $host) { - $host = $routeHost; - if (self::ABSOLUTE_URL !== $referenceType) { - $referenceType = self::NETWORK_PATH; - } - } - } - - if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) { - $port = ''; - if ('http' === $scheme && 80 != $this->context->getHttpPort()) { - $port = ':'.$this->context->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) { - $port = ':'.$this->context->getHttpsPort(); - } - - $schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://"; - $schemeAuthority .= $host.$port; - } - } - - if (self::RELATIVE_PATH === $referenceType) { - $url = self::getRelativePath($this->context->getPathInfo(), $url); - } else { - $url = $schemeAuthority.$this->context->getBaseUrl().$url; - } - - // add a query string if needed - $extra = array_diff_key($parameters, $variables, $defaults); - if ($extra && $query = http_build_query($extra, '', '&')) { - // "/" and "?" can be left decoded for better user experience, see - // http://tools.ietf.org/html/rfc3986#section-3.4 - $url .= '?'.strtr($query, array('%2F' => '/')); - } - - return $url; - } - - /** - * Returns the target path as relative reference from the base path. - * - * Only the URIs path component (no schema, host etc.) is relevant and must be given, starting with a slash. - * Both paths must be absolute and not contain relative parts. - * Relative URLs from one resource to another are useful when generating self-contained downloadable document archives. - * Furthermore, they can be used to reduce the link size in documents. - * - * Example target paths, given a base path of "/a/b/c/d": - * - "/a/b/c/d" -> "" - * - "/a/b/c/" -> "./" - * - "/a/b/" -> "../" - * - "/a/b/c/other" -> "other" - * - "/a/x/y" -> "../../x/y" - * - * @param string $basePath The base path - * @param string $targetPath The target path - * - * @return string The relative target path - */ - public static function getRelativePath($basePath, $targetPath) - { - if ($basePath === $targetPath) { - return ''; - } - - $sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath); - $targetDirs = explode('/', isset($targetPath[0]) && '/' === $targetPath[0] ? substr($targetPath, 1) : $targetPath); - array_pop($sourceDirs); - $targetFile = array_pop($targetDirs); - - foreach ($sourceDirs as $i => $dir) { - if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) { - unset($sourceDirs[$i], $targetDirs[$i]); - } else { - break; - } - } - - $targetDirs[] = $targetFile; - $path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs); - - // A reference to the same base directory or an empty subdirectory must be prefixed with "./". - // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used - // as the first segment of a relative-path reference, as it would be mistaken for a scheme name - // (see http://tools.ietf.org/html/rfc3986#section-4.2). - return '' === $path || '/' === $path[0] - || false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos) - ? "./$path" : $path; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php deleted file mode 100644 index a70c90a62..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Generator; - -use Symfony\Component\Routing\Exception\InvalidParameterException; -use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\RequestContextAwareInterface; - -/** - * UrlGeneratorInterface is the interface that all URL generator classes must implement. - * - * The constants in this interface define the different types of resource references that - * are declared in RFC 3986: http://tools.ietf.org/html/rfc3986 - * We are using the term "URL" instead of "URI" as this is more common in web applications - * and we do not need to distinguish them as the difference is mostly semantical and - * less technical. Generating URIs, i.e. representation-independent resource identifiers, - * is also possible. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -interface UrlGeneratorInterface extends RequestContextAwareInterface -{ - /** - * Generates an absolute URL, e.g. "http://example.com/dir/file". - */ - const ABSOLUTE_URL = true; - - /** - * Generates an absolute path, e.g. "/dir/file". - */ - const ABSOLUTE_PATH = false; - - /** - * Generates a relative path based on the current request path, e.g. "../parent-file". - * - * @see UrlGenerator::getRelativePath() - */ - const RELATIVE_PATH = 'relative'; - - /** - * Generates a network path, e.g. "//example.com/dir/file". - * Such reference reuses the current scheme but specifies the host. - */ - const NETWORK_PATH = 'network'; - - /** - * Generates a URL or path for a specific route based on the given parameters. - * - * Parameters that reference placeholders in the route pattern will substitute them in the - * path or host. Extra params are added as query string to the URL. - * - * When the passed reference type cannot be generated for the route because it requires a different - * host or scheme than the current one, the method will return a more comprehensive reference - * that includes the required params. For example, when you call this method with $referenceType = ABSOLUTE_PATH - * but the route requires the https scheme whereas the current scheme is http, it will instead return an - * ABSOLUTE_URL with the https scheme and the current host. This makes sure the generated URL matches - * the route in any case. - * - * If there is no route with the given name, the generator must throw the RouteNotFoundException. - * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters - * @param bool|string $referenceType The type of reference to be generated (one of the constants) - * - * @return string The generated URL - * - * @throws RouteNotFoundException If the named route doesn't exist - * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route - * @throws InvalidParameterException When a parameter value for a placeholder is not correct because - * it does not match the requirement - * - * @api - */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/LICENSE b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/LICENSE deleted file mode 100644 index 43028bc60..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php deleted file mode 100644 index 757542740..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ /dev/null @@ -1,268 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Doctrine\Common\Annotations\Reader; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Loader\LoaderResolverInterface; - -/** - * AnnotationClassLoader loads routing information from a PHP class and its methods. - * - * You need to define an implementation for the getRouteDefaults() method. Most of the - * time, this method should define some PHP callable to be called for the route - * (a controller in MVC speak). - * - * The @Route annotation can be set on the class (for global parameters), - * and on each method. - * - * The @Route annotation main value is the route path. The annotation also - * recognizes several parameters: requirements, options, defaults, schemes, - * methods, host, and name. The name parameter is mandatory. - * Here is an example of how you should be able to use it: - * - * /** - * * @Route("/Blog") - * * / - * class Blog - * { - * /** - * * @Route("/", name="blog_index") - * * / - * public function index() - * { - * } - * - * /** - * * @Route("/{id}", name="blog_post", requirements = {"id" = "\d+"}) - * * / - * public function show() - * { - * } - * } - * - * @author Fabien Potencier - */ -abstract class AnnotationClassLoader implements LoaderInterface -{ - /** - * @var Reader - */ - protected $reader; - - /** - * @var string - */ - protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route'; - - /** - * @var int - */ - protected $defaultRouteIndex = 0; - - /** - * Constructor. - * - * @param Reader $reader - */ - public function __construct(Reader $reader) - { - $this->reader = $reader; - } - - /** - * Sets the annotation class to read route properties from. - * - * @param string $class A fully-qualified class name - */ - public function setRouteAnnotationClass($class) - { - $this->routeAnnotationClass = $class; - } - - /** - * Loads from annotations from a class. - * - * @param string $class A class name - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When route can't be parsed - */ - public function load($class, $type = null) - { - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); - } - - $class = new \ReflectionClass($class); - if ($class->isAbstract()) { - throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class)); - } - - $globals = $this->getGlobals($class); - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($class->getFileName())); - - foreach ($class->getMethods() as $method) { - $this->defaultRouteIndex = 0; - foreach ($this->reader->getMethodAnnotations($method) as $annot) { - if ($annot instanceof $this->routeAnnotationClass) { - $this->addRoute($collection, $annot, $globals, $class, $method); - } - } - } - - return $collection; - } - - protected function addRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method) - { - $name = $annot->getName(); - if (null === $name) { - $name = $this->getDefaultRouteName($class, $method); - } - - $defaults = array_replace($globals['defaults'], $annot->getDefaults()); - foreach ($method->getParameters() as $param) { - if (!isset($defaults[$param->getName()]) && $param->isOptional()) { - $defaults[$param->getName()] = $param->getDefaultValue(); - } - } - $requirements = array_replace($globals['requirements'], $annot->getRequirements()); - $options = array_replace($globals['options'], $annot->getOptions()); - $schemes = array_replace($globals['schemes'], $annot->getSchemes()); - $methods = array_replace($globals['methods'], $annot->getMethods()); - - $host = $annot->getHost(); - if (null === $host) { - $host = $globals['host']; - } - - $condition = $annot->getCondition(); - if (null === $condition) { - $condition = $globals['condition']; - } - - $route = $this->createRoute($globals['path'].$annot->getPath(), $defaults, $requirements, $options, $host, $schemes, $methods, $condition); - - $this->configureRoute($route, $class, $method, $annot); - - $collection->add($name, $route); - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type); - } - - /** - * {@inheritdoc} - */ - public function setResolver(LoaderResolverInterface $resolver) - { - } - - /** - * {@inheritdoc} - */ - public function getResolver() - { - } - - /** - * Gets the default route name for a class method. - * - * @param \ReflectionClass $class - * @param \ReflectionMethod $method - * - * @return string - */ - protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) - { - $name = strtolower(str_replace('\\', '_', $class->name).'_'.$method->name); - if ($this->defaultRouteIndex > 0) { - $name .= '_'.$this->defaultRouteIndex; - } - ++$this->defaultRouteIndex; - - return $name; - } - - protected function getGlobals(\ReflectionClass $class) - { - $globals = array( - 'path' => '', - 'requirements' => array(), - 'options' => array(), - 'defaults' => array(), - 'schemes' => array(), - 'methods' => array(), - 'host' => '', - 'condition' => '', - ); - - if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { - // for BC reasons - if (null !== $annot->getPath()) { - $globals['path'] = $annot->getPath(); - } elseif (null !== $annot->getPattern()) { - $globals['path'] = $annot->getPattern(); - } - - if (null !== $annot->getRequirements()) { - $globals['requirements'] = $annot->getRequirements(); - } - - if (null !== $annot->getOptions()) { - $globals['options'] = $annot->getOptions(); - } - - if (null !== $annot->getDefaults()) { - $globals['defaults'] = $annot->getDefaults(); - } - - if (null !== $annot->getSchemes()) { - $globals['schemes'] = $annot->getSchemes(); - } - - if (null !== $annot->getMethods()) { - $globals['methods'] = $annot->getMethods(); - } - - if (null !== $annot->getHost()) { - $globals['host'] = $annot->getHost(); - } - - if (null !== $annot->getCondition()) { - $globals['condition'] = $annot->getCondition(); - } - } - - return $globals; - } - - protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition) - { - return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition); - } - - abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php deleted file mode 100644 index abd68ed6c..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Resource\DirectoryResource; - -/** - * AnnotationDirectoryLoader loads routing information from annotations set - * on PHP classes and methods. - * - * @author Fabien Potencier - */ -class AnnotationDirectoryLoader extends AnnotationFileLoader -{ - /** - * Loads from annotations from a directory. - * - * @param string $path A directory path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed - */ - public function load($path, $type = null) - { - $dir = $this->locator->locate($path); - - $collection = new RouteCollection(); - $collection->addResource(new DirectoryResource($dir, '/\.php$/')); - $files = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY)); - usort($files, function (\SplFileInfo $a, \SplFileInfo $b) { - return (string) $a > (string) $b ? 1 : -1; - }); - - foreach ($files as $file) { - if (!$file->isFile() || '.php' !== substr($file->getFilename(), -4)) { - continue; - } - - if ($class = $this->findClass($file)) { - $refl = new \ReflectionClass($class); - if ($refl->isAbstract()) { - continue; - } - - $collection->addCollection($this->loader->load($class, $type)); - } - } - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - try { - $path = $this->locator->locate($resource); - } catch (\Exception $e) { - return false; - } - - return is_string($resource) && is_dir($path) && (!$type || 'annotation' === $type); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php deleted file mode 100644 index 8ce57ac18..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\FileLocatorInterface; - -/** - * AnnotationFileLoader loads routing information from annotations set - * on a PHP class and its methods. - * - * @author Fabien Potencier - */ -class AnnotationFileLoader extends FileLoader -{ - protected $loader; - - /** - * Constructor. - * - * @param FileLocatorInterface $locator A FileLocator instance - * @param AnnotationClassLoader $loader An AnnotationClassLoader instance - * - * @throws \RuntimeException - */ - public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader) - { - if (!function_exists('token_get_all')) { - throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.'); - } - - parent::__construct($locator); - - $this->loader = $loader; - } - - /** - * Loads from annotations from a file. - * - * @param string $file A PHP file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $collection = new RouteCollection(); - if ($class = $this->findClass($path)) { - $collection->addResource(new FileResource($path)); - $collection->addCollection($this->loader->load($class, $type)); - } - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type); - } - - /** - * Returns the full class name for the first class in the file. - * - * @param string $file A PHP file path - * - * @return string|false Full class name if found, false otherwise - */ - protected function findClass($file) - { - $class = false; - $namespace = false; - $tokens = token_get_all(file_get_contents($file)); - for ($i = 0, $count = count($tokens); $i < $count; ++$i) { - $token = $tokens[$i]; - - if (!is_array($token)) { - continue; - } - - if (true === $class && T_STRING === $token[0]) { - return $namespace.'\\'.$token[1]; - } - - if (true === $namespace && T_STRING === $token[0]) { - $namespace = ''; - do { - $namespace .= $token[1]; - $token = $tokens[++$i]; - } while ($i < $count && is_array($token) && in_array($token[0], array(T_NS_SEPARATOR, T_STRING))); - } - - if (T_CLASS === $token[0]) { - $class = true; - } - - if (T_NAMESPACE === $token[0]) { - $namespace = true; - } - } - - return false; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php deleted file mode 100644 index 9edab1e9e..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Config\Loader\Loader; -use Symfony\Component\Routing\RouteCollection; - -/** - * ClosureLoader loads routes from a PHP closure. - * - * The Closure must return a RouteCollection instance. - * - * @author Fabien Potencier - * - * @api - */ -class ClosureLoader extends Loader -{ - /** - * Loads a Closure. - * - * @param \Closure $closure A Closure - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @api - */ - public function load($closure, $type = null) - { - return $closure(); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function supports($resource, $type = null) - { - return $resource instanceof \Closure && (!$type || 'closure' === $type); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php deleted file mode 100644 index d1970e52d..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\RouteCollection; - -/** - * PhpFileLoader loads routes from a PHP file. - * - * The file must return a RouteCollection instance. - * - * @author Fabien Potencier - * - * @api - */ -class PhpFileLoader extends FileLoader -{ - /** - * Loads a PHP file. - * - * @param string $file A PHP file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @api - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - $this->setCurrentDir(dirname($path)); - - $collection = self::includeFile($path, $this); - $collection->addResource(new FileResource($path)); - - return $collection; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type); - } - - /** - * Safe include. Used for scope isolation. - * - * @param string $file File to include - * @param PhpFileLoader $loader the loader variable is exposed to the included file below - * - * @return RouteCollection - */ - private static function includeFile($file, PhpFileLoader $loader) - { - return include $file; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php deleted file mode 100644 index 8a95f5128..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ /dev/null @@ -1,256 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Loader\FileLoader; -use Symfony\Component\Config\Util\XmlUtils; - -/** - * XmlFileLoader loads XML routing files. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class XmlFileLoader extends FileLoader -{ - const NAMESPACE_URI = 'http://symfony.com/schema/routing'; - const SCHEME_PATH = '/schema/routing/routing-1.0.xsd'; - - /** - * Loads an XML file. - * - * @param string $file An XML file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When the file cannot be loaded or when the XML cannot be - * parsed because it does not validate against the scheme. - * - * @api - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - $xml = $this->loadFile($path); - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($path)); - - // process routes and imports - foreach ($xml->documentElement->childNodes as $node) { - if (!$node instanceof \DOMElement) { - continue; - } - - $this->parseNode($collection, $node, $path, $file); - } - - return $collection; - } - - /** - * Parses a node from a loaded XML file. - * - * @param RouteCollection $collection Collection to associate with the node - * @param \DOMElement $node Element to parse - * @param string $path Full path of the XML file being processed - * @param string $file Loaded file name - * - * @throws \InvalidArgumentException When the XML is invalid - */ - protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file) - { - if (self::NAMESPACE_URI !== $node->namespaceURI) { - return; - } - - switch ($node->localName) { - case 'route': - $this->parseRoute($collection, $node, $path); - break; - case 'import': - $this->parseImport($collection, $node, $path, $file); - break; - default: - throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "route" or "import".', $node->localName, $path)); - } - } - - /** - * {@inheritdoc} - * - * @api - */ - public function supports($resource, $type = null) - { - return is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type); - } - - /** - * Parses a route and adds it to the RouteCollection. - * - * @param RouteCollection $collection RouteCollection instance - * @param \DOMElement $node Element to parse that represents a Route - * @param string $path Full path of the XML file being processed - * - * @throws \InvalidArgumentException When the XML is invalid - */ - protected function parseRoute(RouteCollection $collection, \DOMElement $node, $path) - { - if ('' === ($id = $node->getAttribute('id')) || (!$node->hasAttribute('pattern') && !$node->hasAttribute('path'))) { - throw new \InvalidArgumentException(sprintf('The element in file "%s" must have an "id" and a "path" attribute.', $path)); - } - - if ($node->hasAttribute('pattern')) { - if ($node->hasAttribute('path')) { - throw new \InvalidArgumentException(sprintf('The element in file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path)); - } - - $node->setAttribute('path', $node->getAttribute('pattern')); - $node->removeAttribute('pattern'); - } - - $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY); - $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY); - - list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); - - $route = new Route($node->getAttribute('path'), $defaults, $requirements, $options, $node->getAttribute('host'), $schemes, $methods, $condition); - $collection->add($id, $route); - } - - /** - * Parses an import and adds the routes in the resource to the RouteCollection. - * - * @param RouteCollection $collection RouteCollection instance - * @param \DOMElement $node Element to parse that represents a Route - * @param string $path Full path of the XML file being processed - * @param string $file Loaded file name - * - * @throws \InvalidArgumentException When the XML is invalid - */ - protected function parseImport(RouteCollection $collection, \DOMElement $node, $path, $file) - { - if ('' === $resource = $node->getAttribute('resource')) { - throw new \InvalidArgumentException(sprintf('The element in file "%s" must have a "resource" attribute.', $path)); - } - - $type = $node->getAttribute('type'); - $prefix = $node->getAttribute('prefix'); - $host = $node->hasAttribute('host') ? $node->getAttribute('host') : null; - $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null; - $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null; - - list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path); - - $this->setCurrentDir(dirname($path)); - - $subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file); - /* @var $subCollection RouteCollection */ - $subCollection->addPrefix($prefix); - if (null !== $host) { - $subCollection->setHost($host); - } - if (null !== $condition) { - $subCollection->setCondition($condition); - } - if (null !== $schemes) { - $subCollection->setSchemes($schemes); - } - if (null !== $methods) { - $subCollection->setMethods($methods); - } - $subCollection->addDefaults($defaults); - $subCollection->addRequirements($requirements); - $subCollection->addOptions($options); - - $collection->addCollection($subCollection); - } - - /** - * Loads an XML file. - * - * @param string $file An XML file path - * - * @return \DOMDocument - * - * @throws \InvalidArgumentException When loading of XML file fails because of syntax errors - * or when the XML structure is not as expected by the scheme - - * see validate() - */ - protected function loadFile($file) - { - return XmlUtils::loadFile($file, __DIR__.static::SCHEME_PATH); - } - - /** - * Parses the config elements (default, requirement, option). - * - * @param \DOMElement $node Element to parse that contains the configs - * @param string $path Full path of the XML file being processed - * - * @return array An array with the defaults as first item, requirements as second and options as third. - * - * @throws \InvalidArgumentException When the XML is invalid - */ - private function parseConfigs(\DOMElement $node, $path) - { - $defaults = array(); - $requirements = array(); - $options = array(); - $condition = null; - - foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { - switch ($n->localName) { - case 'default': - if ($this->isElementValueNull($n)) { - $defaults[$n->getAttribute('key')] = null; - } else { - $defaults[$n->getAttribute('key')] = trim($n->textContent); - } - - break; - case 'requirement': - $requirements[$n->getAttribute('key')] = trim($n->textContent); - break; - case 'option': - $options[$n->getAttribute('key')] = trim($n->textContent); - break; - case 'condition': - $condition = trim($n->textContent); - break; - default: - throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "default", "requirement" or "option".', $n->localName, $path)); - } - } - - return array($defaults, $requirements, $options, $condition); - } - - private function isElementValueNull(\DOMElement $element) - { - $namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance'; - - if (!$element->hasAttributeNS($namespaceUri, 'nil')) { - return false; - } - - return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php deleted file mode 100644 index a051851d8..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ /dev/null @@ -1,217 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Yaml\Parser as YamlParser; -use Symfony\Component\Config\Loader\FileLoader; - -/** - * YamlFileLoader loads Yaml routing files. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class YamlFileLoader extends FileLoader -{ - private static $availableKeys = array( - 'resource', 'type', 'prefix', 'pattern', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', - ); - private $yamlParser; - - /** - * Loads a Yaml file. - * - * @param string $file A Yaml file path - * @param string|null $type The resource type - * - * @return RouteCollection A RouteCollection instance - * - * @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid - * - * @api - */ - public function load($file, $type = null) - { - $path = $this->locator->locate($file); - - if (!stream_is_local($path)) { - throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path)); - } - - if (!file_exists($path)) { - throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path)); - } - - if (null === $this->yamlParser) { - $this->yamlParser = new YamlParser(); - } - - $config = $this->yamlParser->parse(file_get_contents($path)); - - $collection = new RouteCollection(); - $collection->addResource(new FileResource($path)); - - // empty file - if (null === $config) { - return $collection; - } - - // not an array - if (!is_array($config)) { - throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path)); - } - - foreach ($config as $name => $config) { - if (isset($config['pattern'])) { - if (isset($config['path'])) { - throw new \InvalidArgumentException(sprintf('The file "%s" cannot define both a "path" and a "pattern" attribute. Use only "path".', $path)); - } - - $config['path'] = $config['pattern']; - unset($config['pattern']); - } - - $this->validate($config, $name, $path); - - if (isset($config['resource'])) { - $this->parseImport($collection, $config, $path, $file); - } else { - $this->parseRoute($collection, $name, $config, $path); - } - } - - return $collection; - } - - /** - * {@inheritdoc} - * - * @api - */ - public function supports($resource, $type = null) - { - return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type); - } - - /** - * Parses a route and adds it to the RouteCollection. - * - * @param RouteCollection $collection A RouteCollection instance - * @param string $name Route name - * @param array $config Route definition - * @param string $path Full path of the YAML file being processed - */ - protected function parseRoute(RouteCollection $collection, $name, array $config, $path) - { - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); - $host = isset($config['host']) ? $config['host'] : ''; - $schemes = isset($config['schemes']) ? $config['schemes'] : array(); - $methods = isset($config['methods']) ? $config['methods'] : array(); - $condition = isset($config['condition']) ? $config['condition'] : null; - - $route = new Route($config['path'], $defaults, $requirements, $options, $host, $schemes, $methods, $condition); - - $collection->add($name, $route); - } - - /** - * Parses an import and adds the routes in the resource to the RouteCollection. - * - * @param RouteCollection $collection A RouteCollection instance - * @param array $config Route definition - * @param string $path Full path of the YAML file being processed - * @param string $file Loaded file name - */ - protected function parseImport(RouteCollection $collection, array $config, $path, $file) - { - $type = isset($config['type']) ? $config['type'] : null; - $prefix = isset($config['prefix']) ? $config['prefix'] : ''; - $defaults = isset($config['defaults']) ? $config['defaults'] : array(); - $requirements = isset($config['requirements']) ? $config['requirements'] : array(); - $options = isset($config['options']) ? $config['options'] : array(); - $host = isset($config['host']) ? $config['host'] : null; - $condition = isset($config['condition']) ? $config['condition'] : null; - $schemes = isset($config['schemes']) ? $config['schemes'] : null; - $methods = isset($config['methods']) ? $config['methods'] : null; - - $this->setCurrentDir(dirname($path)); - - $subCollection = $this->import($config['resource'], $type, false, $file); - /* @var $subCollection RouteCollection */ - $subCollection->addPrefix($prefix); - if (null !== $host) { - $subCollection->setHost($host); - } - if (null !== $condition) { - $subCollection->setCondition($condition); - } - if (null !== $schemes) { - $subCollection->setSchemes($schemes); - } - if (null !== $methods) { - $subCollection->setMethods($methods); - } - $subCollection->addDefaults($defaults); - $subCollection->addRequirements($requirements); - $subCollection->addOptions($options); - - $collection->addCollection($subCollection); - } - - /** - * Validates the route configuration. - * - * @param array $config A resource config - * @param string $name The config key - * @param string $path The loaded file path - * - * @throws \InvalidArgumentException If one of the provided config keys is not supported, - * something is missing or the combination is nonsense - */ - protected function validate($config, $name, $path) - { - if (!is_array($config)) { - throw new \InvalidArgumentException(sprintf('The definition of "%s" in "%s" must be a YAML array.', $name, $path)); - } - if ($extraKeys = array_diff(array_keys($config), self::$availableKeys)) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".', - $path, $name, implode('", "', $extraKeys), implode('", "', self::$availableKeys) - )); - } - if (isset($config['resource']) && isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" must not specify both the "resource" key and the "path" key for "%s". Choose between an import and a route definition.', - $path, $name - )); - } - if (!isset($config['resource']) && isset($config['type'])) { - throw new \InvalidArgumentException(sprintf( - 'The "type" key for the route definition "%s" in "%s" is unsupported. It is only available for imports in combination with the "resource" key.', - $name, $path - )); - } - if (!isset($config['resource']) && !isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'You must define a "path" for the route "%s" in file "%s".', - $name, $path - )); - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd deleted file mode 100644 index d40aa4221..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php deleted file mode 100644 index 12cd3f026..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper). - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * The performance gains are minimal and it's very hard to replicate - * the behavior of PHP implementation. - * - * @author Fabien Potencier - * @author Arnaud Le Blanc - */ -class ApacheUrlMatcher extends UrlMatcher -{ - /** - * Tries to match a URL based on Apache mod_rewrite matching. - * - * Returns false if no route matches the URL. - * - * @param string $pathinfo The pathinfo to be parsed - * - * @return array An array of parameters - * - * @throws MethodNotAllowedException If the current method is not allowed - */ - public function match($pathinfo) - { - $parameters = array(); - $defaults = array(); - $allow = array(); - $route = null; - - foreach ($this->denormalizeValues($_SERVER) as $key => $value) { - $name = $key; - - // 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; - } - - while (0 === strpos($name, 'REDIRECT_')) { - $name = substr($name, 9); - } - - // expect _ROUTING__ - // or _ROUTING_ - - 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; - } - } elseif ('default' === $type) { - $defaults[$name] = $value; - } elseif ('route' === $type) { - $route = $value; - } elseif ('allow' === $type) { - $allow[] = $name; - } - - unset($_SERVER[$key]); - } - - if (null !== $route) { - $parameters['_route'] = $route; - - return $this->mergeDefaults($parameters, $defaults); - } elseif (0 < count($allow)) { - throw new MethodNotAllowedException($allow); - } else { - return parent::match($pathinfo); - } - } - - /** - * Denormalizes an array of values. - * - * @param string[] $values - * - * @return array - */ - private function denormalizeValues(array $values) - { - $normalizedValues = array(); - foreach ($values as $key => $value) { - if (preg_match('~^(.*)\[(\d+)\]$~', $key, $matches)) { - if (!isset($normalizedValues[$matches[1]])) { - $normalizedValues[$matches[1]] = array(); - } - $normalizedValues[$matches[1]][(int) $matches[2]] = $value; - } else { - $normalizedValues[$key] = $value; - } - } - - return $normalizedValues; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php deleted file mode 100644 index b97f9f35c..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ /dev/null @@ -1,281 +0,0 @@ - - * - * 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; - -/** - * Dumps a set of Apache mod_rewrite rules. - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. - * The performance gains are minimal and it's very hard to replicate - * the behavior of PHP implementation. - * - * @author Fabien Potencier - * @author Kris Wallsmith - */ -class ApacheMatcherDumper extends MatcherDumper -{ - /** - * Dumps a set of Apache mod_rewrite rules. - * - * Available options: - * - * * script_name: The script name (app.php by default) - * * base_uri: The base URI ("" by default) - * - * @param array $options An array of options - * - * @return string A string to be used as Apache rewrite rules - * - * @throws \LogicException When the route regex is invalid - */ - public function dump(array $options = array()) - { - $options = array_merge(array( - 'script_name' => 'app.php', - 'base_uri' => '', - ), $options); - - $options['script_name'] = self::escape($options['script_name'], ' ', '\\'); - - $rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]"); - $methodVars = array(); - $hostRegexUnique = 0; - $prevHostRegex = ''; - - foreach ($this->getRoutes()->all() as $name => $route) { - if ($route->getCondition()) { - throw new \LogicException(sprintf('Unable to dump the routes for Apache as route "%s" has a condition.', $name)); - } - - $compiledRoute = $route->compile(); - $hostRegex = $compiledRoute->getHostRegex(); - - if (null !== $hostRegex && $prevHostRegex !== $hostRegex) { - $prevHostRegex = $hostRegex; - ++$hostRegexUnique; - - $rule = array(); - - $regex = $this->regexToApacheRegex($hostRegex); - $regex = self::escape($regex, ' ', '\\'); - - $rule[] = sprintf('RewriteCond %%{HTTP:Host} %s', $regex); - - $variables = array(); - $variables[] = sprintf('E=__ROUTING_host_%s:1', $hostRegexUnique); - - foreach ($compiledRoute->getHostVariables() as $i => $variable) { - $variables[] = sprintf('E=__ROUTING_host_%s_%s:%%%d', $hostRegexUnique, $variable, $i + 1); - } - - $variables = implode(',', $variables); - - $rule[] = sprintf('RewriteRule .? - [%s]', $variables); - - $rules[] = implode("\n", $rule); - } - - $rules[] = $this->dumpRoute($name, $route, $options, $hostRegexUnique); - - 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 %%{ENV:_ROUTING__allow_%s} =1%s', $methodVar, isset($methodVars[$i + 1]) ? ' [OR]' : ''); - } - $rule[] = sprintf('RewriteRule .* %s [QSA,L]', $options['script_name']); - - $rules[] = implode("\n", $rule); - } - - 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 $hostRegexUnique Unique identifier for the host regex - * - * @return string The compiled route - */ - private function dumpRoute($name, $route, array $options, $hostRegexUnique) - { - $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->getHostVariables() as $variable) { - $variables[] = sprintf('E=_ROUTING_param_%s:%%{ENV:__ROUTING_host_%s_%s}', $variable, $hostRegexUnique, $variable); - } - foreach ($compiledRoute->getPathVariables() as $i => $variable) { - $variables[] = 'E=_ROUTING_param_'.$variable.':%'.($i + 1); - } - foreach ($this->normalizeValues($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 ($compiledRoute->getHostRegex()) { - $rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique); - } - - $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 ($compiledRoute->getHostRegex()) { - $rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique); - } - - $rule[] = 'RewriteCond %{REQUEST_URI} '.substr($regex, 0, -2).'$'; - $rule[] = 'RewriteRule .* $0/ [QSA,L,R=301]'; - } - - // the main rule - - if ($compiledRoute->getHostRegex()) { - $rule[] = sprintf('RewriteCond %%{ENV:__ROUTING_host_%s} =1', $hostRegexUnique); - } - - $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. - * - * @param string $string The string to be escaped - * @param string $char The character to be escaped - * @param string $with The character to be used for escaping - * - * @return string The escaped string - */ - private static function escape($string, $char, $with) - { - $escaped = false; - $output = ''; - foreach (str_split($string) as $symbol) { - if ($escaped) { - $output .= $symbol; - $escaped = false; - continue; - } - if ($symbol === $char) { - $output .= $with.$char; - continue; - } - if ($symbol === $with) { - $escaped = true; - } - $output .= $symbol; - } - - return $output; - } - - /** - * Normalizes an array of values. - * - * @param array $values - * - * @return string[] - */ - private function normalizeValues(array $values) - { - $normalizedValues = array(); - foreach ($values as $key => $value) { - if (is_array($value)) { - foreach ($value as $index => $bit) { - $normalizedValues[sprintf('%s[%s]', $key, $index)] = $bit; - } - } else { - $normalizedValues[$key] = (string) $value; - } - } - - return $normalizedValues; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php deleted file mode 100644 index f91df9847..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php +++ /dev/null @@ -1,159 +0,0 @@ - - * - * 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 - */ -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 self) { - $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 self) { - $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 bool 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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php deleted file mode 100644 index 6a615f21a..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * 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 - */ -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 - * - * @throws \LogicException - */ - public function addPrefixRoute(DumperRoute $route) - { - $prefix = $route->getRoute()->compile()->getStaticPrefix(); - - for ($collection = $this; null !== $collection; $collection = $collection->getParent()) { - // Same prefix, add to current leave - if ($collection->prefix === $prefix) { - $collection->add($route); - - return $collection; - } - - // Prefix starts with route's prefix - if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) { - $child = new self(); - $child->setPrefix(substr($prefix, 0, strlen($collection->prefix) + 1)); - $collection->add($child); - - return $child->addPrefixRoute($route); - } - } - - // Reached only if the root has a non empty prefix - throw new \LogicException('The collection root must not have a prefix'); - } - - /** - * 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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php deleted file mode 100644 index 2928cdcc0..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * 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 - */ -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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php deleted file mode 100644 index 52edc017e..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * 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\RouteCollection; - -/** - * MatcherDumper is the abstract class for all built-in matcher dumpers. - * - * @author Fabien Potencier - */ -abstract class MatcherDumper implements MatcherDumperInterface -{ - /** - * @var RouteCollection - */ - private $routes; - - /** - * Constructor. - * - * @param RouteCollection $routes The RouteCollection to dump - */ - public function __construct(RouteCollection $routes) - { - $this->routes = $routes; - } - - /** - * {@inheritdoc} - */ - public function getRoutes() - { - return $this->routes; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php deleted file mode 100644 index 5e7c134b9..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * 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\RouteCollection; - -/** - * MatcherDumperInterface is the interface that all matcher dumper classes must implement. - * - * @author Fabien Potencier - */ -interface MatcherDumperInterface -{ - /** - * Dumps a set of routes to a string representation of executable code - * that can then be used to match a request against these routes. - * - * @param array $options An array of options - * - * @return string Executable code - */ - public function dump(array $options = array()); - - /** - * Gets the routes to dump. - * - * @return RouteCollection A RouteCollection instance - */ - public function getRoutes(); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php deleted file mode 100644 index d507c60ac..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ /dev/null @@ -1,412 +0,0 @@ - - * - * 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; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; - -/** - * PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes. - * - * @author Fabien Potencier - * @author Tobias Schultze - * @author Arnaud Le Blanc - */ -class PhpMatcherDumper extends MatcherDumper -{ - private $expressionLanguage; - - /** - * @var ExpressionFunctionProviderInterface[] - */ - private $expressionLanguageProviders = array(); - - /** - * Dumps a set of routes to a PHP class. - * - * Available options: - * - * * class: The class name - * * base_class: The base class name - * - * @param array $options An array of options - * - * @return string A PHP class representing the matcher class - */ - public function dump(array $options = array()) - { - $options = array_replace(array( - 'class' => 'ProjectUrlMatcher', - 'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', - ), $options); - - // trailing slash support is only enabled if we know how to redirect the user - $interfaces = class_implements($options['base_class']); - $supportsRedirections = isset($interfaces['Symfony\\Component\\Routing\\Matcher\\RedirectableUrlMatcherInterface']); - - return <<context = \$context; - } - -{$this->generateMatchMethod($supportsRedirections)} -} - -EOF; - } - - public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) - { - $this->expressionLanguageProviders[] = $provider; - } - - /** - * Generates the code for the match method implementing UrlMatcherInterface. - * - * @param bool $supportsRedirections Whether redirections are supported by the base class - * - * @return string Match method as PHP code - */ - private function generateMatchMethod($supportsRedirections) - { - $code = rtrim($this->compileRoutes($this->getRoutes(), $supportsRedirections), "\n"); - - return <<context; - \$request = \$this->request; - -$code - - throw 0 < count(\$allow) ? new MethodNotAllowedException(array_unique(\$allow)) : new ResourceNotFoundException(); - } -EOF; - } - - /** - * Generates PHP code to match a RouteCollection with all its routes. - * - * @param RouteCollection $routes A RouteCollection instance - * @param bool $supportsRedirections Whether redirections are supported by the base class - * - * @return string PHP code - */ - private function compileRoutes(RouteCollection $routes, $supportsRedirections) - { - $fetchedHost = false; - - $groups = $this->groupRoutesByHostRegex($routes); - $code = ''; - - foreach ($groups as $collection) { - if (null !== $regex = $collection->getAttribute('host_regex')) { - if (!$fetchedHost) { - $code .= " \$host = \$this->context->getHost();\n\n"; - $fetchedHost = true; - } - - $code .= sprintf(" if (preg_match(%s, \$host, \$hostMatches)) {\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 $code; - } - - /** - * Generates PHP code recursively to match a tree of routes. - * - * @param DumperPrefixCollection $collection A DumperPrefixCollection instance - * @param bool $supportsRedirections Whether redirections are supported by the base class - * @param string $parentPrefix Prefix of the parent collection - * - * @return string PHP code - */ - private function compilePrefixRoutes(DumperPrefixCollection $collection, $supportsRedirections, $parentPrefix = '') - { - $code = ''; - $prefix = $collection->getPrefix(); - $optimizable = 1 < strlen($prefix) && 1 < count($collection->all()); - $optimizedPrefix = $parentPrefix; - - if ($optimizable) { - $optimizedPrefix = $prefix; - - $code .= sprintf(" if (0 === strpos(\$pathinfo, %s)) {\n", var_export($prefix, true)); - } - - 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"; - } - } - - if ($optimizable) { - $code .= " }\n\n"; - // apply extra indention at each line (except empty ones) - $code = preg_replace('/^.{2,}$/m', ' $0', $code); - } - - return $code; - } - - /** - * Compiles a single Route to PHP code used to match it against the path info. - * - * @param Route $route A Route instance - * @param string $name The name of the Route - * @param bool $supportsRedirections Whether redirections are supported by the base class - * @param string|null $parentPrefix The prefix of the parent collection used to optimize the code - * - * @return string PHP code - * - * @throws \LogicException - */ - private function compileRoute(Route $route, $name, $supportsRedirections, $parentPrefix = null) - { - $code = ''; - $compiledRoute = $route->compile(); - $conditions = array(); - $hasTrailingSlash = false; - $matches = false; - $hostMatches = false; - $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'; - } - } - - $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods)); - - if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P.*?)\$\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; - } else { - $conditions[] = sprintf('$pathinfo === %s', var_export(str_replace('\\', '', $m['url']), true)); - } - } else { - if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) { - $conditions[] = sprintf('0 === strpos($pathinfo, %s)', var_export($compiledRoute->getStaticPrefix(), true)); - } - - $regex = $compiledRoute->getRegex(); - if ($supportsTrailingSlash && $pos = strpos($regex, '/$')) { - $regex = substr($regex, 0, $pos).'/?$'.substr($regex, $pos + 2); - $hasTrailingSlash = true; - } - $conditions[] = sprintf('preg_match(%s, $pathinfo, $matches)', var_export($regex, true)); - - $matches = true; - } - - if ($compiledRoute->getHostVariables()) { - $hostMatches = true; - } - - if ($route->getCondition()) { - $conditions[] = $this->getExpressionLanguage()->compile($route->getCondition(), array('context', 'request')); - } - - $conditions = implode(' && ', $conditions); - - $code .= <<context->getMethod() != '$methods[0]') { - \$allow[] = '$methods[0]'; - goto $gotoname; - } - - -EOF; - } else { - $methods = implode("', '", $methods); - $code .= <<context->getMethod(), array('$methods'))) { - \$allow = array_merge(\$allow, array('$methods')); - goto $gotoname; - } - - -EOF; - } - } - - if ($hasTrailingSlash) { - $code .= <<redirect(\$pathinfo.'/', '$name'); - } - - -EOF; - } - - if ($schemes = $route->getSchemes()) { - if (!$supportsRedirections) { - throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); - } - $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); - $code .= <<context->getScheme()])) { - return \$this->redirect(\$pathinfo, '$name', key(\$requiredSchemes)); - } - - -EOF; - } - - // optimize parameters array - if ($matches || $hostMatches) { - $vars = array(); - if ($hostMatches) { - $vars[] = '$hostMatches'; - } - 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_replace($route->getDefaults(), array('_route' => $name)), true))); - } else { - $code .= sprintf(" return array('_route' => '%s');\n", $name); - } - $code .= " }\n"; - - if ($methods) { - $code .= " $gotoname:\n"; - } - - return $code; - } - - /** - * Groups consecutive routes having the same host regex. - * - * The result is a collection of collections of routes having the same host regex. - * - * @param RouteCollection $routes A flat RouteCollection - * - * @return DumperCollection A collection with routes grouped by host regex in sub-collections - */ - private function groupRoutesByHostRegex(RouteCollection $routes) - { - $groups = new DumperCollection(); - - $currentGroup = new DumperCollection(); - $currentGroup->setAttribute('host_regex', null); - $groups->add($currentGroup); - - foreach ($routes as $name => $route) { - $hostRegex = $route->compile()->getHostRegex(); - if ($currentGroup->getAttribute('host_regex') !== $hostRegex) { - $currentGroup = new DumperCollection(); - $currentGroup->setAttribute('host_regex', $hostRegex); - $groups->add($currentGroup); - } - $currentGroup->add(new DumperRoute($name, $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; - } - - private function getExpressionLanguage() - { - if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { - throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); - } - $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); - } - - return $this->expressionLanguage; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php deleted file mode 100644 index 236f55a5a..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Route; - -/** - * @author Fabien Potencier - * - * @api - */ -abstract class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface -{ - /** - * {@inheritdoc} - */ - public function match($pathinfo) - { - try { - $parameters = parent::match($pathinfo); - } catch (ResourceNotFoundException $e) { - if ('/' === substr($pathinfo, -1) || !in_array($this->context->getMethod(), array('HEAD', 'GET'))) { - throw $e; - } - - try { - parent::match($pathinfo.'/'); - - return $this->redirect($pathinfo.'/', null); - } catch (ResourceNotFoundException $e2) { - throw $e; - } - } - - return $parameters; - } - - /** - * {@inheritdoc} - */ - protected function handleRouteRequirements($pathinfo, $name, Route $route) - { - // expression condition - if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) { - return array(self::REQUIREMENT_MISMATCH, null); - } - - // check HTTP scheme requirement - $scheme = $this->context->getScheme(); - $schemes = $route->getSchemes(); - if ($schemes && !$route->hasScheme($scheme)) { - return array(self::ROUTE_MATCH, $this->redirect($pathinfo, $name, current($schemes))); - } - - return array(self::REQUIREMENT_MATCH, null); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php deleted file mode 100644 index ea91e0751..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -/** - * RedirectableUrlMatcherInterface knows how to redirect the user. - * - * @author Fabien Potencier - * - * @api - */ -interface RedirectableUrlMatcherInterface -{ - /** - * Redirects the user to another URL. - * - * @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 - * - * @api - */ - public function redirect($path, $route, $scheme = null); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php deleted file mode 100644 index b5def3d46..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * RequestMatcherInterface is the interface that all request matcher classes must implement. - * - * @author Fabien Potencier - */ -interface RequestMatcherInterface -{ - /** - * Tries to match a request with a set of routes. - * - * If the matcher can not find information, it must throw one of the exceptions documented - * below. - * - * @param Request $request The request to match - * - * @return array An array of parameters - * - * @throws ResourceNotFoundException If no matching resource could be found - * @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed - */ - public function matchRequest(Request $request); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php deleted file mode 100644 index 35296c6c6..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\ExceptionInterface; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -/** - * TraceableUrlMatcher helps debug path info matching by tracing the match. - * - * @author Fabien Potencier - */ -class TraceableUrlMatcher extends UrlMatcher -{ - const ROUTE_DOES_NOT_MATCH = 0; - const ROUTE_ALMOST_MATCHES = 1; - const ROUTE_MATCHES = 2; - - protected $traces; - - public function getTraces($pathinfo) - { - $this->traces = array(); - - try { - $this->match($pathinfo); - } catch (ExceptionInterface $e) { - } - - return $this->traces; - } - - protected function matchCollection($pathinfo, RouteCollection $routes) - { - foreach ($routes as $name => $route) { - $compiledRoute = $route->compile(); - - if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) { - // does it match without any requirements? - $r = new Route($route->getPath(), $route->getDefaults(), array(), $route->getOptions()); - $cr = $r->compile(); - if (!preg_match($cr->getRegex(), $pathinfo)) { - $this->addTrace(sprintf('Path "%s" does not match', $route->getPath()), self::ROUTE_DOES_NOT_MATCH, $name, $route); - - continue; - } - - foreach ($route->getRequirements() as $n => $regex) { - $r = new Route($route->getPath(), $route->getDefaults(), array($n => $regex), $route->getOptions()); - $cr = $r->compile(); - - if (in_array($n, $cr->getVariables()) && !preg_match($cr->getRegex(), $pathinfo)) { - $this->addTrace(sprintf('Requirement for "%s" does not match (%s)', $n, $regex), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue 2; - } - } - - continue; - } - - // check host requirement - $hostMatches = array(); - if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { - $this->addTrace(sprintf('Host "%s" does not match the requirement ("%s")', $this->context->getHost(), $route->getHost()), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue; - } - - // check HTTP method requirement - if ($req = $route->getRequirement('_method')) { - // HEAD and GET are equivalent as per RFC - if ('HEAD' === $method = $this->context->getMethod()) { - $method = 'GET'; - } - - if (!in_array($method, $req = explode('|', strtoupper($req)))) { - $this->allow = array_merge($this->allow, $req); - - $this->addTrace(sprintf('Method "%s" does not match the requirement ("%s")', $this->context->getMethod(), implode(', ', $req)), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue; - } - } - - // check condition - if ($condition = $route->getCondition()) { - if (!$this->getExpressionLanguage()->evaluate($condition, array('context' => $this->context, 'request' => $this->request))) { - $this->addTrace(sprintf('Condition "%s" does not evaluate to "true"', $condition), self::ROUTE_ALMOST_MATCHES, $name, $route); - - continue; - } - } - - // check HTTP scheme requirement - if ($requiredSchemes = $route->getSchemes()) { - $scheme = $this->context->getScheme(); - - if (!$route->hasScheme($scheme)) { - $this->addTrace(sprintf('Scheme "%s" does not match any of the required schemes ("%s"); the user will be redirected to first required scheme', $scheme, implode(', ', $requiredSchemes)), self::ROUTE_ALMOST_MATCHES, $name, $route); - - return true; - } - } - - $this->addTrace('Route matches!', self::ROUTE_MATCHES, $name, $route); - - return true; - } - } - - private function addTrace($log, $level = self::ROUTE_DOES_NOT_MATCH, $name = null, $route = null) - { - $this->traces[] = array( - 'log' => $log, - 'name' => $name, - 'level' => $level, - 'path' => null !== $route ? $route->getPath() : null, - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php deleted file mode 100644 index 3ed5ac7fb..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ /dev/null @@ -1,255 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Route; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; - -/** - * UrlMatcher matches URL based on a set of routes. - * - * @author Fabien Potencier - * - * @api - */ -class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface -{ - const REQUIREMENT_MATCH = 0; - const REQUIREMENT_MISMATCH = 1; - const ROUTE_MATCH = 2; - - /** - * @var RequestContext - */ - protected $context; - - /** - * @var array - */ - protected $allow = array(); - - /** - * @var RouteCollection - */ - protected $routes; - - protected $request; - protected $expressionLanguage; - - /** - * @var ExpressionFunctionProviderInterface[] - */ - protected $expressionLanguageProviders = array(); - - /** - * Constructor. - * - * @param RouteCollection $routes A RouteCollection instance - * @param RequestContext $context The context - * - * @api - */ - public function __construct(RouteCollection $routes, RequestContext $context) - { - $this->routes = $routes; - $this->context = $context; - } - - /** - * {@inheritdoc} - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - return $this->context; - } - - /** - * {@inheritdoc} - */ - public function match($pathinfo) - { - $this->allow = array(); - - if ($ret = $this->matchCollection(rawurldecode($pathinfo), $this->routes)) { - return $ret; - } - - throw 0 < count($this->allow) - ? new MethodNotAllowedException(array_unique(array_map('strtoupper', $this->allow))) - : new ResourceNotFoundException(sprintf('No routes found for "%s".', $pathinfo)); - } - - /** - * {@inheritdoc} - */ - public function matchRequest(Request $request) - { - $this->request = $request; - - $ret = $this->match($request->getPathInfo()); - - $this->request = null; - - return $ret; - } - - public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) - { - $this->expressionLanguageProviders[] = $provider; - } - - /** - * Tries to match a URL with a set of routes. - * - * @param string $pathinfo The path info to be parsed - * @param RouteCollection $routes The set of routes - * - * @return array An array of parameters - * - * @throws ResourceNotFoundException If the resource could not be found - * @throws MethodNotAllowedException If the resource was found but the request method is not allowed - */ - protected function matchCollection($pathinfo, RouteCollection $routes) - { - foreach ($routes as $name => $route) { - $compiledRoute = $route->compile(); - - // check the static prefix of the URL first. Only use the more expensive preg_match when it matches - if ('' !== $compiledRoute->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute->getStaticPrefix())) { - continue; - } - - if (!preg_match($compiledRoute->getRegex(), $pathinfo, $matches)) { - continue; - } - - $hostMatches = array(); - if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { - continue; - } - - // check HTTP method requirement - if ($req = $route->getRequirement('_method')) { - // HEAD and GET are equivalent as per RFC - if ('HEAD' === $method = $this->context->getMethod()) { - $method = 'GET'; - } - - if (!in_array($method, $req = explode('|', strtoupper($req)))) { - $this->allow = array_merge($this->allow, $req); - - continue; - } - } - - $status = $this->handleRouteRequirements($pathinfo, $name, $route); - - if (self::ROUTE_MATCH === $status[0]) { - return $status[1]; - } - - if (self::REQUIREMENT_MISMATCH === $status[0]) { - continue; - } - - return $this->getAttributes($route, $name, array_replace($matches, $hostMatches)); - } - } - - /** - * 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. - * - * @param string $pathinfo The path - * @param string $name The route name - * @param Route $route The route - * - * @return array The first element represents the status, the second contains additional information - */ - protected function handleRouteRequirements($pathinfo, $name, Route $route) - { - // expression condition - if ($route->getCondition() && !$this->getExpressionLanguage()->evaluate($route->getCondition(), array('context' => $this->context, 'request' => $this->request))) { - return array(self::REQUIREMENT_MISMATCH, null); - } - - // check HTTP scheme requirement - $scheme = $this->context->getScheme(); - $status = $route->getSchemes() && !$route->hasScheme($scheme) ? self::REQUIREMENT_MISMATCH : self::REQUIREMENT_MATCH; - - return array($status, null); - } - - /** - * Get merged default parameters. - * - * @param array $params The parameters - * @param array $defaults The defaults - * - * @return array Merged default parameters - */ - protected function mergeDefaults($params, $defaults) - { - foreach ($params as $key => $value) { - if (!is_int($key)) { - $defaults[$key] = $value; - } - } - - return $defaults; - } - - protected function getExpressionLanguage() - { - if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { - throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); - } - $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders); - } - - return $this->expressionLanguage; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php deleted file mode 100644 index dd718b156..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Matcher; - -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - -/** - * UrlMatcherInterface is the interface that all URL matcher classes must implement. - * - * @author Fabien Potencier - * - * @api - */ -interface UrlMatcherInterface extends RequestContextAwareInterface -{ - /** - * Tries to match a URL path with a set of routes. - * - * If the matcher can not find information, it must throw one of the exceptions documented - * below. - * - * @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded) - * - * @return array An array of parameters - * - * @throws ResourceNotFoundException If the resource could not be found - * @throws MethodNotAllowedException If the resource was found but the request method is not allowed - * - * @api - */ - public function match($pathinfo); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/README.md b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/README.md deleted file mode 100644 index 1a94583a8..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/README.md +++ /dev/null @@ -1,36 +0,0 @@ -Routing Component -================= - -Routing associates a request with the code that will convert it to a response. - -The example below demonstrates how you can set up a fully working routing -system: - -```php -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; - -$routes = new RouteCollection(); -$routes->add('hello', new Route('/hello', array('controller' => 'foo'))); - -$context = new RequestContext(); - -// this is optional and can be done without a Request instance -$context->fromRequest(Request::createFromGlobals()); - -$matcher = new UrlMatcher($routes, $context); - -$parameters = $matcher->match('/hello'); -``` - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Routing/ - $ composer install - $ phpunit diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php deleted file mode 100644 index 577d1d030..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContext.php +++ /dev/null @@ -1,364 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Holds information about the current request. - * - * This class implements a fluent interface. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class RequestContext -{ - private $baseUrl; - private $pathInfo; - private $method; - private $host; - private $scheme; - private $httpPort; - private $httpsPort; - private $queryString; - - /** - * @var array - */ - private $parameters = array(); - - /** - * Constructor. - * - * @param string $baseUrl The base URL - * @param string $method The HTTP method - * @param string $host The HTTP host name - * @param string $scheme The HTTP scheme - * @param int $httpPort The HTTP port - * @param int $httpsPort The HTTPS port - * @param string $path The path - * @param string $queryString The query string - * - * @api - */ - public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '') - { - $this->setBaseUrl($baseUrl); - $this->setMethod($method); - $this->setHost($host); - $this->setScheme($scheme); - $this->setHttpPort($httpPort); - $this->setHttpsPort($httpsPort); - $this->setPathInfo($path); - $this->setQueryString($queryString); - } - - /** - * Updates the RequestContext information based on a HttpFoundation Request. - * - * @param Request $request A Request instance - * - * @return RequestContext The current instance, implementing a fluent interface - */ - public function fromRequest(Request $request) - { - $this->setBaseUrl($request->getBaseUrl()); - $this->setPathInfo($request->getPathInfo()); - $this->setMethod($request->getMethod()); - $this->setHost($request->getHost()); - $this->setScheme($request->getScheme()); - $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort()); - $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort); - $this->setQueryString($request->server->get('QUERY_STRING', '')); - - return $this; - } - - /** - * Gets the base URL. - * - * @return string The base URL - */ - public function getBaseUrl() - { - return $this->baseUrl; - } - - /** - * Sets the base URL. - * - * @param string $baseUrl The base URL - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setBaseUrl($baseUrl) - { - $this->baseUrl = $baseUrl; - - return $this; - } - - /** - * Gets the path info. - * - * @return string The path info - */ - public function getPathInfo() - { - return $this->pathInfo; - } - - /** - * Sets the path info. - * - * @param string $pathInfo The path info - * - * @return RequestContext The current instance, implementing a fluent interface - */ - public function setPathInfo($pathInfo) - { - $this->pathInfo = $pathInfo; - - return $this; - } - - /** - * Gets the HTTP method. - * - * The method is always an uppercased string. - * - * @return string The HTTP method - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the HTTP method. - * - * @param string $method The HTTP method - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setMethod($method) - { - $this->method = strtoupper($method); - - return $this; - } - - /** - * Gets the HTTP host. - * - * The host is always lowercased because it must be treated case-insensitive. - * - * @return string The HTTP host - */ - public function getHost() - { - return $this->host; - } - - /** - * Sets the HTTP host. - * - * @param string $host The HTTP host - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setHost($host) - { - $this->host = strtolower($host); - - return $this; - } - - /** - * Gets the HTTP scheme. - * - * @return string The HTTP scheme - */ - public function getScheme() - { - return $this->scheme; - } - - /** - * Sets the HTTP scheme. - * - * @param string $scheme The HTTP scheme - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setScheme($scheme) - { - $this->scheme = strtolower($scheme); - - return $this; - } - - /** - * Gets the HTTP port. - * - * @return int The HTTP port - */ - public function getHttpPort() - { - return $this->httpPort; - } - - /** - * Sets the HTTP port. - * - * @param int $httpPort The HTTP port - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setHttpPort($httpPort) - { - $this->httpPort = (int) $httpPort; - - return $this; - } - - /** - * Gets the HTTPS port. - * - * @return int The HTTPS port - */ - public function getHttpsPort() - { - return $this->httpsPort; - } - - /** - * Sets the HTTPS port. - * - * @param int $httpsPort The HTTPS port - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setHttpsPort($httpsPort) - { - $this->httpsPort = (int) $httpsPort; - - return $this; - } - - /** - * Gets the query string. - * - * @return string The query string without the "?" - */ - public function getQueryString() - { - return $this->queryString; - } - - /** - * Sets the query string. - * - * @param string $queryString The query string (after "?") - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setQueryString($queryString) - { - // string cast to be fault-tolerant, accepting null - $this->queryString = (string) $queryString; - - return $this; - } - - /** - * Returns the parameters. - * - * @return array The parameters - */ - public function getParameters() - { - return $this->parameters; - } - - /** - * Sets the parameters. - * - * @param array $parameters The parameters - * - * @return RequestContext The current instance, implementing a fluent interface - */ - public function setParameters(array $parameters) - { - $this->parameters = $parameters; - - return $this; - } - - /** - * Gets a parameter value. - * - * @param string $name A parameter name - * - * @return mixed The parameter value or null if nonexistent - */ - public function getParameter($name) - { - return isset($this->parameters[$name]) ? $this->parameters[$name] : null; - } - - /** - * Checks if a parameter value is set for the given parameter. - * - * @param string $name A parameter name - * - * @return bool True if the parameter value is set, false otherwise - */ - public function hasParameter($name) - { - return array_key_exists($name, $this->parameters); - } - - /** - * Sets a parameter value. - * - * @param string $name A parameter name - * @param mixed $parameter The parameter value - * - * @return RequestContext The current instance, implementing a fluent interface - * - * @api - */ - public function setParameter($name, $parameter) - { - $this->parameters[$name] = $parameter; - - return $this; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php deleted file mode 100644 index daf52549d..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * @api - */ -interface RequestContextAwareInterface -{ - /** - * Sets the request context. - * - * @param RequestContext $context The context - * - * @api - */ - public function setContext(RequestContext $context); - - /** - * Gets the request context. - * - * @return RequestContext The context - * - * @api - */ - public function getContext(); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Route.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Route.php deleted file mode 100644 index d2ddbd393..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Route.php +++ /dev/null @@ -1,655 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * A Route describes a route and its parameters. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class Route implements \Serializable -{ - /** - * @var string - */ - private $path = '/'; - - /** - * @var string - */ - private $host = ''; - - /** - * @var array - */ - private $schemes = array(); - - /** - * @var array - */ - private $methods = array(); - - /** - * @var array - */ - private $defaults = array(); - - /** - * @var array - */ - private $requirements = array(); - - /** - * @var array - */ - private $options = array(); - - /** - * @var null|CompiledRoute - */ - private $compiled; - - /** - * @var string - */ - private $condition = ''; - - /** - * Constructor. - * - * Available options: - * - * * compiler_class: A class name able to compile this route instance (RouteCompiler by default) - * - * @param string $path 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 $host The host pattern to match - * @param string|array $schemes A required URI scheme or an array of restricted schemes - * @param string|array $methods A required HTTP method or an array of restricted methods - * @param string $condition A condition that should evaluate to true for the route to match - * - * @api - */ - public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '') - { - $this->setPath($path); - $this->setDefaults($defaults); - $this->setRequirements($requirements); - $this->setOptions($options); - $this->setHost($host); - // The conditions make sure that an initial empty $schemes/$methods does not override the corresponding requirement. - // They can be removed when the BC layer is removed. - if ($schemes) { - $this->setSchemes($schemes); - } - if ($methods) { - $this->setMethods($methods); - } - $this->setCondition($condition); - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - return serialize(array( - 'path' => $this->path, - 'host' => $this->host, - 'defaults' => $this->defaults, - 'requirements' => $this->requirements, - 'options' => $this->options, - 'schemes' => $this->schemes, - 'methods' => $this->methods, - 'condition' => $this->condition, - 'compiled' => $this->compiled, - )); - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - $this->path = $data['path']; - $this->host = $data['host']; - $this->defaults = $data['defaults']; - $this->requirements = $data['requirements']; - $this->options = $data['options']; - $this->schemes = $data['schemes']; - $this->methods = $data['methods']; - - if (isset($data['condition'])) { - $this->condition = $data['condition']; - } - if (isset($data['compiled'])) { - $this->compiled = $data['compiled']; - } - } - - /** - * Returns the pattern for the path. - * - * @return string The pattern - * - * @deprecated Deprecated in 2.2, to be removed in 3.0. Use getPath instead. - */ - public function getPattern() - { - return $this->path; - } - - /** - * Sets the pattern for the path. - * - * This method implements a fluent interface. - * - * @param string $pattern The path pattern - * - * @return Route The current Route instance - * - * @deprecated Deprecated in 2.2, to be removed in 3.0. Use setPath instead. - */ - public function setPattern($pattern) - { - return $this->setPath($pattern); - } - - /** - * Returns the pattern for the path. - * - * @return string The path pattern - */ - public function getPath() - { - return $this->path; - } - - /** - * Sets the pattern for the path. - * - * This method implements a fluent interface. - * - * @param string $pattern The path pattern - * - * @return Route The current Route instance - */ - public function setPath($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->path = '/'.ltrim(trim($pattern), '/'); - $this->compiled = null; - - return $this; - } - - /** - * Returns the pattern for the host. - * - * @return string The host pattern - */ - public function getHost() - { - return $this->host; - } - - /** - * Sets the pattern for the host. - * - * This method implements a fluent interface. - * - * @param string $pattern The host pattern - * - * @return Route The current Route instance - */ - public function setHost($pattern) - { - $this->host = (string) $pattern; - $this->compiled = null; - - return $this; - } - - /** - * Returns the lowercased schemes this route is restricted to. - * So an empty array means that any scheme is allowed. - * - * @return array The schemes - */ - public function getSchemes() - { - return $this->schemes; - } - - /** - * Sets the schemes (e.g. 'https') this route is restricted to. - * So an empty array means that any scheme is allowed. - * - * This method implements a fluent interface. - * - * @param string|array $schemes The scheme or an array of schemes - * - * @return Route The current Route instance - */ - public function setSchemes($schemes) - { - $this->schemes = array_map('strtolower', (array) $schemes); - - // this is to keep BC and will be removed in a future version - if ($this->schemes) { - $this->requirements['_scheme'] = implode('|', $this->schemes); - } else { - unset($this->requirements['_scheme']); - } - - $this->compiled = null; - - return $this; - } - - /** - * Checks if a scheme requirement has been set. - * - * @param string $scheme - * - * @return bool true if the scheme requirement exists, otherwise false - */ - public function hasScheme($scheme) - { - return in_array(strtolower($scheme), $this->schemes, true); - } - - /** - * Returns the uppercased HTTP methods this route is restricted to. - * So an empty array means that any method is allowed. - * - * @return array The methods - */ - public function getMethods() - { - return $this->methods; - } - - /** - * Sets the HTTP methods (e.g. 'POST') this route is restricted to. - * So an empty array means that any method is allowed. - * - * This method implements a fluent interface. - * - * @param string|array $methods The method or an array of methods - * - * @return Route The current Route instance - */ - public function setMethods($methods) - { - $this->methods = array_map('strtoupper', (array) $methods); - - // this is to keep BC and will be removed in a future version - if ($this->methods) { - $this->requirements['_method'] = implode('|', $this->methods); - } else { - unset($this->requirements['_method']); - } - - $this->compiled = null; - - return $this; - } - - /** - * Returns the options. - * - * @return array The options - */ - public function getOptions() - { - return $this->options; - } - - /** - * Sets the options. - * - * This method implements a fluent interface. - * - * @param array $options The options - * - * @return Route The current Route instance - */ - public function setOptions(array $options) - { - $this->options = array( - 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler', - ); - - return $this->addOptions($options); - } - - /** - * Adds options. - * - * This method implements a fluent interface. - * - * @param array $options The options - * - * @return Route The current Route instance - */ - public function addOptions(array $options) - { - foreach ($options as $name => $option) { - $this->options[$name] = $option; - } - $this->compiled = null; - - return $this; - } - - /** - * Sets an option value. - * - * This method implements a fluent interface. - * - * @param string $name An option name - * @param mixed $value The option value - * - * @return Route The current Route instance - * - * @api - */ - public function setOption($name, $value) - { - $this->options[$name] = $value; - $this->compiled = null; - - return $this; - } - - /** - * Get an option value. - * - * @param string $name An option name - * - * @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 an option has been set. - * - * @param string $name An option name - * - * @return bool true if the option is set, false otherwise - */ - public function hasOption($name) - { - return array_key_exists($name, $this->options); - } - - /** - * Returns the defaults. - * - * @return array The defaults - */ - public function getDefaults() - { - return $this->defaults; - } - - /** - * Sets the defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * - * @return Route The current Route instance - */ - public function setDefaults(array $defaults) - { - $this->defaults = array(); - - return $this->addDefaults($defaults); - } - - /** - * Adds defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * - * @return Route The current Route instance - */ - public function addDefaults(array $defaults) - { - foreach ($defaults as $name => $default) { - $this->defaults[$name] = $default; - } - $this->compiled = null; - - return $this; - } - - /** - * Gets a default value. - * - * @param string $name A variable name - * - * @return mixed The default value or null when not given - */ - public function getDefault($name) - { - return isset($this->defaults[$name]) ? $this->defaults[$name] : null; - } - - /** - * Checks if a default value is set for the given variable. - * - * @param string $name A variable name - * - * @return bool true if the default value is set, false otherwise - */ - public function hasDefault($name) - { - return array_key_exists($name, $this->defaults); - } - - /** - * Sets a default value. - * - * @param string $name A variable name - * @param mixed $default The default value - * - * @return Route The current Route instance - * - * @api - */ - public function setDefault($name, $default) - { - $this->defaults[$name] = $default; - $this->compiled = null; - - return $this; - } - - /** - * Returns the requirements. - * - * @return array The requirements - */ - public function getRequirements() - { - return $this->requirements; - } - - /** - * Sets the requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * - * @return Route The current Route instance - */ - public function setRequirements(array $requirements) - { - $this->requirements = array(); - - return $this->addRequirements($requirements); - } - - /** - * Adds requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * - * @return Route The current Route instance - */ - public function addRequirements(array $requirements) - { - foreach ($requirements as $key => $regex) { - $this->requirements[$key] = $this->sanitizeRequirement($key, $regex); - } - $this->compiled = null; - - return $this; - } - - /** - * Returns the requirement for the given key. - * - * @param string $key The key - * - * @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 $key A variable name - * - * @return bool 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. - * - * @param string $key The key - * @param string $regex The regex - * - * @return Route The current Route instance - * - * @api - */ - public function setRequirement($key, $regex) - { - $this->requirements[$key] = $this->sanitizeRequirement($key, $regex); - $this->compiled = null; - - return $this; - } - - /** - * Returns the condition. - * - * @return string The condition - */ - public function getCondition() - { - return $this->condition; - } - - /** - * Sets the condition. - * - * This method implements a fluent interface. - * - * @param string $condition The condition - * - * @return Route The current Route instance - */ - public function setCondition($condition) - { - $this->condition = (string) $condition; - $this->compiled = null; - - return $this; - } - - /** - * Compiles the route. - * - * @return CompiledRoute A CompiledRoute instance - * - * @throws \LogicException If the Route cannot be compiled because the - * path or host pattern is invalid - * - * @see RouteCompiler which is responsible for the compilation process - */ - public function compile() - { - if (null !== $this->compiled) { - return $this->compiled; - } - - $class = $this->getOption('compiler_class'); - - return $this->compiled = $class::compile($this); - } - - private function sanitizeRequirement($key, $regex) - { - if (!is_string($regex)) { - throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key)); - } - - 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)); - } - - // this is to keep BC and will be removed in a future version - if ('_scheme' === $key) { - $this->setSchemes(explode('|', $regex)); - } elseif ('_method' === $key) { - $this->setMethods(explode('|', $regex)); - } - - return $regex; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php deleted file mode 100644 index df37f36e1..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php +++ /dev/null @@ -1,285 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\Config\Resource\ResourceInterface; - -/** - * A RouteCollection represents a set of Route instances. - * - * When adding a route at the end of the collection, an existing route - * with the same name is removed first. So there can only be one route - * with a given name. - * - * @author Fabien Potencier - * @author Tobias Schultze - * - * @api - */ -class RouteCollection implements \IteratorAggregate, \Countable -{ - /** - * @var Route[] - */ - private $routes = array(); - - /** - * @var array - */ - private $resources = array(); - - public function __clone() - { - foreach ($this->routes as $name => $route) { - $this->routes[$name] = clone $route; - } - } - - /** - * Gets the current RouteCollection as an Iterator that includes all routes. - * - * It implements \IteratorAggregate. - * - * @see all() - * - * @return \ArrayIterator An \ArrayIterator object for iterating over routes - */ - public function getIterator() - { - return new \ArrayIterator($this->routes); - } - - /** - * Gets the number of Routes in this collection. - * - * @return int The number of routes - */ - public function count() - { - return count($this->routes); - } - - /** - * Adds a route. - * - * @param string $name The route name - * @param Route $route A Route instance - * - * @api - */ - public function add($name, Route $route) - { - unset($this->routes[$name]); - - $this->routes[$name] = $route; - } - - /** - * Returns all routes in this collection. - * - * @return Route[] An array of routes - */ - public function all() - { - return $this->routes; - } - - /** - * Gets a route by name. - * - * @param string $name The route name - * - * @return Route|null A Route instance or null when not found - */ - public function get($name) - { - return isset($this->routes[$name]) ? $this->routes[$name] : null; - } - - /** - * Removes a route or an array of routes by name from the collection. - * - * @param string|array $name The route name or an array of route names - */ - public function remove($name) - { - foreach ((array) $name as $n) { - unset($this->routes[$n]); - } - } - - /** - * Adds a route collection at the end of the current set by appending all - * routes of the added collection. - * - * @param RouteCollection $collection A RouteCollection instance - * - * @api - */ - public function addCollection(RouteCollection $collection) - { - // we need to remove all routes with the same names first because just replacing them - // would not place the new route at the end of the merged array - foreach ($collection->all() as $name => $route) { - unset($this->routes[$name]); - $this->routes[$name] = $route; - } - - $this->resources = array_merge($this->resources, $collection->getResources()); - } - - /** - * Adds a prefix to the path of all child routes. - * - * @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 - * - * @api - */ - public function addPrefix($prefix, array $defaults = array(), array $requirements = array()) - { - $prefix = trim(trim($prefix), '/'); - - if ('' === $prefix) { - return; - } - - foreach ($this->routes as $route) { - $route->setPath('/'.$prefix.$route->getPath()); - $route->addDefaults($defaults); - $route->addRequirements($requirements); - } - } - - /** - * Sets the host pattern on all routes. - * - * @param string $pattern The pattern - * @param array $defaults An array of default values - * @param array $requirements An array of requirements - */ - public function setHost($pattern, array $defaults = array(), array $requirements = array()) - { - foreach ($this->routes as $route) { - $route->setHost($pattern); - $route->addDefaults($defaults); - $route->addRequirements($requirements); - } - } - - /** - * Sets a condition on all routes. - * - * Existing conditions will be overridden. - * - * @param string $condition The condition - */ - public function setCondition($condition) - { - foreach ($this->routes as $route) { - $route->setCondition($condition); - } - } - - /** - * Adds defaults to all routes. - * - * An existing default value under the same name in a route will be overridden. - * - * @param array $defaults An array of default values - */ - public function addDefaults(array $defaults) - { - if ($defaults) { - foreach ($this->routes as $route) { - $route->addDefaults($defaults); - } - } - } - - /** - * Adds requirements to all routes. - * - * An existing requirement under the same name in a route will be overridden. - * - * @param array $requirements An array of requirements - */ - public function addRequirements(array $requirements) - { - if ($requirements) { - foreach ($this->routes as $route) { - $route->addRequirements($requirements); - } - } - } - - /** - * Adds options to all routes. - * - * An existing option value under the same name in a route will be overridden. - * - * @param array $options An array of options - */ - public function addOptions(array $options) - { - if ($options) { - foreach ($this->routes as $route) { - $route->addOptions($options); - } - } - } - - /** - * Sets the schemes (e.g. 'https') all child routes are restricted to. - * - * @param string|array $schemes The scheme or an array of schemes - */ - public function setSchemes($schemes) - { - foreach ($this->routes as $route) { - $route->setSchemes($schemes); - } - } - - /** - * Sets the HTTP methods (e.g. 'POST') all child routes are restricted to. - * - * @param string|array $methods The method or an array of methods - */ - public function setMethods($methods) - { - foreach ($this->routes as $route) { - $route->setMethods($methods); - } - } - - /** - * Returns an array of resources loaded to build this collection. - * - * @return ResourceInterface[] An array of resources - */ - public function getResources() - { - return array_unique($this->resources); - } - - /** - * Adds a resource for this collection. - * - * @param ResourceInterface $resource A resource instance - */ - public function addResource(ResourceInterface $resource) - { - $this->resources[] = $resource; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php deleted file mode 100644 index f6637da66..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php +++ /dev/null @@ -1,229 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * RouteCompiler compiles Route instances to CompiledRoute instances. - * - * @author Fabien Potencier - * @author Tobias Schultze - */ -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 \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 static function compile(Route $route) - { - $hostVariables = array(); - $variables = array(); - $hostRegex = null; - $hostTokens = array(); - - if ('' !== $host = $route->getHost()) { - $result = self::compilePattern($route, $host, true); - - $hostVariables = $result['variables']; - $variables = $hostVariables; - - $hostTokens = $result['tokens']; - $hostRegex = $result['regex']; - } - - $path = $route->getPath(); - - $result = self::compilePattern($route, $path, 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, - $hostRegex, - $hostTokens, - $hostVariables, - array_unique($variables) - ); - } - - private static function compilePattern(Route $route, $pattern, $isHost) - { - $tokens = array(); - $variables = array(); - $matches = array(); - $pos = 0; - $defaultSeparator = $isHost ? '.' : '/'; - - // 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]); - $precedingChar = strlen($precedingText) > 0 ? substr($precedingText, -1) : ''; - $isSeparator = '' !== $precedingChar && false !== strpos(static::SEPARATORS, $precedingChar); - - 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)); - } - - if ($isSeparator && strlen($precedingText) > 1) { - $tokens[] = array('text', substr($precedingText, 0, -1)); - } elseif (!$isSeparator && strlen($precedingText) > 0) { - $tokens[] = array('text', $precedingText); - } - - $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 = self::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 .= '+'; - } - } - - $tokens[] = array('variable', $isSeparator ? $precedingChar : '', $regexp, $varName); - $variables[] = $varName; - } - - if ($pos < strlen($pattern)) { - $tokens[] = array('text', substr($pattern, $pos)); - } - - // find the first optional token - $firstOptional = PHP_INT_MAX; - if (!$isHost) { - for ($i = count($tokens) - 1; $i >= 0; --$i) { - $token = $tokens[$i]; - if ('variable' === $token[0] && $route->hasDefault($token[3])) { - $firstOptional = $i; - } else { - break; - } - } - } - - // compute the matching regexp - $regexp = ''; - for ($i = 0, $nbToken = count($tokens); $i < $nbToken; ++$i) { - $regexp .= self::computeRegexp($tokens, $i, $firstOptional); - } - - return array( - 'staticPrefix' => 'text' === $tokens[0][0] ? $tokens[0][1] : '', - 'regex' => self::REGEX_DELIMITER.'^'.$regexp.'$'.self::REGEX_DELIMITER.'s'.($isHost ? 'i' : ''), - '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 static 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. - * - * @param array $tokens The route tokens - * @param int $index The index of the current token - * @param int $firstOptional The index of the first optional token - * - * @return string The regexp pattern for a single token - */ - private static function computeRegexp(array $tokens, $index, $firstOptional) - { - $token = $tokens[$index]; - if ('text' === $token[0]) { - // Text tokens - return preg_quote($token[1], self::REGEX_DELIMITER); - } else { - // Variable tokens - if (0 === $index && 0 === $firstOptional) { - // When the only token is an optional variable token, the separator is required - return sprintf('%s(?P<%s>%s)?', preg_quote($token[1], self::REGEX_DELIMITER), $token[3], $token[2]); - } else { - $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 - // matched the optional subpattern is not passed back. - $regexp = "(?:$regexp"; - $nbTokens = count($tokens); - if ($nbTokens - 1 == $index) { - // Close the optional subpatterns - $regexp .= str_repeat(')?', $nbTokens - $firstOptional - (0 === $firstOptional ? 1 : 0)); - } - } - - return $regexp; - } - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php deleted file mode 100644 index e6f8ee6de..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -/** - * RouteCompilerInterface is the interface that all RouteCompiler classes must implement. - * - * @author Fabien Potencier - */ -interface RouteCompilerInterface -{ - /** - * Compiles the current route instance. - * - * @param Route $route A Route instance - * - * @return CompiledRoute A CompiledRoute instance - * - * @throws \LogicException If the Route cannot be compiled because the - * path or host pattern is invalid - */ - public static function compile(Route $route); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Router.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Router.php deleted file mode 100644 index c7c926d43..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Router.php +++ /dev/null @@ -1,346 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\ConfigCache; -use Psr\Log\LoggerInterface; -use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\Generator\Dumper\GeneratorDumperInterface; -use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; -use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; - -/** - * The Router class is an example of the integration of all pieces of the - * routing system for easier use. - * - * @author Fabien Potencier - */ -class Router implements RouterInterface, RequestMatcherInterface -{ - /** - * @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; - - /** - * @var array - */ - protected $options = array(); - - /** - * @var LoggerInterface|null - */ - protected $logger; - - /** - * @var ExpressionFunctionProviderInterface[] - */ - private $expressionLanguageProviders = array(); - - /** - * Constructor. - * - * @param LoaderInterface $loader A LoaderInterface instance - * @param mixed $resource The main resource to load - * @param array $options An array of options - * @param RequestContext $context The context - * @param LoggerInterface $logger A logger instance - */ - public function __construct(LoaderInterface $loader, $resource, array $options = array(), RequestContext $context = null, LoggerInterface $logger = null) - { - $this->loader = $loader; - $this->resource = $resource; - $this->logger = $logger; - $this->context = $context ?: new RequestContext(); - $this->setOptions($options); - } - - /** - * Sets options. - * - * Available options: - * - * * cache_dir: The cache directory (or null to disable caching) - * * debug: Whether to enable debugging or not (false by default) - * * resource_type: Type hint for the main resource (optional) - * - * @param array $options An array of options - * - * @throws \InvalidArgumentException When unsupported option is provided - */ - public function setOptions(array $options) - { - $this->options = array( - 'cache_dir' => null, - 'debug' => false, - 'generator_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', - 'generator_base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', - 'generator_dumper_class' => 'Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper', - 'generator_cache_class' => 'ProjectUrlGenerator', - 'matcher_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', - 'matcher_base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', - 'matcher_dumper_class' => 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper', - 'matcher_cache_class' => 'ProjectUrlMatcher', - 'resource_type' => null, - 'strict_requirements' => true, - ); - - // check option names and live merge, if errors are encountered Exception will be thrown - $invalid = array(); - foreach ($options as $key => $value) { - if (array_key_exists($key, $this->options)) { - $this->options[$key] = $value; - } else { - $invalid[] = $key; - } - } - - if ($invalid) { - throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('", "', $invalid))); - } - } - - /** - * Sets an option. - * - * @param string $key The key - * @param mixed $value The value - * - * @throws \InvalidArgumentException - */ - public function setOption($key, $value) - { - if (!array_key_exists($key, $this->options)) { - throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key)); - } - - $this->options[$key] = $value; - } - - /** - * Gets an option value. - * - * @param string $key The key - * - * @return mixed The value - * - * @throws \InvalidArgumentException - */ - public function getOption($key) - { - if (!array_key_exists($key, $this->options)) { - throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key)); - } - - return $this->options[$key]; - } - - /** - * {@inheritdoc} - */ - public function getRouteCollection() - { - if (null === $this->collection) { - $this->collection = $this->loader->load($this->resource, $this->options['resource_type']); - } - - return $this->collection; - } - - /** - * {@inheritdoc} - */ - public function setContext(RequestContext $context) - { - $this->context = $context; - - if (null !== $this->matcher) { - $this->getMatcher()->setContext($context); - } - if (null !== $this->generator) { - $this->getGenerator()->setContext($context); - } - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - return $this->context; - } - - /** - * {@inheritdoc} - */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) - { - return $this->getGenerator()->generate($name, $parameters, $referenceType); - } - - /** - * {@inheritdoc} - */ - public function match($pathinfo) - { - return $this->getMatcher()->match($pathinfo); - } - - /** - * {@inheritdoc} - */ - public function matchRequest(Request $request) - { - $matcher = $this->getMatcher(); - if (!$matcher instanceof RequestMatcherInterface) { - // fallback to the default UrlMatcherInterface - return $matcher->match($request->getPathInfo()); - } - - return $matcher->matchRequest($request); - } - - /** - * Gets the UrlMatcher instance associated with this Router. - * - * @return UrlMatcherInterface A UrlMatcherInterface instance - */ - public function getMatcher() - { - if (null !== $this->matcher) { - return $this->matcher; - } - - if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) { - $this->matcher = new $this->options['matcher_class']($this->getRouteCollection(), $this->context); - if (method_exists($this->matcher, 'addExpressionLanguageProvider')) { - foreach ($this->expressionLanguageProviders as $provider) { - $this->matcher->addExpressionLanguageProvider($provider); - } - } - - return $this->matcher; - } - - $class = $this->options['matcher_cache_class']; - $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']); - if (!$cache->isFresh()) { - $dumper = $this->getMatcherDumperInstance(); - if (method_exists($dumper, 'addExpressionLanguageProvider')) { - foreach ($this->expressionLanguageProviders as $provider) { - $dumper->addExpressionLanguageProvider($provider); - } - } - - $options = array( - 'class' => $class, - 'base_class' => $this->options['matcher_base_class'], - ); - - $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources()); - } - - require_once $cache; - - return $this->matcher = new $class($this->context); - } - - /** - * Gets the UrlGenerator instance associated with this Router. - * - * @return UrlGeneratorInterface A UrlGeneratorInterface instance - */ - public function getGenerator() - { - if (null !== $this->generator) { - return $this->generator; - } - - if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) { - $this->generator = new $this->options['generator_class']($this->getRouteCollection(), $this->context, $this->logger); - } else { - $class = $this->options['generator_cache_class']; - $cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']); - if (!$cache->isFresh()) { - $dumper = $this->getGeneratorDumperInstance(); - - $options = array( - 'class' => $class, - 'base_class' => $this->options['generator_base_class'], - ); - - $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources()); - } - - require_once $cache; - - $this->generator = new $class($this->context, $this->logger); - } - - if ($this->generator instanceof ConfigurableRequirementsInterface) { - $this->generator->setStrictRequirements($this->options['strict_requirements']); - } - - return $this->generator; - } - - public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) - { - $this->expressionLanguageProviders[] = $provider; - } - - /** - * @return GeneratorDumperInterface - */ - protected function getGeneratorDumperInstance() - { - return new $this->options['generator_dumper_class']($this->getRouteCollection()); - } - - /** - * @return MatcherDumperInterface - */ - protected function getMatcherDumperInstance() - { - return new $this->options['matcher_dumper_class']($this->getRouteCollection()); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouterInterface.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouterInterface.php deleted file mode 100644 index a10ae34e0..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/RouterInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing; - -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; - -/** - * RouterInterface is the interface that all Router classes must implement. - * - * This interface is the concatenation of UrlMatcherInterface and UrlGeneratorInterface. - * - * @author Fabien Potencier - */ -interface RouterInterface extends UrlMatcherInterface, UrlGeneratorInterface -{ - /** - * Gets the RouteCollection instance associated with this Router. - * - * @return RouteCollection A RouteCollection instance - */ - public function getRouteCollection(); -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php deleted file mode 100644 index eb4d22045..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Annotation; - -use Symfony\Component\Routing\Annotation\Route; - -class RouteTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \BadMethodCallException - */ - public function testInvalidRouteParameter() - { - $route = new Route(array('foo' => 'bar')); - } - - /** - * @dataProvider getValidParameters - */ - public function testRouteParameters($parameter, $value, $getter) - { - $route = new Route(array($parameter => $value)); - $this->assertEquals($route->$getter(), $value); - } - - public function getValidParameters() - { - return array( - array('value', '/Blog', 'getPath'), - 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('schemes', array('https'), 'getSchemes'), - array('methods', array('GET', 'POST'), 'getMethods'), - array('host', array('{locale}.example.com'), 'getHost'), - array('condition', array('context.getMethod() == "GET"'), 'getCondition'), - ); - } - - /** - * @group legacy - */ - public function testLegacyGetPattern() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $route = new Route(array('value' => '/Blog')); - $this->assertEquals($route->getPattern(), '/Blog'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php deleted file mode 100644 index 215ebb707..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/CompiledRouteTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use Symfony\Component\Routing\CompiledRoute; - -class CompiledRouteTest extends \PHPUnit_Framework_TestCase -{ - public function testAccessors() - { - $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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php deleted file mode 100644 index 56bcab2a9..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * 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; - -abstract class AbstractClass -{ -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php deleted file mode 100644 index a3882773c..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * 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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/FooClass.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/FooClass.php deleted file mode 100644 index 320dc3500..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/FooClass.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * 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 FooClass -{ -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php deleted file mode 100644 index 9fd5754a1..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * 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; - -use Symfony\Component\Routing\Loader\XmlFileLoader; -use Symfony\Component\Config\Util\XmlUtils; - -/** - * XmlFileLoader with schema validation turned off. - */ -class CustomXmlFileLoader extends XmlFileLoader -{ - protected function loadFile($file) - { - return XmlUtils::loadFile($file, function () { return true; }); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php deleted file mode 100644 index 15937bcf0..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * 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; - -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface; - -/** - * @author Fabien Potencier - */ -class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface -{ - public function redirect($path, $route, $scheme = null) - { - return array( - '_controller' => 'Some controller reference...', - 'path' => $path, - 'scheme' => $scheme, - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/annotated.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/annotated.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache deleted file mode 100644 index 26a561cc9..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.apache +++ /dev/null @@ -1,163 +0,0 @@ -# skip "real" requests -RewriteCond %{REQUEST_FILENAME} -f -RewriteRule .* - [QSA,L] - -# foo -RewriteCond %{REQUEST_URI} ^/foo/(baz|symfony)$ -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_param_bar:%1,E=_ROUTING_default_bar:toto] - -# 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_param_foo:%1] - -# 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_param_foo:%1] - -# baz -RewriteCond %{REQUEST_URI} ^/test/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] - -# 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] - -# baz4 -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_param_foo:%1] - -# baz5 -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 .* $0/ [QSA,L,R=301] -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_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_param_foo:%1] - -# baz6 -RewriteCond %{REQUEST_URI} ^/test/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] - -# 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_host_1:1] - -# route1 -RewriteCond %{ENV:__ROUTING_host_1} =1 -RewriteCond %{REQUEST_URI} ^/route1$ -RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route1] - -# route2 -RewriteCond %{ENV:__ROUTING_host_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_host_2:1] - -# route3 -RewriteCond %{ENV:__ROUTING_host_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_host_3:1] - -# route4 -RewriteCond %{ENV:__ROUTING_host_3} =1 -RewriteCond %{REQUEST_URI} ^/route4$ -RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route4] - -RewriteCond %{HTTP:Host} ^c\.example\.com$ -RewriteRule .? - [E=__ROUTING_host_4:1] - -# route5 -RewriteCond %{ENV:__ROUTING_host_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_host_5:1,E=__ROUTING_host_5_var1:%1] - -# route11 -RewriteCond %{ENV:__ROUTING_host_5} =1 -RewriteCond %{REQUEST_URI} ^/route11$ -RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route11,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1}] - -# route12 -RewriteCond %{ENV:__ROUTING_host_5} =1 -RewriteCond %{REQUEST_URI} ^/route12$ -RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route12,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_default_var1:val] - -# route13 -RewriteCond %{ENV:__ROUTING_host_5} =1 -RewriteCond %{REQUEST_URI} ^/route13/([^/]++)$ -RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route13,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1] - -# route14 -RewriteCond %{ENV:__ROUTING_host_5} =1 -RewriteCond %{REQUEST_URI} ^/route14/([^/]++)$ -RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route14,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val] - -RewriteCond %{HTTP:Host} ^c\.example\.com$ -RewriteRule .? - [E=__ROUTING_host_6:1] - -# route15 -RewriteCond %{ENV:__ROUTING_host_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 %{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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php deleted file mode 100644 index 4ea0b8a1a..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ /dev/null @@ -1,312 +0,0 @@ -context = $context; - } - - public function match($pathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($pathinfo); - $context = $this->context; - $request = $this->request; - - // foo - if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); - } - - if (0 === strpos($pathinfo, '/bar')) { - // bar - if (preg_match('#^/bar/(?P[^/]++)$#s', $pathinfo, $matches)) { - if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { - $allow = array_merge($allow, array('GET', 'HEAD')); - goto not_bar; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); - } - not_bar: - - // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#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: - - } - - 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'); - } - - // baz3 - if ($pathinfo === '/test/baz3/') { - return array('_route' => 'baz3'); - } - - } - - // baz4 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); - } - - // baz5 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ($this->context->getMethod() != 'POST') { - $allow[] = 'POST'; - goto not_baz5; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); - } - not_baz5: - - // baz.baz6 - if (preg_match('#^/test/(?P[^/]++)/$#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: - - } - - // foofoo - if ($pathinfo === '/foofoo') { - return array ( 'def' => 'test', '_route' => 'foofoo',); - } - - // quoter - if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); - } - - // space - if ($pathinfo === '/spa ce') { - return array('_route' => 'space'); - } - - if (0 === strpos($pathinfo, '/a')) { - if (0 === strpos($pathinfo, '/a/b\'b')) { - // foo1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); - } - - // bar1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); - } - - } - - // overridden - if (preg_match('#^/a/(?P.*)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); - } - - // bar2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); - } - - } - - } - - if (0 === strpos($pathinfo, '/multi')) { - // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); - } - - // overridden2 - if ($pathinfo === '/multi/new') { - return array('_route' => 'overridden2'); - } - - // hey - if ($pathinfo === '/multi/hey/') { - return array('_route' => 'hey'); - } - - } - - // foo3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); - } - - // bar3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#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[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); - } - - } - - $host = $this->context->getHost(); - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route1 - if ($pathinfo === '/route1') { - return array('_route' => 'route1'); - } - - // route2 - if ($pathinfo === '/c2/route2') { - return array('_route' => 'route2'); - } - - } - - if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { - // route3 - if ($pathinfo === '/c2/route3') { - return array('_route' => 'route3'); - } - - } - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route4 - if ($pathinfo === '/route4') { - return array('_route' => 'route4'); - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route5 - if ($pathinfo === '/route5') { - return array('_route' => 'route5'); - } - - } - - // route6 - if ($pathinfo === '/route6') { - return array('_route' => 'route6'); - } - - if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { - if (0 === strpos($pathinfo, '/route1')) { - // route11 - if ($pathinfo === '/route11') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); - } - - // route12 - if ($pathinfo === '/route12') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); - } - - // route13 - if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); - } - - // route14 - if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); - } - - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route15 - if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#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[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); - } - - // route17 - if ($pathinfo === '/route17') { - return array('_route' => 'route17'); - } - - } - - if (0 === strpos($pathinfo, '/a')) { - // a - if ($pathinfo === '/a/a...') { - return array('_route' => 'a'); - } - - if (0 === strpos($pathinfo, '/a/b')) { - // b - if (preg_match('#^/a/b/(?P[^/]++)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); - } - - } - - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache deleted file mode 100644 index 309f2ff0e..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.apache +++ /dev/null @@ -1,7 +0,0 @@ -# skip "real" requests -RewriteCond %{REQUEST_FILENAME} -f -RewriteRule .* - [QSA,L] - -# foo -RewriteCond %{REQUEST_URI} ^/foo$ -RewriteRule .* ap\ p_d\ ev.php [QSA,L,E=_ROUTING_route:foo] diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php deleted file mode 100644 index f9d3fa2d8..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ /dev/null @@ -1,344 +0,0 @@ -context = $context; - } - - public function match($pathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($pathinfo); - $context = $this->context; - $request = $this->request; - - // foo - if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); - } - - if (0 === strpos($pathinfo, '/bar')) { - // bar - if (preg_match('#^/bar/(?P[^/]++)$#s', $pathinfo, $matches)) { - if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) { - $allow = array_merge($allow, array('GET', 'HEAD')); - goto not_bar; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); - } - not_bar: - - // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#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: - - } - - 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'); - } - - // baz3 - if (rtrim($pathinfo, '/') === '/test/baz3') { - if (substr($pathinfo, -1) !== '/') { - return $this->redirect($pathinfo.'/', 'baz3'); - } - - return array('_route' => 'baz3'); - } - - } - - // baz4 - if (preg_match('#^/test/(?P[^/]++)/?$#s', $pathinfo, $matches)) { - if (substr($pathinfo, -1) !== '/') { - return $this->redirect($pathinfo.'/', 'baz4'); - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); - } - - // baz5 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ($this->context->getMethod() != 'POST') { - $allow[] = 'POST'; - goto not_baz5; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); - } - not_baz5: - - // baz.baz6 - if (preg_match('#^/test/(?P[^/]++)/$#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: - - } - - // foofoo - if ($pathinfo === '/foofoo') { - return array ( 'def' => 'test', '_route' => 'foofoo',); - } - - // quoter - if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); - } - - // space - if ($pathinfo === '/spa ce') { - return array('_route' => 'space'); - } - - if (0 === strpos($pathinfo, '/a')) { - if (0 === strpos($pathinfo, '/a/b\'b')) { - // foo1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); - } - - // bar1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); - } - - } - - // overridden - if (preg_match('#^/a/(?P.*)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); - } - - // bar2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); - } - - } - - } - - if (0 === strpos($pathinfo, '/multi')) { - // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); - } - - // overridden2 - if ($pathinfo === '/multi/new') { - return array('_route' => 'overridden2'); - } - - // hey - if (rtrim($pathinfo, '/') === '/multi/hey') { - if (substr($pathinfo, -1) !== '/') { - return $this->redirect($pathinfo.'/', 'hey'); - } - - return array('_route' => 'hey'); - } - - } - - // foo3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); - } - - // bar3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#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[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); - } - - } - - $host = $this->context->getHost(); - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route1 - if ($pathinfo === '/route1') { - return array('_route' => 'route1'); - } - - // route2 - if ($pathinfo === '/c2/route2') { - return array('_route' => 'route2'); - } - - } - - if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { - // route3 - if ($pathinfo === '/c2/route3') { - return array('_route' => 'route3'); - } - - } - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route4 - if ($pathinfo === '/route4') { - return array('_route' => 'route4'); - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route5 - if ($pathinfo === '/route5') { - return array('_route' => 'route5'); - } - - } - - // route6 - if ($pathinfo === '/route6') { - return array('_route' => 'route6'); - } - - if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { - if (0 === strpos($pathinfo, '/route1')) { - // route11 - if ($pathinfo === '/route11') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); - } - - // route12 - if ($pathinfo === '/route12') { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); - } - - // route13 - if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); - } - - // route14 - if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); - } - - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route15 - if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#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[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); - } - - // route17 - if ($pathinfo === '/route17') { - return array('_route' => 'route17'); - } - - } - - if (0 === strpos($pathinfo, '/a')) { - // a - if ($pathinfo === '/a/a...') { - return array('_route' => 'a'); - } - - if (0 === strpos($pathinfo, '/a/b')) { - // b - if (preg_match('#^/a/b/(?P[^/]++)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); - } - - } - - } - - // secure - if ($pathinfo === '/secure') { - $requiredSchemes = array ( 'https' => 0,); - if (!isset($requiredSchemes[$this->context->getScheme()])) { - return $this->redirect($pathinfo, 'secure', key($requiredSchemes)); - } - - return array('_route' => 'secure'); - } - - // nonsecure - if ($pathinfo === '/nonsecure') { - $requiredSchemes = array ( 'http' => 0,); - if (!isset($requiredSchemes[$this->context->getScheme()])) { - return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes)); - } - - return array('_route' => 'nonsecure'); - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php deleted file mode 100644 index d9da7b02d..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ /dev/null @@ -1,50 +0,0 @@ -context = $context; - } - - public function match($pathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($pathinfo); - $context = $this->context; - $request = $this->request; - - if (0 === strpos($pathinfo, '/rootprefix')) { - // static - if ($pathinfo === '/rootprefix/test') { - return array('_route' => 'static'); - } - - // dynamic - if (preg_match('#^/rootprefix/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ()); - } - - } - - // with-condition - if ($pathinfo === '/with-condition' && ($context->getMethod() == "GET")) { - return array('_route' => 'with-condition'); - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/empty.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/empty.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/foo.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/foo.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/foo1.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/foo1.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/incomplete.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/incomplete.yml deleted file mode 100644 index df64d324f..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/incomplete.yml +++ /dev/null @@ -1,2 +0,0 @@ -blog_show: - defaults: { _controller: MyBlogBundle:Blog:show } diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml deleted file mode 100644 index 4ea4115f2..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_path.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_path.xml deleted file mode 100644 index ef5bc088d..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/missing_path.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml deleted file mode 100644 index bdd6a4732..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - MyBundle:Blog:show - \w+ - en|fr|de - RouteCompiler - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml deleted file mode 100644 index a3e947372..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml +++ /dev/null @@ -1,3 +0,0 @@ -blog_show: - resource: validpattern.yml - path: /test diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml deleted file mode 100644 index 547cda3b6..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml +++ /dev/null @@ -1,3 +0,0 @@ -blog_show: - path: /blog/{slug} - type: custom diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml deleted file mode 100644 index 755e44304..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - MyBundle:Blog:show - GET - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.yml deleted file mode 100644 index 257cc5642..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid.yml +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid2.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid2.yml deleted file mode 100644 index cfa9992bb..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalid2.yml +++ /dev/null @@ -1 +0,0 @@ -route: string diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidkeys.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidkeys.yml deleted file mode 100644 index 015e270fb..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidkeys.yml +++ /dev/null @@ -1,3 +0,0 @@ -someroute: - resource: path/to/some.yml - name_prefix: test_ diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidnode.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidnode.xml deleted file mode 100644 index 863ef03b9..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidnode.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - bar - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml deleted file mode 100644 index a46961eee..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - MyBundle:Blog:show - GET - - baz - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/null_values.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/null_values.xml deleted file mode 100644 index f9e2aa24d..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/null_values.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - foo - bar - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml deleted file mode 100644 index 78be239aa..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml +++ /dev/null @@ -1,2 +0,0 @@ -"#$péß^a|": - path: "true" diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php deleted file mode 100644 index 08badb441..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.php +++ /dev/null @@ -1,28 +0,0 @@ -add('blog_show', new Route( - '/blog/{slug}', - array('_controller' => 'MyBlogBundle:Blog:show'), - array('locale' => '\w+'), - array('compiler_class' => 'RouteCompiler'), - '{locale}.example.com', - array('https'), - array('GET', 'POST', 'put', 'OpTiOnS'), - 'context.getMethod() == "GET"' -)); -$collection->add('blog_show_legacy', new Route( - '/blog/{slug}', - array('_controller' => 'MyBlogBundle:Blog:show'), - array('_method' => 'GET|POST|put|OpTiOnS', '_scheme' => 'https', 'locale' => '\w+'), - array('compiler_class' => 'RouteCompiler'), - '{locale}.example.com', - array(), - array(), - 'context.getMethod() == "GET"' -)); - -return $collection; diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml deleted file mode 100644 index a8221314c..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - MyBundle:Blog:show - \w+ - - context.getMethod() == "GET" - - - - MyBundle:Blog:show - - GET|POST|put|OpTiOnS - hTTps - \w+ - - context.getMethod() == "GET" - - - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml deleted file mode 100644 index 26136c396..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml +++ /dev/null @@ -1,22 +0,0 @@ -blog_show: - path: /blog/{slug} - defaults: { _controller: "MyBundle:Blog:show" } - host: "{locale}.example.com" - requirements: { 'locale': '\w+' } - methods: ['GET','POST','put','OpTiOnS'] - schemes: ['https'] - condition: 'context.getMethod() == "GET"' - options: - compiler_class: RouteCompiler - -blog_show_legacy: - pattern: /blog/{slug} - defaults: { _controller: "MyBundle:Blog:show" } - host: "{locale}.example.com" - requirements: { '_method': 'GET|POST|put|OpTiOnS', _scheme: https, 'locale': '\w+' } - condition: 'context.getMethod() == "GET"' - options: - compiler_class: RouteCompiler - -blog_show_inherited: - path: /blog/{slug} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.php deleted file mode 100644 index 482c80b29..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.php +++ /dev/null @@ -1,18 +0,0 @@ -import('validpattern.php'); -$collection->addDefaults(array( - 'foo' => 123, -)); -$collection->addRequirements(array( - 'foo' => '\d+', -)); -$collection->addOptions(array( - 'foo' => 'bar', -)); -$collection->setCondition('context.getMethod() == "POST"'); -$collection->addPrefix('/prefix'); - -return $collection; diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml deleted file mode 100644 index b7a15ddc7..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - 123 - \d+ - - context.getMethod() == "POST" - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml deleted file mode 100644 index faf2263ae..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validresource.yml +++ /dev/null @@ -1,8 +0,0 @@ -_blog: - resource: validpattern.yml - prefix: /{foo} - defaults: { 'foo': '123' } - requirements: { 'foo': '\d+' } - options: { 'foo': 'bar' } - host: "" - condition: 'context.getMethod() == "POST"' diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/with_define_path_variable.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/with_define_path_variable.php deleted file mode 100644 index 5871420b1..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/with_define_path_variable.php +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php deleted file mode 100644 index f45271a43..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ /dev/null @@ -1,150 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Generator\Dumper; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper; -use Symfony\Component\Routing\RequestContext; - -class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var RouteCollection - */ - private $routeCollection; - - /** - * @var PhpGeneratorDumper - */ - private $generatorDumper; - - /** - * @var string - */ - private $testTmpFilepath; - - protected function setUp() - { - parent::setUp(); - - $this->routeCollection = new RouteCollection(); - $this->generatorDumper = new PhpGeneratorDumper($this->routeCollection); - $this->testTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.php'; - @unlink($this->testTmpFilepath); - } - - protected function tearDown() - { - parent::tearDown(); - - @unlink($this->testTmpFilepath); - - $this->routeCollection = null; - $this->generatorDumper = null; - $this->testTmpFilepath = null; - } - - public function testDumpWithRoutes() - { - $this->routeCollection->add('Test', new Route('/testing/{foo}')); - $this->routeCollection->add('Test2', new Route('/testing2')); - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump()); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php')); - - $absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), true); - $absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), true); - $relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), false); - $relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), false); - - $this->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar'); - $this->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2'); - $this->assertEquals($relativeUrlWithParameter, '/app.php/testing/bar'); - $this->assertEquals($relativeUrlWithoutParameter, '/app.php/testing2'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testDumpWithoutRoutes() - { - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'WithoutRoutesUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \WithoutRoutesUrlGenerator(new RequestContext('/app.php')); - - $projectUrlGenerator->generate('Test', array()); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException - */ - public function testGenerateNonExistingRoute() - { - $this->routeCollection->add('Test', new Route('/test')); - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'NonExistingRoutesUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \NonExistingRoutesUrlGenerator(new RequestContext()); - $url = $projectUrlGenerator->generate('NonExisting', array()); - } - - public function testDumpForRouteWithDefaults() - { - $this->routeCollection->add('Test', new Route('/testing/{foo}', array('foo' => 'bar'))); - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'DefaultRoutesUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \DefaultRoutesUrlGenerator(new RequestContext()); - $url = $projectUrlGenerator->generate('Test', array()); - - $this->assertEquals($url, '/testing'); - } - - public function testDumpWithSchemeRequirement() - { - $this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https'))); - $this->routeCollection->add('Test2', new Route('/testing_bc', array(), array('_scheme' => 'https'))); // BC - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php')); - - $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true); - $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true); - $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false); - $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false); - - $this->assertEquals($absoluteUrl, 'ftp://localhost/app.php/testing'); - $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc'); - $this->assertEquals($relativeUrl, 'ftp://localhost/app.php/testing'); - $this->assertEquals($relativeUrlBC, 'https://localhost/app.php/testing_bc'); - - $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https')); - - $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true); - $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true); - $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false); - $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false); - - $this->assertEquals($absoluteUrl, 'https://localhost/app.php/testing'); - $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc'); - $this->assertEquals($relativeUrl, '/app.php/testing'); - $this->assertEquals($relativeUrlBC, '/app.php/testing_bc'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php deleted file mode 100644 index 9419e133c..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ /dev/null @@ -1,678 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Generator; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\Generator\UrlGenerator; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\RequestContext; - -class UrlGeneratorTest extends \PHPUnit_Framework_TestCase -{ - public function testAbsoluteUrlWithPort80() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array(), true); - - $this->assertEquals('http://localhost/app.php/testing', $url); - } - - public function testAbsoluteSecureUrlWithPort443() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', array(), true); - - $this->assertEquals('https://localhost/app.php/testing', $url); - } - - public function testAbsoluteUrlWithNonStandardPort() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes, array('httpPort' => 8080))->generate('test', array(), true); - - $this->assertEquals('http://localhost:8080/app.php/testing', $url); - } - - public function testAbsoluteSecureUrlWithNonStandardPort() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes, array('httpsPort' => 8080, 'scheme' => 'https'))->generate('test', array(), true); - - $this->assertEquals('https://localhost:8080/app.php/testing', $url); - } - - public function testRelativeUrlWithoutParameters() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array(), false); - - $this->assertEquals('/app.php/testing', $url); - } - - public function testRelativeUrlWithParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), false); - - $this->assertEquals('/app.php/testing/bar', $url); - } - - public function testRelativeUrlWithNullParameter() - { - $routes = $this->getRoutes('test', new Route('/testing.{format}', array('format' => null))); - $url = $this->getGenerator($routes)->generate('test', array(), false); - - $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))); - // 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() - { - $routes = $this->getRoutes('test', new Route('/testing/{page}')); - $url = $this->getGenerator($routes)->generate('test', array('page' => 0), false); - - $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')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), false); - - $this->assertEquals('/app.php/testing?foo=bar', $url); - } - - public function testAbsoluteUrlWithExtraParameters() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), true); - - $this->assertEquals('http://localhost/app.php/testing?foo=bar', $url); - } - - public function testUrlWithNullExtraParameters() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => null), true); - - $this->assertEquals('http://localhost/app.php/testing', $url); - } - - public function testUrlWithExtraParametersFromGlobals() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $generator = $this->getGenerator($routes); - $context = new RequestContext('/app.php'); - $context->setParameter('bar', 'bar'); - $generator->setContext($context); - $url = $generator->generate('test', array('foo' => 'bar')); - - $this->assertEquals('/app.php/testing?foo=bar', $url); - } - - public function testUrlWithGlobalParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}')); - $generator = $this->getGenerator($routes); - $context = new RequestContext('/app.php'); - $context->setParameter('foo', 'bar'); - $generator->setContext($context); - $url = $generator->generate('test', array()); - - $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 - */ - public function testGenerateWithoutRoutes() - { - $routes = $this->getRoutes('foo', new Route('/testing/{foo}')); - $this->getGenerator($routes)->generate('test', array(), true); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\MissingMandatoryParametersException - */ - public function testGenerateForRouteWithoutMandatoryParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}')); - $this->getGenerator($routes)->generate('test', array(), true); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException - */ - public function testGenerateForRouteWithInvalidOptionalParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); - $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+'))); - $generator = $this->getGenerator($routes); - $generator->setStrictRequirements(false); - $this->assertNull($generator->generate('test', array('foo' => 'bar'), true)); - } - - public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $logger->expects($this->once()) - ->method('error'); - $generator = $this->getGenerator($routes, array(), $logger); - $generator->setStrictRequirements(false); - $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 - */ - public function testGenerateForRouteWithInvalidMandatoryParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => 'd+'))); - $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'))); // BC - $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); // BC - $this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http'))); - $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); - $this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); - } - - public function testSchemeRequirementForcesAbsoluteUrl() - { - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'https'))); // BC - $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array('_scheme' => 'http'))); // BC - $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); - $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http'))); - $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); - } - - public function testSchemeRequirementCreatesUrlForFirstRequiredScheme() - { - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('Ftp', 'https'))); - $this->assertEquals('ftp://localhost/app.php/', $this->getGenerator($routes)->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))); - - $this->assertEquals('/app.php/category/foo', $this->getGenerator($routes)->generate('test', array('slug1' => 'foo'))); - } - - public function testWithAnIntegerAsADefaultValue() - { - $routes = $this->getRoutes('test', new Route('/{default}', array('default' => 0))); - - $this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo'))); - } - - public function testNullForOptionalParameterIsIgnored() - { - $routes = $this->getRoutes('test', new Route('/test/{default}', array('default' => 0))); - - $this->assertEquals('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => null))); - } - - public function testQueryParamSameAsDefault() - { - $routes = $this->getRoutes('test', new Route('/test', array('default' => 'value'))); - - $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => 'foo'))); - $this->assertSame('/app.php/test', $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) - // and other special ASCII chars. These chars are tested as static text path, variable path and query param. - $chars = '@:[]/()*\'" +,;-._~&$<>|{}%\\^`!?foo=bar#id'; - $routes = $this->getRoutes('test', new Route("/$chars/{varpath}", array(), array('varpath' => '.+'))); - $this->assertSame('/app.php/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id' - .'/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id' - .'?query=%40%3A%5B%5D/%28%29%2A%27%22+%2B%2C%3B-._%7E%26%24%3C%3E%7C%7B%7D%25%5C%5E%60%21%3Ffoo%3Dbar%23id', - $this->getGenerator($routes)->generate('test', array( - 'varpath' => $chars, - 'query' => $chars, - )) - ); - } - - public function testEncodingOfRelativePathSegments() - { - $routes = $this->getRoutes('test', new Route('/dir/../dir/..')); - $this->assertSame('/app.php/dir/%2E%2E/dir/%2E%2E', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/dir/./dir/.')); - $this->assertSame('/app.php/dir/%2E/dir/%2E', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/a./.a/a../..a/...')); - $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 testWithHostDifferentFromContext() - { - $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - - $this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' => 'Fabien', 'locale' => 'fr'))); - } - - public function testWithHostSameAsContext() - { - $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 testWithHostSameAsContextAndAbsolute() - { - $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 testUrlWithInvalidParameterInHost() - { - $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 testUrlWithInvalidParameterInHostWhenParamHasADefaultValue() - { - $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 testUrlWithInvalidParameterEqualsDefaultValueInHost() - { - $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 testUrlWithInvalidParameterInHostInNonStrictMode() - { - $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)); - } - - public function testHostIsCaseInsensitive() - { - $routes = $this->getRoutes('test', new Route('/', array(), array('locale' => 'en|de|fr'), array(), '{locale}.FooBar.com')); - $generator = $this->getGenerator($routes); - $this->assertSame('//EN.FooBar.com/app.php/', $generator->generate('test', array('locale' => 'EN'), UrlGeneratorInterface::NETWORK_PATH)); - } - - public function testGenerateNetworkPathBC() - { - $routes = $this->getRoutes('test', new Route('/{name}', array(), array('_scheme' => 'http'), array(), '{locale}.example.com')); - - $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' - ); - $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', - array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' - ); - $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' - ); - $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' - ); - } - - public function testGenerateNetworkPath() - { - $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com', array('http'))); - - $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' - ); - $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', - array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' - ); - $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' - ); - $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' - ); - } - - public function testGenerateRelativePath() - { - $routes = new RouteCollection(); - $routes->add('article', new Route('/{author}/{article}/')); - $routes->add('comments', new Route('/{author}/{article}/comments')); - $routes->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com')); - $routes->add('schemeBC', new Route('/{author}', array(), array('_scheme' => 'https'))); // BC - $routes->add('scheme', new Route('/{author}/blog', array(), array(), array(), '', array('https'))); - $routes->add('unrelated', new Route('/about')); - - $generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/')); - - $this->assertSame('comments', $generator->generate('comments', - array('author' => 'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('comments?page=2', $generator->generate('comments', - array('author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('../twig-is-great/', $generator->generate('article', - array('author' => 'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article', - array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host', - array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('https://example.com/app.php/bernhard', $generator->generate('schemeBC', - array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme', - array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('../../about', $generator->generate('unrelated', - array(), UrlGeneratorInterface::RELATIVE_PATH) - ); - } - - /** - * @dataProvider provideRelativePaths - */ - public function testGetRelativePath($sourcePath, $targetPath, $expectedPath) - { - $this->assertSame($expectedPath, UrlGenerator::getRelativePath($sourcePath, $targetPath)); - } - - public function provideRelativePaths() - { - return array( - array( - '/same/dir/', - '/same/dir/', - '', - ), - array( - '/same/file', - '/same/file', - '', - ), - array( - '/', - '/file', - 'file', - ), - array( - '/', - '/dir/file', - 'dir/file', - ), - array( - '/dir/file.html', - '/dir/different-file.html', - 'different-file.html', - ), - array( - '/same/dir/extra-file', - '/same/dir/', - './', - ), - array( - '/parent/dir/', - '/parent/', - '../', - ), - array( - '/parent/dir/extra-file', - '/parent/', - '../', - ), - array( - '/a/b/', - '/x/y/z/', - '../../x/y/z/', - ), - array( - '/a/b/c/d/e', - '/a/c/d', - '../../../c/d', - ), - array( - '/a/b/c//', - '/a/b/c/', - '../', - ), - array( - '/a/b/c/', - '/a/b/c//', - './/', - ), - array( - '/root/a/b/c/', - '/root/x/b/c/', - '../../../x/b/c/', - ), - array( - '/a/b/c/d/', - '/a', - '../../../../a', - ), - array( - '/special-chars/sp%20ce/1€/mäh/e=mc²', - '/special-chars/sp%20ce/1€/<µ>/e=mc²', - '../<µ>/e=mc²', - ), - array( - 'not-rooted', - 'dir/file', - 'dir/file', - ), - array( - '//dir/', - '', - '../../', - ), - array( - '/dir/', - '/dir/file:with-colon', - './file:with-colon', - ), - array( - '/dir/', - '/dir/subdir/file:with-colon', - 'subdir/file:with-colon', - ), - array( - '/dir/', - '/dir/:subdir/', - './:subdir/', - ), - ); - } - - protected function getGenerator(RouteCollection $routes, array $parameters = array(), $logger = null) - { - $context = new RequestContext('/app.php'); - foreach ($parameters as $key => $value) { - $method = 'set'.$key; - $context->$method($value); - } - $generator = new UrlGenerator($routes, $context, $logger); - - return $generator; - } - - protected function getRoutes($name, Route $route) - { - $routes = new RouteCollection(); - $routes->add($name, $route); - - return $routes; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php deleted file mode 100644 index 288bf64ff..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -abstract class AbstractAnnotationLoaderTest extends \PHPUnit_Framework_TestCase -{ - public function getReader() - { - return $this->getMockBuilder('Doctrine\Common\Annotations\Reader') - ->disableOriginalConstructor() - ->getMock() - ; - } - - public function getClassLoader($reader) - { - return $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader') - ->setConstructorArgs(array($reader)) - ->getMockForAbstractClass() - ; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php deleted file mode 100644 index 03ba15257..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Annotation\Route; - -class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest -{ - protected $loader; - - protected function setUp() - { - parent::setUp(); - - $this->reader = $this->getReader(); - $this->loader = $this->getClassLoader($this->reader); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLoadMissingClass() - { - $this->loader->load('MissingClass'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLoadAbstractClass() - { - $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\AbstractClass'); - } - - /** - * @dataProvider provideTestSupportsChecksResource - */ - public function testSupportsChecksResource($resource, $expectedSupports) - { - $this->assertSame($expectedSupports, $this->loader->supports($resource), '->supports() returns true if the resource is loadable'); - } - - public function provideTestSupportsChecksResource() - { - return array( - array('class', true), - array('\fully\qualified\class\name', true), - array('namespaced\class\without\leading\slash', true), - array('ÿClassWithLegalSpecialCharacters', true), - array('5', false), - array('foo.foo', false), - array(null, false), - ); - } - - public function testSupportsChecksTypeIfSpecified() - { - $this->assertTrue($this->loader->supports('class', 'annotation'), '->supports() checks the resource type if specified'); - $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'), - ), - array( - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('name' => 'route1', 'defaults' => array('arg2' => 'foobar')), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), - ), - array( - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('name' => 'route1', 'defaults' => array('arg2' => 'foo'), 'condition' => 'context.getMethod() == "GET"'), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), - ), - ); - } - - /** - * @dataProvider getLoadTests - */ - public function testLoad($className, $routeDatas = array(), $methodArgs = array()) - { - $routeDatas = array_replace(array( - 'name' => 'route', - 'path' => '/', - 'requirements' => array(), - 'options' => array(), - 'defaults' => array(), - 'schemes' => array(), - 'methods' => array(), - 'condition' => null, - ), $routeDatas); - - $this->reader - ->expects($this->once()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array($this->getAnnotatedRoute($routeDatas)))) - ; - $routeCollection = $this->loader->load($className); - $route = $routeCollection->get($routeDatas['name']); - - $this->assertSame($routeDatas['path'], $route->getPath(), '->load preserves path 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($methodArgs, $routeDatas['defaults']), $route->getDefaults(), '->load preserves defaults annotation'); - $this->assertEquals($routeDatas['condition'], $route->getCondition(), '->load preserves condition annotation'); - } - - public function testClassRouteLoad() - { - $classRouteDatas = array('path' => '/classRoutePrefix'); - - $routeDatas = array( - 'name' => 'route1', - 'path' => '/', - ); - - $this->reader - ->expects($this->once()) - ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteDatas))) - ; - - $this->reader - ->expects($this->once()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array($this->getAnnotatedRoute($routeDatas)))) - ; - $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass'); - $route = $routeCollection->get($routeDatas['name']); - - $this->assertSame($classRouteDatas['path'].$routeDatas['path'], $route->getPath(), '->load preserves class route path annotation'); - } - - private function getAnnotatedRoute($datas) - { - return new Route($datas); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php deleted file mode 100644 index 29126ba4f..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader; -use Symfony\Component\Config\FileLocator; - -class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest -{ - protected $loader; - protected $reader; - - protected function setUp() - { - parent::setUp(); - - $this->reader = $this->getReader(); - $this->loader = new AnnotationDirectoryLoader(new FileLocator(), $this->getClassLoader($this->reader)); - } - - public function testLoad() - { - $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'); - } - - public function testSupports() - { - $fixturesDir = __DIR__.'/../Fixtures'; - - $this->assertTrue($this->loader->supports($fixturesDir), '->supports() returns true if the resource is loadable'); - $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($this->loader->supports($fixturesDir, 'annotation'), '->supports() checks the resource type if specified'); - $this->assertFalse($this->loader->supports($fixturesDir, 'foo'), '->supports() checks the resource type if specified'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php deleted file mode 100644 index f0a8a0e32..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Loader\AnnotationFileLoader; -use Symfony\Component\Config\FileLocator; - -class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest -{ - protected $loader; - protected $reader; - - protected function setUp() - { - parent::setUp(); - - $this->reader = $this->getReader(); - $this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader)); - } - - public function testLoad() - { - $this->reader->expects($this->once())->method('getClassAnnotation'); - - $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); - } - - public function testSupports() - { - $fixture = __DIR__.'/../Fixtures/annotated.php'; - - $this->assertTrue($this->loader->supports($fixture), '->supports() returns true if the resource is loadable'); - $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($this->loader->supports($fixture, 'annotation'), '->supports() checks the resource type if specified'); - $this->assertFalse($this->loader->supports($fixture, 'foo'), '->supports() checks the resource type if specified'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php deleted file mode 100644 index d34fa87ec..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/ClosureLoaderTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Loader\ClosureLoader; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -class ClosureLoaderTest extends \PHPUnit_Framework_TestCase -{ - public function testSupports() - { - $loader = new ClosureLoader(); - - $closure = function () {}; - - $this->assertTrue($loader->supports($closure), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports($closure, 'closure'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports($closure, 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoad() - { - $loader = new ClosureLoader(); - - $route = new Route('/'); - $routes = $loader->load(function () use ($route) { - $routes = new RouteCollection(); - - $routes->add('foo', $route); - - return $routes; - }); - - $this->assertEquals($route, $routes->get('foo'), '->load() loads a \Closure resource'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php deleted file mode 100644 index 8e2d98499..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Routing\Loader\PhpFileLoader; - -class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase -{ - public function testSupports() - { - $loader = new PhpFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); - - $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports('foo.php', 'php'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports('foo.php', 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoadWithRoute() - { - $loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validpattern.php'); - $routes = $routeCollection->all(); - - $this->assertCount(2, $routes, 'Two routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - } - } - - public function testLoadWithImport() - { - $loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validresource.php'); - $routes = $routeCollection->all(); - - $this->assertCount(2, $routes, 'Two routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/prefix/blog/{slug}', $route->getPath()); - $this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - } - } - - public function testThatDefiningVariableInConfigFileHasNoSideEffects() - { - $locator = new FileLocator(array(__DIR__.'/../Fixtures')); - $loader = new PhpFileLoader($locator); - $routeCollection = $loader->load('with_define_path_variable.php'); - $resources = $routeCollection->getResources(); - $this->assertCount(1, $resources); - $this->assertContainsOnly('Symfony\Component\Config\Resource\ResourceInterface', $resources); - $fileResource = reset($resources); - $this->assertSame( - realpath($locator->locate('with_define_path_variable.php')), - (string) $fileResource - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php deleted file mode 100644 index c488c43bc..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Routing\Loader\XmlFileLoader; -use Symfony\Component\Routing\Tests\Fixtures\CustomXmlFileLoader; - -class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase -{ - public function testSupports() - { - $loader = new XmlFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); - - $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports('foo.xml', 'xml'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports('foo.xml', 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoadWithRoute() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validpattern.xml'); - $routes = $routeCollection->all(); - - $this->assertCount(3, $routes, 'Three routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - $identicalRoutes = array_slice($routes, 0, 2); - - foreach ($identicalRoutes as $route) { - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('locale')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); - } - } - - public function testLoadWithNamespacePrefix() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('namespaceprefix.xml'); - - $this->assertCount(1, $routeCollection->all(), 'One route is loaded'); - - $route = $routeCollection->get('blog_show'); - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{_locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('slug')); - $this->assertSame('en|fr|de', $route->getRequirement('_locale')); - $this->assertNull($route->getDefault('slug')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - } - - public function testLoadWithImport() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validresource.xml'); - $routes = $routeCollection->all(); - - $this->assertCount(3, $routes, 'Three routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/{foo}/blog/{slug}', $route->getPath()); - $this->assertSame('123', $route->getDefault('foo')); - $this->assertSame('\d+', $route->getRequirement('foo')); - $this->assertSame('bar', $route->getOption('foo')); - $this->assertSame('', $route->getHost()); - $this->assertSame('context.getMethod() == "POST"', $route->getCondition()); - } - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getPathsToInvalidFiles - */ - public function testLoadThrowsExceptionWithInvalidFile($filePath) - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load($filePath); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getPathsToInvalidFiles - */ - public function testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation($filePath) - { - $loader = new CustomXmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load($filePath); - } - - public function getPathsToInvalidFiles() - { - return array(array('nonvalidnode.xml'), array('nonvalidroute.xml'), array('nonvalid.xml'), array('missing_id.xml'), array('missing_path.xml')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Document types are not allowed. - */ - public function testDocTypeIsNotAllowed() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load('withdoctype.xml'); - } - - public function testNullValues() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('null_values.xml'); - $route = $routeCollection->get('blog_show'); - - $this->assertTrue($route->hasDefault('foo')); - $this->assertNull($route->getDefault('foo')); - $this->assertTrue($route->hasDefault('bar')); - $this->assertNull($route->getDefault('bar')); - $this->assertEquals('foo', $route->getDefault('foobar')); - $this->assertEquals('bar', $route->getDefault('baz')); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php deleted file mode 100644 index 6589ef7b7..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Routing\Loader\YamlFileLoader; -use Symfony\Component\Config\Resource\FileResource; - -class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase -{ - public function testSupports() - { - $loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\FileLocator')); - - $this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable'); - $this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports('foo.yml', 'yaml'), '->supports() checks the resource type if specified'); - $this->assertTrue($loader->supports('foo.yaml', 'yaml'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports('foo.yml', 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoadDoesNothingIfEmpty() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $collection = $loader->load('empty.yml'); - - $this->assertEquals(array(), $collection->all()); - $this->assertEquals(array(new FileResource(realpath(__DIR__.'/../Fixtures/empty.yml'))), $collection->getResources()); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getPathsToInvalidFiles - */ - public function testLoadThrowsExceptionWithInvalidFile($filePath) - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load($filePath); - } - - public function getPathsToInvalidFiles() - { - return array(array('nonvalid.yml'), array('nonvalid2.yml'), array('incomplete.yml'), array('nonvalidkeys.yml'), array('nonesense_resource_plus_path.yml'), array('nonesense_type_without_resource.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->getPath()); - } - - public function testLoadWithRoute() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validpattern.yml'); - $routes = $routeCollection->all(); - - $this->assertCount(3, $routes, 'Three routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - $identicalRoutes = array_slice($routes, 0, 2); - - foreach ($identicalRoutes as $route) { - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('locale')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); - } - } - - public function testLoadWithResource() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validresource.yml'); - $routes = $routeCollection->all(); - - $this->assertCount(3, $routes, 'Three routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/{foo}/blog/{slug}', $route->getPath()); - $this->assertSame('123', $route->getDefault('foo')); - $this->assertSame('\d+', $route->getRequirement('foo')); - $this->assertSame('bar', $route->getOption('foo')); - $this->assertSame('', $route->getHost()); - $this->assertSame('context.getMethod() == "POST"', $route->getCondition()); - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php deleted file mode 100644 index 7b6001c1f..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperCollectionTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php deleted file mode 100644 index de01a75d0..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -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()->getPath()); - } - } - - return $string; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php deleted file mode 100644 index 5ba250243..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/LegacyApacheMatcherDumperTest.php +++ /dev/null @@ -1,204 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher\Dumper; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper; - -/** - * @group legacy - */ -class LegacyApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase -{ - protected static $fixturesPath; - - public static function setUpBeforeClass() - { - self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/'); - } - - protected function setUp() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - } - - public function testDump() - { - $dumper = new ApacheMatcherDumper($this->getRouteCollection()); - - $this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher1.apache', $dumper->dump(), '->dump() dumps basic routes to the correct apache format.'); - } - - /** - * @dataProvider provideEscapeFixtures - */ - public function testEscapePattern($src, $dest, $char, $with, $message) - { - $r = new \ReflectionMethod(new ApacheMatcherDumper($this->getRouteCollection()), 'escape'); - $r->setAccessible(true); - $this->assertEquals($dest, $r->invoke(null, $src, $char, $with), $message); - } - - public function provideEscapeFixtures() - { - return array( - array('foo', 'foo', ' ', '-', 'Preserve string that should not be escaped'), - array('fo-o', 'fo-o', ' ', '-', 'Preserve string that should not be escaped'), - array('fo o', 'fo- o', ' ', '-', 'Escape special characters'), - array('fo-- o', 'fo--- o', ' ', '-', 'Escape special characters'), - array('fo- o', 'fo- o', ' ', '-', 'Do not escape already escaped string'), - ); - } - - public function testEscapeScriptName() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - $dumper = new ApacheMatcherDumper($collection); - $this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher2.apache', $dumper->dump(array('script_name' => 'ap p_d\ ev.php'))); - } - - private function getRouteCollection() - { - $collection = new RouteCollection(); - - // defaults and requirements - $collection->add('foo', new Route( - '/foo/{bar}', - array('def' => 'test'), - array('bar' => 'baz|symfony') - )); - // defaults parameters in pattern - $collection->add('foobar', new Route( - '/foo/{bar}', - array('bar' => 'toto') - )); - // method requirement - $collection->add('bar', new Route( - '/bar/{foo}', - array(), - array('_method' => 'GET|head') - )); - // method requirement (again) - $collection->add('baragain', new Route( - '/baragain/{foo}', - array(), - array('_method' => 'get|post') - )); - // simple - $collection->add('baz', new Route( - '/test/baz' - )); - // simple with extension - $collection->add('baz2', new Route( - '/test/baz.html' - )); - // trailing slash - $collection->add('baz3', new Route( - '/test/baz3/' - )); - // trailing slash with variable - $collection->add('baz4', new Route( - '/test/{foo}/' - )); - // trailing slash and safe method - $collection->add('baz5', new Route( - '/test/{foo}/', - array(), - array('_method' => 'get') - )); - // trailing slash and unsafe method - $collection->add('baz5unsafe', new Route( - '/testunsafe/{foo}/', - array(), - array('_method' => 'post') - )); - // complex - $collection->add('baz6', new Route( - '/test/baz', - array('foo' => 'bar baz') - )); - // space in path - $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); - - $collection2->addPrefix('/c2'); - $collection1->addCollection($collection2); - - $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); - - // host 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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php deleted file mode 100644 index 7cf529c34..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ /dev/null @@ -1,264 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher\Dumper; - -use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \LogicException - */ - public function testDumpWhenSchemeIsUsedWithoutAProperDumper() - { - $collection = new RouteCollection(); - $collection->add('secure', new Route( - '/secure', - array(), - array('_scheme' => 'https') - )); - $dumper = new PhpMatcherDumper($collection); - $dumper->dump(); - } - - /** - * @dataProvider getRouteCollections - */ - 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.'); - } - - public function getRouteCollections() - { - /* test case 1 */ - - $collection = new RouteCollection(); - - $collection->add('overridden', new Route('/overridden')); - - // defaults and requirements - $collection->add('foo', new Route( - '/foo/{bar}', - array('def' => 'test'), - array('bar' => 'baz|symfony') - )); - // method requirement - $collection->add('bar', new Route( - '/bar/{foo}', - array(), - array('_method' => 'GET|head') - )); - // GET method requirement automatically adds HEAD as valid - $collection->add('barhead', new Route( - '/barhead/{foo}', - array(), - array('_method' => 'GET') - )); - // simple - $collection->add('baz', new Route( - '/test/baz' - )); - // simple with extension - $collection->add('baz2', new Route( - '/test/baz.html' - )); - // trailing slash - $collection->add('baz3', new Route( - '/test/baz3/' - )); - // trailing slash with variable - $collection->add('baz4', new Route( - '/test/{foo}/' - )); - // trailing slash and method - $collection->add('baz5', new Route( - '/test/{foo}/', - array(), - array('_method' => 'post') - )); - // complex name - $collection->add('baz.baz6', new Route( - '/test/{foo}/', - array(), - array('_method' => 'put') - )); - // defaults without variable - $collection->add('foofoo', new Route( - '/foofoo', - array('def' => 'test') - )); - // pattern with quotes - $collection->add('quoter', new Route( - '/{quoter}', - array(), - array('quoter' => '[\']+') - )); - // space in pattern - $collection->add('space', new Route( - '/spa ce' - )); - - // prefixes - $collection1 = new RouteCollection(); - $collection1->add('overridden', new Route('/overridden1')); - $collection1->add('foo1', new Route('/{foo}')); - $collection1->add('bar1', new Route('/{bar}')); - $collection1->addPrefix('/b\'b'); - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1); - $collection2->add('overridden', new Route('/{var}', array(), array('var' => '.*'))); - $collection1 = new RouteCollection(); - $collection1->add('foo2', new Route('/{foo1}')); - $collection1->add('bar2', new Route('/{bar1}')); - $collection1->addPrefix('/b\'b'); - $collection2->addCollection($collection1); - $collection2->addPrefix('/a'); - $collection->addCollection($collection2); - - // overridden through addCollection() and multiple sub-collections with no own prefix - $collection1 = new RouteCollection(); - $collection1->add('overridden2', new Route('/old')); - $collection1->add('helloWorld', new Route('/hello/{who}', array('who' => 'World!'))); - $collection2 = new RouteCollection(); - $collection3 = new RouteCollection(); - $collection3->add('overridden2', new Route('/new')); - $collection3->add('hey', new Route('/hey/')); - $collection2->addCollection($collection3); - $collection1->addCollection($collection2); - $collection1->addPrefix('/multi'); - $collection->addCollection($collection1); - - // "dynamic" prefix - $collection1 = new RouteCollection(); - $collection1->add('foo3', new Route('/{foo}')); - $collection1->add('bar3', new Route('/{bar}')); - $collection1->addPrefix('/b'); - $collection1->addPrefix('{_locale}'); - $collection->addCollection($collection1); - - // route between collections - $collection->add('ababa', new Route('/ababa')); - - // collection with static prefix but only one route - $collection1 = new RouteCollection(); - $collection1->add('foo4', new Route('/{foo}')); - $collection1->addPrefix('/aba'); - $collection->addCollection($collection1); - - // prefix and host - - $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); - - // host 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...')); - $collection2 = new RouteCollection(); - $collection2->add('b', new Route('/{var}')); - $collection3 = new RouteCollection(); - $collection3->add('c', new Route('/{var}')); - $collection3->addPrefix('/c'); - $collection2->addCollection($collection3); - $collection2->addPrefix('/b'); - $collection1->addCollection($collection2); - $collection1->addPrefix('/a'); - $collection->addCollection($collection1); - - /* test case 2 */ - - $redirectCollection = clone $collection; - - // force HTTPS redirection - $redirectCollection->add('secure', new Route( - '/secure', - array(), - array('_scheme' => 'https') - )); - - // force HTTP redirection - $redirectCollection->add('nonsecure', new Route( - '/nonsecure', - array(), - array('_scheme' => 'http') - )); - - /* test case 3 */ - - $rootprefixCollection = new RouteCollection(); - $rootprefixCollection->add('static', new Route('/test')); - $rootprefixCollection->add('dynamic', new Route('/{var}')); - $rootprefixCollection->addPrefix('rootprefix'); - $route = new Route('/with-condition'); - $route->setCondition('context.getMethod() == "GET"'); - $rootprefixCollection->add('with-condition', $route); - - return array( - array($collection, 'url_matcher1.php', array()), - array($redirectCollection, 'url_matcher2.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')), - array($rootprefixCollection, 'url_matcher3.php', array()), - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/LegacyApacheUrlMatcherTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/LegacyApacheUrlMatcherTest.php deleted file mode 100644 index f42b7f206..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/LegacyApacheUrlMatcherTest.php +++ /dev/null @@ -1,156 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Matcher\ApacheUrlMatcher; - -/** - * @group legacy - */ -class LegacyApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase -{ - protected $server; - - protected function setUp() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->server = $_SERVER; - } - - protected function tearDown() - { - $_SERVER = $this->server; - } - - /** - * @dataProvider getMatchData - */ - public function testMatch($name, $pathinfo, $server, $expect) - { - $collection = new RouteCollection(); - $context = new RequestContext(); - $matcher = new ApacheUrlMatcher($collection, $context); - - $_SERVER = $server; - - $result = $matcher->match($pathinfo); - $this->assertSame(var_export($expect, true), var_export($result, true)); - } - - public function getMatchData() - { - return array( - array( - 'Simple route', - '/hello/world', - array( - '_ROUTING_route' => 'hello', - '_ROUTING_param__controller' => 'AcmeBundle:Default:index', - '_ROUTING_param_name' => 'world', - ), - array( - '_controller' => 'AcmeBundle:Default:index', - 'name' => 'world', - '_route' => 'hello', - ), - ), - array( - 'Route with params and defaults', - '/hello/hugo', - array( - '_ROUTING_route' => 'hello', - '_ROUTING_param__controller' => 'AcmeBundle:Default:index', - '_ROUTING_param_name' => 'hugo', - '_ROUTING_default_name' => 'world', - ), - array( - 'name' => 'hugo', - '_controller' => 'AcmeBundle:Default:index', - '_route' => 'hello', - ), - ), - array( - 'Route with defaults only', - '/hello', - array( - '_ROUTING_route' => 'hello', - '_ROUTING_param__controller' => 'AcmeBundle:Default:index', - '_ROUTING_default_name' => 'world', - ), - array( - 'name' => 'world', - '_controller' => 'AcmeBundle:Default:index', - '_route' => 'hello', - ), - ), - array( - 'Redirect with many ignored attributes', - '/legacy/{cat1}/{cat2}/{id}.html', - array( - '_ROUTING_route' => 'product_view', - '_ROUTING_param__controller' => 'FrameworkBundle:Redirect:redirect', - '_ROUTING_default_ignoreAttributes[0]' => 'attr_a', - '_ROUTING_default_ignoreAttributes[1]' => 'attr_b', - ), - array( - 'ignoreAttributes' => array('attr_a', 'attr_b'), - '_controller' => 'FrameworkBundle:Redirect:redirect', - '_route' => 'product_view', - ), - ), - array( - 'REDIRECT_ envs', - '/hello/world', - array( - '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/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php deleted file mode 100644 index 5cbb60547..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; - -class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase -{ - public function testRedirectWhenNoSlash() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/')); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher->expects($this->once())->method('redirect'); - $matcher->match('/foo'); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ - public function testRedirectWhenNoSlashForNonSafeMethod() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/')); - - $context = new RequestContext(); - $context->setMethod('POST'); - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, $context)); - $matcher->match('/foo'); - } - - public function testSchemeRedirectBC() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher - ->expects($this->once()) - ->method('redirect') - ->with('/foo', 'foo', 'https') - ->will($this->returnValue(array('_route' => 'foo'))) - ; - $matcher->match('/foo'); - } - - public function testSchemeRedirectRedirectsToFirstScheme() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('FTP', 'HTTPS'))); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher - ->expects($this->once()) - ->method('redirect') - ->with('/foo', 'foo', 'ftp') - ->will($this->returnValue(array('_route' => 'foo'))) - ; - $matcher->match('/foo'); - } - - public function testNoSchemaRedirectIfOnOfMultipleSchemesMatches() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https', 'http'))); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher - ->expects($this->never()) - ->method('redirect') - ; - $matcher->match('/foo'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php deleted file mode 100644 index 969ab0a2f..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Matcher\TraceableUrlMatcher; - -class TraceableUrlMatcherTest extends \PHPUnit_Framework_TestCase -{ - public function test() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array('_method' => 'POST'))); - $coll->add('bar', new Route('/bar/{id}', array(), array('id' => '\d+'))); - $coll->add('bar1', new Route('/bar/{name}', array(), array('id' => '\w+', '_method' => 'POST'))); - $coll->add('bar2', new Route('/foo', array(), array(), array(), 'baz')); - $coll->add('bar3', new Route('/foo1', array(), array(), array(), 'baz')); - $coll->add('bar4', new Route('/foo2', array(), array(), array(), 'baz', array(), array(), 'context.getMethod() == "GET"')); - - $context = new RequestContext(); - $context->setHost('baz'); - - $matcher = new TraceableUrlMatcher($coll, $context); - $traces = $matcher->getTraces('/babar'); - $this->assertEquals(array(0, 0, 0, 0, 0, 0), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/foo'); - $this->assertEquals(array(1, 0, 0, 2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/bar/12'); - $this->assertEquals(array(0, 2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/bar/dd'); - $this->assertEquals(array(0, 1, 1, 0, 0, 0), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/foo1'); - $this->assertEquals(array(0, 0, 0, 0, 2), $this->getLevels($traces)); - - $context->setMethod('POST'); - $traces = $matcher->getTraces('/foo'); - $this->assertEquals(array(2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/bar/dd'); - $this->assertEquals(array(0, 1, 2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/foo2'); - $this->assertEquals(array(0, 0, 0, 0, 0, 1), $this->getLevels($traces)); - } - - public function testMatchRouteOnMultipleHosts() - { - $routes = new RouteCollection(); - $routes->add('first', new Route( - '/mypath/', - array('_controller' => 'MainBundle:Info:first'), - array(), - array(), - 'some.example.com' - )); - - $routes->add('second', new Route( - '/mypath/', - array('_controller' => 'MainBundle:Info:second'), - array(), - array(), - 'another.example.com' - )); - - $context = new RequestContext(); - $context->setHost('baz'); - - $matcher = new TraceableUrlMatcher($routes, $context); - - $traces = $matcher->getTraces('/mypath/'); - $this->assertEquals( - array(TraceableUrlMatcher::ROUTE_ALMOST_MATCHES, TraceableUrlMatcher::ROUTE_ALMOST_MATCHES), - $this->getLevels($traces) - ); - } - - public function getLevels($traces) - { - $levels = array(); - foreach ($traces as $trace) { - $levels[] = $trace['level']; - } - - return $levels; - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php deleted file mode 100644 index 99f2bc3ec..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ /dev/null @@ -1,429 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; - -class UrlMatcherTest extends \PHPUnit_Framework_TestCase -{ - public function testNoMethodSoAllowed() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo')); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/foo'); - } - - public function testMethodNotAllowed() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array('_method' => 'post'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - - try { - $matcher->match('/foo'); - $this->fail(); - } catch (MethodNotAllowedException $e) { - $this->assertEquals(array('POST'), $e->getAllowedMethods()); - } - } - - public function testHeadAllowedWhenRequirementContainsGet() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array('_method' => 'get'))); - - $matcher = new UrlMatcher($coll, new RequestContext('', 'head')); - $matcher->match('/foo'); - } - - public function testMethodNotAllowedAggregatesAllowedMethods() - { - $coll = new RouteCollection(); - $coll->add('foo1', new Route('/foo', array(), array('_method' => 'post'))); - $coll->add('foo2', new Route('/foo', array(), array('_method' => 'put|delete'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - - try { - $matcher->match('/foo'); - $this->fail(); - } catch (MethodNotAllowedException $e) { - $this->assertEquals(array('POST', 'PUT', 'DELETE'), $e->getAllowedMethods()); - } - } - - public function testMatch() - { - // test the patterns are matched and parameters are returned - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo/{bar}')); - $matcher = new UrlMatcher($collection, new RequestContext()); - try { - $matcher->match('/no-match'); - $this->fail(); - } catch (ResourceNotFoundException $e) { - } - $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz'), $matcher->match('/foo/baz')); - - // test that defaults are merged - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo/{bar}', array('def' => 'test'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'def' => 'test'), $matcher->match('/foo/baz')); - - // test that route "method" is ignored if no method is given in the context - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo', array(), array('_method' => 'GET|head'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertInternalType('array', $matcher->match('/foo')); - - // route does not match with POST method context - $matcher = new UrlMatcher($collection, new RequestContext('', 'post')); - try { - $matcher->match('/foo'); - $this->fail(); - } catch (MethodNotAllowedException $e) { - } - - // route does match with GET or HEAD method context - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertInternalType('array', $matcher->match('/foo')); - $matcher = new UrlMatcher($collection, new RequestContext('', 'head')); - $this->assertInternalType('array', $matcher->match('/foo')); - - // route with an optional variable as the first segment - $collection = new RouteCollection(); - $collection->add('bar', new Route('/{bar}/foo', array('bar' => 'bar'), array('bar' => 'foo|bar'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/bar/foo')); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo/foo')); - - $collection = new RouteCollection(); - $collection->add('bar', new Route('/{bar}', array('bar' => 'bar'), array('bar' => 'foo|bar'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo')); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/')); - - // route with only optional variables - $collection = new RouteCollection(); - $collection->add('bar', new Route('/{foo}/{bar}', array('foo' => 'foo', 'bar' => 'bar'), array())); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'bar', 'foo' => 'foo', 'bar' => 'bar'), $matcher->match('/')); - $this->assertEquals(array('_route' => 'bar', 'foo' => 'a', 'bar' => 'bar'), $matcher->match('/a')); - $this->assertEquals(array('_route' => 'bar', 'foo' => 'a', 'bar' => 'b'), $matcher->match('/a/b')); - } - - public function testMatchWithPrefixes() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{foo}')); - $collection->addPrefix('/b'); - $collection->addPrefix('/a'); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'foo' => 'foo'), $matcher->match('/a/b/foo')); - } - - public function testMatchWithDynamicPrefix() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{foo}')); - $collection->addPrefix('/b'); - $collection->addPrefix('/{_locale}'); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $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(); - $chars = '!"$%éà &\'()*+,./:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[]^_`abcdefghijklmnopqrstuvwxyz{|}~-'; - $collection->add('foo', new Route('/{foo}/bar', array(), array('foo' => '['.preg_quote($chars).']+'))); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'foo' => $chars), $matcher->match('/'.rawurlencode($chars).'/bar')); - $this->assertEquals(array('_route' => 'foo', 'foo' => $chars), $matcher->match('/'.strtr($chars, array('%' => '%25')).'/bar')); - } - - public function testMatchWithDotMetacharacterInRequirements() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{foo}/bar', array(), array('foo' => '.+'))); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'foo' => "\n"), $matcher->match('/'.urlencode("\n").'/bar'), 'linefeed character is matched'); - } - - public function testMatchOverriddenRoute() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/foo1')); - - $collection->addCollection($collection1); - - $matcher = new UrlMatcher($collection, new RequestContext()); - - $this->assertEquals(array('_route' => 'foo'), $matcher->match('/foo1')); - $this->setExpectedException('Symfony\Component\Routing\Exception\ResourceNotFoundException'); - $this->assertEquals(array(), $matcher->match('/foo')); - } - - public function testMatchRegression() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{foo}')); - $coll->add('bar', new Route('/foo/bar/{foo}')); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $this->assertEquals(array('foo' => 'bar', '_route' => 'bar'), $matcher->match('/foo/bar/bar')); - - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{bar}')); - $matcher = new UrlMatcher($collection, new RequestContext()); - try { - $matcher->match('/'); - $this->fail(); - } catch (ResourceNotFoundException $e) { - } - } - - 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(); - $coll->add('test', new Route('/{foo}-{bar}-', array(), array('foo' => '.+', 'bar' => '.+'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $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 - */ - public function testSchemeRequirementBC() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/foo'); - } - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ - public function testSchemeRequirement() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https'))); - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/foo'); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ - public function testCondition() - { - $coll = new RouteCollection(); - $route = new Route('/foo'); - $route->setCondition('context.getMethod() == "POST"'); - $coll->add('foo', $route); - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/foo'); - } - - public function testDecodeOnce() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{foo}')); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $this->assertEquals(array('foo' => 'bar%23', '_route' => 'foo'), $matcher->match('/foo/bar%2523')); - } - - public function testCannotRelyOnPrefix() - { - $coll = new RouteCollection(); - - $subColl = new RouteCollection(); - $subColl->add('bar', new Route('/bar')); - $subColl->addPrefix('/prefix'); - // overwrite the pattern, so the prefix is not valid anymore for this route in the collection - $subColl->get('bar')->setPath('/new'); - - $coll->addCollection($subColl); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $this->assertEquals(array('_route' => 'bar'), $matcher->match('/new')); - } - - public function testWithHost() - { - $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 testWithHostOnRouteCollection() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{foo}')); - $coll->add('bar', new Route('/bar/{foo}', array(), array(), array(), '{locale}.example.net')); - $coll->setHost('{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 testWithOutHostHostDoesNotMatch() - { - $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'); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ - public function testPathIsCaseSensitive() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/locale', array(), array('locale' => 'EN|FR|DE'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/en'); - } - - public function testHostIsCaseInsensitive() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/', array(), array('locale' => 'EN|FR|DE'), array(), '{locale}.example.com')); - - $matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com')); - $this->assertEquals(array('_route' => 'foo', 'locale' => 'en'), $matcher->match('/')); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RequestContextTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RequestContextTest.php deleted file mode 100644 index 58612683e..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RequestContextTest.php +++ /dev/null @@ -1,159 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\RequestContext; - -class RequestContextTest extends \PHPUnit_Framework_TestCase -{ - public function testConstruct() - { - $requestContext = new RequestContext( - 'foo', - 'post', - 'foo.bar', - 'HTTPS', - 8080, - 444, - '/baz', - 'bar=foobar' - ); - - $this->assertEquals('foo', $requestContext->getBaseUrl()); - $this->assertEquals('POST', $requestContext->getMethod()); - $this->assertEquals('foo.bar', $requestContext->getHost()); - $this->assertEquals('https', $requestContext->getScheme()); - $this->assertSame(8080, $requestContext->getHttpPort()); - $this->assertSame(444, $requestContext->getHttpsPort()); - $this->assertEquals('/baz', $requestContext->getPathInfo()); - $this->assertEquals('bar=foobar', $requestContext->getQueryString()); - } - - public function testFromRequest() - { - $request = Request::create('https://test.com:444/foo?bar=baz'); - $requestContext = new RequestContext(); - $requestContext->setHttpPort(123); - $requestContext->fromRequest($request); - - $this->assertEquals('', $requestContext->getBaseUrl()); - $this->assertEquals('GET', $requestContext->getMethod()); - $this->assertEquals('test.com', $requestContext->getHost()); - $this->assertEquals('https', $requestContext->getScheme()); - $this->assertEquals('/foo', $requestContext->getPathInfo()); - $this->assertEquals('bar=baz', $requestContext->getQueryString()); - $this->assertSame(123, $requestContext->getHttpPort()); - $this->assertSame(444, $requestContext->getHttpsPort()); - - $request = Request::create('http://test.com:8080/foo?bar=baz'); - $requestContext = new RequestContext(); - $requestContext->setHttpsPort(567); - $requestContext->fromRequest($request); - - $this->assertSame(8080, $requestContext->getHttpPort()); - $this->assertSame(567, $requestContext->getHttpsPort()); - } - - public function testGetParameters() - { - $requestContext = new RequestContext(); - $this->assertEquals(array(), $requestContext->getParameters()); - - $requestContext->setParameters(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $requestContext->getParameters()); - } - - public function testHasParameter() - { - $requestContext = new RequestContext(); - $requestContext->setParameters(array('foo' => 'bar')); - - $this->assertTrue($requestContext->hasParameter('foo')); - $this->assertFalse($requestContext->hasParameter('baz')); - } - - public function testGetParameter() - { - $requestContext = new RequestContext(); - $requestContext->setParameters(array('foo' => 'bar')); - - $this->assertEquals('bar', $requestContext->getParameter('foo')); - $this->assertNull($requestContext->getParameter('baz')); - } - - public function testSetParameter() - { - $requestContext = new RequestContext(); - $requestContext->setParameter('foo', 'bar'); - - $this->assertEquals('bar', $requestContext->getParameter('foo')); - } - - public function testMethod() - { - $requestContext = new RequestContext(); - $requestContext->setMethod('post'); - - $this->assertSame('POST', $requestContext->getMethod()); - } - - public function testScheme() - { - $requestContext = new RequestContext(); - $requestContext->setScheme('HTTPS'); - - $this->assertSame('https', $requestContext->getScheme()); - } - - public function testHost() - { - $requestContext = new RequestContext(); - $requestContext->setHost('eXampLe.com'); - - $this->assertSame('example.com', $requestContext->getHost()); - } - - public function testQueryString() - { - $requestContext = new RequestContext(); - $requestContext->setQueryString(null); - - $this->assertSame('', $requestContext->getQueryString()); - } - - public function testPort() - { - $requestContext = new RequestContext(); - $requestContext->setHttpPort('123'); - $requestContext->setHttpsPort('456'); - - $this->assertSame(123, $requestContext->getHttpPort()); - $this->assertSame(456, $requestContext->getHttpsPort()); - } - - public function testFluentInterface() - { - $requestContext = new RequestContext(); - - $this->assertSame($requestContext, $requestContext->setBaseUrl('/app.php')); - $this->assertSame($requestContext, $requestContext->setPathInfo('/index')); - $this->assertSame($requestContext, $requestContext->setMethod('POST')); - $this->assertSame($requestContext, $requestContext->setScheme('https')); - $this->assertSame($requestContext, $requestContext->setHost('example.com')); - $this->assertSame($requestContext, $requestContext->setQueryString('foo=bar')); - $this->assertSame($requestContext, $requestContext->setHttpPort(80)); - $this->assertSame($requestContext, $requestContext->setHttpsPort(443)); - $this->assertSame($requestContext, $requestContext->setParameters(array())); - $this->assertSame($requestContext, $requestContext->setParameter('foo', 'bar')); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php deleted file mode 100644 index ad2d0e0f2..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ /dev/null @@ -1,304 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; - -class RouteCollectionTest extends \PHPUnit_Framework_TestCase -{ - public function testRoute() - { - $collection = new RouteCollection(); - $route = new Route('/foo'); - $collection->add('foo', $route); - $this->assertEquals(array('foo' => $route), $collection->all(), '->add() adds a route'); - $this->assertEquals($route, $collection->get('foo'), '->get() returns a route by name'); - $this->assertNull($collection->get('bar'), '->get() returns null if a route does not exist'); - } - - public function testOverriddenRoute() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - $collection->add('foo', new Route('/foo1')); - - $this->assertEquals('/foo1', $collection->get('foo')->getPath()); - } - - public function testDeepOverriddenRoute() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/foo1')); - - $collection2 = new RouteCollection(); - $collection2->add('foo', new Route('/foo2')); - - $collection1->addCollection($collection2); - $collection->addCollection($collection1); - - $this->assertEquals('/foo2', $collection1->get('foo')->getPath()); - $this->assertEquals('/foo2', $collection->get('foo')->getPath()); - } - - public function testIterator() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', $bar = new Route('/bar')); - $collection1->add('foo', $foo = new Route('/foo-new')); - $collection->addCollection($collection1); - $collection->add('last', $last = new Route('/last')); - - $this->assertInstanceOf('\ArrayIterator', $collection->getIterator()); - $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'last' => $last), $collection->getIterator()->getArrayCopy()); - } - - public function testCount() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', new Route('/bar')); - $collection->addCollection($collection1); - - $this->assertCount(2, $collection); - } - - public function testAddCollection() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', $bar = new Route('/bar')); - $collection1->add('foo', $foo = new Route('/foo-new')); - - $collection2 = new RouteCollection(); - $collection2->add('grandchild', $grandchild = new Route('/grandchild')); - - $collection1->addCollection($collection2); - $collection->addCollection($collection1); - $collection->add('last', $last = new Route('/last')); - - $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'grandchild' => $grandchild, 'last' => $last), $collection->all(), - '->addCollection() imports routes of another collection, overrides if necessary and adds them at the end'); - } - - public function testAddCollectionWithResources() - { - $collection = new RouteCollection(); - $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); - $collection1 = new RouteCollection(); - $collection1->addResource($foo1 = new FileResource(__DIR__.'/Fixtures/foo1.xml')); - $collection->addCollection($collection1); - $this->assertEquals(array($foo, $foo1), $collection->getResources(), '->addCollection() merges resources'); - } - - public function testAddDefaultsAndRequirementsAndOptions() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{placeholder}')); - $collection1 = new RouteCollection(); - $collection1->add('bar', new Route('/{placeholder}', - array('_controller' => 'fixed', 'placeholder' => 'default'), array('placeholder' => '.+'), array('option' => 'value')) - ); - $collection->addCollection($collection1); - - $collection->addDefaults(array('placeholder' => 'new-default')); - $this->assertEquals(array('placeholder' => 'new-default'), $collection->get('foo')->getDefaults(), '->addDefaults() adds defaults to all routes'); - $this->assertEquals(array('_controller' => 'fixed', 'placeholder' => 'new-default'), $collection->get('bar')->getDefaults(), - '->addDefaults() adds defaults to all routes and overwrites existing ones'); - - $collection->addRequirements(array('placeholder' => '\d+')); - $this->assertEquals(array('placeholder' => '\d+'), $collection->get('foo')->getRequirements(), '->addRequirements() adds requirements to all routes'); - $this->assertEquals(array('placeholder' => '\d+'), $collection->get('bar')->getRequirements(), - '->addRequirements() adds requirements to all routes and overwrites existing ones'); - - $collection->addOptions(array('option' => 'new-value')); - $this->assertEquals( - array('option' => 'new-value', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), - $collection->get('bar')->getOptions(), '->addOptions() adds options to all routes and overwrites existing ones' - ); - } - - public function testAddPrefix() - { - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo')); - $collection2 = new RouteCollection(); - $collection2->add('bar', $bar = new Route('/bar')); - $collection->addCollection($collection2); - $collection->addPrefix(' / '); - $this->assertSame('/foo', $collection->get('foo')->getPath(), '->addPrefix() trims the prefix and a single slash has no effect'); - $collection->addPrefix('/{admin}', array('admin' => 'admin'), array('admin' => '\d+')); - $this->assertEquals('/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() adds a prefix to all routes'); - $this->assertEquals('/{admin}/bar', $collection->get('bar')->getPath(), '->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'); - $collection->addPrefix('0'); - $this->assertEquals('/0/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash'); - $collection->addPrefix('/ /'); - $this->assertSame('/ /0/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() can handle spaces if desired'); - $this->assertSame('/ /0/{admin}/bar', $collection->get('bar')->getPath(), 'the route pattern of an added collection is in synch with the added prefix'); - } - - public function testAddPrefixOverridesDefaultsAndRequirements() - { - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo')); - $collection->add('bar', $bar = new Route('/bar', array(), array('_scheme' => 'http'))); - $collection->addPrefix('/admin', array(), array('_scheme' => 'https')); - - $this->assertEquals('https', $collection->get('foo')->getRequirement('_scheme'), '->addPrefix() overrides existing requirements'); - $this->assertEquals('https', $collection->get('bar')->getRequirement('_scheme'), '->addPrefix() overrides existing requirements'); - } - - public function testResource() - { - $collection = new RouteCollection(); - $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); - $collection->addResource($bar = new FileResource(__DIR__.'/Fixtures/bar.xml')); - $collection->addResource(new FileResource(__DIR__.'/Fixtures/foo.xml')); - - $this->assertEquals(array($foo, $bar), $collection->getResources(), - '->addResource() adds a resource and getResources() only returns unique ones by comparing the string representation'); - } - - public function testUniqueRouteWithGivenName() - { - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/old')); - $collection2 = new RouteCollection(); - $collection3 = new RouteCollection(); - $collection3->add('foo', $new = new Route('/new')); - - $collection2->addCollection($collection3); - $collection1->addCollection($collection2); - - $this->assertSame($new, $collection1->get('foo'), '->get() returns new route that overrode previous one'); - // size of 1 because collection1 contains /new but not /old anymore - $this->assertCount(1, $collection1->getIterator(), '->addCollection() removes previous routes when adding new routes with the same name'); - } - - public function testGet() - { - $collection1 = new RouteCollection(); - $collection1->add('a', $a = new Route('/a')); - $collection2 = new RouteCollection(); - $collection2->add('b', $b = new Route('/b')); - $collection1->addCollection($collection2); - $collection1->add('$péß^a|', $c = new Route('/special')); - - $this->assertSame($b, $collection1->get('b'), '->get() returns correct route in child collection'); - $this->assertSame($c, $collection1->get('$péß^a|'), '->get() can handle special characters'); - $this->assertNull($collection2->get('a'), '->get() does not return the route defined in parent collection'); - $this->assertNull($collection1->get('non-existent'), '->get() returns null when route does not exist'); - $this->assertNull($collection1->get(0), '->get() does not disclose internal child RouteCollection'); - } - - public function testRemove() - { - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', $bar = new Route('/bar')); - $collection->addCollection($collection1); - $collection->add('last', $last = new Route('/last')); - - $collection->remove('foo'); - $this->assertSame(array('bar' => $bar, 'last' => $last), $collection->all(), '->remove() can remove a single route'); - $collection->remove(array('bar', 'last')); - $this->assertSame(array(), $collection->all(), '->remove() accepts an array and can remove multiple routes at once'); - } - - public function testSetHost() - { - $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->setHost('{locale}.example.com'); - - $this->assertEquals('{locale}.example.com', $routea->getHost()); - $this->assertEquals('{locale}.example.com', $routeb->getHost()); - } - - public function testSetCondition() - { - $collection = new RouteCollection(); - $routea = new Route('/a'); - $routeb = new Route('/b', array(), array(), array(), '{locale}.example.net', array(), array(), 'context.getMethod() == "GET"'); - $collection->add('a', $routea); - $collection->add('b', $routeb); - - $collection->setCondition('context.getMethod() == "POST"'); - - $this->assertEquals('context.getMethod() == "POST"', $routea->getCondition()); - $this->assertEquals('context.getMethod() == "POST"', $routeb->getCondition()); - } - - public function testClone() - { - $collection = new RouteCollection(); - $collection->add('a', new Route('/a')); - $collection->add('b', new Route('/b', array('placeholder' => 'default'), array('placeholder' => '.+'))); - - $clonedCollection = clone $collection; - - $this->assertCount(2, $clonedCollection); - $this->assertEquals($collection->get('a'), $clonedCollection->get('a')); - $this->assertNotSame($collection->get('a'), $clonedCollection->get('a')); - $this->assertEquals($collection->get('b'), $clonedCollection->get('b')); - $this->assertNotSame($collection->get('b'), $clonedCollection->get('b')); - } - - public function testSetSchemes() - { - $collection = new RouteCollection(); - $routea = new Route('/a', array(), array(), array(), '', 'http'); - $routeb = new Route('/b'); - $collection->add('a', $routea); - $collection->add('b', $routeb); - - $collection->setSchemes(array('http', 'https')); - - $this->assertEquals(array('http', 'https'), $routea->getSchemes()); - $this->assertEquals(array('http', 'https'), $routeb->getSchemes()); - } - - public function testSetMethods() - { - $collection = new RouteCollection(); - $routea = new Route('/a', array(), array(), array(), '', array(), array('GET', 'POST')); - $routeb = new Route('/b'); - $collection->add('a', $routea); - $collection->add('b', $routeb); - - $collection->setMethods('PUT'); - - $this->assertEquals(array('PUT'), $routea->getMethods()); - $this->assertEquals(array('PUT'), $routeb->getMethods()); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php deleted file mode 100644 index 2b7c17faa..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ /dev/null @@ -1,253 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use Symfony\Component\Routing\Route; - -class RouteCompilerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider provideCompileData - */ - public function testCompile($name, $arguments, $prefix, $regex, $variables, $tokens) - { - $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, $compiled->getRegex(), $name.' (regex)'); - $this->assertEquals($variables, $compiled->getVariables(), $name.' (variables)'); - $this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)'); - } - - public function provideCompileData() - { - return array( - array( - 'Static route', - array('/foo'), - '/foo', '#^/foo$#s', array(), array( - array('text', '/foo'), - ),), - - array( - 'Route with a variable', - array('/foo/{bar}'), - '/foo', '#^/foo/(?P[^/]++)$#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(?:/(?P[^/]++))?$#s', array('bar'), array( - array('variable', '/', '[^/]++', 'bar'), - array('text', '/foo'), - ),), - - array( - 'Route with several variables', - array('/foo/{bar}/{foobar}'), - '/foo', '#^/foo/(?P[^/]++)/(?P[^/]++)$#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(?:/(?P[^/]++)(?:/(?P[^/]++))?)?$#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/(?P[^/]++)/(?P[^/]++)$#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')), - '', '#^/(?P[^/]++)?$#s', array('bar'), array( - array('variable', '/', '[^/]++', 'bar'), - ),), - - array( - 'Route with a requirement of 0', - array('/{bar}', array('bar' => null), array('bar' => '0')), - '', '#^/(?P0)?$#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)')), - '', '#^/(?P(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')), - '', '#^/(?P[^/]++)?(?:/(?P[^/]++))?$#s', array('foo', 'bar'), array( - array('variable', '/', '[^/]++', 'bar'), - array('variable', '/', '[^/]++', 'foo'), - ),), - - array( - 'Route with a variable in last position', - array('/foo-{bar}'), - '/foo', '#^/foo\-(?P[^/]++)$#s', array('bar'), array( - array('variable', '-', '[^/]++', 'bar'), - array('text', '/foo'), - ),), - - array( - 'Route with nested placeholders', - array('/{static{var}static}'), - '/{static', '#^/\{static(?P[^/]+)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[^/\.]+)(?P[^/\.]+)(?P(y|Y))(?:(?P[^/\.]++)(?:\.(?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/(?P[^/\.]++)\.(?P<_format>[^/]++)$#s', array('bar', '_format'), array( - array('variable', '.', '[^/]++', '_format'), - array('variable', '/', '[^/\.]++', 'bar'), - array('text', '/foo'), - ),), - ); - } - - /** - * @expectedException \LogicException - */ - public function testRouteWithSameVariableTwice() - { - $route = new Route('/{name}/{name}'); - - $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 provideCompileWithHostData - */ - public function testCompileWithHost($name, $arguments, $prefix, $regex, $variables, $pathVariables, $tokens, $hostRegex, $hostVariables, $hostTokens) - { - $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($hostRegex, str_replace(array("\n", ' '), '', $compiled->getHostRegex()), $name.' (host regex)'); - $this->assertEquals($hostVariables, $compiled->getHostVariables(), $name.' (host variables)'); - $this->assertEquals($hostTokens, $compiled->getHostTokens(), $name.' (host tokens)'); - } - - public function provideCompileWithHostData() - { - return array( - array( - 'Route with host pattern', - array('/hello', array(), array(), array(), 'www.example.com'), - '/hello', '#^/hello$#s', array(), array(), array( - array('text', '/hello'), - ), - '#^www\.example\.com$#si', array(), array( - array('text', 'www.example.com'), - ), - ), - array( - 'Route with host pattern and some variables', - array('/hello/{name}', array(), array(), array(), 'www.example.{tld}'), - '/hello', '#^/hello/(?P[^/]++)$#s', array('tld', 'name'), array('name'), array( - array('variable', '/', '[^/]++', 'name'), - array('text', '/hello'), - ), - '#^www\.example\.(?P[^\.]++)$#si', array('tld'), array( - array('variable', '.', '[^\.]++', 'tld'), - array('text', 'www.example'), - ), - ), - array( - 'Route with variable at beginning of host', - array('/hello', array(), array(), array(), '{locale}.example.{tld}'), - '/hello', '#^/hello$#s', array('locale', 'tld'), array(), array( - array('text', '/hello'), - ), - '#^(?P[^\.]++)\.example\.(?P[^\.]++)$#si', array('locale', 'tld'), array( - array('variable', '.', '[^\.]++', 'tld'), - array('text', '.example'), - array('variable', '', '[^\.]++', 'locale'), - ), - ), - array( - 'Route with host 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[^\.]++)\.example\.(?P[^\.]++)$#si', array('locale', 'tld'), array( - array('variable', '.', '[^\.]++', 'tld'), - array('text', '.example'), - array('variable', '', '[^\.]++', 'locale'), - ), - ), - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php deleted file mode 100644 index 224a6dc7d..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouteTest.php +++ /dev/null @@ -1,280 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use Symfony\Component\Routing\Route; - -class RouteTest extends \PHPUnit_Framework_TestCase -{ - public function testConstructor() - { - $route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'), '{locale}.example.com'); - $this->assertEquals('/{foo}', $route->getPath(), '__construct() takes a path 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->getHost(), '__construct() takes a host pattern as its fifth argument'); - - $route = new Route('/', array(), array(), array(), '', array('Https'), array('POST', 'put'), 'context.getMethod() == "GET"'); - $this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes schemes as its sixth argument and lowercases it'); - $this->assertEquals(array('POST', 'PUT'), $route->getMethods(), '__construct() takes methods as its seventh argument and uppercases it'); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition(), '__construct() takes a condition as its eight argument'); - - $route = new Route('/', array(), array(), array(), '', 'Https', 'Post'); - $this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes a single scheme as its sixth argument'); - $this->assertEquals(array('POST'), $route->getMethods(), '__construct() takes a single method as its seventh argument'); - } - - public function testPath() - { - $route = new Route('/{foo}'); - $route->setPath('/{bar}'); - $this->assertEquals('/{bar}', $route->getPath(), '->setPath() sets the path'); - $route->setPath(''); - $this->assertEquals('/', $route->getPath(), '->setPath() adds a / at the beginning of the path if needed'); - $route->setPath('bar'); - $this->assertEquals('/bar', $route->getPath(), '->setPath() adds a / at the beginning of the path if needed'); - $this->assertEquals($route, $route->setPath(''), '->setPath() implements a fluent interface'); - $route->setPath('//path'); - $this->assertEquals('/path', $route->getPath(), '->setPath() does not allow two slashes "//" at the beginning of the path as it would be confused with a network path when generating the path from the route'); - } - - public function testOptions() - { - $route = new Route('/{foo}'); - $route->setOptions(array('foo' => 'bar')); - $this->assertEquals(array_merge(array( - 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler', - ), array('foo' => 'bar')), $route->getOptions(), '->setOptions() sets the options'); - $this->assertEquals($route, $route->setOptions(array()), '->setOptions() implements a fluent interface'); - - $route->setOptions(array('foo' => 'foo')); - $route->addOptions(array('bar' => 'bar')); - $this->assertEquals($route, $route->addOptions(array()), '->addOptions() implements a fluent interface'); - $this->assertEquals(array('foo' => 'foo', 'bar' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), $route->getOptions(), '->addDefaults() keep previous defaults'); - } - - public function testOption() - { - $route = new Route('/{foo}'); - $this->assertFalse($route->hasOption('foo'), '->hasOption() return false if option is not set'); - $this->assertEquals($route, $route->setOption('foo', 'bar'), '->setOption() implements a fluent interface'); - $this->assertEquals('bar', $route->getOption('foo'), '->setOption() sets the option'); - $this->assertTrue($route->hasOption('foo'), '->hasOption() return true if option is set'); - } - - public function testDefaults() - { - $route = new Route('/{foo}'); - $route->setDefaults(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '->setDefaults() sets the defaults'); - $this->assertEquals($route, $route->setDefaults(array()), '->setDefaults() implements a fluent interface'); - - $route->setDefault('foo', 'bar'); - $this->assertEquals('bar', $route->getDefault('foo'), '->setDefault() sets a default value'); - - $route->setDefault('foo2', 'bar2'); - $this->assertEquals('bar2', $route->getDefault('foo2'), '->getDefault() return the default value'); - $this->assertNull($route->getDefault('not_defined'), '->getDefault() return null if default value is not set'); - - $route->setDefault('_controller', $closure = function () { return 'Hello'; }); - $this->assertEquals($closure, $route->getDefault('_controller'), '->setDefault() sets a default value'); - - $route->setDefaults(array('foo' => 'foo')); - $route->addDefaults(array('bar' => 'bar')); - $this->assertEquals($route, $route->addDefaults(array()), '->addDefaults() implements a fluent interface'); - $this->assertEquals(array('foo' => 'foo', 'bar' => 'bar'), $route->getDefaults(), '->addDefaults() keep previous defaults'); - } - - public function testRequirements() - { - $route = new Route('/{foo}'); - $route->setRequirements(array('foo' => '\d+')); - $this->assertEquals(array('foo' => '\d+'), $route->getRequirements(), '->setRequirements() sets the requirements'); - $this->assertEquals('\d+', $route->getRequirement('foo'), '->getRequirement() returns a requirement'); - $this->assertNull($route->getRequirement('bar'), '->getRequirement() returns null if a requirement is not defined'); - $route->setRequirements(array('foo' => '^\d+$')); - $this->assertEquals('\d+', $route->getRequirement('foo'), '->getRequirement() removes ^ and $ from the path'); - $this->assertEquals($route, $route->setRequirements(array()), '->setRequirements() implements a fluent interface'); - - $route->setRequirements(array('foo' => '\d+')); - $route->addRequirements(array('bar' => '\d+')); - $this->assertEquals($route, $route->addRequirements(array()), '->addRequirements() implements a fluent interface'); - $this->assertEquals(array('foo' => '\d+', 'bar' => '\d+'), $route->getRequirements(), '->addRequirement() keep previous requirements'); - } - - public function testRequirement() - { - $route = new Route('/{foo}'); - $this->assertFalse($route->hasRequirement('foo'), '->hasRequirement() return false if requirement is not set'); - $route->setRequirement('foo', '^\d+$'); - $this->assertEquals('\d+', $route->getRequirement('foo'), '->setRequirement() removes ^ and $ from the path'); - $this->assertTrue($route->hasRequirement('foo'), '->hasRequirement() return true if requirement is set'); - } - - /** - * @dataProvider getInvalidRequirements - * @expectedException \InvalidArgumentException - */ - public function testSetInvalidRequirement($req) - { - $route = new Route('/{foo}'); - $route->setRequirement('foo', $req); - } - - public function getInvalidRequirements() - { - return array( - array(''), - array(array()), - array('^$'), - array('^'), - array('$'), - ); - } - - public function testHost() - { - $route = new Route('/'); - $route->setHost('{locale}.example.net'); - $this->assertEquals('{locale}.example.net', $route->getHost(), '->setHost() sets the host pattern'); - } - - public function testScheme() - { - $route = new Route('/'); - $this->assertEquals(array(), $route->getSchemes(), 'schemes is initialized with array()'); - $this->assertFalse($route->hasScheme('http')); - $route->setSchemes('hTTp'); - $this->assertEquals(array('http'), $route->getSchemes(), '->setSchemes() accepts a single scheme string and lowercases it'); - $this->assertTrue($route->hasScheme('htTp')); - $this->assertFalse($route->hasScheme('httpS')); - $route->setSchemes(array('HttpS', 'hTTp')); - $this->assertEquals(array('https', 'http'), $route->getSchemes(), '->setSchemes() accepts an array of schemes and lowercases them'); - $this->assertTrue($route->hasScheme('htTp')); - $this->assertTrue($route->hasScheme('httpS')); - } - - public function testSchemeIsBC() - { - $route = new Route('/'); - $route->setRequirement('_scheme', 'http|https'); - $this->assertEquals('http|https', $route->getRequirement('_scheme')); - $this->assertEquals(array('http', 'https'), $route->getSchemes()); - $this->assertTrue($route->hasScheme('https')); - $this->assertTrue($route->hasScheme('http')); - $this->assertFalse($route->hasScheme('ftp')); - $route->setSchemes(array('hTTp')); - $this->assertEquals('http', $route->getRequirement('_scheme')); - $route->setSchemes(array()); - $this->assertNull($route->getRequirement('_scheme')); - } - - public function testMethod() - { - $route = new Route('/'); - $this->assertEquals(array(), $route->getMethods(), 'methods is initialized with array()'); - $route->setMethods('gEt'); - $this->assertEquals(array('GET'), $route->getMethods(), '->setMethods() accepts a single method string and uppercases it'); - $route->setMethods(array('gEt', 'PosT')); - $this->assertEquals(array('GET', 'POST'), $route->getMethods(), '->setMethods() accepts an array of methods and uppercases them'); - } - - public function testMethodIsBC() - { - $route = new Route('/'); - $route->setRequirement('_method', 'GET|POST'); - $this->assertEquals('GET|POST', $route->getRequirement('_method')); - $this->assertEquals(array('GET', 'POST'), $route->getMethods()); - $route->setMethods(array('gEt')); - $this->assertEquals('GET', $route->getRequirement('_method')); - $route->setMethods(array()); - $this->assertNull($route->getRequirement('_method')); - } - - public function testCondition() - { - $route = new Route('/'); - $this->assertSame('', $route->getCondition()); - $route->setCondition('context.getMethod() == "GET"'); - $this->assertSame('context.getMethod() == "GET"', $route->getCondition()); - } - - public function testCompile() - { - $route = new Route('/{foo}'); - $this->assertInstanceOf('Symfony\Component\Routing\CompiledRoute', $compiled = $route->compile(), '->compile() returns a compiled route'); - $this->assertSame($compiled, $route->compile(), '->compile() only compiled the route once if unchanged'); - $route->setRequirement('foo', '.*'); - $this->assertNotSame($compiled, $route->compile(), '->compile() recompiles if the route was modified'); - } - - /** - * @group legacy - */ - public function testLegacyPattern() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $route = new Route('/{foo}'); - $this->assertEquals('/{foo}', $route->getPattern()); - - $route->setPattern('/bar'); - $this->assertEquals('/bar', $route->getPattern()); - } - - public function testSerialize() - { - $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+')); - - $serialized = serialize($route); - $unserialized = unserialize($serialized); - - $this->assertEquals($route, $unserialized); - $this->assertNotSame($route, $unserialized); - } - - /** - * Tests that the compiled version is also serialized to prevent the overhead - * of compiling it again after unserialize. - */ - public function testSerializeWhenCompiled() - { - $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+')); - $route->setHost('{locale}.example.net'); - $route->compile(); - - $serialized = serialize($route); - $unserialized = unserialize($serialized); - - $this->assertEquals($route, $unserialized); - $this->assertNotSame($route, $unserialized); - } - - /** - * Tests that the serialized representation of a route in one symfony version - * also works in later symfony versions, i.e. the unserialized route is in the - * same state as another, semantically equivalent, route. - */ - public function testSerializedRepresentationKeepsWorking() - { - $serialized = 'C:31:"Symfony\Component\Routing\Route":934:{a:8:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":569:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:30:"#^/prefix(?:/(?P\d+))?$#s";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:39:"#^(?P[^\.]++)\.example\.net$#si";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}}'; - $unserialized = unserialize($serialized); - - $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+')); - $route->setHost('{locale}.example.net'); - $route->compile(); - - $this->assertEquals($route, $unserialized); - $this->assertNotSame($route, $unserialized); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php deleted file mode 100644 index 9a1c568ee..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/Tests/RouterTest.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use Symfony\Component\Routing\Router; -use Symfony\Component\HttpFoundation\Request; - -class RouterTest extends \PHPUnit_Framework_TestCase -{ - private $router = null; - - private $loader = null; - - protected function setUp() - { - $this->loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); - $this->router = new Router($this->loader, 'routing.yml'); - } - - public function testSetOptionsWithSupportedOptions() - { - $this->router->setOptions(array( - 'cache_dir' => './cache', - 'debug' => true, - 'resource_type' => 'ResourceType', - )); - - $this->assertSame('./cache', $this->router->getOption('cache_dir')); - $this->assertTrue($this->router->getOption('debug')); - $this->assertSame('ResourceType', $this->router->getOption('resource_type')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The Router does not support the following options: "option_foo", "option_bar" - */ - public function testSetOptionsWithUnsupportedOptions() - { - $this->router->setOptions(array( - 'cache_dir' => './cache', - 'option_foo' => true, - 'option_bar' => 'baz', - 'resource_type' => 'ResourceType', - )); - } - - public function testSetOptionWithSupportedOption() - { - $this->router->setOption('cache_dir', './cache'); - - $this->assertSame('./cache', $this->router->getOption('cache_dir')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The Router does not support the "option_foo" option - */ - public function testSetOptionWithUnsupportedOption() - { - $this->router->setOption('option_foo', true); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The Router does not support the "option_foo" option - */ - public function testGetOptionWithUnsupportedOption() - { - $this->router->getOption('option_foo', true); - } - - public function testThatRouteCollectionIsLoaded() - { - $this->router->setOption('resource_type', 'ResourceType'); - - $routeCollection = $this->getMock('Symfony\Component\Routing\RouteCollection'); - - $this->loader->expects($this->once()) - ->method('load')->with('routing.yml', 'ResourceType') - ->will($this->returnValue($routeCollection)); - - $this->assertSame($routeCollection, $this->router->getRouteCollection()); - } - - /** - * @dataProvider provideMatcherOptionsPreventingCaching - */ - public function testMatcherIsCreatedIfCacheIsNotConfigured($option) - { - $this->router->setOption($option, null); - - $this->loader->expects($this->once()) - ->method('load')->with('routing.yml', null) - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); - - $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); - } - - public function provideMatcherOptionsPreventingCaching() - { - return array( - array('cache_dir'), - array('matcher_cache_class'), - ); - } - - /** - * @dataProvider provideGeneratorOptionsPreventingCaching - */ - public function testGeneratorIsCreatedIfCacheIsNotConfigured($option) - { - $this->router->setOption($option, null); - - $this->loader->expects($this->once()) - ->method('load')->with('routing.yml', null) - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); - - $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); - } - - public function provideGeneratorOptionsPreventingCaching() - { - return array( - array('cache_dir'), - array('generator_cache_class'), - ); - } - - public function testMatchRequestWithUrlMatcherInterface() - { - $matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); - $matcher->expects($this->once())->method('match'); - - $p = new \ReflectionProperty($this->router, 'matcher'); - $p->setAccessible(true); - $p->setValue($this->router, $matcher); - - $this->router->matchRequest(Request::create('/')); - } - - public function testMatchRequestWithRequestMatcherInterface() - { - $matcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); - $matcher->expects($this->once())->method('matchRequest'); - - $p = new \ReflectionProperty($this->router, 'matcher'); - $p->setAccessible(true); - $p->setValue($this->router, $matcher); - - $this->router->matchRequest(Request::create('/')); - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/composer.json b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/composer.json deleted file mode 100644 index a162431b0..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/composer.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "symfony/routing", - "type": "library", - "description": "Symfony Routing Component", - "keywords": ["routing", "router", "URL", "URI"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7", - "symfony/config": "~2.2", - "symfony/http-foundation": "~2.3", - "symfony/yaml": "~2.0,>=2.0.5", - "symfony/expression-language": "~2.4", - "doctrine/annotations": "~1.0", - "doctrine/common": "~2.2", - "psr/log": "~1.0" - }, - "suggest": { - "symfony/config": "For using the all-in-one router or any loader", - "symfony/yaml": "For using the YAML loader", - "symfony/expression-language": "For using expression matching", - "doctrine/annotations": "For using the annotation loader" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\Routing\\": "" } - }, - "target-dir": "Symfony/Component/Routing", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/exclude.txt b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/exclude.txt deleted file mode 100644 index 9010fbf2e..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/exclude.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -# The following source files are not re-distributed with the "build" of the application -# since they are used solely for constructing other files during the build process -# -Tests \ No newline at end of file diff --git a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist b/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist deleted file mode 100644 index fae243c81..000000000 --- a/lib/silex/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - ./Tests/ - - - - - - ./ - - ./vendor - ./Tests - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Annotation/RouteTest.php b/lib/silex/vendor/symfony/routing/Tests/Annotation/RouteTest.php deleted file mode 100644 index 9af22f29f..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Annotation/RouteTest.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Annotation; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Annotation\Route; - -class RouteTest extends TestCase -{ - /** - * @expectedException \BadMethodCallException - */ - public function testInvalidRouteParameter() - { - $route = new Route(array('foo' => 'bar')); - } - - /** - * @dataProvider getValidParameters - */ - public function testRouteParameters($parameter, $value, $getter) - { - $route = new Route(array($parameter => $value)); - $this->assertEquals($route->$getter(), $value); - } - - public function getValidParameters() - { - return array( - array('value', '/Blog', 'getPath'), - array('requirements', array('locale' => 'en'), 'getRequirements'), - array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'), - array('name', 'blog_index', 'getName'), - array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'), - array('schemes', array('https'), 'getSchemes'), - array('methods', array('GET', 'POST'), 'getMethods'), - array('host', '{locale}.example.com', 'getHost'), - array('condition', 'context.getMethod() == "GET"', 'getCondition'), - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/CompiledRouteTest.php b/lib/silex/vendor/symfony/routing/Tests/CompiledRouteTest.php deleted file mode 100644 index 5bec7bbd7..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/CompiledRouteTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\CompiledRoute; - -class CompiledRouteTest extends TestCase -{ - public function testAccessors() - { - $compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), null, 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/lib/silex/vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php b/lib/silex/vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php deleted file mode 100644 index 97a34c969..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass; - -class RoutingResolverPassTest extends TestCase -{ - public function testProcess() - { - $container = new ContainerBuilder(); - $container->register('routing.resolver', LoaderResolver::class); - $container->register('loader1')->addTag('routing.loader'); - $container->register('loader2')->addTag('routing.loader'); - - (new RoutingResolverPass())->process($container); - - $this->assertEquals( - array(array('addLoader', array(new Reference('loader1'))), array('addLoader', array(new Reference('loader2')))), - $container->getDefinition('routing.resolver')->getMethodCalls() - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php deleted file mode 100644 index 56bcab2a9..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * 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; - -abstract class AbstractClass -{ -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php deleted file mode 100644 index a3882773c..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * 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/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php deleted file mode 100644 index 471968b57..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * 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 BazClass -{ - public function __invoke() - { - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php deleted file mode 100644 index 320dc3500..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * 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 FooClass -{ -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php deleted file mode 100644 index ee8f4b071..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php +++ /dev/null @@ -1,13 +0,0 @@ - - * - * 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; - -use Symfony\Component\Routing\CompiledRoute; - -class CustomCompiledRoute extends CompiledRoute -{ -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php deleted file mode 100644 index c2e2afd9a..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * 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; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCompiler; - -class CustomRouteCompiler extends RouteCompiler -{ - /** - * {@inheritdoc} - */ - public static function compile(Route $route) - { - return new CustomCompiledRoute('', '', array(), array()); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php deleted file mode 100644 index 9fd5754a1..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * 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; - -use Symfony\Component\Routing\Loader\XmlFileLoader; -use Symfony\Component\Config\Util\XmlUtils; - -/** - * XmlFileLoader with schema validation turned off. - */ -class CustomXmlFileLoader extends XmlFileLoader -{ - protected function loadFile($file) - { - return XmlUtils::loadFile($file, function () { return true; }); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php deleted file mode 100644 index de8789564..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * 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\OtherAnnotatedClasses; - -trait AnonymousClassInTrait -{ - public function test() - { - return new class() { - public function foo() - { - } - }; - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php deleted file mode 100644 index 8900d34e5..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php +++ /dev/null @@ -1,3 +0,0 @@ -class NoStartTagClass -{ -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php deleted file mode 100644 index 729c9b4d0..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * 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\OtherAnnotatedClasses; - -class VariadicClass -{ - public function routeAction(...$params) - { - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php deleted file mode 100644 index 15937bcf0..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * 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; - -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface; - -/** - * @author Fabien Potencier - */ -class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface -{ - public function redirect($path, $route, $scheme = null) - { - return array( - '_controller' => 'Some controller reference...', - 'path' => $path, - 'scheme' => $scheme, - ); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/annotated.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/annotated.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/bad_format.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/bad_format.yml deleted file mode 100644 index 8ba50e2e4..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/bad_format.yml +++ /dev/null @@ -1,3 +0,0 @@ -blog_show: - path: /blog/{slug} - defaults: { _controller: "MyBundle:Blog:show" } diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/bar.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/bar.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml deleted file mode 100644 index bbe727d41..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - FrameworkBundle:Template:template - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml deleted file mode 100644 index 4240b74dc..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml +++ /dev/null @@ -1,4 +0,0 @@ -_static: - resource: routing.yml - defaults: - _controller: FrameworkBundle:Template:template diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml deleted file mode 100644 index 378b9ca18..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml deleted file mode 100644 index 1a71c62b2..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml +++ /dev/null @@ -1,3 +0,0 @@ -_static: - resource: routing.yml - controller: FrameworkBundle:Template:template diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml deleted file mode 100644 index e3c755a40..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - AppBundle:Blog:index - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml deleted file mode 100644 index db1ab3cbe..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml +++ /dev/null @@ -1,5 +0,0 @@ -_static: - resource: routing.yml - controller: FrameworkBundle:Template:template - defaults: - _controller: AppBundle:Homepage:show diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml deleted file mode 100644 index f47c57b30..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - AppBundle:Blog:index - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml deleted file mode 100644 index 00a2c0e97..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml +++ /dev/null @@ -1,5 +0,0 @@ -app_blog: - path: /blog - controller: AppBundle:Homepage:show - defaults: - _controller: AppBundle:Blog:index diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.xml deleted file mode 100644 index 6420138a6..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - AppBundle:Blog:list - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.yml deleted file mode 100644 index cb71ec3b7..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/controller/routing.yml +++ /dev/null @@ -1,11 +0,0 @@ -app_homepage: - path: / - controller: AppBundle:Homepage:show - -app_blog: - path: /blog - defaults: - _controller: AppBundle:Blog:list - -app_logout: - path: /logout diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml deleted file mode 100644 index d07883662..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml +++ /dev/null @@ -1,2 +0,0 @@ -route1: - path: /route/1 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml deleted file mode 100644 index 938fb2457..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml +++ /dev/null @@ -1,2 +0,0 @@ -route2: - path: /route/2 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml deleted file mode 100644 index 088cfb4d4..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml +++ /dev/null @@ -1,2 +0,0 @@ -route3: - path: /route/3 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml deleted file mode 100644 index af829e58c..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml +++ /dev/null @@ -1,3 +0,0 @@ -_directory: - resource: "../directory" - type: directory diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php deleted file mode 100644 index 839c7d137..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php +++ /dev/null @@ -1,39 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - if ('/' === $pathinfo) { - throw new Symfony\Component\Routing\Exception\NoConfigurationException(); - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php deleted file mode 100644 index 5d7dca8e5..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php +++ /dev/null @@ -1,312 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - if (0 === strpos($pathinfo, '/foo')) { - // foo - if (preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); - } - - // foofoo - if ('/foofoo' === $pathinfo) { - return array ( 'def' => 'test', '_route' => 'foofoo',); - } - - } - - elseif (0 === strpos($pathinfo, '/bar')) { - // bar - if (preg_match('#^/bar/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_bar; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); - } - not_bar: - - // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_barhead; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ()); - } - not_barhead: - - } - - elseif (0 === strpos($pathinfo, '/test')) { - if (0 === strpos($pathinfo, '/test/baz')) { - // baz - if ('/test/baz' === $pathinfo) { - return array('_route' => 'baz'); - } - - // baz2 - if ('/test/baz.html' === $pathinfo) { - return array('_route' => 'baz2'); - } - - // baz3 - if ('/test/baz3/' === $pathinfo) { - return array('_route' => 'baz3'); - } - - } - - // baz4 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); - } - - // baz5 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_baz5; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); - } - not_baz5: - - // baz.baz6 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('PUT' !== $canonicalMethod) { - $allow[] = 'PUT'; - goto not_bazbaz6; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ()); - } - not_bazbaz6: - - } - - // quoter - if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); - } - - // space - if ('/spa ce' === $pathinfo) { - return array('_route' => 'space'); - } - - if (0 === strpos($pathinfo, '/a')) { - if (0 === strpos($pathinfo, '/a/b\'b')) { - // foo1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); - } - - // bar1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); - } - - } - - // overridden - if (preg_match('#^/a/(?P.*)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); - } - - // bar2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); - } - - } - - } - - elseif (0 === strpos($pathinfo, '/multi')) { - // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); - } - - // hey - if ('/multi/hey/' === $pathinfo) { - return array('_route' => 'hey'); - } - - // overridden2 - if ('/multi/new' === $pathinfo) { - return array('_route' => 'overridden2'); - } - - } - - // foo3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); - } - - // bar3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); - } - - if (0 === strpos($pathinfo, '/aba')) { - // ababa - if ('/ababa' === $pathinfo) { - return array('_route' => 'ababa'); - } - - // foo4 - if (preg_match('#^/aba/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); - } - - } - - $host = $context->getHost(); - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route1 - if ('/route1' === $pathinfo) { - return array('_route' => 'route1'); - } - - // route2 - if ('/c2/route2' === $pathinfo) { - return array('_route' => 'route2'); - } - - } - - if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { - // route3 - if ('/c2/route3' === $pathinfo) { - return array('_route' => 'route3'); - } - - } - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route4 - if ('/route4' === $pathinfo) { - return array('_route' => 'route4'); - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route5 - if ('/route5' === $pathinfo) { - return array('_route' => 'route5'); - } - - } - - // route6 - if ('/route6' === $pathinfo) { - return array('_route' => 'route6'); - } - - if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { - if (0 === strpos($pathinfo, '/route1')) { - // route11 - if ('/route11' === $pathinfo) { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); - } - - // route12 - if ('/route12' === $pathinfo) { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); - } - - // route13 - if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); - } - - // route14 - if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); - } - - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route15 - if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); - } - - } - - // route16 - if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); - } - - // route17 - if ('/route17' === $pathinfo) { - return array('_route' => 'route17'); - } - - // a - if ('/a/a...' === $pathinfo) { - return array('_route' => 'a'); - } - - if (0 === strpos($pathinfo, '/a/b')) { - // b - if (preg_match('#^/a/b/(?P[^/]++)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); - } - - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php deleted file mode 100644 index 49ce082a8..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php +++ /dev/null @@ -1,349 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - if (0 === strpos($pathinfo, '/foo')) { - // foo - if (preg_match('#^/foo/(?Pbaz|symfony)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',)); - } - - // foofoo - if ('/foofoo' === $pathinfo) { - return array ( 'def' => 'test', '_route' => 'foofoo',); - } - - } - - elseif (0 === strpos($pathinfo, '/bar')) { - // bar - if (preg_match('#^/bar/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_bar; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ()); - } - not_bar: - - // barhead - if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_barhead; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ()); - } - not_barhead: - - } - - elseif (0 === strpos($pathinfo, '/test')) { - if (0 === strpos($pathinfo, '/test/baz')) { - // baz - if ('/test/baz' === $pathinfo) { - return array('_route' => 'baz'); - } - - // baz2 - if ('/test/baz.html' === $pathinfo) { - return array('_route' => 'baz2'); - } - - // baz3 - if ('/test/baz3' === $trimmedPathinfo) { - $ret = array('_route' => 'baz3'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz3')); - } - - return $ret; - } - - } - - // baz4 - if (preg_match('#^/test/(?P[^/]++)/?$#s', $pathinfo, $matches)) { - $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ()); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz4')); - } - - return $ret; - } - - // baz5 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_baz5; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ()); - } - not_baz5: - - // baz.baz6 - if (preg_match('#^/test/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('PUT' !== $canonicalMethod) { - $allow[] = 'PUT'; - goto not_bazbaz6; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ()); - } - not_bazbaz6: - - } - - // quoter - if (preg_match('#^/(?P[\']+)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ()); - } - - // space - if ('/spa ce' === $pathinfo) { - return array('_route' => 'space'); - } - - if (0 === strpos($pathinfo, '/a')) { - if (0 === strpos($pathinfo, '/a/b\'b')) { - // foo1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ()); - } - - // bar1 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ()); - } - - } - - // overridden - if (preg_match('#^/a/(?P.*)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ()); - } - - // bar2 - if (preg_match('#^/a/b\'b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ()); - } - - } - - } - - elseif (0 === strpos($pathinfo, '/multi')) { - // helloWorld - if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P[^/]++))?$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',)); - } - - // hey - if ('/multi/hey' === $trimmedPathinfo) { - $ret = array('_route' => 'hey'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'hey')); - } - - return $ret; - } - - // overridden2 - if ('/multi/new' === $pathinfo) { - return array('_route' => 'overridden2'); - } - - } - - // foo3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ()); - } - - // bar3 - if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ()); - } - - if (0 === strpos($pathinfo, '/aba')) { - // ababa - if ('/ababa' === $pathinfo) { - return array('_route' => 'ababa'); - } - - // foo4 - if (preg_match('#^/aba/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ()); - } - - } - - $host = $context->getHost(); - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route1 - if ('/route1' === $pathinfo) { - return array('_route' => 'route1'); - } - - // route2 - if ('/c2/route2' === $pathinfo) { - return array('_route' => 'route2'); - } - - } - - if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) { - // route3 - if ('/c2/route3' === $pathinfo) { - return array('_route' => 'route3'); - } - - } - - if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) { - // route4 - if ('/route4' === $pathinfo) { - return array('_route' => 'route4'); - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route5 - if ('/route5' === $pathinfo) { - return array('_route' => 'route5'); - } - - } - - // route6 - if ('/route6' === $pathinfo) { - return array('_route' => 'route6'); - } - - if (preg_match('#^(?P[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) { - if (0 === strpos($pathinfo, '/route1')) { - // route11 - if ('/route11' === $pathinfo) { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ()); - } - - // route12 - if ('/route12' === $pathinfo) { - return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',)); - } - - // route13 - if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ()); - } - - // route14 - if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',)); - } - - } - - } - - if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) { - // route15 - if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ()); - } - - } - - // route16 - if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',)); - } - - // route17 - if ('/route17' === $pathinfo) { - return array('_route' => 'route17'); - } - - // a - if ('/a/a...' === $pathinfo) { - return array('_route' => 'a'); - } - - if (0 === strpos($pathinfo, '/a/b')) { - // b - if (preg_match('#^/a/b/(?P[^/]++)$#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/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ()); - } - - } - - // secure - if ('/secure' === $pathinfo) { - $ret = array('_route' => 'secure'); - $requiredSchemes = array ( 'https' => 0,); - if (!isset($requiredSchemes[$scheme])) { - return array_replace($ret, $this->redirect($rawPathinfo, 'secure', key($requiredSchemes))); - } - - return $ret; - } - - // nonsecure - if ('/nonsecure' === $pathinfo) { - $ret = array('_route' => 'nonsecure'); - $requiredSchemes = array ( 'http' => 0,); - if (!isset($requiredSchemes[$scheme])) { - return array_replace($ret, $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes))); - } - - return $ret; - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php deleted file mode 100644 index ae5495631..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php +++ /dev/null @@ -1,53 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - if (0 === strpos($pathinfo, '/rootprefix')) { - // static - if ('/rootprefix/test' === $pathinfo) { - return array('_route' => 'static'); - } - - // dynamic - if (preg_match('#^/rootprefix/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ()); - } - - } - - // with-condition - if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) { - return array('_route' => 'with-condition'); - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php deleted file mode 100644 index 50da489fb..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php +++ /dev/null @@ -1,104 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - // just_head - if ('/just_head' === $pathinfo) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_just_head; - } - - return array('_route' => 'just_head'); - } - not_just_head: - - // head_and_get - if ('/head_and_get' === $pathinfo) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_head_and_get; - } - - return array('_route' => 'head_and_get'); - } - not_head_and_get: - - // get_and_head - if ('/get_and_head' === $pathinfo) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_get_and_head; - } - - return array('_route' => 'get_and_head'); - } - not_get_and_head: - - // post_and_head - if ('/post_and_get' === $pathinfo) { - if (!in_array($requestMethod, array('POST', 'HEAD'))) { - $allow = array_merge($allow, array('POST', 'HEAD')); - goto not_post_and_head; - } - - return array('_route' => 'post_and_head'); - } - not_post_and_head: - - if (0 === strpos($pathinfo, '/put_and_post')) { - // put_and_post - if ('/put_and_post' === $pathinfo) { - if (!in_array($requestMethod, array('PUT', 'POST'))) { - $allow = array_merge($allow, array('PUT', 'POST')); - goto not_put_and_post; - } - - return array('_route' => 'put_and_post'); - } - not_put_and_post: - - // put_and_get_and_head - if ('/put_and_post' === $pathinfo) { - if (!in_array($canonicalMethod, array('PUT', 'GET'))) { - $allow = array_merge($allow, array('PUT', 'GET')); - goto not_put_and_get_and_head; - } - - return array('_route' => 'put_and_get_and_head'); - } - not_put_and_get_and_head: - - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php deleted file mode 100644 index 51be5b0bc..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php +++ /dev/null @@ -1,162 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - if (0 === strpos($pathinfo, '/a')) { - // a_first - if ('/a/11' === $pathinfo) { - return array('_route' => 'a_first'); - } - - // a_second - if ('/a/22' === $pathinfo) { - return array('_route' => 'a_second'); - } - - // a_third - if ('/a/333' === $pathinfo) { - return array('_route' => 'a_third'); - } - - } - - // a_wildcard - if (preg_match('#^/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'a_wildcard')), array ()); - } - - if (0 === strpos($pathinfo, '/a')) { - // a_fourth - if ('/a/44' === $trimmedPathinfo) { - $ret = array('_route' => 'a_fourth'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fourth')); - } - - return $ret; - } - - // a_fifth - if ('/a/55' === $trimmedPathinfo) { - $ret = array('_route' => 'a_fifth'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fifth')); - } - - return $ret; - } - - // a_sixth - if ('/a/66' === $trimmedPathinfo) { - $ret = array('_route' => 'a_sixth'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_sixth')); - } - - return $ret; - } - - } - - // nested_wildcard - if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'nested_wildcard')), array ()); - } - - if (0 === strpos($pathinfo, '/nested/group')) { - // nested_a - if ('/nested/group/a' === $trimmedPathinfo) { - $ret = array('_route' => 'nested_a'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_a')); - } - - return $ret; - } - - // nested_b - if ('/nested/group/b' === $trimmedPathinfo) { - $ret = array('_route' => 'nested_b'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_b')); - } - - return $ret; - } - - // nested_c - if ('/nested/group/c' === $trimmedPathinfo) { - $ret = array('_route' => 'nested_c'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_c')); - } - - return $ret; - } - - } - - elseif (0 === strpos($pathinfo, '/slashed/group')) { - // slashed_a - if ('/slashed/group' === $trimmedPathinfo) { - $ret = array('_route' => 'slashed_a'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_a')); - } - - return $ret; - } - - // slashed_b - if ('/slashed/group/b' === $trimmedPathinfo) { - $ret = array('_route' => 'slashed_b'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_b')); - } - - return $ret; - } - - // slashed_c - if ('/slashed/group/c' === $trimmedPathinfo) { - $ret = array('_route' => 'slashed_c'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_c')); - } - - return $ret; - } - - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php deleted file mode 100644 index 933525699..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php +++ /dev/null @@ -1,199 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - if (0 === strpos($pathinfo, '/trailing/simple')) { - // simple_trailing_slash_no_methods - if ('/trailing/simple/no-methods/' === $pathinfo) { - return array('_route' => 'simple_trailing_slash_no_methods'); - } - - // simple_trailing_slash_GET_method - if ('/trailing/simple/get-method/' === $pathinfo) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_simple_trailing_slash_GET_method; - } - - return array('_route' => 'simple_trailing_slash_GET_method'); - } - not_simple_trailing_slash_GET_method: - - // simple_trailing_slash_HEAD_method - if ('/trailing/simple/head-method/' === $pathinfo) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_simple_trailing_slash_HEAD_method; - } - - return array('_route' => 'simple_trailing_slash_HEAD_method'); - } - not_simple_trailing_slash_HEAD_method: - - // simple_trailing_slash_POST_method - if ('/trailing/simple/post-method/' === $pathinfo) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_simple_trailing_slash_POST_method; - } - - return array('_route' => 'simple_trailing_slash_POST_method'); - } - not_simple_trailing_slash_POST_method: - - } - - elseif (0 === strpos($pathinfo, '/trailing/regex')) { - // regex_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P[^/]++)/$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ()); - } - - // regex_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_regex_trailing_slash_GET_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ()); - } - not_regex_trailing_slash_GET_method: - - // regex_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_regex_trailing_slash_HEAD_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ()); - } - not_regex_trailing_slash_HEAD_method: - - // regex_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_regex_trailing_slash_POST_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ()); - } - not_regex_trailing_slash_POST_method: - - } - - elseif (0 === strpos($pathinfo, '/not-trailing/simple')) { - // simple_not_trailing_slash_no_methods - if ('/not-trailing/simple/no-methods' === $pathinfo) { - return array('_route' => 'simple_not_trailing_slash_no_methods'); - } - - // simple_not_trailing_slash_GET_method - if ('/not-trailing/simple/get-method' === $pathinfo) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_simple_not_trailing_slash_GET_method; - } - - return array('_route' => 'simple_not_trailing_slash_GET_method'); - } - not_simple_not_trailing_slash_GET_method: - - // simple_not_trailing_slash_HEAD_method - if ('/not-trailing/simple/head-method' === $pathinfo) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_simple_not_trailing_slash_HEAD_method; - } - - return array('_route' => 'simple_not_trailing_slash_HEAD_method'); - } - not_simple_not_trailing_slash_HEAD_method: - - // simple_not_trailing_slash_POST_method - if ('/not-trailing/simple/post-method' === $pathinfo) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_simple_not_trailing_slash_POST_method; - } - - return array('_route' => 'simple_not_trailing_slash_POST_method'); - } - not_simple_not_trailing_slash_POST_method: - - } - - elseif (0 === strpos($pathinfo, '/not-trailing/regex')) { - // regex_not_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ()); - } - - // regex_not_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_regex_not_trailing_slash_GET_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ()); - } - not_regex_not_trailing_slash_GET_method: - - // regex_not_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_regex_not_trailing_slash_HEAD_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ()); - } - not_regex_not_trailing_slash_HEAD_method: - - // regex_not_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_regex_not_trailing_slash_POST_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ()); - } - not_regex_not_trailing_slash_POST_method: - - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php deleted file mode 100644 index bceee6f3a..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php +++ /dev/null @@ -1,229 +0,0 @@ -context = $context; - } - - public function match($rawPathinfo) - { - $allow = array(); - $pathinfo = rawurldecode($rawPathinfo); - $trimmedPathinfo = rtrim($pathinfo, '/'); - $context = $this->context; - $request = $this->request; - $requestMethod = $canonicalMethod = $context->getMethod(); - $scheme = $context->getScheme(); - - if ('HEAD' === $requestMethod) { - $canonicalMethod = 'GET'; - } - - - if (0 === strpos($pathinfo, '/trailing/simple')) { - // simple_trailing_slash_no_methods - if ('/trailing/simple/no-methods' === $trimmedPathinfo) { - $ret = array('_route' => 'simple_trailing_slash_no_methods'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_no_methods')); - } - - return $ret; - } - - // simple_trailing_slash_GET_method - if ('/trailing/simple/get-method' === $trimmedPathinfo) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_simple_trailing_slash_GET_method; - } - - $ret = array('_route' => 'simple_trailing_slash_GET_method'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_GET_method')); - } - - return $ret; - } - not_simple_trailing_slash_GET_method: - - // simple_trailing_slash_HEAD_method - if ('/trailing/simple/head-method' === $trimmedPathinfo) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_simple_trailing_slash_HEAD_method; - } - - $ret = array('_route' => 'simple_trailing_slash_HEAD_method'); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_HEAD_method')); - } - - return $ret; - } - not_simple_trailing_slash_HEAD_method: - - // simple_trailing_slash_POST_method - if ('/trailing/simple/post-method/' === $pathinfo) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_simple_trailing_slash_POST_method; - } - - return array('_route' => 'simple_trailing_slash_POST_method'); - } - not_simple_trailing_slash_POST_method: - - } - - elseif (0 === strpos($pathinfo, '/trailing/regex')) { - // regex_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P[^/]++)/?$#s', $pathinfo, $matches)) { - $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ()); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_no_methods')); - } - - return $ret; - } - - // regex_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P[^/]++)/?$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_regex_trailing_slash_GET_method; - } - - $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ()); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_GET_method')); - } - - return $ret; - } - not_regex_trailing_slash_GET_method: - - // regex_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P[^/]++)/?$#s', $pathinfo, $matches)) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_regex_trailing_slash_HEAD_method; - } - - $ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ()); - if (substr($pathinfo, -1) !== '/') { - return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_HEAD_method')); - } - - return $ret; - } - not_regex_trailing_slash_HEAD_method: - - // regex_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P[^/]++)/$#s', $pathinfo, $matches)) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_regex_trailing_slash_POST_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ()); - } - not_regex_trailing_slash_POST_method: - - } - - elseif (0 === strpos($pathinfo, '/not-trailing/simple')) { - // simple_not_trailing_slash_no_methods - if ('/not-trailing/simple/no-methods' === $pathinfo) { - return array('_route' => 'simple_not_trailing_slash_no_methods'); - } - - // simple_not_trailing_slash_GET_method - if ('/not-trailing/simple/get-method' === $pathinfo) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_simple_not_trailing_slash_GET_method; - } - - return array('_route' => 'simple_not_trailing_slash_GET_method'); - } - not_simple_not_trailing_slash_GET_method: - - // simple_not_trailing_slash_HEAD_method - if ('/not-trailing/simple/head-method' === $pathinfo) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_simple_not_trailing_slash_HEAD_method; - } - - return array('_route' => 'simple_not_trailing_slash_HEAD_method'); - } - not_simple_not_trailing_slash_HEAD_method: - - // simple_not_trailing_slash_POST_method - if ('/not-trailing/simple/post-method' === $pathinfo) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_simple_not_trailing_slash_POST_method; - } - - return array('_route' => 'simple_not_trailing_slash_POST_method'); - } - not_simple_not_trailing_slash_POST_method: - - } - - elseif (0 === strpos($pathinfo, '/not-trailing/regex')) { - // regex_not_trailing_slash_no_methods - if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P[^/]++)$#s', $pathinfo, $matches)) { - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ()); - } - - // regex_not_trailing_slash_GET_method - if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('GET' !== $canonicalMethod) { - $allow[] = 'GET'; - goto not_regex_not_trailing_slash_GET_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ()); - } - not_regex_not_trailing_slash_GET_method: - - // regex_not_trailing_slash_HEAD_method - if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('HEAD' !== $requestMethod) { - $allow[] = 'HEAD'; - goto not_regex_not_trailing_slash_HEAD_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ()); - } - not_regex_not_trailing_slash_HEAD_method: - - // regex_not_trailing_slash_POST_method - if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P[^/]++)$#s', $pathinfo, $matches)) { - if ('POST' !== $canonicalMethod) { - $allow[] = 'POST'; - goto not_regex_not_trailing_slash_POST_method; - } - - return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ()); - } - not_regex_not_trailing_slash_POST_method: - - } - - throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException(); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/empty.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/empty.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/file_resource.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/file_resource.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/foo.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/foo.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/foo1.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/foo1.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/incomplete.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/incomplete.yml deleted file mode 100644 index df64d324f..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/incomplete.yml +++ /dev/null @@ -1,2 +0,0 @@ -blog_show: - defaults: { _controller: MyBlogBundle:Blog:show } diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_defaults.xml deleted file mode 100644 index f93bf9c6a..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_defaults.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - true - 1 - 3.5 - foo - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml deleted file mode 100644 index 987086dbd..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - - true - 1 - 3.5 - foo - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml deleted file mode 100644 index 32d393c56..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - - true - 1 - 3.5 - foo - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_null_values.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_null_values.xml deleted file mode 100644 index c70e03ccc..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/list_null_values.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - - - - - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_defaults.xml deleted file mode 100644 index 47feb29b9..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_defaults.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - true - 1 - 3.5 - foo - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml deleted file mode 100644 index 6d770653b..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - - true - 1 - 3.5 - foo - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml deleted file mode 100644 index 2beee6143..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - - true - 1 - 3.5 - foo - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_null_values.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_null_values.xml deleted file mode 100644 index 8fd8954e0..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/map_null_values.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - - - - - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_id.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_id.xml deleted file mode 100644 index 4ea4115f2..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_id.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_path.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_path.xml deleted file mode 100644 index ef5bc088d..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/missing_path.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml deleted file mode 100644 index e33955ae4..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - MyBundle:Blog:show - \w+ - en|fr|de - RouteCompiler - - 1 - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml deleted file mode 100644 index a3e947372..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml +++ /dev/null @@ -1,3 +0,0 @@ -blog_show: - resource: validpattern.yml - path: /test diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml deleted file mode 100644 index 547cda3b6..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml +++ /dev/null @@ -1,3 +0,0 @@ -blog_show: - path: /blog/{slug} - type: custom diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.xml deleted file mode 100644 index dc147d2e6..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - MyBundle:Blog:show - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.yml deleted file mode 100644 index 257cc5642..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid.yml +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml deleted file mode 100644 index cfa9992bb..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml +++ /dev/null @@ -1 +0,0 @@ -route: string diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml deleted file mode 100644 index 015e270fb..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml +++ /dev/null @@ -1,3 +0,0 @@ -someroute: - resource: path/to/some.yml - name_prefix: test_ diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml deleted file mode 100644 index 863ef03b9..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - bar - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml deleted file mode 100644 index 908958c03..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - MyBundle:Blog:show - - baz - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/null_values.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/null_values.xml deleted file mode 100644 index f9e2aa24d..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/null_values.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - foo - bar - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl.php deleted file mode 100644 index 04f6d7ed6..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl.php +++ /dev/null @@ -1,21 +0,0 @@ -add('foo', '/foo') - ->condition('abc') - ->options(array('utf8' => true)) - ->add('buz', 'zub') - ->controller('foo:act'); - - $routes->import('php_dsl_sub.php') - ->prefix('/sub') - ->requirements(array('id' => '\d+')); - - $routes->add('ouf', '/ouf') - ->schemes(array('https')) - ->methods(array('GET')) - ->defaults(array('id' => 0)); -}; diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php deleted file mode 100644 index 9eb444ded..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php +++ /dev/null @@ -1,14 +0,0 @@ -collection('c_') - ->prefix('pub'); - - $add('bar', '/bar'); - - $add->collection('pub_') - ->host('host') - ->add('buz', 'buz'); -}; diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml deleted file mode 100644 index ecfde2801..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - AcmeBlogBundle:Blog:index - - - - true - - - 1 - - - 3.5 - - - false - - - 1 - - - 0 - - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/special_route_name.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/special_route_name.yml deleted file mode 100644 index 78be239aa..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/special_route_name.yml +++ /dev/null @@ -1,2 +0,0 @@ -"#$péß^a|": - path: "true" diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.php deleted file mode 100644 index edc16d8c2..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.php +++ /dev/null @@ -1,18 +0,0 @@ -add('blog_show', new Route( - '/blog/{slug}', - array('_controller' => 'MyBlogBundle:Blog:show'), - array('locale' => '\w+'), - array('compiler_class' => 'RouteCompiler'), - '{locale}.example.com', - array('https'), - array('GET', 'POST', 'put', 'OpTiOnS'), - 'context.getMethod() == "GET"' -)); - -return $collection; diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.xml deleted file mode 100644 index dbc72e46d..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - MyBundle:Blog:show - \w+ - - context.getMethod() == "GET" - - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.yml deleted file mode 100644 index 565abaaa2..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validpattern.yml +++ /dev/null @@ -1,13 +0,0 @@ -blog_show: - path: /blog/{slug} - defaults: { _controller: "MyBundle:Blog:show" } - host: "{locale}.example.com" - requirements: { 'locale': '\w+' } - methods: ['GET','POST','put','OpTiOnS'] - schemes: ['https'] - condition: 'context.getMethod() == "GET"' - options: - compiler_class: RouteCompiler - -blog_show_inherited: - path: /blog/{slug} diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.php deleted file mode 100644 index 482c80b29..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.php +++ /dev/null @@ -1,18 +0,0 @@ -import('validpattern.php'); -$collection->addDefaults(array( - 'foo' => 123, -)); -$collection->addRequirements(array( - 'foo' => '\d+', -)); -$collection->addOptions(array( - 'foo' => 'bar', -)); -$collection->setCondition('context.getMethod() == "POST"'); -$collection->addPrefix('/prefix'); - -return $collection; diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.xml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.xml deleted file mode 100644 index b7a15ddc7..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - 123 - \d+ - - context.getMethod() == "POST" - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.yml b/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.yml deleted file mode 100644 index faf2263ae..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/validresource.yml +++ /dev/null @@ -1,8 +0,0 @@ -_blog: - resource: validpattern.yml - prefix: /{foo} - defaults: { 'foo': '123' } - requirements: { 'foo': '\d+' } - options: { 'foo': 'bar' } - host: "" - condition: 'context.getMethod() == "POST"' diff --git a/lib/silex/vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php b/lib/silex/vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php deleted file mode 100644 index 5871420b1..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/lib/silex/vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/lib/silex/vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php deleted file mode 100644 index f84802b35..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ /dev/null @@ -1,181 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Generator\Dumper; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper; -use Symfony\Component\Routing\RequestContext; - -class PhpGeneratorDumperTest extends TestCase -{ - /** - * @var RouteCollection - */ - private $routeCollection; - - /** - * @var PhpGeneratorDumper - */ - private $generatorDumper; - - /** - * @var string - */ - private $testTmpFilepath; - - /** - * @var string - */ - private $largeTestTmpFilepath; - - protected function setUp() - { - parent::setUp(); - - $this->routeCollection = new RouteCollection(); - $this->generatorDumper = new PhpGeneratorDumper($this->routeCollection); - $this->testTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.php'; - $this->largeTestTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.large.php'; - @unlink($this->testTmpFilepath); - @unlink($this->largeTestTmpFilepath); - } - - protected function tearDown() - { - parent::tearDown(); - - @unlink($this->testTmpFilepath); - - $this->routeCollection = null; - $this->generatorDumper = null; - $this->testTmpFilepath = null; - } - - public function testDumpWithRoutes() - { - $this->routeCollection->add('Test', new Route('/testing/{foo}')); - $this->routeCollection->add('Test2', new Route('/testing2')); - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump()); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php')); - - $absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL); - $absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL); - $relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH); - $relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter); - $this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter); - $this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter); - $this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter); - } - - public function testDumpWithTooManyRoutes() - { - if (defined('HHVM_VERSION_ID')) { - $this->markTestSkipped('HHVM consumes too much memory on this test.'); - } - - $this->routeCollection->add('Test', new Route('/testing/{foo}')); - for ($i = 0; $i < 32769; ++$i) { - $this->routeCollection->add('route_'.$i, new Route('/route_'.$i)); - } - $this->routeCollection->add('Test2', new Route('/testing2')); - - file_put_contents($this->largeTestTmpFilepath, $this->generatorDumper->dump(array( - 'class' => 'ProjectLargeUrlGenerator', - ))); - $this->routeCollection = $this->generatorDumper = null; - include $this->largeTestTmpFilepath; - - $projectUrlGenerator = new \ProjectLargeUrlGenerator(new RequestContext('/app.php')); - - $absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL); - $absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL); - $relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH); - $relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter); - $this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter); - $this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter); - $this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testDumpWithoutRoutes() - { - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'WithoutRoutesUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \WithoutRoutesUrlGenerator(new RequestContext('/app.php')); - - $projectUrlGenerator->generate('Test', array()); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException - */ - public function testGenerateNonExistingRoute() - { - $this->routeCollection->add('Test', new Route('/test')); - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'NonExistingRoutesUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \NonExistingRoutesUrlGenerator(new RequestContext()); - $url = $projectUrlGenerator->generate('NonExisting', array()); - } - - public function testDumpForRouteWithDefaults() - { - $this->routeCollection->add('Test', new Route('/testing/{foo}', array('foo' => 'bar'))); - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'DefaultRoutesUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \DefaultRoutesUrlGenerator(new RequestContext()); - $url = $projectUrlGenerator->generate('Test', array()); - - $this->assertEquals('/testing', $url); - } - - public function testDumpWithSchemeRequirement() - { - $this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https'))); - - file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator'))); - include $this->testTmpFilepath; - - $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php')); - - $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL); - $relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('ftp://localhost/app.php/testing', $absoluteUrl); - $this->assertEquals('ftp://localhost/app.php/testing', $relativeUrl); - - $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https')); - - $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL); - $relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('https://localhost/app.php/testing', $absoluteUrl); - $this->assertEquals('/app.php/testing', $relativeUrl); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php b/lib/silex/vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php deleted file mode 100644 index 68add771b..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php +++ /dev/null @@ -1,724 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Generator; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\Generator\UrlGenerator; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\RequestContext; - -class UrlGeneratorTest extends TestCase -{ - public function testAbsoluteUrlWithPort80() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL); - - $this->assertEquals('http://localhost/app.php/testing', $url); - } - - public function testAbsoluteSecureUrlWithPort443() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL); - - $this->assertEquals('https://localhost/app.php/testing', $url); - } - - public function testAbsoluteUrlWithNonStandardPort() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes, array('httpPort' => 8080))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL); - - $this->assertEquals('http://localhost:8080/app.php/testing', $url); - } - - public function testAbsoluteSecureUrlWithNonStandardPort() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes, array('httpsPort' => 8080, 'scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL); - - $this->assertEquals('https://localhost:8080/app.php/testing', $url); - } - - public function testRelativeUrlWithoutParameters() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('/app.php/testing', $url); - } - - public function testRelativeUrlWithParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('/app.php/testing/bar', $url); - } - - public function testRelativeUrlWithNullParameter() - { - $routes = $this->getRoutes('test', new Route('/testing.{format}', array('format' => null))); - $url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - - $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))); - // 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(), UrlGeneratorInterface::ABSOLUTE_PATH); - } - - public function testRelativeUrlWithOptionalZeroParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{page}')); - $url = $this->getGenerator($routes)->generate('test', array('page' => 0), UrlGeneratorInterface::ABSOLUTE_PATH); - - $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')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('/app.php/testing?foo=bar', $url); - } - - public function testAbsoluteUrlWithExtraParameters() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL); - - $this->assertEquals('http://localhost/app.php/testing?foo=bar', $url); - } - - public function testUrlWithNullExtraParameters() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array('foo' => null), UrlGeneratorInterface::ABSOLUTE_URL); - - $this->assertEquals('http://localhost/app.php/testing', $url); - } - - public function testUrlWithExtraParametersFromGlobals() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $generator = $this->getGenerator($routes); - $context = new RequestContext('/app.php'); - $context->setParameter('bar', 'bar'); - $generator->setContext($context); - $url = $generator->generate('test', array('foo' => 'bar')); - - $this->assertEquals('/app.php/testing?foo=bar', $url); - } - - public function testUrlWithGlobalParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}')); - $generator = $this->getGenerator($routes); - $context = new RequestContext('/app.php'); - $context->setParameter('foo', 'bar'); - $generator->setContext($context); - $url = $generator->generate('test', array()); - - $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 - */ - public function testGenerateWithoutRoutes() - { - $routes = $this->getRoutes('foo', new Route('/testing/{foo}')); - $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\MissingMandatoryParametersException - */ - public function testGenerateForRouteWithoutMandatoryParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}')); - $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException - */ - public function testGenerateForRouteWithInvalidOptionalParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); - $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL); - } - - /** - * @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'), UrlGeneratorInterface::ABSOLUTE_URL); - } - - public function testGenerateForRouteWithInvalidOptionalParameterNonStrict() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); - $generator = $this->getGenerator($routes); - $generator->setStrictRequirements(false); - $this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL)); - } - - public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+'))); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $logger->expects($this->once()) - ->method('error'); - $generator = $this->getGenerator($routes, array(), $logger); - $generator->setStrictRequirements(false); - $this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL)); - } - - 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 - */ - public function testGenerateForRouteWithInvalidMandatoryParameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => 'd+'))); - $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException - */ - public function testGenerateForRouteWithInvalidUtf8Parameter() - { - $routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '\pL+'), array('utf8' => true))); - $this->getGenerator($routes)->generate('test', array('foo' => 'abc123'), UrlGeneratorInterface::ABSOLUTE_URL); - } - - /** - * @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(), array(), '', array('http'))); - $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); - $this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); - } - - public function testSchemeRequirementForcesAbsoluteUrl() - { - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https'))); - $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test')); - - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http'))); - $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test')); - } - - public function testSchemeRequirementCreatesUrlForFirstRequiredScheme() - { - $routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('Ftp', 'https'))); - $this->assertEquals('ftp://localhost/app.php/', $this->getGenerator($routes)->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))); - - $this->assertEquals('/app.php/category/foo', $this->getGenerator($routes)->generate('test', array('slug1' => 'foo'))); - } - - public function testWithAnIntegerAsADefaultValue() - { - $routes = $this->getRoutes('test', new Route('/{default}', array('default' => 0))); - - $this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo'))); - } - - public function testNullForOptionalParameterIsIgnored() - { - $routes = $this->getRoutes('test', new Route('/test/{default}', array('default' => 0))); - - $this->assertEquals('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => null))); - } - - public function testQueryParamSameAsDefault() - { - $routes = $this->getRoutes('test', new Route('/test', array('page' => 1))); - - $this->assertSame('/app.php/test?page=2', $this->getGenerator($routes)->generate('test', array('page' => 2))); - $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => 1))); - $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => '1'))); - $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test')); - } - - public function testArrayQueryParamSameAsDefault() - { - $routes = $this->getRoutes('test', new Route('/test', array('array' => array('foo', 'bar')))); - - $this->assertSame('/app.php/test?array%5B0%5D=bar&array%5B1%5D=foo', $this->getGenerator($routes)->generate('test', array('array' => array('bar', 'foo')))); - $this->assertSame('/app.php/test?array%5Ba%5D=foo&array%5Bb%5D=bar', $this->getGenerator($routes)->generate('test', array('array' => array('a' => 'foo', 'b' => 'bar')))); - $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array('foo', 'bar')))); - $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array(1 => 'bar', 0 => 'foo')))); - $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() - { - $expectedPath = '/app.php/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id' - .'/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id' - .'?query=%40%3A%5B%5D/%28%29%2A%27%22%20%2B%2C%3B-._~%26%24%3C%3E%7C%7B%7D%25%5C%5E%60%21%3Ffoo%3Dbar%23id'; - - // This tests the encoding of reserved characters that are used for delimiting of URI components (defined in RFC 3986) - // and other special ASCII chars. These chars are tested as static text path, variable path and query param. - $chars = '@:[]/()*\'" +,;-._~&$<>|{}%\\^`!?foo=bar#id'; - $routes = $this->getRoutes('test', new Route("/$chars/{varpath}", array(), array('varpath' => '.+'))); - $this->assertSame($expectedPath, $this->getGenerator($routes)->generate('test', array( - 'varpath' => $chars, - 'query' => $chars, - ))); - } - - public function testEncodingOfRelativePathSegments() - { - $routes = $this->getRoutes('test', new Route('/dir/../dir/..')); - $this->assertSame('/app.php/dir/%2E%2E/dir/%2E%2E', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/dir/./dir/.')); - $this->assertSame('/app.php/dir/%2E/dir/%2E', $this->getGenerator($routes)->generate('test')); - $routes = $this->getRoutes('test', new Route('/a./.a/a../..a/...')); - $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->{method_exists($this, $_ = 'expectException') ? $_ : '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 testWithHostDifferentFromContext() - { - $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - - $this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' => 'Fabien', 'locale' => 'fr'))); - } - - public function testWithHostSameAsContext() - { - $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 testWithHostSameAsContextAndAbsolute() - { - $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'), UrlGeneratorInterface::ABSOLUTE_URL)); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException - */ - public function testUrlWithInvalidParameterInHost() - { - $routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com')); - $this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException - */ - public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue() - { - $routes = $this->getRoutes('test', new Route('/', array('foo' => 'bar'), array('foo' => 'bar'), array(), '{foo}.example.com')); - $this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException - */ - public function testUrlWithInvalidParameterEqualsDefaultValueInHost() - { - $routes = $this->getRoutes('test', new Route('/', array('foo' => 'baz'), array('foo' => 'bar'), array(), '{foo}.example.com')); - $this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH); - } - - public function testUrlWithInvalidParameterInHostInNonStrictMode() - { - $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'), UrlGeneratorInterface::ABSOLUTE_PATH)); - } - - public function testHostIsCaseInsensitive() - { - $routes = $this->getRoutes('test', new Route('/', array(), array('locale' => 'en|de|fr'), array(), '{locale}.FooBar.com')); - $generator = $this->getGenerator($routes); - $this->assertSame('//EN.FooBar.com/app.php/', $generator->generate('test', array('locale' => 'EN'), UrlGeneratorInterface::NETWORK_PATH)); - } - - public function testDefaultHostIsUsedWhenContextHostIsEmpty() - { - $routes = $this->getRoutes('test', new Route('/route', array('domain' => 'my.fallback.host'), array('domain' => '.+'), array(), '{domain}', array('http'))); - - $generator = $this->getGenerator($routes); - $generator->getContext()->setHost(''); - - $this->assertSame('http://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL)); - } - - public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot() - { - $routes = $this->getRoutes('test', new Route('/route', array('domain' => 'my.fallback.host'), array('domain' => '.+'), array(), '{domain}', array('http', 'https'))); - - $generator = $this->getGenerator($routes); - $generator->getContext()->setHost(''); - $generator->getContext()->setScheme('https'); - - $this->assertSame('https://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL)); - } - - public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot() - { - $routes = $this->getRoutes('test', new Route('/route', array(), array(), array(), '', array('http', 'https'))); - - $generator = $this->getGenerator($routes); - $generator->getContext()->setHost(''); - $generator->getContext()->setScheme('https'); - - $this->assertSame('/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL)); - } - - public function testGenerateNetworkPath() - { - $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com', array('http'))); - - $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' - ); - $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', - array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' - ); - $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' - ); - $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' - ); - } - - public function testGenerateRelativePath() - { - $routes = new RouteCollection(); - $routes->add('article', new Route('/{author}/{article}/')); - $routes->add('comments', new Route('/{author}/{article}/comments')); - $routes->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com')); - $routes->add('scheme', new Route('/{author}/blog', array(), array(), array(), '', array('https'))); - $routes->add('unrelated', new Route('/about')); - - $generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/')); - - $this->assertSame('comments', $generator->generate('comments', - array('author' => 'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('comments?page=2', $generator->generate('comments', - array('author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('../twig-is-great/', $generator->generate('article', - array('author' => 'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article', - array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host', - array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme', - array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) - ); - $this->assertSame('../../about', $generator->generate('unrelated', - array(), UrlGeneratorInterface::RELATIVE_PATH) - ); - } - - /** - * @dataProvider provideRelativePaths - */ - public function testGetRelativePath($sourcePath, $targetPath, $expectedPath) - { - $this->assertSame($expectedPath, UrlGenerator::getRelativePath($sourcePath, $targetPath)); - } - - public function provideRelativePaths() - { - return array( - array( - '/same/dir/', - '/same/dir/', - '', - ), - array( - '/same/file', - '/same/file', - '', - ), - array( - '/', - '/file', - 'file', - ), - array( - '/', - '/dir/file', - 'dir/file', - ), - array( - '/dir/file.html', - '/dir/different-file.html', - 'different-file.html', - ), - array( - '/same/dir/extra-file', - '/same/dir/', - './', - ), - array( - '/parent/dir/', - '/parent/', - '../', - ), - array( - '/parent/dir/extra-file', - '/parent/', - '../', - ), - array( - '/a/b/', - '/x/y/z/', - '../../x/y/z/', - ), - array( - '/a/b/c/d/e', - '/a/c/d', - '../../../c/d', - ), - array( - '/a/b/c//', - '/a/b/c/', - '../', - ), - array( - '/a/b/c/', - '/a/b/c//', - './/', - ), - array( - '/root/a/b/c/', - '/root/x/b/c/', - '../../../x/b/c/', - ), - array( - '/a/b/c/d/', - '/a', - '../../../../a', - ), - array( - '/special-chars/sp%20ce/1€/mäh/e=mc²', - '/special-chars/sp%20ce/1€/<µ>/e=mc²', - '../<µ>/e=mc²', - ), - array( - 'not-rooted', - 'dir/file', - 'dir/file', - ), - array( - '//dir/', - '', - '../../', - ), - array( - '/dir/', - '/dir/file:with-colon', - './file:with-colon', - ), - array( - '/dir/', - '/dir/subdir/file:with-colon', - 'subdir/file:with-colon', - ), - array( - '/dir/', - '/dir/:subdir/', - './:subdir/', - ), - ); - } - - public function testFragmentsCanBeAppendedToUrls() - { - $routes = $this->getRoutes('test', new Route('/testing')); - - $url = $this->getGenerator($routes)->generate('test', array('_fragment' => 'frag ment'), UrlGeneratorInterface::ABSOLUTE_PATH); - $this->assertEquals('/app.php/testing#frag%20ment', $url); - - $url = $this->getGenerator($routes)->generate('test', array('_fragment' => '0'), UrlGeneratorInterface::ABSOLUTE_PATH); - $this->assertEquals('/app.php/testing#0', $url); - } - - public function testFragmentsDoNotEscapeValidCharacters() - { - $routes = $this->getRoutes('test', new Route('/testing')); - $url = $this->getGenerator($routes)->generate('test', array('_fragment' => '?/'), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('/app.php/testing#?/', $url); - } - - public function testFragmentsCanBeDefinedAsDefaults() - { - $routes = $this->getRoutes('test', new Route('/testing', array('_fragment' => 'fragment'))); - $url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH); - - $this->assertEquals('/app.php/testing#fragment', $url); - } - - protected function getGenerator(RouteCollection $routes, array $parameters = array(), $logger = null) - { - $context = new RequestContext('/app.php'); - foreach ($parameters as $key => $value) { - $method = 'set'.$key; - $context->$method($value); - } - - return new UrlGenerator($routes, $context, $logger); - } - - protected function getRoutes($name, Route $route) - { - $routes = new RouteCollection(); - $routes->add($name, $route); - - return $routes; - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php deleted file mode 100644 index e8bbe8fcf..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; - -abstract class AbstractAnnotationLoaderTest extends TestCase -{ - public function getReader() - { - return $this->getMockBuilder('Doctrine\Common\Annotations\Reader') - ->disableOriginalConstructor() - ->getMock() - ; - } - - public function getClassLoader($reader) - { - return $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader') - ->setConstructorArgs(array($reader)) - ->getMockForAbstractClass() - ; - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php deleted file mode 100644 index 70db1ccd9..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php +++ /dev/null @@ -1,255 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Annotation\Route; - -class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest -{ - protected $loader; - private $reader; - - protected function setUp() - { - parent::setUp(); - - $this->reader = $this->getReader(); - $this->loader = $this->getClassLoader($this->reader); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLoadMissingClass() - { - $this->loader->load('MissingClass'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testLoadAbstractClass() - { - $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\AbstractClass'); - } - - /** - * @dataProvider provideTestSupportsChecksResource - */ - public function testSupportsChecksResource($resource, $expectedSupports) - { - $this->assertSame($expectedSupports, $this->loader->supports($resource), '->supports() returns true if the resource is loadable'); - } - - public function provideTestSupportsChecksResource() - { - return array( - array('class', true), - array('\fully\qualified\class\name', true), - array('namespaced\class\without\leading\slash', true), - array('ÿClassWithLegalSpecialCharacters', true), - array('5', false), - array('foo.foo', false), - array(null, false), - ); - } - - public function testSupportsChecksTypeIfSpecified() - { - $this->assertTrue($this->loader->supports('class', 'annotation'), '->supports() checks the resource type if specified'); - $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', 'path' => '/path'), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), - ), - array( - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('defaults' => array('arg2' => 'foo'), 'requirements' => array('arg3' => '\w+')), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), - ), - array( - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('options' => array('foo' => 'bar')), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), - ), - array( - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('schemes' => array('https'), 'methods' => array('GET')), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), - ), - array( - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - array('condition' => 'context.getMethod() == "GET"'), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), - ), - ); - } - - /** - * @dataProvider getLoadTests - */ - public function testLoad($className, $routeData = array(), $methodArgs = array()) - { - $routeData = array_replace(array( - 'name' => 'route', - 'path' => '/', - 'requirements' => array(), - 'options' => array(), - 'defaults' => array(), - 'schemes' => array(), - 'methods' => array(), - 'condition' => '', - ), $routeData); - - $this->reader - ->expects($this->once()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array($this->getAnnotatedRoute($routeData)))) - ; - - $routeCollection = $this->loader->load($className); - $route = $routeCollection->get($routeData['name']); - - $this->assertSame($routeData['path'], $route->getPath(), '->load preserves path annotation'); - $this->assertCount( - count($routeData['requirements']), - array_intersect_assoc($routeData['requirements'], $route->getRequirements()), - '->load preserves requirements annotation' - ); - $this->assertCount( - count($routeData['options']), - array_intersect_assoc($routeData['options'], $route->getOptions()), - '->load preserves options annotation' - ); - $this->assertCount( - count($routeData['defaults']), - $route->getDefaults(), - '->load preserves defaults annotation' - ); - $this->assertEquals($routeData['schemes'], $route->getSchemes(), '->load preserves schemes annotation'); - $this->assertEquals($routeData['methods'], $route->getMethods(), '->load preserves methods annotation'); - $this->assertSame($routeData['condition'], $route->getCondition(), '->load preserves condition annotation'); - } - - public function testClassRouteLoad() - { - $classRouteData = array( - 'name' => 'prefix_', - 'path' => '/prefix', - 'schemes' => array('https'), - 'methods' => array('GET'), - ); - - $methodRouteData = array( - 'name' => 'route1', - 'path' => '/path', - 'schemes' => array('http'), - 'methods' => array('POST', 'PUT'), - ); - - $this->reader - ->expects($this->once()) - ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) - ; - $this->reader - ->expects($this->once()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array($this->getAnnotatedRoute($methodRouteData)))) - ; - - $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass'); - $route = $routeCollection->get($classRouteData['name'].$methodRouteData['name']); - - $this->assertSame($classRouteData['path'].$methodRouteData['path'], $route->getPath(), '->load concatenates class and method route path'); - $this->assertEquals(array_merge($classRouteData['schemes'], $methodRouteData['schemes']), $route->getSchemes(), '->load merges class and method route schemes'); - $this->assertEquals(array_merge($classRouteData['methods'], $methodRouteData['methods']), $route->getMethods(), '->load merges class and method route methods'); - } - - public function testInvokableClassRouteLoad() - { - $classRouteData = array( - 'name' => 'route1', - 'path' => '/', - 'schemes' => array('https'), - 'methods' => array('GET'), - ); - - $this->reader - ->expects($this->exactly(2)) - ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) - ; - $this->reader - ->expects($this->once()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array())) - ; - - $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); - $route = $routeCollection->get($classRouteData['name']); - - $this->assertSame($classRouteData['path'], $route->getPath(), '->load preserves class route path'); - $this->assertEquals(array_merge($classRouteData['schemes'], $classRouteData['schemes']), $route->getSchemes(), '->load preserves class route schemes'); - $this->assertEquals(array_merge($classRouteData['methods'], $classRouteData['methods']), $route->getMethods(), '->load preserves class route methods'); - } - - public function testInvokableClassWithMethodRouteLoad() - { - $classRouteData = array( - 'name' => 'route1', - 'path' => '/prefix', - 'schemes' => array('https'), - 'methods' => array('GET'), - ); - - $methodRouteData = array( - 'name' => 'route2', - 'path' => '/path', - 'schemes' => array('http'), - 'methods' => array('POST', 'PUT'), - ); - - $this->reader - ->expects($this->once()) - ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) - ; - $this->reader - ->expects($this->once()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array($this->getAnnotatedRoute($methodRouteData)))) - ; - - $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); - $route = $routeCollection->get($classRouteData['name']); - - $this->assertNull($route, '->load ignores class route'); - - $route = $routeCollection->get($classRouteData['name'].$methodRouteData['name']); - - $this->assertSame($classRouteData['path'].$methodRouteData['path'], $route->getPath(), '->load concatenates class and method route path'); - $this->assertEquals(array_merge($classRouteData['schemes'], $methodRouteData['schemes']), $route->getSchemes(), '->load merges class and method route schemes'); - $this->assertEquals(array_merge($classRouteData['methods'], $methodRouteData['methods']), $route->getMethods(), '->load merges class and method route methods'); - } - - private function getAnnotatedRoute($data) - { - return new Route($data); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php deleted file mode 100644 index 1e8ee3940..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader; -use Symfony\Component\Config\FileLocator; - -class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest -{ - protected $loader; - protected $reader; - - protected function setUp() - { - parent::setUp(); - - $this->reader = $this->getReader(); - $this->loader = new AnnotationDirectoryLoader(new FileLocator(), $this->getClassLoader($this->reader)); - } - - public function testLoad() - { - $this->reader->expects($this->exactly(4))->method('getClassAnnotation'); - - $this->reader - ->expects($this->any()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array())) - ; - - $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses'); - } - - public function testLoadIgnoresHiddenDirectories() - { - $this->expectAnnotationsToBeReadFrom(array( - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass', - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass', - 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass', - )); - - $this->reader - ->expects($this->any()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array())) - ; - - $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses'); - } - - public function testSupports() - { - $fixturesDir = __DIR__.'/../Fixtures'; - - $this->assertTrue($this->loader->supports($fixturesDir), '->supports() returns true if the resource is loadable'); - $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($this->loader->supports($fixturesDir, 'annotation'), '->supports() checks the resource type if specified'); - $this->assertFalse($this->loader->supports($fixturesDir, 'foo'), '->supports() checks the resource type if specified'); - } - - public function testItSupportsAnyAnnotation() - { - $this->assertTrue($this->loader->supports(__DIR__.'/../Fixtures/even-with-not-existing-folder', 'annotation')); - } - - public function testLoadFileIfLocatedResourceIsFile() - { - $this->reader->expects($this->exactly(1))->method('getClassAnnotation'); - - $this->reader - ->expects($this->any()) - ->method('getMethodAnnotations') - ->will($this->returnValue(array())) - ; - - $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); - } - - private function expectAnnotationsToBeReadFrom(array $classes) - { - $this->reader->expects($this->exactly(count($classes))) - ->method('getClassAnnotation') - ->with($this->callback(function (\ReflectionClass $class) use ($classes) { - return in_array($class->getName(), $classes); - })); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php deleted file mode 100644 index 7f1d57655..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Loader\AnnotationFileLoader; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Routing\Annotation\Route; - -class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest -{ - protected $loader; - protected $reader; - - protected function setUp() - { - parent::setUp(); - - $this->reader = $this->getReader(); - $this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader)); - } - - public function testLoad() - { - $this->reader->expects($this->once())->method('getClassAnnotation'); - - $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); - } - - /** - * @requires PHP 5.4 - */ - public function testLoadTraitWithClassConstant() - { - $this->reader->expects($this->never())->method('getClassAnnotation'); - - $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php'); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Did you forgot to add the "loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/NoStartTagClass.php'); - } - - /** - * @requires PHP 5.6 - */ - public function testLoadVariadic() - { - $route = new Route(array('path' => '/path/to/{id}')); - $this->reader->expects($this->once())->method('getClassAnnotation'); - $this->reader->expects($this->once())->method('getMethodAnnotations') - ->will($this->returnValue(array($route))); - - $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php'); - } - - /** - * @requires PHP 7.0 - */ - public function testLoadAnonymousClass() - { - $this->reader->expects($this->never())->method('getClassAnnotation'); - $this->reader->expects($this->never())->method('getMethodAnnotations'); - - $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php'); - } - - public function testSupports() - { - $fixture = __DIR__.'/../Fixtures/annotated.php'; - - $this->assertTrue($this->loader->supports($fixture), '->supports() returns true if the resource is loadable'); - $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($this->loader->supports($fixture, 'annotation'), '->supports() checks the resource type if specified'); - $this->assertFalse($this->loader->supports($fixture, 'foo'), '->supports() checks the resource type if specified'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php deleted file mode 100644 index 5d963f86f..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Loader\ClosureLoader; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -class ClosureLoaderTest extends TestCase -{ - public function testSupports() - { - $loader = new ClosureLoader(); - - $closure = function () {}; - - $this->assertTrue($loader->supports($closure), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports($closure, 'closure'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports($closure, 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoad() - { - $loader = new ClosureLoader(); - - $route = new Route('/'); - $routes = $loader->load(function () use ($route) { - $routes = new RouteCollection(); - - $routes->add('foo', $route); - - return $routes; - }); - - $this->assertEquals($route, $routes->get('foo'), '->load() loads a \Closure resource'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php deleted file mode 100644 index fc29d371e..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use Symfony\Component\Routing\Loader\DirectoryLoader; -use Symfony\Component\Routing\Loader\YamlFileLoader; -use Symfony\Component\Routing\Loader\AnnotationFileLoader; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Routing\RouteCollection; - -class DirectoryLoaderTest extends AbstractAnnotationLoaderTest -{ - private $loader; - private $reader; - - protected function setUp() - { - parent::setUp(); - - $locator = new FileLocator(); - $this->reader = $this->getReader(); - $this->loader = new DirectoryLoader($locator); - $resolver = new LoaderResolver(array( - new YamlFileLoader($locator), - new AnnotationFileLoader($locator, $this->getClassLoader($this->reader)), - $this->loader, - )); - $this->loader->setResolver($resolver); - } - - public function testLoadDirectory() - { - $collection = $this->loader->load(__DIR__.'/../Fixtures/directory', 'directory'); - $this->verifyCollection($collection); - } - - public function testImportDirectory() - { - $collection = $this->loader->load(__DIR__.'/../Fixtures/directory_import', 'directory'); - $this->verifyCollection($collection); - } - - private function verifyCollection(RouteCollection $collection) - { - $routes = $collection->all(); - - $this->assertCount(3, $routes, 'Three routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - for ($i = 1; $i <= 3; ++$i) { - $this->assertSame('/route/'.$i, $routes['route'.$i]->getPath()); - } - } - - public function testSupports() - { - $fixturesDir = __DIR__.'/../Fixtures'; - - $this->assertFalse($this->loader->supports($fixturesDir), '->supports(*) returns false'); - - $this->assertTrue($this->loader->supports($fixturesDir, 'directory'), '->supports(*, "directory") returns true'); - $this->assertFalse($this->loader->supports($fixturesDir, 'foo'), '->supports(*, "foo") returns false'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php deleted file mode 100644 index 408fa0b45..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Loader\ObjectRouteLoader; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -class ObjectRouteLoaderTest extends TestCase -{ - public function testLoadCallsServiceAndReturnsCollection() - { - $loader = new ObjectRouteLoaderForTest(); - - // create a basic collection that will be returned - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $loader->loaderMap = array( - 'my_route_provider_service' => new RouteService($collection), - ); - - $actualRoutes = $loader->load( - 'my_route_provider_service:loadRoutes', - 'service' - ); - - $this->assertSame($collection, $actualRoutes); - // the service file should be listed as a resource - $this->assertNotEmpty($actualRoutes->getResources()); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getBadResourceStrings - */ - public function testExceptionWithoutSyntax($resourceString) - { - $loader = new ObjectRouteLoaderForTest(); - $loader->load($resourceString); - } - - public function getBadResourceStrings() - { - return array( - array('Foo'), - array('Bar::baz'), - array('Foo:Bar:baz'), - ); - } - - /** - * @expectedException \LogicException - */ - public function testExceptionOnNoObjectReturned() - { - $loader = new ObjectRouteLoaderForTest(); - $loader->loaderMap = array('my_service' => 'NOT_AN_OBJECT'); - $loader->load('my_service:method'); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testExceptionOnBadMethod() - { - $loader = new ObjectRouteLoaderForTest(); - $loader->loaderMap = array('my_service' => new \stdClass()); - $loader->load('my_service:method'); - } - - /** - * @expectedException \LogicException - */ - public function testExceptionOnMethodNotReturningCollection() - { - $service = $this->getMockBuilder('stdClass') - ->setMethods(array('loadRoutes')) - ->getMock(); - $service->expects($this->once()) - ->method('loadRoutes') - ->will($this->returnValue('NOT_A_COLLECTION')); - - $loader = new ObjectRouteLoaderForTest(); - $loader->loaderMap = array('my_service' => $service); - $loader->load('my_service:loadRoutes'); - } -} - -class ObjectRouteLoaderForTest extends ObjectRouteLoader -{ - public $loaderMap = array(); - - protected function getServiceObject($id) - { - return isset($this->loaderMap[$id]) ? $this->loaderMap[$id] : null; - } -} - -class RouteService -{ - private $collection; - - public function __construct($collection) - { - $this->collection = $collection; - } - - public function loadRoutes() - { - return $this->collection; - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php deleted file mode 100644 index 608d84ed7..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\Loader\PhpFileLoader; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -class PhpFileLoaderTest extends TestCase -{ - public function testSupports() - { - $loader = new PhpFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); - - $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports('foo.php', 'php'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports('foo.php', 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoadWithRoute() - { - $loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validpattern.php'); - $routes = $routeCollection->all(); - - $this->assertCount(1, $routes, 'One route is loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - } - } - - public function testLoadWithImport() - { - $loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validresource.php'); - $routes = $routeCollection->all(); - - $this->assertCount(1, $routes, 'One route is loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/prefix/blog/{slug}', $route->getPath()); - $this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - } - } - - public function testThatDefiningVariableInConfigFileHasNoSideEffects() - { - $locator = new FileLocator(array(__DIR__.'/../Fixtures')); - $loader = new PhpFileLoader($locator); - $routeCollection = $loader->load('with_define_path_variable.php'); - $resources = $routeCollection->getResources(); - $this->assertCount(1, $resources); - $this->assertContainsOnly('Symfony\Component\Config\Resource\ResourceInterface', $resources); - $fileResource = reset($resources); - $this->assertSame( - realpath($locator->locate('with_define_path_variable.php')), - (string) $fileResource - ); - } - - public function testRoutingConfigurator() - { - $locator = new FileLocator(array(__DIR__.'/../Fixtures')); - $loader = new PhpFileLoader($locator); - $routeCollection = $loader->load('php_dsl.php'); - - $expectedCollection = new RouteCollection(); - - $expectedCollection->add('foo', (new Route('/foo')) - ->setOptions(array('utf8' => true)) - ->setCondition('abc') - ); - $expectedCollection->add('buz', (new Route('/zub')) - ->setDefaults(array('_controller' => 'foo:act')) - ); - $expectedCollection->add('c_bar', (new Route('/sub/pub/bar')) - ->setRequirements(array('id' => '\d+')) - ); - $expectedCollection->add('c_pub_buz', (new Route('/sub/pub/buz')) - ->setHost('host') - ->setRequirements(array('id' => '\d+')) - ); - $expectedCollection->add('ouf', (new Route('/ouf')) - ->setSchemes(array('https')) - ->setMethods(array('GET')) - ->setDefaults(array('id' => 0)) - ); - - $expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_sub.php'))); - $expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl.php'))); - - $this->assertEquals($expectedCollection, $routeCollection); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php deleted file mode 100644 index 221434b00..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php +++ /dev/null @@ -1,364 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Routing\Loader\XmlFileLoader; -use Symfony\Component\Routing\Tests\Fixtures\CustomXmlFileLoader; - -class XmlFileLoaderTest extends TestCase -{ - public function testSupports() - { - $loader = new XmlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); - - $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports('foo.xml', 'xml'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports('foo.xml', 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoadWithRoute() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validpattern.xml'); - $route = $routeCollection->get('blog_show'); - - $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('locale')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); - } - - public function testLoadWithNamespacePrefix() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('namespaceprefix.xml'); - - $this->assertCount(1, $routeCollection->all(), 'One route is loaded'); - - $route = $routeCollection->get('blog_show'); - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{_locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('slug')); - $this->assertSame('en|fr|de', $route->getRequirement('_locale')); - $this->assertNull($route->getDefault('slug')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertSame(1, $route->getDefault('page')); - } - - public function testLoadWithImport() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validresource.xml'); - $routes = $routeCollection->all(); - - $this->assertCount(2, $routes, 'Two routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/{foo}/blog/{slug}', $route->getPath()); - $this->assertSame('123', $route->getDefault('foo')); - $this->assertSame('\d+', $route->getRequirement('foo')); - $this->assertSame('bar', $route->getOption('foo')); - $this->assertSame('', $route->getHost()); - $this->assertSame('context.getMethod() == "POST"', $route->getCondition()); - } - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getPathsToInvalidFiles - */ - public function testLoadThrowsExceptionWithInvalidFile($filePath) - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load($filePath); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getPathsToInvalidFiles - */ - public function testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation($filePath) - { - $loader = new CustomXmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load($filePath); - } - - public function getPathsToInvalidFiles() - { - return array(array('nonvalidnode.xml'), array('nonvalidroute.xml'), array('nonvalid.xml'), array('missing_id.xml'), array('missing_path.xml')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Document types are not allowed. - */ - public function testDocTypeIsNotAllowed() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load('withdoctype.xml'); - } - - public function testNullValues() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('null_values.xml'); - $route = $routeCollection->get('blog_show'); - - $this->assertTrue($route->hasDefault('foo')); - $this->assertNull($route->getDefault('foo')); - $this->assertTrue($route->hasDefault('bar')); - $this->assertNull($route->getDefault('bar')); - $this->assertEquals('foo', $route->getDefault('foobar')); - $this->assertEquals('bar', $route->getDefault('baz')); - } - - public function testScalarDataTypeDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('scalar_defaults.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - '_controller' => 'AcmeBlogBundle:Blog:index', - 'slug' => null, - 'published' => true, - 'page' => 1, - 'price' => 3.5, - 'archived' => false, - 'free' => true, - 'locked' => false, - 'foo' => null, - 'bar' => null, - ), - $route->getDefaults() - ); - } - - public function testListDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('list_defaults.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - '_controller' => 'AcmeBlogBundle:Blog:index', - 'values' => array(true, 1, 3.5, 'foo'), - ), - $route->getDefaults() - ); - } - - public function testListInListDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('list_in_list_defaults.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - '_controller' => 'AcmeBlogBundle:Blog:index', - 'values' => array(array(true, 1, 3.5, 'foo')), - ), - $route->getDefaults() - ); - } - - public function testListInMapDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('list_in_map_defaults.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - '_controller' => 'AcmeBlogBundle:Blog:index', - 'values' => array('list' => array(true, 1, 3.5, 'foo')), - ), - $route->getDefaults() - ); - } - - public function testMapDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('map_defaults.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - '_controller' => 'AcmeBlogBundle:Blog:index', - 'values' => array( - 'public' => true, - 'page' => 1, - 'price' => 3.5, - 'title' => 'foo', - ), - ), - $route->getDefaults() - ); - } - - public function testMapInListDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('map_in_list_defaults.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - '_controller' => 'AcmeBlogBundle:Blog:index', - 'values' => array(array( - 'public' => true, - 'page' => 1, - 'price' => 3.5, - 'title' => 'foo', - )), - ), - $route->getDefaults() - ); - } - - public function testMapInMapDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('map_in_map_defaults.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - '_controller' => 'AcmeBlogBundle:Blog:index', - 'values' => array('map' => array( - 'public' => true, - 'page' => 1, - 'price' => 3.5, - 'title' => 'foo', - )), - ), - $route->getDefaults() - ); - } - - public function testNullValuesInList() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('list_null_values.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame(array(null, null, null, null, null, null), $route->getDefault('list')); - } - - public function testNullValuesInMap() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('map_null_values.xml'); - $route = $routeCollection->get('blog'); - - $this->assertSame( - array( - 'boolean' => null, - 'integer' => null, - 'float' => null, - 'string' => null, - 'list' => null, - 'map' => null, - ), - $route->getDefault('map') - ); - } - - public function testLoadRouteWithControllerAttribute() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load('routing.xml'); - - $route = $routeCollection->get('app_homepage'); - - $this->assertSame('AppBundle:Homepage:show', $route->getDefault('_controller')); - } - - public function testLoadRouteWithoutControllerAttribute() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load('routing.xml'); - - $route = $routeCollection->get('app_logout'); - - $this->assertNull($route->getDefault('_controller')); - } - - public function testLoadRouteWithControllerSetInDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load('routing.xml'); - - $route = $routeCollection->get('app_blog'); - - $this->assertSame('AppBundle:Blog:list', $route->getDefault('_controller')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for "app_blog"/ - */ - public function testOverrideControllerInDefaults() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $loader->load('override_defaults.xml'); - } - - /** - * @dataProvider provideFilesImportingRoutesWithControllers - */ - public function testImportRouteWithController($file) - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load($file); - - $route = $routeCollection->get('app_homepage'); - $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); - - $route = $routeCollection->get('app_blog'); - $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); - - $route = $routeCollection->get('app_logout'); - $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); - } - - public function provideFilesImportingRoutesWithControllers() - { - yield array('import_controller.xml'); - yield array('import__controller.xml'); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for the "import" tag/ - */ - public function testImportWithOverriddenController() - { - $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $loader->load('import_override_defaults.xml'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Loader/YamlFileLoaderTest.php b/lib/silex/vendor/symfony/routing/Tests/Loader/YamlFileLoaderTest.php deleted file mode 100644 index 1f7fd4389..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Loader/YamlFileLoaderTest.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Routing\Loader\YamlFileLoader; -use Symfony\Component\Config\Resource\FileResource; - -class YamlFileLoaderTest extends TestCase -{ - public function testSupports() - { - $loader = new YamlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock()); - - $this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable'); - $this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable'); - $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); - - $this->assertTrue($loader->supports('foo.yml', 'yaml'), '->supports() checks the resource type if specified'); - $this->assertTrue($loader->supports('foo.yaml', 'yaml'), '->supports() checks the resource type if specified'); - $this->assertFalse($loader->supports('foo.yml', 'foo'), '->supports() checks the resource type if specified'); - } - - public function testLoadDoesNothingIfEmpty() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $collection = $loader->load('empty.yml'); - - $this->assertEquals(array(), $collection->all()); - $this->assertEquals(array(new FileResource(realpath(__DIR__.'/../Fixtures/empty.yml'))), $collection->getResources()); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getPathsToInvalidFiles - */ - public function testLoadThrowsExceptionWithInvalidFile($filePath) - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $loader->load($filePath); - } - - public function getPathsToInvalidFiles() - { - return array( - array('nonvalid.yml'), - array('nonvalid2.yml'), - array('incomplete.yml'), - array('nonvalidkeys.yml'), - array('nonesense_resource_plus_path.yml'), - array('nonesense_type_without_resource.yml'), - array('bad_format.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->getPath()); - } - - public function testLoadWithRoute() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validpattern.yml'); - $route = $routeCollection->get('blog_show'); - - $this->assertInstanceOf('Symfony\Component\Routing\Route', $route); - $this->assertSame('/blog/{slug}', $route->getPath()); - $this->assertSame('{locale}.example.com', $route->getHost()); - $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller')); - $this->assertSame('\w+', $route->getRequirement('locale')); - $this->assertSame('RouteCompiler', $route->getOption('compiler_class')); - $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods()); - $this->assertEquals(array('https'), $route->getSchemes()); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition()); - } - - public function testLoadWithResource() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); - $routeCollection = $loader->load('validresource.yml'); - $routes = $routeCollection->all(); - - $this->assertCount(2, $routes, 'Two routes are loaded'); - $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes); - - foreach ($routes as $route) { - $this->assertSame('/{foo}/blog/{slug}', $route->getPath()); - $this->assertSame('123', $route->getDefault('foo')); - $this->assertSame('\d+', $route->getRequirement('foo')); - $this->assertSame('bar', $route->getOption('foo')); - $this->assertSame('', $route->getHost()); - $this->assertSame('context.getMethod() == "POST"', $route->getCondition()); - } - } - - public function testLoadRouteWithControllerAttribute() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load('routing.yml'); - - $route = $routeCollection->get('app_homepage'); - - $this->assertSame('AppBundle:Homepage:show', $route->getDefault('_controller')); - } - - public function testLoadRouteWithoutControllerAttribute() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load('routing.yml'); - - $route = $routeCollection->get('app_logout'); - - $this->assertNull($route->getDefault('_controller')); - } - - public function testLoadRouteWithControllerSetInDefaults() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load('routing.yml'); - - $route = $routeCollection->get('app_blog'); - - $this->assertSame('AppBundle:Blog:list', $route->getDefault('_controller')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/ - */ - public function testOverrideControllerInDefaults() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $loader->load('override_defaults.yml'); - } - - /** - * @dataProvider provideFilesImportingRoutesWithControllers - */ - public function testImportRouteWithController($file) - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $routeCollection = $loader->load($file); - - $route = $routeCollection->get('app_homepage'); - $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); - - $route = $routeCollection->get('app_blog'); - $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); - - $route = $routeCollection->get('app_logout'); - $this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller')); - } - - public function provideFilesImportingRoutesWithControllers() - { - yield array('import_controller.yml'); - yield array('import__controller.yml'); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/ - */ - public function testImportWithOverriddenController() - { - $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller'))); - $loader->load('import_override_defaults.yml'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/DumperCollectionTest.php b/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/DumperCollectionTest.php deleted file mode 100644 index 823efdb84..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/DumperCollectionTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher\Dumper; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Matcher\Dumper\DumperCollection; - -class DumperCollectionTest extends 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/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php deleted file mode 100644 index e4c18c47b..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ /dev/null @@ -1,459 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher\Dumper; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; -use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface; -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -class PhpMatcherDumperTest extends TestCase -{ - /** - * @var string - */ - private $matcherClass; - - /** - * @var string - */ - private $dumpPath; - - protected function setUp() - { - parent::setUp(); - - $this->matcherClass = uniqid('ProjectUrlMatcher'); - $this->dumpPath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_matcher.'.$this->matcherClass.'.php'; - } - - protected function tearDown() - { - parent::tearDown(); - - @unlink($this->dumpPath); - } - - /** - * @expectedException \LogicException - */ - public function testDumpWhenSchemeIsUsedWithoutAProperDumper() - { - $collection = new RouteCollection(); - $collection->add('secure', new Route( - '/secure', - array(), - array(), - array(), - '', - array('https') - )); - $dumper = new PhpMatcherDumper($collection); - $dumper->dump(); - } - - public function testRedirectPreservesUrlEncoding() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo:bar/')); - - $class = $this->generateDumpedMatcher($collection, true); - - $matcher = $this->getMockBuilder($class) - ->setMethods(array('redirect')) - ->setConstructorArgs(array(new RequestContext())) - ->getMock(); - - $matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/', 'foo')->willReturn(array()); - - $matcher->match('/foo%3Abar'); - } - - /** - * @dataProvider getRouteCollections - */ - 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.'); - } - - public function getRouteCollections() - { - /* test case 1 */ - - $collection = new RouteCollection(); - - $collection->add('overridden', new Route('/overridden')); - - // defaults and requirements - $collection->add('foo', new Route( - '/foo/{bar}', - array('def' => 'test'), - array('bar' => 'baz|symfony') - )); - // method requirement - $collection->add('bar', new Route( - '/bar/{foo}', - array(), - array(), - array(), - '', - array(), - array('GET', 'head') - )); - // GET method requirement automatically adds HEAD as valid - $collection->add('barhead', new Route( - '/barhead/{foo}', - array(), - array(), - array(), - '', - array(), - array('GET') - )); - // simple - $collection->add('baz', new Route( - '/test/baz' - )); - // simple with extension - $collection->add('baz2', new Route( - '/test/baz.html' - )); - // trailing slash - $collection->add('baz3', new Route( - '/test/baz3/' - )); - // trailing slash with variable - $collection->add('baz4', new Route( - '/test/{foo}/' - )); - // trailing slash and method - $collection->add('baz5', new Route( - '/test/{foo}/', - array(), - array(), - array(), - '', - array(), - array('post') - )); - // complex name - $collection->add('baz.baz6', new Route( - '/test/{foo}/', - array(), - array(), - array(), - '', - array(), - array('put') - )); - // defaults without variable - $collection->add('foofoo', new Route( - '/foofoo', - array('def' => 'test') - )); - // pattern with quotes - $collection->add('quoter', new Route( - '/{quoter}', - array(), - array('quoter' => '[\']+') - )); - // space in pattern - $collection->add('space', new Route( - '/spa ce' - )); - - // prefixes - $collection1 = new RouteCollection(); - $collection1->add('overridden', new Route('/overridden1')); - $collection1->add('foo1', new Route('/{foo}')); - $collection1->add('bar1', new Route('/{bar}')); - $collection1->addPrefix('/b\'b'); - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1); - $collection2->add('overridden', new Route('/{var}', array(), array('var' => '.*'))); - $collection1 = new RouteCollection(); - $collection1->add('foo2', new Route('/{foo1}')); - $collection1->add('bar2', new Route('/{bar1}')); - $collection1->addPrefix('/b\'b'); - $collection2->addCollection($collection1); - $collection2->addPrefix('/a'); - $collection->addCollection($collection2); - - // overridden through addCollection() and multiple sub-collections with no own prefix - $collection1 = new RouteCollection(); - $collection1->add('overridden2', new Route('/old')); - $collection1->add('helloWorld', new Route('/hello/{who}', array('who' => 'World!'))); - $collection2 = new RouteCollection(); - $collection3 = new RouteCollection(); - $collection3->add('overridden2', new Route('/new')); - $collection3->add('hey', new Route('/hey/')); - $collection2->addCollection($collection3); - $collection1->addCollection($collection2); - $collection1->addPrefix('/multi'); - $collection->addCollection($collection1); - - // "dynamic" prefix - $collection1 = new RouteCollection(); - $collection1->add('foo3', new Route('/{foo}')); - $collection1->add('bar3', new Route('/{bar}')); - $collection1->addPrefix('/b'); - $collection1->addPrefix('{_locale}'); - $collection->addCollection($collection1); - - // route between collections - $collection->add('ababa', new Route('/ababa')); - - // collection with static prefix but only one route - $collection1 = new RouteCollection(); - $collection1->add('foo4', new Route('/{foo}')); - $collection1->addPrefix('/aba'); - $collection->addCollection($collection1); - - // prefix and host - - $collection1 = new RouteCollection(); - - $route1 = new Route('/route1', array(), array(), array(), 'a.example.com'); - $collection1->add('route1', $route1); - - $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); - - // host 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...')); - $collection2 = new RouteCollection(); - $collection2->add('b', new Route('/{var}')); - $collection3 = new RouteCollection(); - $collection3->add('c', new Route('/{var}')); - $collection3->addPrefix('/c'); - $collection2->addCollection($collection3); - $collection2->addPrefix('/b'); - $collection1->addCollection($collection2); - $collection1->addPrefix('/a'); - $collection->addCollection($collection1); - - /* test case 2 */ - - $redirectCollection = clone $collection; - - // force HTTPS redirection - $redirectCollection->add('secure', new Route( - '/secure', - array(), - array(), - array(), - '', - array('https') - )); - - // force HTTP redirection - $redirectCollection->add('nonsecure', new Route( - '/nonsecure', - array(), - array(), - array(), - '', - array('http') - )); - - /* test case 3 */ - - $rootprefixCollection = new RouteCollection(); - $rootprefixCollection->add('static', new Route('/test')); - $rootprefixCollection->add('dynamic', new Route('/{var}')); - $rootprefixCollection->addPrefix('rootprefix'); - $route = new Route('/with-condition'); - $route->setCondition('context.getMethod() == "GET"'); - $rootprefixCollection->add('with-condition', $route); - - /* test case 4 */ - $headMatchCasesCollection = new RouteCollection(); - $headMatchCasesCollection->add('just_head', new Route( - '/just_head', - array(), - array(), - array(), - '', - array(), - array('HEAD') - )); - $headMatchCasesCollection->add('head_and_get', new Route( - '/head_and_get', - array(), - array(), - array(), - '', - array(), - array('HEAD', 'GET') - )); - $headMatchCasesCollection->add('get_and_head', new Route( - '/get_and_head', - array(), - array(), - array(), - '', - array(), - array('GET', 'HEAD') - )); - $headMatchCasesCollection->add('post_and_head', new Route( - '/post_and_get', - array(), - array(), - array(), - '', - array(), - array('POST', 'HEAD') - )); - $headMatchCasesCollection->add('put_and_post', new Route( - '/put_and_post', - array(), - array(), - array(), - '', - array(), - array('PUT', 'POST') - )); - $headMatchCasesCollection->add('put_and_get_and_head', new Route( - '/put_and_post', - array(), - array(), - array(), - '', - array(), - array('PUT', 'GET', 'HEAD') - )); - - /* test case 5 */ - $groupOptimisedCollection = new RouteCollection(); - $groupOptimisedCollection->add('a_first', new Route('/a/11')); - $groupOptimisedCollection->add('a_second', new Route('/a/22')); - $groupOptimisedCollection->add('a_third', new Route('/a/333')); - $groupOptimisedCollection->add('a_wildcard', new Route('/{param}')); - $groupOptimisedCollection->add('a_fourth', new Route('/a/44/')); - $groupOptimisedCollection->add('a_fifth', new Route('/a/55/')); - $groupOptimisedCollection->add('a_sixth', new Route('/a/66/')); - $groupOptimisedCollection->add('nested_wildcard', new Route('/nested/{param}')); - $groupOptimisedCollection->add('nested_a', new Route('/nested/group/a/')); - $groupOptimisedCollection->add('nested_b', new Route('/nested/group/b/')); - $groupOptimisedCollection->add('nested_c', new Route('/nested/group/c/')); - - $groupOptimisedCollection->add('slashed_a', new Route('/slashed/group/')); - $groupOptimisedCollection->add('slashed_b', new Route('/slashed/group/b/')); - $groupOptimisedCollection->add('slashed_c', new Route('/slashed/group/c/')); - - $trailingSlashCollection = new RouteCollection(); - $trailingSlashCollection->add('simple_trailing_slash_no_methods', new Route('/trailing/simple/no-methods/', array(), array(), array(), '', array(), array())); - $trailingSlashCollection->add('simple_trailing_slash_GET_method', new Route('/trailing/simple/get-method/', array(), array(), array(), '', array(), array('GET'))); - $trailingSlashCollection->add('simple_trailing_slash_HEAD_method', new Route('/trailing/simple/head-method/', array(), array(), array(), '', array(), array('HEAD'))); - $trailingSlashCollection->add('simple_trailing_slash_POST_method', new Route('/trailing/simple/post-method/', array(), array(), array(), '', array(), array('POST'))); - $trailingSlashCollection->add('regex_trailing_slash_no_methods', new Route('/trailing/regex/no-methods/{param}/', array(), array(), array(), '', array(), array())); - $trailingSlashCollection->add('regex_trailing_slash_GET_method', new Route('/trailing/regex/get-method/{param}/', array(), array(), array(), '', array(), array('GET'))); - $trailingSlashCollection->add('regex_trailing_slash_HEAD_method', new Route('/trailing/regex/head-method/{param}/', array(), array(), array(), '', array(), array('HEAD'))); - $trailingSlashCollection->add('regex_trailing_slash_POST_method', new Route('/trailing/regex/post-method/{param}/', array(), array(), array(), '', array(), array('POST'))); - - $trailingSlashCollection->add('simple_not_trailing_slash_no_methods', new Route('/not-trailing/simple/no-methods', array(), array(), array(), '', array(), array())); - $trailingSlashCollection->add('simple_not_trailing_slash_GET_method', new Route('/not-trailing/simple/get-method', array(), array(), array(), '', array(), array('GET'))); - $trailingSlashCollection->add('simple_not_trailing_slash_HEAD_method', new Route('/not-trailing/simple/head-method', array(), array(), array(), '', array(), array('HEAD'))); - $trailingSlashCollection->add('simple_not_trailing_slash_POST_method', new Route('/not-trailing/simple/post-method', array(), array(), array(), '', array(), array('POST'))); - $trailingSlashCollection->add('regex_not_trailing_slash_no_methods', new Route('/not-trailing/regex/no-methods/{param}', array(), array(), array(), '', array(), array())); - $trailingSlashCollection->add('regex_not_trailing_slash_GET_method', new Route('/not-trailing/regex/get-method/{param}', array(), array(), array(), '', array(), array('GET'))); - $trailingSlashCollection->add('regex_not_trailing_slash_HEAD_method', new Route('/not-trailing/regex/head-method/{param}', array(), array(), array(), '', array(), array('HEAD'))); - $trailingSlashCollection->add('regex_not_trailing_slash_POST_method', new Route('/not-trailing/regex/post-method/{param}', array(), array(), array(), '', array(), array('POST'))); - - return array( - array(new RouteCollection(), 'url_matcher0.php', array()), - array($collection, 'url_matcher1.php', array()), - array($redirectCollection, 'url_matcher2.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')), - array($rootprefixCollection, 'url_matcher3.php', array()), - array($headMatchCasesCollection, 'url_matcher4.php', array()), - array($groupOptimisedCollection, 'url_matcher5.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')), - array($trailingSlashCollection, 'url_matcher6.php', array()), - array($trailingSlashCollection, 'url_matcher7.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')), - ); - } - - /** - * @param $dumper - */ - private function generateDumpedMatcher(RouteCollection $collection, $redirectableStub = false) - { - $options = array('class' => $this->matcherClass); - - if ($redirectableStub) { - $options['base_class'] = '\Symfony\Component\Routing\Tests\Matcher\Dumper\RedirectableUrlMatcherStub'; - } - - $dumper = new PhpMatcherDumper($collection); - $code = $dumper->dump($options); - - file_put_contents($this->dumpPath, $code); - include $this->dumpPath; - - return $this->matcherClass; - } -} - -abstract class RedirectableUrlMatcherStub extends UrlMatcher implements RedirectableUrlMatcherInterface -{ - public function redirect($path, $route, $scheme = null) - { - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php b/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php deleted file mode 100644 index 37419e774..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php +++ /dev/null @@ -1,175 +0,0 @@ -compile()->getStaticPrefix(); - $collection->addRoute($staticPrefix, $name); - } - - $collection->optimizeGroups(); - $dumped = $this->dumpCollection($collection); - $this->assertEquals($expected, $dumped); - } - - public function routeProvider() - { - return array( - 'Simple - not nested' => array( - array( - array('/', 'root'), - array('/prefix/segment/', 'prefix_segment'), - array('/leading/segment/', 'leading_segment'), - ), - << array( - array( - array('/', 'root'), - array('/prefix/segment/aa', 'prefix_segment'), - array('/prefix/segment/bb', 'leading_segment'), - ), - << array( - array( - array('/', 'root'), - array('/prefix/segment/', 'prefix_segment'), - array('/prefix/segment/bb', 'leading_segment'), - ), - << /prefix/segment prefix_segment --> /prefix/segment/bb leading_segment -EOF - ), - 'Simple one level nesting' => array( - array( - array('/', 'root'), - array('/group/segment/', 'nested_segment'), - array('/group/thing/', 'some_segment'), - array('/group/other/', 'other_segment'), - ), - << /group/segment nested_segment --> /group/thing some_segment --> /group/other other_segment -EOF - ), - 'Retain matching order with groups' => array( - array( - array('/group/aa/', 'aa'), - array('/group/bb/', 'bb'), - array('/group/cc/', 'cc'), - array('/', 'root'), - array('/group/dd/', 'dd'), - array('/group/ee/', 'ee'), - array('/group/ff/', 'ff'), - ), - << /group/aa aa --> /group/bb bb --> /group/cc cc -/ root -/group --> /group/dd dd --> /group/ee ee --> /group/ff ff -EOF - ), - 'Retain complex matching order with groups at base' => array( - array( - array('/aaa/111/', 'first_aaa'), - array('/prefixed/group/aa/', 'aa'), - array('/prefixed/group/bb/', 'bb'), - array('/prefixed/group/cc/', 'cc'), - array('/prefixed/', 'root'), - array('/prefixed/group/dd/', 'dd'), - array('/prefixed/group/ee/', 'ee'), - array('/prefixed/group/ff/', 'ff'), - array('/aaa/222/', 'second_aaa'), - array('/aaa/333/', 'third_aaa'), - ), - << /aaa/111 first_aaa --> /aaa/222 second_aaa --> /aaa/333 third_aaa -/prefixed --> /prefixed/group --> -> /prefixed/group/aa aa --> -> /prefixed/group/bb bb --> -> /prefixed/group/cc cc --> /prefixed root --> /prefixed/group --> -> /prefixed/group/dd dd --> -> /prefixed/group/ee ee --> -> /prefixed/group/ff ff -EOF - ), - - 'Group regardless of segments' => array( - array( - array('/aaa-111/', 'a1'), - array('/aaa-222/', 'a2'), - array('/aaa-333/', 'a3'), - array('/group-aa/', 'g1'), - array('/group-bb/', 'g2'), - array('/group-cc/', 'g3'), - ), - << /aaa-111 a1 --> /aaa-222 a2 --> /aaa-333 a3 -/group- --> /group-aa g1 --> /group-bb g2 --> /group-cc g3 -EOF - ), - ); - } - - private function dumpCollection(StaticPrefixCollection $collection, $prefix = '') - { - $lines = array(); - - foreach ($collection->getItems() as $item) { - if ($item instanceof StaticPrefixCollection) { - $lines[] = $prefix.$item->getPrefix(); - $lines[] = $this->dumpCollection($item, $prefix.'-> '); - } else { - $lines[] = $prefix.implode(' ', $item); - } - } - - return implode("\n", $lines); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/lib/silex/vendor/symfony/routing/Tests/Matcher/RedirectableUrlMatcherTest.php deleted file mode 100644 index 0948e002a..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Matcher/RedirectableUrlMatcherTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; - -class RedirectableUrlMatcherTest extends TestCase -{ - public function testRedirectWhenNoSlash() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/')); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher->expects($this->once())->method('redirect')->will($this->returnValue(array())); - $matcher->match('/foo'); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ - public function testRedirectWhenNoSlashForNonSafeMethod() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/')); - - $context = new RequestContext(); - $context->setMethod('POST'); - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, $context)); - $matcher->match('/foo'); - } - - public function testSchemeRedirectRedirectsToFirstScheme() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('FTP', 'HTTPS'))); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher - ->expects($this->once()) - ->method('redirect') - ->with('/foo', 'foo', 'ftp') - ->will($this->returnValue(array('_route' => 'foo'))) - ; - $matcher->match('/foo'); - } - - public function testNoSchemaRedirectIfOnOfMultipleSchemesMatches() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https', 'http'))); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher - ->expects($this->never()) - ->method('redirect'); - $matcher->match('/foo'); - } - - public function testSchemeRedirectWithParams() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{bar}', array(), array(), array(), '', array('https'))); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher - ->expects($this->once()) - ->method('redirect') - ->with('/foo/baz', 'foo', 'https') - ->will($this->returnValue(array('redirect' => 'value'))) - ; - $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'), $matcher->match('/foo/baz')); - } - - public function testSlashRedirectWithParams() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{bar}/')); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher - ->expects($this->once()) - ->method('redirect') - ->with('/foo/baz/', 'foo', null) - ->will($this->returnValue(array('redirect' => 'value'))) - ; - $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'), $matcher->match('/foo/baz')); - } - - public function testRedirectPreservesUrlEncoding() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo:bar/')); - - $matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext())); - $matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/')->willReturn(array()); - $matcher->match('/foo%3Abar'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Matcher/TraceableUrlMatcherTest.php b/lib/silex/vendor/symfony/routing/Tests/Matcher/TraceableUrlMatcherTest.php deleted file mode 100644 index 9f0529e2d..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Matcher/TraceableUrlMatcherTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Matcher\TraceableUrlMatcher; - -class TraceableUrlMatcherTest extends TestCase -{ - public function test() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array(), array('POST'))); - $coll->add('bar', new Route('/bar/{id}', array(), array('id' => '\d+'))); - $coll->add('bar1', new Route('/bar/{name}', array(), array('id' => '\w+'), array(), '', array(), array('POST'))); - $coll->add('bar2', new Route('/foo', array(), array(), array(), 'baz')); - $coll->add('bar3', new Route('/foo1', array(), array(), array(), 'baz')); - $coll->add('bar4', new Route('/foo2', array(), array(), array(), 'baz', array(), array(), 'context.getMethod() == "GET"')); - - $context = new RequestContext(); - $context->setHost('baz'); - - $matcher = new TraceableUrlMatcher($coll, $context); - $traces = $matcher->getTraces('/babar'); - $this->assertSame(array(0, 0, 0, 0, 0, 0), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/foo'); - $this->assertSame(array(1, 0, 0, 2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/bar/12'); - $this->assertSame(array(0, 2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/bar/dd'); - $this->assertSame(array(0, 1, 1, 0, 0, 0), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/foo1'); - $this->assertSame(array(0, 0, 0, 0, 2), $this->getLevels($traces)); - - $context->setMethod('POST'); - $traces = $matcher->getTraces('/foo'); - $this->assertSame(array(2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/bar/dd'); - $this->assertSame(array(0, 1, 2), $this->getLevels($traces)); - - $traces = $matcher->getTraces('/foo2'); - $this->assertSame(array(0, 0, 0, 0, 0, 1), $this->getLevels($traces)); - } - - public function testMatchRouteOnMultipleHosts() - { - $routes = new RouteCollection(); - $routes->add('first', new Route( - '/mypath/', - array('_controller' => 'MainBundle:Info:first'), - array(), - array(), - 'some.example.com' - )); - - $routes->add('second', new Route( - '/mypath/', - array('_controller' => 'MainBundle:Info:second'), - array(), - array(), - 'another.example.com' - )); - - $context = new RequestContext(); - $context->setHost('baz'); - - $matcher = new TraceableUrlMatcher($routes, $context); - - $traces = $matcher->getTraces('/mypath/'); - $this->assertSame( - array(TraceableUrlMatcher::ROUTE_ALMOST_MATCHES, TraceableUrlMatcher::ROUTE_ALMOST_MATCHES), - $this->getLevels($traces) - ); - } - - public function getLevels($traces) - { - $levels = array(); - foreach ($traces as $trace) { - $levels[] = $trace['level']; - } - - return $levels; - } - - public function testRoutesWithConditions() - { - $routes = new RouteCollection(); - $routes->add('foo', new Route('/foo', array(), array(), array(), 'baz', array(), array(), "request.headers.get('User-Agent') matches '/firefox/i'")); - - $context = new RequestContext(); - $context->setHost('baz'); - - $matcher = new TraceableUrlMatcher($routes, $context); - - $notMatchingRequest = Request::create('/foo', 'GET'); - $traces = $matcher->getTracesForRequest($notMatchingRequest); - $this->assertEquals("Condition \"request.headers.get('User-Agent') matches '/firefox/i'\" does not evaluate to \"true\"", $traces[0]['log']); - - $matchingRequest = Request::create('/foo', 'GET', array(), array(), array(), array('HTTP_USER_AGENT' => 'Firefox')); - $traces = $matcher->getTracesForRequest($matchingRequest); - $this->assertEquals('Route matches!', $traces[0]['log']); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php b/lib/silex/vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php deleted file mode 100644 index 8545c2c29..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php +++ /dev/null @@ -1,441 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Matcher; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RequestContext; - -class UrlMatcherTest extends TestCase -{ - public function testNoMethodSoAllowed() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo')); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $this->assertInternalType('array', $matcher->match('/foo')); - } - - public function testMethodNotAllowed() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array(), array('post'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - - try { - $matcher->match('/foo'); - $this->fail(); - } catch (MethodNotAllowedException $e) { - $this->assertEquals(array('POST'), $e->getAllowedMethods()); - } - } - - public function testHeadAllowedWhenRequirementContainsGet() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array(), array('get'))); - - $matcher = new UrlMatcher($coll, new RequestContext('', 'head')); - $this->assertInternalType('array', $matcher->match('/foo')); - } - - public function testMethodNotAllowedAggregatesAllowedMethods() - { - $coll = new RouteCollection(); - $coll->add('foo1', new Route('/foo', array(), array(), array(), '', array(), array('post'))); - $coll->add('foo2', new Route('/foo', array(), array(), array(), '', array(), array('put', 'delete'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - - try { - $matcher->match('/foo'); - $this->fail(); - } catch (MethodNotAllowedException $e) { - $this->assertEquals(array('POST', 'PUT', 'DELETE'), $e->getAllowedMethods()); - } - } - - public function testMatch() - { - // test the patterns are matched and parameters are returned - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo/{bar}')); - $matcher = new UrlMatcher($collection, new RequestContext()); - try { - $matcher->match('/no-match'); - $this->fail(); - } catch (ResourceNotFoundException $e) { - } - $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz'), $matcher->match('/foo/baz')); - - // test that defaults are merged - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo/{bar}', array('def' => 'test'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'def' => 'test'), $matcher->match('/foo/baz')); - - // test that route "method" is ignored if no method is given in the context - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo', array(), array(), array(), '', array(), array('get', 'head'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertInternalType('array', $matcher->match('/foo')); - - // route does not match with POST method context - $matcher = new UrlMatcher($collection, new RequestContext('', 'post')); - try { - $matcher->match('/foo'); - $this->fail(); - } catch (MethodNotAllowedException $e) { - } - - // route does match with GET or HEAD method context - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertInternalType('array', $matcher->match('/foo')); - $matcher = new UrlMatcher($collection, new RequestContext('', 'head')); - $this->assertInternalType('array', $matcher->match('/foo')); - - // route with an optional variable as the first segment - $collection = new RouteCollection(); - $collection->add('bar', new Route('/{bar}/foo', array('bar' => 'bar'), array('bar' => 'foo|bar'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/bar/foo')); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo/foo')); - - $collection = new RouteCollection(); - $collection->add('bar', new Route('/{bar}', array('bar' => 'bar'), array('bar' => 'foo|bar'))); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo')); - $this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/')); - - // route with only optional variables - $collection = new RouteCollection(); - $collection->add('bar', new Route('/{foo}/{bar}', array('foo' => 'foo', 'bar' => 'bar'), array())); - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'bar', 'foo' => 'foo', 'bar' => 'bar'), $matcher->match('/')); - $this->assertEquals(array('_route' => 'bar', 'foo' => 'a', 'bar' => 'bar'), $matcher->match('/a')); - $this->assertEquals(array('_route' => 'bar', 'foo' => 'a', 'bar' => 'b'), $matcher->match('/a/b')); - } - - public function testMatchWithPrefixes() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{foo}')); - $collection->addPrefix('/b'); - $collection->addPrefix('/a'); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'foo' => 'foo'), $matcher->match('/a/b/foo')); - } - - public function testMatchWithDynamicPrefix() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{foo}')); - $collection->addPrefix('/b'); - $collection->addPrefix('/{_locale}'); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $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(); - $chars = '!"$%éà &\'()*+,./:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[]^_`abcdefghijklmnopqrstuvwxyz{|}~-'; - $collection->add('foo', new Route('/{foo}/bar', array(), array('foo' => '['.preg_quote($chars).']+'), array('utf8' => true))); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'foo' => $chars), $matcher->match('/'.rawurlencode($chars).'/bar')); - $this->assertEquals(array('_route' => 'foo', 'foo' => $chars), $matcher->match('/'.strtr($chars, array('%' => '%25')).'/bar')); - } - - public function testMatchWithDotMetacharacterInRequirements() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{foo}/bar', array(), array('foo' => '.+'))); - - $matcher = new UrlMatcher($collection, new RequestContext()); - $this->assertEquals(array('_route' => 'foo', 'foo' => "\n"), $matcher->match('/'.urlencode("\n").'/bar'), 'linefeed character is matched'); - } - - public function testMatchOverriddenRoute() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/foo1')); - - $collection->addCollection($collection1); - - $matcher = new UrlMatcher($collection, new RequestContext()); - - $this->assertEquals(array('_route' => 'foo'), $matcher->match('/foo1')); - $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException'); - $this->assertEquals(array(), $matcher->match('/foo')); - } - - public function testMatchRegression() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{foo}')); - $coll->add('bar', new Route('/foo/bar/{foo}')); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $this->assertEquals(array('foo' => 'bar', '_route' => 'bar'), $matcher->match('/foo/bar/bar')); - - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{bar}')); - $matcher = new UrlMatcher($collection, new RequestContext()); - try { - $matcher->match('/'); - $this->fail(); - } catch (ResourceNotFoundException $e) { - } - } - - 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(); - $coll->add('test', new Route('/{foo}-{bar}-', array(), array('foo' => '.+', 'bar' => '.+'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $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->{method_exists($this, $_ = 'expectException') ? $_ : '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->{method_exists($this, $_ = 'expectException') ? $_ : '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 - */ - public function testSchemeRequirement() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https'))); - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/foo'); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ - public function testCondition() - { - $coll = new RouteCollection(); - $route = new Route('/foo'); - $route->setCondition('context.getMethod() == "POST"'); - $coll->add('foo', $route); - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/foo'); - } - - public function testRequestCondition() - { - $coll = new RouteCollection(); - $route = new Route('/foo/{bar}'); - $route->setCondition('request.getBaseUrl() == "/sub/front.php" and request.getPathInfo() == "/foo/bar"'); - $coll->add('foo', $route); - $matcher = new UrlMatcher($coll, new RequestContext('/sub/front.php')); - $this->assertEquals(array('bar' => 'bar', '_route' => 'foo'), $matcher->match('/foo/bar')); - } - - public function testDecodeOnce() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{foo}')); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $this->assertEquals(array('foo' => 'bar%23', '_route' => 'foo'), $matcher->match('/foo/bar%2523')); - } - - public function testCannotRelyOnPrefix() - { - $coll = new RouteCollection(); - - $subColl = new RouteCollection(); - $subColl->add('bar', new Route('/bar')); - $subColl->addPrefix('/prefix'); - // overwrite the pattern, so the prefix is not valid anymore for this route in the collection - $subColl->get('bar')->setPath('/new'); - - $coll->addCollection($subColl); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $this->assertEquals(array('_route' => 'bar'), $matcher->match('/new')); - } - - public function testWithHost() - { - $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 testWithHostOnRouteCollection() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/foo/{foo}')); - $coll->add('bar', new Route('/bar/{foo}', array(), array(), array(), '{locale}.example.net')); - $coll->setHost('{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 testWithOutHostHostDoesNotMatch() - { - $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'); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ - public function testPathIsCaseSensitive() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/locale', array(), array('locale' => 'EN|FR|DE'))); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/en'); - } - - public function testHostIsCaseInsensitive() - { - $coll = new RouteCollection(); - $coll->add('foo', new Route('/', array(), array('locale' => 'EN|FR|DE'), array(), '{locale}.example.com')); - - $matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com')); - $this->assertEquals(array('_route' => 'foo', 'locale' => 'en'), $matcher->match('/')); - } - - /** - * @expectedException \Symfony\Component\Routing\Exception\NoConfigurationException - */ - public function testNoConfiguration() - { - $coll = new RouteCollection(); - - $matcher = new UrlMatcher($coll, new RequestContext()); - $matcher->match('/'); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/RequestContextTest.php b/lib/silex/vendor/symfony/routing/Tests/RequestContextTest.php deleted file mode 100644 index ffe29d1a7..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/RequestContextTest.php +++ /dev/null @@ -1,160 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\RequestContext; - -class RequestContextTest extends TestCase -{ - public function testConstruct() - { - $requestContext = new RequestContext( - 'foo', - 'post', - 'foo.bar', - 'HTTPS', - 8080, - 444, - '/baz', - 'bar=foobar' - ); - - $this->assertEquals('foo', $requestContext->getBaseUrl()); - $this->assertEquals('POST', $requestContext->getMethod()); - $this->assertEquals('foo.bar', $requestContext->getHost()); - $this->assertEquals('https', $requestContext->getScheme()); - $this->assertSame(8080, $requestContext->getHttpPort()); - $this->assertSame(444, $requestContext->getHttpsPort()); - $this->assertEquals('/baz', $requestContext->getPathInfo()); - $this->assertEquals('bar=foobar', $requestContext->getQueryString()); - } - - public function testFromRequest() - { - $request = Request::create('https://test.com:444/foo?bar=baz'); - $requestContext = new RequestContext(); - $requestContext->setHttpPort(123); - $requestContext->fromRequest($request); - - $this->assertEquals('', $requestContext->getBaseUrl()); - $this->assertEquals('GET', $requestContext->getMethod()); - $this->assertEquals('test.com', $requestContext->getHost()); - $this->assertEquals('https', $requestContext->getScheme()); - $this->assertEquals('/foo', $requestContext->getPathInfo()); - $this->assertEquals('bar=baz', $requestContext->getQueryString()); - $this->assertSame(123, $requestContext->getHttpPort()); - $this->assertSame(444, $requestContext->getHttpsPort()); - - $request = Request::create('http://test.com:8080/foo?bar=baz'); - $requestContext = new RequestContext(); - $requestContext->setHttpsPort(567); - $requestContext->fromRequest($request); - - $this->assertSame(8080, $requestContext->getHttpPort()); - $this->assertSame(567, $requestContext->getHttpsPort()); - } - - public function testGetParameters() - { - $requestContext = new RequestContext(); - $this->assertEquals(array(), $requestContext->getParameters()); - - $requestContext->setParameters(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $requestContext->getParameters()); - } - - public function testHasParameter() - { - $requestContext = new RequestContext(); - $requestContext->setParameters(array('foo' => 'bar')); - - $this->assertTrue($requestContext->hasParameter('foo')); - $this->assertFalse($requestContext->hasParameter('baz')); - } - - public function testGetParameter() - { - $requestContext = new RequestContext(); - $requestContext->setParameters(array('foo' => 'bar')); - - $this->assertEquals('bar', $requestContext->getParameter('foo')); - $this->assertNull($requestContext->getParameter('baz')); - } - - public function testSetParameter() - { - $requestContext = new RequestContext(); - $requestContext->setParameter('foo', 'bar'); - - $this->assertEquals('bar', $requestContext->getParameter('foo')); - } - - public function testMethod() - { - $requestContext = new RequestContext(); - $requestContext->setMethod('post'); - - $this->assertSame('POST', $requestContext->getMethod()); - } - - public function testScheme() - { - $requestContext = new RequestContext(); - $requestContext->setScheme('HTTPS'); - - $this->assertSame('https', $requestContext->getScheme()); - } - - public function testHost() - { - $requestContext = new RequestContext(); - $requestContext->setHost('eXampLe.com'); - - $this->assertSame('example.com', $requestContext->getHost()); - } - - public function testQueryString() - { - $requestContext = new RequestContext(); - $requestContext->setQueryString(null); - - $this->assertSame('', $requestContext->getQueryString()); - } - - public function testPort() - { - $requestContext = new RequestContext(); - $requestContext->setHttpPort('123'); - $requestContext->setHttpsPort('456'); - - $this->assertSame(123, $requestContext->getHttpPort()); - $this->assertSame(456, $requestContext->getHttpsPort()); - } - - public function testFluentInterface() - { - $requestContext = new RequestContext(); - - $this->assertSame($requestContext, $requestContext->setBaseUrl('/app.php')); - $this->assertSame($requestContext, $requestContext->setPathInfo('/index')); - $this->assertSame($requestContext, $requestContext->setMethod('POST')); - $this->assertSame($requestContext, $requestContext->setScheme('https')); - $this->assertSame($requestContext, $requestContext->setHost('example.com')); - $this->assertSame($requestContext, $requestContext->setQueryString('foo=bar')); - $this->assertSame($requestContext, $requestContext->setHttpPort(80)); - $this->assertSame($requestContext, $requestContext->setHttpsPort(443)); - $this->assertSame($requestContext, $requestContext->setParameters(array())); - $this->assertSame($requestContext, $requestContext->setParameter('foo', 'bar')); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/RouteCollectionBuilderTest.php b/lib/silex/vendor/symfony/routing/Tests/RouteCollectionBuilderTest.php deleted file mode 100644 index f6af600bd..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/RouteCollectionBuilderTest.php +++ /dev/null @@ -1,364 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Routing\Loader\YamlFileLoader; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RouteCollectionBuilder; - -class RouteCollectionBuilderTest extends TestCase -{ - public function testImport() - { - $resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); - $resolver->expects($this->once()) - ->method('resolve') - ->with('admin_routing.yml', 'yaml') - ->will($this->returnValue($resolvedLoader)); - - $originalRoute = new Route('/foo/path'); - $expectedCollection = new RouteCollection(); - $expectedCollection->add('one_test_route', $originalRoute); - $expectedCollection->addResource(new FileResource(__DIR__.'/Fixtures/file_resource.yml')); - - $resolvedLoader - ->expects($this->once()) - ->method('load') - ->with('admin_routing.yml', 'yaml') - ->will($this->returnValue($expectedCollection)); - - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->any()) - ->method('getResolver') - ->will($this->returnValue($resolver)); - - // import the file! - $routes = new RouteCollectionBuilder($loader); - $importedRoutes = $routes->import('admin_routing.yml', '/', 'yaml'); - - // we should get back a RouteCollectionBuilder - $this->assertInstanceOf('Symfony\Component\Routing\RouteCollectionBuilder', $importedRoutes); - - // get the collection back so we can look at it - $addedCollection = $importedRoutes->build(); - $route = $addedCollection->get('one_test_route'); - $this->assertSame($originalRoute, $route); - // should return file_resource.yml, which is in the original collection - $this->assertCount(1, $addedCollection->getResources()); - - // make sure the routes were imported into the top-level builder - $routeCollection = $routes->build(); - $this->assertCount(1, $routes->build()); - $this->assertCount(1, $routeCollection->getResources()); - } - - public function testImportAddResources() - { - $routeCollectionBuilder = new RouteCollectionBuilder(new YamlFileLoader(new FileLocator(array(__DIR__.'/Fixtures/')))); - $routeCollectionBuilder->import('file_resource.yml'); - $routeCollection = $routeCollectionBuilder->build(); - - $this->assertCount(1, $routeCollection->getResources()); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testImportWithoutLoaderThrowsException() - { - $collectionBuilder = new RouteCollectionBuilder(); - $collectionBuilder->import('routing.yml'); - } - - public function testAdd() - { - $collectionBuilder = new RouteCollectionBuilder(); - - $addedRoute = $collectionBuilder->add('/checkout', 'AppBundle:Order:checkout'); - $addedRoute2 = $collectionBuilder->add('/blogs', 'AppBundle:Blog:list', 'blog_list'); - $this->assertInstanceOf('Symfony\Component\Routing\Route', $addedRoute); - $this->assertEquals('AppBundle:Order:checkout', $addedRoute->getDefault('_controller')); - - $finalCollection = $collectionBuilder->build(); - $this->assertSame($addedRoute2, $finalCollection->get('blog_list')); - } - - public function testFlushOrdering() - { - $importedCollection = new RouteCollection(); - $importedCollection->add('imported_route1', new Route('/imported/foo1')); - $importedCollection->add('imported_route2', new Route('/imported/foo2')); - - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - // make this loader able to do the import - keeps mocking simple - $loader->expects($this->any()) - ->method('supports') - ->will($this->returnValue(true)); - $loader - ->expects($this->once()) - ->method('load') - ->will($this->returnValue($importedCollection)); - - $routes = new RouteCollectionBuilder($loader); - - // 1) Add a route - $routes->add('/checkout', 'AppBundle:Order:checkout', 'checkout_route'); - // 2) Import from a file - $routes->mount('/', $routes->import('admin_routing.yml')); - // 3) Add another route - $routes->add('/', 'AppBundle:Default:homepage', 'homepage'); - // 4) Add another route - $routes->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard'); - - // set a default value - $routes->setDefault('_locale', 'fr'); - - $actualCollection = $routes->build(); - - $this->assertCount(5, $actualCollection); - $actualRouteNames = array_keys($actualCollection->all()); - $this->assertEquals(array( - 'checkout_route', - 'imported_route1', - 'imported_route2', - 'homepage', - 'admin_dashboard', - ), $actualRouteNames); - - // make sure the defaults were set - $checkoutRoute = $actualCollection->get('checkout_route'); - $defaults = $checkoutRoute->getDefaults(); - $this->assertArrayHasKey('_locale', $defaults); - $this->assertEquals('fr', $defaults['_locale']); - } - - public function testFlushSetsRouteNames() - { - $collectionBuilder = new RouteCollectionBuilder(); - - // add a "named" route - $collectionBuilder->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard'); - // add an unnamed route - $collectionBuilder->add('/blogs', 'AppBundle:Blog:list') - ->setMethods(array('GET')); - - // integer route names are allowed - they don't confuse things - $collectionBuilder->add('/products', 'AppBundle:Product:list', 100); - - $actualCollection = $collectionBuilder->build(); - $actualRouteNames = array_keys($actualCollection->all()); - $this->assertEquals(array( - 'admin_dashboard', - 'GET_blogs', - '100', - ), $actualRouteNames); - } - - public function testFlushSetsDetailsOnChildrenRoutes() - { - $routes = new RouteCollectionBuilder(); - - $routes->add('/blogs/{page}', 'listAction', 'blog_list') - // unique things for the route - ->setDefault('page', 1) - ->setRequirement('id', '\d+') - ->setOption('expose', true) - // things that the collection will try to override (but won't) - ->setDefault('_format', 'html') - ->setRequirement('_format', 'json|xml') - ->setOption('fooBar', true) - ->setHost('example.com') - ->setCondition('request.isSecure()') - ->setSchemes(array('https')) - ->setMethods(array('POST')); - - // a simple route, nothing added to it - $routes->add('/blogs/{id}', 'editAction', 'blog_edit'); - - // configure the collection itself - $routes - // things that will not override the child route - ->setDefault('_format', 'json') - ->setRequirement('_format', 'xml') - ->setOption('fooBar', false) - ->setHost('symfony.com') - ->setCondition('request.query.get("page")==1') - // some unique things that should be set on the child - ->setDefault('_locale', 'fr') - ->setRequirement('_locale', 'fr|en') - ->setOption('niceRoute', true) - ->setSchemes(array('http')) - ->setMethods(array('GET', 'POST')); - - $collection = $routes->build(); - $actualListRoute = $collection->get('blog_list'); - - $this->assertEquals(1, $actualListRoute->getDefault('page')); - $this->assertEquals('\d+', $actualListRoute->getRequirement('id')); - $this->assertTrue($actualListRoute->getOption('expose')); - // none of these should be overridden - $this->assertEquals('html', $actualListRoute->getDefault('_format')); - $this->assertEquals('json|xml', $actualListRoute->getRequirement('_format')); - $this->assertTrue($actualListRoute->getOption('fooBar')); - $this->assertEquals('example.com', $actualListRoute->getHost()); - $this->assertEquals('request.isSecure()', $actualListRoute->getCondition()); - $this->assertEquals(array('https'), $actualListRoute->getSchemes()); - $this->assertEquals(array('POST'), $actualListRoute->getMethods()); - // inherited from the main collection - $this->assertEquals('fr', $actualListRoute->getDefault('_locale')); - $this->assertEquals('fr|en', $actualListRoute->getRequirement('_locale')); - $this->assertTrue($actualListRoute->getOption('niceRoute')); - - $actualEditRoute = $collection->get('blog_edit'); - // inherited from the collection - $this->assertEquals('symfony.com', $actualEditRoute->getHost()); - $this->assertEquals('request.query.get("page")==1', $actualEditRoute->getCondition()); - $this->assertEquals(array('http'), $actualEditRoute->getSchemes()); - $this->assertEquals(array('GET', 'POST'), $actualEditRoute->getMethods()); - } - - /** - * @dataProvider providePrefixTests - */ - public function testFlushPrefixesPaths($collectionPrefix, $routePath, $expectedPath) - { - $routes = new RouteCollectionBuilder(); - - $routes->add($routePath, 'someController', 'test_route'); - - $outerRoutes = new RouteCollectionBuilder(); - $outerRoutes->mount($collectionPrefix, $routes); - - $collection = $outerRoutes->build(); - - $this->assertEquals($expectedPath, $collection->get('test_route')->getPath()); - } - - public function providePrefixTests() - { - $tests = array(); - // empty prefix is of course ok - $tests[] = array('', '/foo', '/foo'); - // normal prefix - does not matter if it's a wildcard - $tests[] = array('/{admin}', '/foo', '/{admin}/foo'); - // shows that a prefix will always be given the starting slash - $tests[] = array('0', '/foo', '/0/foo'); - - // spaces are ok, and double slahses at the end are cleaned - $tests[] = array('/ /', '/foo', '/ /foo'); - - return $tests; - } - - public function testFlushSetsPrefixedWithMultipleLevels() - { - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $routes = new RouteCollectionBuilder($loader); - - $routes->add('homepage', 'MainController::homepageAction', 'homepage'); - - $adminRoutes = $routes->createBuilder(); - $adminRoutes->add('/dashboard', 'AdminController::dashboardAction', 'admin_dashboard'); - - // embedded collection under /admin - $adminBlogRoutes = $routes->createBuilder(); - $adminBlogRoutes->add('/new', 'BlogController::newAction', 'admin_blog_new'); - // mount into admin, but before the parent collection has been mounted - $adminRoutes->mount('/blog', $adminBlogRoutes); - - // now mount the /admin routes, above should all still be /blog/admin - $routes->mount('/admin', $adminRoutes); - // add a route after mounting - $adminRoutes->add('/users', 'AdminController::userAction', 'admin_users'); - - // add another sub-collection after the mount - $otherAdminRoutes = $routes->createBuilder(); - $otherAdminRoutes->add('/sales', 'StatsController::indexAction', 'admin_stats_sales'); - $adminRoutes->mount('/stats', $otherAdminRoutes); - - // add a normal collection and see that it is also prefixed - $importedCollection = new RouteCollection(); - $importedCollection->add('imported_route', new Route('/foo')); - // make this loader able to do the import - keeps mocking simple - $loader->expects($this->any()) - ->method('supports') - ->will($this->returnValue(true)); - $loader - ->expects($this->any()) - ->method('load') - ->will($this->returnValue($importedCollection)); - // import this from the /admin route builder - $adminRoutes->import('admin.yml', '/imported'); - - $collection = $routes->build(); - $this->assertEquals('/admin/dashboard', $collection->get('admin_dashboard')->getPath(), 'Routes before mounting have the prefix'); - $this->assertEquals('/admin/users', $collection->get('admin_users')->getPath(), 'Routes after mounting have the prefix'); - $this->assertEquals('/admin/blog/new', $collection->get('admin_blog_new')->getPath(), 'Sub-collections receive prefix even if mounted before parent prefix'); - $this->assertEquals('/admin/stats/sales', $collection->get('admin_stats_sales')->getPath(), 'Sub-collections receive prefix if mounted after parent prefix'); - $this->assertEquals('/admin/imported/foo', $collection->get('imported_route')->getPath(), 'Normal RouteCollections are also prefixed properly'); - } - - public function testAutomaticRouteNamesDoNotConflict() - { - $routes = new RouteCollectionBuilder(); - - $adminRoutes = $routes->createBuilder(); - // route 1 - $adminRoutes->add('/dashboard', ''); - - $accountRoutes = $routes->createBuilder(); - // route 2 - $accountRoutes->add('/dashboard', '') - ->setMethods(array('GET')); - // route 3 - $accountRoutes->add('/dashboard', '') - ->setMethods(array('POST')); - - $routes->mount('/admin', $adminRoutes); - $routes->mount('/account', $accountRoutes); - - $collection = $routes->build(); - // there are 2 routes (i.e. with non-conflicting names) - $this->assertCount(3, $collection->all()); - } - - public function testAddsThePrefixOnlyOnceWhenLoadingMultipleCollections() - { - $firstCollection = new RouteCollection(); - $firstCollection->add('a', new Route('/a')); - - $secondCollection = new RouteCollection(); - $secondCollection->add('b', new Route('/b')); - - $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->any()) - ->method('supports') - ->will($this->returnValue(true)); - $loader - ->expects($this->any()) - ->method('load') - ->will($this->returnValue(array($firstCollection, $secondCollection))); - - $routeCollectionBuilder = new RouteCollectionBuilder($loader); - $routeCollectionBuilder->import('/directory/recurse/*', '/other/', 'glob'); - $routes = $routeCollectionBuilder->build()->all(); - - $this->assertEquals(2, count($routes)); - $this->assertEquals('/other/a', $routes['a']->getPath()); - $this->assertEquals('/other/b', $routes['b']->getPath()); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/RouteCollectionTest.php b/lib/silex/vendor/symfony/routing/Tests/RouteCollectionTest.php deleted file mode 100644 index 83457ff14..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/RouteCollectionTest.php +++ /dev/null @@ -1,305 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; -use Symfony\Component\Config\Resource\FileResource; - -class RouteCollectionTest extends TestCase -{ - public function testRoute() - { - $collection = new RouteCollection(); - $route = new Route('/foo'); - $collection->add('foo', $route); - $this->assertEquals(array('foo' => $route), $collection->all(), '->add() adds a route'); - $this->assertEquals($route, $collection->get('foo'), '->get() returns a route by name'); - $this->assertNull($collection->get('bar'), '->get() returns null if a route does not exist'); - } - - public function testOverriddenRoute() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - $collection->add('foo', new Route('/foo1')); - - $this->assertEquals('/foo1', $collection->get('foo')->getPath()); - } - - public function testDeepOverriddenRoute() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/foo1')); - - $collection2 = new RouteCollection(); - $collection2->add('foo', new Route('/foo2')); - - $collection1->addCollection($collection2); - $collection->addCollection($collection1); - - $this->assertEquals('/foo2', $collection1->get('foo')->getPath()); - $this->assertEquals('/foo2', $collection->get('foo')->getPath()); - } - - public function testIterator() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', $bar = new Route('/bar')); - $collection1->add('foo', $foo = new Route('/foo-new')); - $collection->addCollection($collection1); - $collection->add('last', $last = new Route('/last')); - - $this->assertInstanceOf('\ArrayIterator', $collection->getIterator()); - $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'last' => $last), $collection->getIterator()->getArrayCopy()); - } - - public function testCount() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', new Route('/bar')); - $collection->addCollection($collection1); - - $this->assertCount(2, $collection); - } - - public function testAddCollection() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', $bar = new Route('/bar')); - $collection1->add('foo', $foo = new Route('/foo-new')); - - $collection2 = new RouteCollection(); - $collection2->add('grandchild', $grandchild = new Route('/grandchild')); - - $collection1->addCollection($collection2); - $collection->addCollection($collection1); - $collection->add('last', $last = new Route('/last')); - - $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'grandchild' => $grandchild, 'last' => $last), $collection->all(), - '->addCollection() imports routes of another collection, overrides if necessary and adds them at the end'); - } - - public function testAddCollectionWithResources() - { - $collection = new RouteCollection(); - $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); - $collection1 = new RouteCollection(); - $collection1->addResource($foo1 = new FileResource(__DIR__.'/Fixtures/foo1.xml')); - $collection->addCollection($collection1); - $this->assertEquals(array($foo, $foo1), $collection->getResources(), '->addCollection() merges resources'); - } - - public function testAddDefaultsAndRequirementsAndOptions() - { - $collection = new RouteCollection(); - $collection->add('foo', new Route('/{placeholder}')); - $collection1 = new RouteCollection(); - $collection1->add('bar', new Route('/{placeholder}', - array('_controller' => 'fixed', 'placeholder' => 'default'), array('placeholder' => '.+'), array('option' => 'value')) - ); - $collection->addCollection($collection1); - - $collection->addDefaults(array('placeholder' => 'new-default')); - $this->assertEquals(array('placeholder' => 'new-default'), $collection->get('foo')->getDefaults(), '->addDefaults() adds defaults to all routes'); - $this->assertEquals(array('_controller' => 'fixed', 'placeholder' => 'new-default'), $collection->get('bar')->getDefaults(), - '->addDefaults() adds defaults to all routes and overwrites existing ones'); - - $collection->addRequirements(array('placeholder' => '\d+')); - $this->assertEquals(array('placeholder' => '\d+'), $collection->get('foo')->getRequirements(), '->addRequirements() adds requirements to all routes'); - $this->assertEquals(array('placeholder' => '\d+'), $collection->get('bar')->getRequirements(), - '->addRequirements() adds requirements to all routes and overwrites existing ones'); - - $collection->addOptions(array('option' => 'new-value')); - $this->assertEquals( - array('option' => 'new-value', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), - $collection->get('bar')->getOptions(), '->addOptions() adds options to all routes and overwrites existing ones' - ); - } - - public function testAddPrefix() - { - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo')); - $collection2 = new RouteCollection(); - $collection2->add('bar', $bar = new Route('/bar')); - $collection->addCollection($collection2); - $collection->addPrefix(' / '); - $this->assertSame('/foo', $collection->get('foo')->getPath(), '->addPrefix() trims the prefix and a single slash has no effect'); - $collection->addPrefix('/{admin}', array('admin' => 'admin'), array('admin' => '\d+')); - $this->assertEquals('/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() adds a prefix to all routes'); - $this->assertEquals('/{admin}/bar', $collection->get('bar')->getPath(), '->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'); - $collection->addPrefix('0'); - $this->assertEquals('/0/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash'); - $collection->addPrefix('/ /'); - $this->assertSame('/ /0/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() can handle spaces if desired'); - $this->assertSame('/ /0/{admin}/bar', $collection->get('bar')->getPath(), 'the route pattern of an added collection is in synch with the added prefix'); - } - - public function testAddPrefixOverridesDefaultsAndRequirements() - { - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo.{_format}')); - $collection->add('bar', $bar = new Route('/bar.{_format}', array(), array('_format' => 'json'))); - $collection->addPrefix('/admin', array(), array('_format' => 'html')); - - $this->assertEquals('html', $collection->get('foo')->getRequirement('_format'), '->addPrefix() overrides existing requirements'); - $this->assertEquals('html', $collection->get('bar')->getRequirement('_format'), '->addPrefix() overrides existing requirements'); - } - - public function testResource() - { - $collection = new RouteCollection(); - $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); - $collection->addResource($bar = new FileResource(__DIR__.'/Fixtures/bar.xml')); - $collection->addResource(new FileResource(__DIR__.'/Fixtures/foo.xml')); - - $this->assertEquals(array($foo, $bar), $collection->getResources(), - '->addResource() adds a resource and getResources() only returns unique ones by comparing the string representation'); - } - - public function testUniqueRouteWithGivenName() - { - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/old')); - $collection2 = new RouteCollection(); - $collection3 = new RouteCollection(); - $collection3->add('foo', $new = new Route('/new')); - - $collection2->addCollection($collection3); - $collection1->addCollection($collection2); - - $this->assertSame($new, $collection1->get('foo'), '->get() returns new route that overrode previous one'); - // size of 1 because collection1 contains /new but not /old anymore - $this->assertCount(1, $collection1->getIterator(), '->addCollection() removes previous routes when adding new routes with the same name'); - } - - public function testGet() - { - $collection1 = new RouteCollection(); - $collection1->add('a', $a = new Route('/a')); - $collection2 = new RouteCollection(); - $collection2->add('b', $b = new Route('/b')); - $collection1->addCollection($collection2); - $collection1->add('$péß^a|', $c = new Route('/special')); - - $this->assertSame($b, $collection1->get('b'), '->get() returns correct route in child collection'); - $this->assertSame($c, $collection1->get('$péß^a|'), '->get() can handle special characters'); - $this->assertNull($collection2->get('a'), '->get() does not return the route defined in parent collection'); - $this->assertNull($collection1->get('non-existent'), '->get() returns null when route does not exist'); - $this->assertNull($collection1->get(0), '->get() does not disclose internal child RouteCollection'); - } - - public function testRemove() - { - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo')); - - $collection1 = new RouteCollection(); - $collection1->add('bar', $bar = new Route('/bar')); - $collection->addCollection($collection1); - $collection->add('last', $last = new Route('/last')); - - $collection->remove('foo'); - $this->assertSame(array('bar' => $bar, 'last' => $last), $collection->all(), '->remove() can remove a single route'); - $collection->remove(array('bar', 'last')); - $this->assertSame(array(), $collection->all(), '->remove() accepts an array and can remove multiple routes at once'); - } - - public function testSetHost() - { - $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->setHost('{locale}.example.com'); - - $this->assertEquals('{locale}.example.com', $routea->getHost()); - $this->assertEquals('{locale}.example.com', $routeb->getHost()); - } - - public function testSetCondition() - { - $collection = new RouteCollection(); - $routea = new Route('/a'); - $routeb = new Route('/b', array(), array(), array(), '{locale}.example.net', array(), array(), 'context.getMethod() == "GET"'); - $collection->add('a', $routea); - $collection->add('b', $routeb); - - $collection->setCondition('context.getMethod() == "POST"'); - - $this->assertEquals('context.getMethod() == "POST"', $routea->getCondition()); - $this->assertEquals('context.getMethod() == "POST"', $routeb->getCondition()); - } - - public function testClone() - { - $collection = new RouteCollection(); - $collection->add('a', new Route('/a')); - $collection->add('b', new Route('/b', array('placeholder' => 'default'), array('placeholder' => '.+'))); - - $clonedCollection = clone $collection; - - $this->assertCount(2, $clonedCollection); - $this->assertEquals($collection->get('a'), $clonedCollection->get('a')); - $this->assertNotSame($collection->get('a'), $clonedCollection->get('a')); - $this->assertEquals($collection->get('b'), $clonedCollection->get('b')); - $this->assertNotSame($collection->get('b'), $clonedCollection->get('b')); - } - - public function testSetSchemes() - { - $collection = new RouteCollection(); - $routea = new Route('/a', array(), array(), array(), '', 'http'); - $routeb = new Route('/b'); - $collection->add('a', $routea); - $collection->add('b', $routeb); - - $collection->setSchemes(array('http', 'https')); - - $this->assertEquals(array('http', 'https'), $routea->getSchemes()); - $this->assertEquals(array('http', 'https'), $routeb->getSchemes()); - } - - public function testSetMethods() - { - $collection = new RouteCollection(); - $routea = new Route('/a', array(), array(), array(), '', array(), array('GET', 'POST')); - $routeb = new Route('/b'); - $collection->add('a', $routea); - $collection->add('b', $routeb); - - $collection->setMethods('PUT'); - - $this->assertEquals(array('PUT'), $routea->getMethods()); - $this->assertEquals(array('PUT'), $routeb->getMethods()); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/RouteCompilerTest.php b/lib/silex/vendor/symfony/routing/Tests/RouteCompilerTest.php deleted file mode 100644 index 54006d7ed..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/RouteCompilerTest.php +++ /dev/null @@ -1,389 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCompiler; - -class RouteCompilerTest extends TestCase -{ - /** - * @dataProvider provideCompileData - */ - public function testCompile($name, $arguments, $prefix, $regex, $variables, $tokens) - { - $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, $compiled->getRegex(), $name.' (regex)'); - $this->assertEquals($variables, $compiled->getVariables(), $name.' (variables)'); - $this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)'); - } - - public function provideCompileData() - { - return array( - array( - 'Static route', - array('/foo'), - '/foo', '#^/foo$#s', array(), array( - array('text', '/foo'), - ), - ), - - array( - 'Route with a variable', - array('/foo/{bar}'), - '/foo', '#^/foo/(?P[^/]++)$#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(?:/(?P[^/]++))?$#s', array('bar'), array( - array('variable', '/', '[^/]++', 'bar'), - array('text', '/foo'), - ), - ), - - array( - 'Route with several variables', - array('/foo/{bar}/{foobar}'), - '/foo', '#^/foo/(?P[^/]++)/(?P[^/]++)$#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(?:/(?P[^/]++)(?:/(?P[^/]++))?)?$#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/(?P[^/]++)/(?P[^/]++)$#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')), - '', '#^/(?P[^/]++)?$#s', array('bar'), array( - array('variable', '/', '[^/]++', 'bar'), - ), - ), - - array( - 'Route with a requirement of 0', - array('/{bar}', array('bar' => null), array('bar' => '0')), - '', '#^/(?P0)?$#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)')), - '', '#^/(?P(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')), - '', '#^/(?P[^/]++)?(?:/(?P[^/]++))?$#s', array('foo', 'bar'), array( - array('variable', '/', '[^/]++', 'bar'), - array('variable', '/', '[^/]++', 'foo'), - ), - ), - - array( - 'Route with a variable in last position', - array('/foo-{bar}'), - '/foo-', '#^/foo\-(?P[^/]++)$#s', array('bar'), array( - array('variable', '-', '[^/]++', 'bar'), - array('text', '/foo'), - ), - ), - - array( - 'Route with nested placeholders', - array('/{static{var}static}'), - '/{static', '#^/\{static(?P[^/]+)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[^/\.]+)(?P[^/\.]+)(?P(y|Y))(?:(?P[^/\.]++)(?:\.(?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/(?P[^/\.]++)\.(?P<_format>[^/]++)$#s', array('bar', '_format'), array( - array('variable', '.', '[^/]++', '_format'), - array('variable', '/', '[^/\.]++', 'bar'), - array('text', '/foo'), - ), - ), - - array( - 'Static non UTF-8 route', - array("/fo\xE9"), - "/fo\xE9", "#^/fo\xE9$#s", array(), array( - array('text', "/fo\xE9"), - ), - ), - - array( - 'Route with an explicit UTF-8 requirement', - array('/{bar}', array('bar' => null), array('bar' => '.'), array('utf8' => true)), - '', '#^/(?P.)?$#su', array('bar'), array( - array('variable', '/', '.', 'bar', true), - ), - ), - ); - } - - /** - * @group legacy - * @dataProvider provideCompileImplicitUtf8Data - * @expectedDeprecation Using UTF-8 route %s without setting the "utf8" option is deprecated %s. - */ - public function testCompileImplicitUtf8Data($name, $arguments, $prefix, $regex, $variables, $tokens, $deprecationType) - { - $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, $compiled->getRegex(), $name.' (regex)'); - $this->assertEquals($variables, $compiled->getVariables(), $name.' (variables)'); - $this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)'); - } - - public function provideCompileImplicitUtf8Data() - { - return array( - array( - 'Static UTF-8 route', - array('/foé'), - '/foé', '#^/foé$#su', array(), array( - array('text', '/foé'), - ), - 'patterns', - ), - - array( - 'Route with an implicit UTF-8 requirement', - array('/{bar}', array('bar' => null), array('bar' => 'é')), - '', '#^/(?Pé)?$#su', array('bar'), array( - array('variable', '/', 'é', 'bar', true), - ), - 'requirements', - ), - - array( - 'Route with a UTF-8 class requirement', - array('/{bar}', array('bar' => null), array('bar' => '\pM')), - '', '#^/(?P\pM)?$#su', array('bar'), array( - array('variable', '/', '\pM', 'bar', true), - ), - 'requirements', - ), - - array( - 'Route with a UTF-8 separator', - array('/foo/{bar}§{_format}', array(), array(), array('compiler_class' => Utf8RouteCompiler::class)), - '/foo', '#^/foo/(?P[^/§]++)§(?P<_format>[^/]++)$#su', array('bar', '_format'), array( - array('variable', '§', '[^/]++', '_format', true), - array('variable', '/', '[^/§]++', 'bar', true), - array('text', '/foo'), - ), - 'patterns', - ), - ); - } - - /** - * @expectedException \LogicException - */ - public function testRouteWithSameVariableTwice() - { - $route = new Route('/{name}/{name}'); - - $compiled = $route->compile(); - } - - /** - * @expectedException \LogicException - */ - public function testRouteCharsetMismatch() - { - $route = new Route("/\xE9/{bar}", array(), array('bar' => '.'), array('utf8' => true)); - - $compiled = $route->compile(); - } - - /** - * @expectedException \LogicException - */ - public function testRequirementCharsetMismatch() - { - $route = new Route('/foo/{bar}', array(), array('bar' => "\xE9"), array('utf8' => true)); - - $compiled = $route->compile(); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRouteWithFragmentAsPathParameter() - { - $route = new Route('/{_fragment}'); - - $compiled = $route->compile(); - } - - /** - * @dataProvider getVariableNamesStartingWithADigit - * @expectedException \DomainException - */ - public function testRouteWithVariableNameStartingWithADigit($name) - { - $route = new Route('/{'.$name.'}'); - $route->compile(); - } - - public function getVariableNamesStartingWithADigit() - { - return array( - array('09'), - array('123'), - array('1e2'), - ); - } - - /** - * @dataProvider provideCompileWithHostData - */ - public function testCompileWithHost($name, $arguments, $prefix, $regex, $variables, $pathVariables, $tokens, $hostRegex, $hostVariables, $hostTokens) - { - $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($hostRegex, str_replace(array("\n", ' '), '', $compiled->getHostRegex()), $name.' (host regex)'); - $this->assertEquals($hostVariables, $compiled->getHostVariables(), $name.' (host variables)'); - $this->assertEquals($hostTokens, $compiled->getHostTokens(), $name.' (host tokens)'); - } - - public function provideCompileWithHostData() - { - return array( - array( - 'Route with host pattern', - array('/hello', array(), array(), array(), 'www.example.com'), - '/hello', '#^/hello$#s', array(), array(), array( - array('text', '/hello'), - ), - '#^www\.example\.com$#si', array(), array( - array('text', 'www.example.com'), - ), - ), - array( - 'Route with host pattern and some variables', - array('/hello/{name}', array(), array(), array(), 'www.example.{tld}'), - '/hello', '#^/hello/(?P[^/]++)$#s', array('tld', 'name'), array('name'), array( - array('variable', '/', '[^/]++', 'name'), - array('text', '/hello'), - ), - '#^www\.example\.(?P[^\.]++)$#si', array('tld'), array( - array('variable', '.', '[^\.]++', 'tld'), - array('text', 'www.example'), - ), - ), - array( - 'Route with variable at beginning of host', - array('/hello', array(), array(), array(), '{locale}.example.{tld}'), - '/hello', '#^/hello$#s', array('locale', 'tld'), array(), array( - array('text', '/hello'), - ), - '#^(?P[^\.]++)\.example\.(?P[^\.]++)$#si', array('locale', 'tld'), array( - array('variable', '.', '[^\.]++', 'tld'), - array('text', '.example'), - array('variable', '', '[^\.]++', 'locale'), - ), - ), - array( - 'Route with host 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[^\.]++)\.example\.(?P[^\.]++)$#si', array('locale', 'tld'), array( - array('variable', '.', '[^\.]++', 'tld'), - array('text', '.example'), - array('variable', '', '[^\.]++', 'locale'), - ), - ), - ); - } - - /** - * @expectedException \DomainException - */ - public function testRouteWithTooLongVariableName() - { - $route = new Route(sprintf('/{%s}', str_repeat('a', RouteCompiler::VARIABLE_MAXIMUM_LENGTH + 1))); - $route->compile(); - } -} - -class Utf8RouteCompiler extends RouteCompiler -{ - const SEPARATORS = '/§'; -} diff --git a/lib/silex/vendor/symfony/routing/Tests/RouteTest.php b/lib/silex/vendor/symfony/routing/Tests/RouteTest.php deleted file mode 100644 index ff7e320c5..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/RouteTest.php +++ /dev/null @@ -1,258 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Route; - -class RouteTest extends TestCase -{ - public function testConstructor() - { - $route = new Route('/{foo}', array('foo' => 'bar'), array('foo' => '\d+'), array('foo' => 'bar'), '{locale}.example.com'); - $this->assertEquals('/{foo}', $route->getPath(), '__construct() takes a path 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->getHost(), '__construct() takes a host pattern as its fifth argument'); - - $route = new Route('/', array(), array(), array(), '', array('Https'), array('POST', 'put'), 'context.getMethod() == "GET"'); - $this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes schemes as its sixth argument and lowercases it'); - $this->assertEquals(array('POST', 'PUT'), $route->getMethods(), '__construct() takes methods as its seventh argument and uppercases it'); - $this->assertEquals('context.getMethod() == "GET"', $route->getCondition(), '__construct() takes a condition as its eight argument'); - - $route = new Route('/', array(), array(), array(), '', 'Https', 'Post'); - $this->assertEquals(array('https'), $route->getSchemes(), '__construct() takes a single scheme as its sixth argument'); - $this->assertEquals(array('POST'), $route->getMethods(), '__construct() takes a single method as its seventh argument'); - } - - public function testPath() - { - $route = new Route('/{foo}'); - $route->setPath('/{bar}'); - $this->assertEquals('/{bar}', $route->getPath(), '->setPath() sets the path'); - $route->setPath(''); - $this->assertEquals('/', $route->getPath(), '->setPath() adds a / at the beginning of the path if needed'); - $route->setPath('bar'); - $this->assertEquals('/bar', $route->getPath(), '->setPath() adds a / at the beginning of the path if needed'); - $this->assertEquals($route, $route->setPath(''), '->setPath() implements a fluent interface'); - $route->setPath('//path'); - $this->assertEquals('/path', $route->getPath(), '->setPath() does not allow two slashes "//" at the beginning of the path as it would be confused with a network path when generating the path from the route'); - } - - public function testOptions() - { - $route = new Route('/{foo}'); - $route->setOptions(array('foo' => 'bar')); - $this->assertEquals(array_merge(array( - 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler', - ), array('foo' => 'bar')), $route->getOptions(), '->setOptions() sets the options'); - $this->assertEquals($route, $route->setOptions(array()), '->setOptions() implements a fluent interface'); - - $route->setOptions(array('foo' => 'foo')); - $route->addOptions(array('bar' => 'bar')); - $this->assertEquals($route, $route->addOptions(array()), '->addOptions() implements a fluent interface'); - $this->assertEquals(array('foo' => 'foo', 'bar' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), $route->getOptions(), '->addDefaults() keep previous defaults'); - } - - public function testOption() - { - $route = new Route('/{foo}'); - $this->assertFalse($route->hasOption('foo'), '->hasOption() return false if option is not set'); - $this->assertEquals($route, $route->setOption('foo', 'bar'), '->setOption() implements a fluent interface'); - $this->assertEquals('bar', $route->getOption('foo'), '->setOption() sets the option'); - $this->assertTrue($route->hasOption('foo'), '->hasOption() return true if option is set'); - } - - public function testDefaults() - { - $route = new Route('/{foo}'); - $route->setDefaults(array('foo' => 'bar')); - $this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '->setDefaults() sets the defaults'); - $this->assertEquals($route, $route->setDefaults(array()), '->setDefaults() implements a fluent interface'); - - $route->setDefault('foo', 'bar'); - $this->assertEquals('bar', $route->getDefault('foo'), '->setDefault() sets a default value'); - - $route->setDefault('foo2', 'bar2'); - $this->assertEquals('bar2', $route->getDefault('foo2'), '->getDefault() return the default value'); - $this->assertNull($route->getDefault('not_defined'), '->getDefault() return null if default value is not set'); - - $route->setDefault('_controller', $closure = function () { return 'Hello'; }); - $this->assertEquals($closure, $route->getDefault('_controller'), '->setDefault() sets a default value'); - - $route->setDefaults(array('foo' => 'foo')); - $route->addDefaults(array('bar' => 'bar')); - $this->assertEquals($route, $route->addDefaults(array()), '->addDefaults() implements a fluent interface'); - $this->assertEquals(array('foo' => 'foo', 'bar' => 'bar'), $route->getDefaults(), '->addDefaults() keep previous defaults'); - } - - public function testRequirements() - { - $route = new Route('/{foo}'); - $route->setRequirements(array('foo' => '\d+')); - $this->assertEquals(array('foo' => '\d+'), $route->getRequirements(), '->setRequirements() sets the requirements'); - $this->assertEquals('\d+', $route->getRequirement('foo'), '->getRequirement() returns a requirement'); - $this->assertNull($route->getRequirement('bar'), '->getRequirement() returns null if a requirement is not defined'); - $route->setRequirements(array('foo' => '^\d+$')); - $this->assertEquals('\d+', $route->getRequirement('foo'), '->getRequirement() removes ^ and $ from the path'); - $this->assertEquals($route, $route->setRequirements(array()), '->setRequirements() implements a fluent interface'); - - $route->setRequirements(array('foo' => '\d+')); - $route->addRequirements(array('bar' => '\d+')); - $this->assertEquals($route, $route->addRequirements(array()), '->addRequirements() implements a fluent interface'); - $this->assertEquals(array('foo' => '\d+', 'bar' => '\d+'), $route->getRequirements(), '->addRequirement() keep previous requirements'); - } - - public function testRequirement() - { - $route = new Route('/{foo}'); - $this->assertFalse($route->hasRequirement('foo'), '->hasRequirement() return false if requirement is not set'); - $route->setRequirement('foo', '^\d+$'); - $this->assertEquals('\d+', $route->getRequirement('foo'), '->setRequirement() removes ^ and $ from the path'); - $this->assertTrue($route->hasRequirement('foo'), '->hasRequirement() return true if requirement is set'); - } - - /** - * @dataProvider getInvalidRequirements - * @expectedException \InvalidArgumentException - */ - public function testSetInvalidRequirement($req) - { - $route = new Route('/{foo}'); - $route->setRequirement('foo', $req); - } - - public function getInvalidRequirements() - { - return array( - array(''), - array(array()), - array('^$'), - array('^'), - array('$'), - ); - } - - public function testHost() - { - $route = new Route('/'); - $route->setHost('{locale}.example.net'); - $this->assertEquals('{locale}.example.net', $route->getHost(), '->setHost() sets the host pattern'); - } - - public function testScheme() - { - $route = new Route('/'); - $this->assertEquals(array(), $route->getSchemes(), 'schemes is initialized with array()'); - $this->assertFalse($route->hasScheme('http')); - $route->setSchemes('hTTp'); - $this->assertEquals(array('http'), $route->getSchemes(), '->setSchemes() accepts a single scheme string and lowercases it'); - $this->assertTrue($route->hasScheme('htTp')); - $this->assertFalse($route->hasScheme('httpS')); - $route->setSchemes(array('HttpS', 'hTTp')); - $this->assertEquals(array('https', 'http'), $route->getSchemes(), '->setSchemes() accepts an array of schemes and lowercases them'); - $this->assertTrue($route->hasScheme('htTp')); - $this->assertTrue($route->hasScheme('httpS')); - } - - public function testMethod() - { - $route = new Route('/'); - $this->assertEquals(array(), $route->getMethods(), 'methods is initialized with array()'); - $route->setMethods('gEt'); - $this->assertEquals(array('GET'), $route->getMethods(), '->setMethods() accepts a single method string and uppercases it'); - $route->setMethods(array('gEt', 'PosT')); - $this->assertEquals(array('GET', 'POST'), $route->getMethods(), '->setMethods() accepts an array of methods and uppercases them'); - } - - public function testCondition() - { - $route = new Route('/'); - $this->assertSame('', $route->getCondition()); - $route->setCondition('context.getMethod() == "GET"'); - $this->assertSame('context.getMethod() == "GET"', $route->getCondition()); - } - - public function testCompile() - { - $route = new Route('/{foo}'); - $this->assertInstanceOf('Symfony\Component\Routing\CompiledRoute', $compiled = $route->compile(), '->compile() returns a compiled route'); - $this->assertSame($compiled, $route->compile(), '->compile() only compiled the route once if unchanged'); - $route->setRequirement('foo', '.*'); - $this->assertNotSame($compiled, $route->compile(), '->compile() recompiles if the route was modified'); - } - - public function testSerialize() - { - $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+')); - - $serialized = serialize($route); - $unserialized = unserialize($serialized); - - $this->assertEquals($route, $unserialized); - $this->assertNotSame($route, $unserialized); - } - - /** - * Tests that the compiled version is also serialized to prevent the overhead - * of compiling it again after unserialize. - */ - public function testSerializeWhenCompiled() - { - $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+')); - $route->setHost('{locale}.example.net'); - $route->compile(); - - $serialized = serialize($route); - $unserialized = unserialize($serialized); - - $this->assertEquals($route, $unserialized); - $this->assertNotSame($route, $unserialized); - } - - /** - * Tests that unserialization does not fail when the compiled Route is of a - * class other than CompiledRoute, such as a subclass of it. - */ - public function testSerializeWhenCompiledWithClass() - { - $route = new Route('/', array(), array(), array('compiler_class' => '\Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler')); - $this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $route->compile(), '->compile() returned a proper route'); - - $serialized = serialize($route); - try { - $unserialized = unserialize($serialized); - $this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $unserialized->compile(), 'the unserialized route compiled successfully'); - } catch (\Exception $e) { - $this->fail('unserializing a route which uses a custom compiled route class'); - } - } - - /** - * Tests that the serialized representation of a route in one symfony version - * also works in later symfony versions, i.e. the unserialized route is in the - * same state as another, semantically equivalent, route. - */ - public function testSerializedRepresentationKeepsWorking() - { - $serialized = 'C:31:"Symfony\Component\Routing\Route":934:{a:8:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":569:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:30:"#^/prefix(?:/(?P\d+))?$#s";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:39:"#^(?P[^\.]++)\.example\.net$#si";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}}'; - $unserialized = unserialize($serialized); - - $route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+')); - $route->setHost('{locale}.example.net'); - $route->compile(); - - $this->assertEquals($route, $unserialized); - $this->assertNotSame($route, $unserialized); - } -} diff --git a/lib/silex/vendor/symfony/routing/Tests/RouterTest.php b/lib/silex/vendor/symfony/routing/Tests/RouterTest.php deleted file mode 100644 index 409959eec..000000000 --- a/lib/silex/vendor/symfony/routing/Tests/RouterTest.php +++ /dev/null @@ -1,162 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Router; -use Symfony\Component\HttpFoundation\Request; - -class RouterTest extends TestCase -{ - private $router = null; - - private $loader = null; - - protected function setUp() - { - $this->loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $this->router = new Router($this->loader, 'routing.yml'); - } - - public function testSetOptionsWithSupportedOptions() - { - $this->router->setOptions(array( - 'cache_dir' => './cache', - 'debug' => true, - 'resource_type' => 'ResourceType', - )); - - $this->assertSame('./cache', $this->router->getOption('cache_dir')); - $this->assertTrue($this->router->getOption('debug')); - $this->assertSame('ResourceType', $this->router->getOption('resource_type')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The Router does not support the following options: "option_foo", "option_bar" - */ - public function testSetOptionsWithUnsupportedOptions() - { - $this->router->setOptions(array( - 'cache_dir' => './cache', - 'option_foo' => true, - 'option_bar' => 'baz', - 'resource_type' => 'ResourceType', - )); - } - - public function testSetOptionWithSupportedOption() - { - $this->router->setOption('cache_dir', './cache'); - - $this->assertSame('./cache', $this->router->getOption('cache_dir')); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The Router does not support the "option_foo" option - */ - public function testSetOptionWithUnsupportedOption() - { - $this->router->setOption('option_foo', true); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The Router does not support the "option_foo" option - */ - public function testGetOptionWithUnsupportedOption() - { - $this->router->getOption('option_foo', true); - } - - public function testThatRouteCollectionIsLoaded() - { - $this->router->setOption('resource_type', 'ResourceType'); - - $routeCollection = $this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock(); - - $this->loader->expects($this->once()) - ->method('load')->with('routing.yml', 'ResourceType') - ->will($this->returnValue($routeCollection)); - - $this->assertSame($routeCollection, $this->router->getRouteCollection()); - } - - /** - * @dataProvider provideMatcherOptionsPreventingCaching - */ - public function testMatcherIsCreatedIfCacheIsNotConfigured($option) - { - $this->router->setOption($option, null); - - $this->loader->expects($this->once()) - ->method('load')->with('routing.yml', null) - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock())); - - $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); - } - - public function provideMatcherOptionsPreventingCaching() - { - return array( - array('cache_dir'), - array('matcher_cache_class'), - ); - } - - /** - * @dataProvider provideGeneratorOptionsPreventingCaching - */ - public function testGeneratorIsCreatedIfCacheIsNotConfigured($option) - { - $this->router->setOption($option, null); - - $this->loader->expects($this->once()) - ->method('load')->with('routing.yml', null) - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock())); - - $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); - } - - public function provideGeneratorOptionsPreventingCaching() - { - return array( - array('cache_dir'), - array('generator_cache_class'), - ); - } - - public function testMatchRequestWithUrlMatcherInterface() - { - $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); - $matcher->expects($this->once())->method('match'); - - $p = new \ReflectionProperty($this->router, 'matcher'); - $p->setAccessible(true); - $p->setValue($this->router, $matcher); - - $this->router->matchRequest(Request::create('/')); - } - - public function testMatchRequestWithRequestMatcherInterface() - { - $matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); - $matcher->expects($this->once())->method('matchRequest'); - - $p = new \ReflectionProperty($this->router, 'matcher'); - $p->setAccessible(true); - $p->setValue($this->router, $matcher); - - $this->router->matchRequest(Request::create('/')); - } -} diff --git a/lib/silex/vendor/symfony/routing/composer.json b/lib/silex/vendor/symfony/routing/composer.json deleted file mode 100644 index 2ad746ec5..000000000 --- a/lib/silex/vendor/symfony/routing/composer.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "symfony/routing", - "type": "library", - "description": "Symfony Routing Component", - "keywords": ["routing", "router", "URL", "URI"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "require-dev": { - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "doctrine/annotations": "~1.0", - "doctrine/common": "~2.2", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.3", - "symfony/yaml": "<3.4" - }, - "suggest": { - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/yaml": "For using the YAML loader", - "symfony/expression-language": "For using expression matching", - "doctrine/annotations": "For using the annotation loader", - "symfony/dependency-injection": "For loading routes from a service" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\Routing\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } -} diff --git a/lib/silex/vendor/symfony/routing/phpunit.xml.dist b/lib/silex/vendor/symfony/routing/phpunit.xml.dist deleted file mode 100644 index bcc095952..000000000 --- a/lib/silex/vendor/symfony/routing/phpunit.xml.dist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Tests - ./vendor - - - - diff --git a/lib/silex/vendor/twig/twig/.editorconfig b/lib/silex/vendor/twig/twig/.editorconfig deleted file mode 100644 index 270f1d1b7..000000000 --- a/lib/silex/vendor/twig/twig/.editorconfig +++ /dev/null @@ -1,18 +0,0 @@ -; top-most EditorConfig file -root = true - -; Unix-style newlines -[*] -end_of_line = LF - -[*.php] -indent_style = space -indent_size = 4 - -[*.test] -indent_style = space -indent_size = 4 - -[*.rst] -indent_style = space -indent_size = 4 diff --git a/lib/silex/vendor/twig/twig/.gitignore b/lib/silex/vendor/twig/twig/.gitignore deleted file mode 100644 index 31103621c..000000000 --- a/lib/silex/vendor/twig/twig/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/build -/composer.lock -/ext/twig/autom4te.cache/ -/phpunit.xml -/vendor diff --git a/lib/silex/vendor/twig/twig/.php_cs.dist b/lib/silex/vendor/twig/twig/.php_cs.dist deleted file mode 100644 index d249ffbe4..000000000 --- a/lib/silex/vendor/twig/twig/.php_cs.dist +++ /dev/null @@ -1,16 +0,0 @@ -setRules(array( - '@Symfony' => true, - '@Symfony:risky' => true, - 'array_syntax' => array('syntax' => 'long'), - 'php_unit_fqcn_annotation' => false, - 'no_unreachable_default_argument_value' => false, - 'braces' => array('allow_single_line_closure' => true), - 'heredoc_to_nowdoc' => false, - 'dir_constant' => false, - )) - ->setRiskyAllowed(true) - ->setFinder(PhpCsFixer\Finder::create()->in(__DIR__)) -; diff --git a/lib/silex/vendor/twig/twig/.travis.yml b/lib/silex/vendor/twig/twig/.travis.yml deleted file mode 100644 index 147eb7df3..000000000 --- a/lib/silex/vendor/twig/twig/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: php - -sudo: false - -cache: - directories: - - vendor - - $HOME/.composer/cache/files - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - nightly - -env: - - TWIG_EXT=no - - TWIG_EXT=yes - -before_install: - # turn off XDebug - - phpenv config-rm xdebug.ini || return 0 - -install: - - travis_retry composer install - -before_script: - - if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi - - if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi - -script: | - if [[ $TRAVIS_PHP_VERSION = 7.* || $TRAVIS_PHP_VERSION = nightly ]]; then - SYMFONY_PHPUNIT_VERSION=6.1 ./vendor/bin/simple-phpunit - else - ./vendor/bin/simple-phpunit - fi - -matrix: - fast_finish: true - exclude: - - php: 7.0 - env: TWIG_EXT=yes - - php: 7.1 - env: TWIG_EXT=yes - - php: nightly - env: TWIG_EXT=yes diff --git a/lib/silex/vendor/twig/twig/CHANGELOG b/lib/silex/vendor/twig/twig/CHANGELOG deleted file mode 100644 index f738c841c..000000000 --- a/lib/silex/vendor/twig/twig/CHANGELOG +++ /dev/null @@ -1,984 +0,0 @@ -* 1.35.0 (2017-09-27) - - * added Twig_Profiler_Profile::reset() - * fixed use TokenParser to return an empty Node - * added RuntimeExtensionInterface - * added circular reference detection when loading templates - -* 1.34.4 (2017-07-04) - - * added support for runtime loaders in IntegrationTestCase - * fixed deprecation when using Twig_Profiler_Dumper_Html - -* 1.34.3 (2017-06-07) - - * fixed namespaces introduction - -* 1.34.2 (2017-06-05) - - * fixed namespaces introduction - -* 1.34.1 (2017-06-05) - - * fixed namespaces introduction - -* 1.34.0 (2017-06-05) - - * added support for PHPUnit 6 when testing extensions - * fixed PHP 7.2 compatibility - * fixed template name generation in Twig_Environment::createTemplate() - * removed final tag on Twig_TokenParser_Include - * added namespaced aliases for all (non-deprecated) classes and interfaces - * dropped HHVM support - * dropped PHP 5.2 support - -* 1.33.2 (2017-04-20) - - * fixed edge case in the method cache for Twig attributes - -* 1.33.1 (2017-04-18) - - * fixed the empty() test - -* 1.33.0 (2017-03-22) - - * fixed a race condition handling when writing cache files - * "length" filter now returns string length when applied to an object that does - not implement \Countable but provides __toString() - * "empty" test will now consider the return value of the __toString() method for - objects implement __toString() but not \Countable - * fixed JS escaping for unicode characters with higher code points - -* 1.32.0 (2017-02-26) - - * fixed deprecation notice in Twig_Util_DeprecationCollector - * added a PSR-11 compatible runtime loader - * added `side` argument to `trim` to allow left or right trimming only. - -* 1.31.0 (2017-01-11) - - * added Twig_NodeCaptureInterface for nodes that capture all output - * fixed marking the environment as initialized too early - * fixed C89 compat for the C extension - * turned fatal error into exception when a previously generated cache is corrupted - * fixed offline cache warm-ups for embedded templates - -* 1.30.0 (2016-12-23) - - * added Twig_FactoryRuntimeLoader - * deprecated function/test/filter/tag overriding - * deprecated the "disable_c_ext" attribute on Twig_Node_Expression_GetAttr - -* 1.29.0 (2016-12-13) - - * fixed sandbox being left enabled if an exception is thrown while rendering - * marked some classes as being final (via @final) - * made Twig_Error report real source path when possible - * added support for {{ _self }} to provide an upgrade path from 1.x to 2.0 (replaces {{ _self.templateName }}) - * deprecated silent display of undefined blocks - * deprecated support for mbstring.func_overload != 0 - -* 1.28.2 (2016-11-23) - - * fixed precedence between getFoo() and isFoo() in Twig_Template::getAttribute() - * improved a deprecation message - -* 1.28.1 (2016-11-18) - - * fixed block() function when used with a template argument - -* 1.28.0 (2016-11-17) - - * added support for the PHP 7 null coalescing operator for the ?? Twig implementation - * exposed a way to access template data and methods in a portable way - * changed context access to use the PHP 7 null coalescing operator when available - * added the "with" tag - * added support for a custom template on the block() function - * added "is defined" support for block() and constant() - * optimized the way attributes are fetched - -* 1.27.0 (2016-10-25) - - * deprecated Twig_Parser::getEnvironment() - * deprecated Twig_Parser::addHandler() and Twig_Parser::addNodeVisitor() - * deprecated Twig_Compiler::addIndentation() - * fixed regression when registering two extensions having the same class name - * deprecated Twig_LoaderInterface::getSource() (implement Twig_SourceContextLoaderInterface instead) - * fixed the filesystem loader with relative paths - * deprecated Twig_Node::getLine() in favor of Twig_Node::getTemplateLine() - * deprecated Twig_Template::getSource() in favor of Twig_Template::getSourceContext() - * deprecated Twig_Node::getFilename() in favor of Twig_Node::getTemplateName() - * deprecated the "filename" escaping strategy (use "name" instead) - * added Twig_Source to hold information about the original template - * deprecated Twig_Error::getTemplateFile() and Twig_Error::setTemplateFile() in favor of Twig_Error::getTemplateName() and Twig_Error::setTemplateName() - * deprecated Parser::getFilename() - * fixed template paths when a template name contains a protocol like vfs:// - * improved debugging with Twig_Sandbox_SecurityError exceptions for disallowed methods and properties - -* 1.26.1 (2016-10-05) - - * removed template source code from generated template classes when debug is disabled - * fixed default implementation of Twig_Template::getDebugInfo() for better BC - * fixed regression on static calls for functions/filters/tests - -* 1.26.0 (2016-10-02) - - * added template cache invalidation based on more environment options - * added a missing deprecation notice - * fixed template paths when a template is stored in a PHAR file - * allowed filters/functions/tests implementation to use a different class than the extension they belong to - * deprecated Twig_ExtensionInterface::getName() - -* 1.25.0 (2016-09-21) - - * changed the way we store template source in template classes - * removed usage of realpath in cache keys - * fixed Twig cache sharing when used with different versions of PHP - * removed embed parent workaround for simple use cases - * deprecated the ability to store non Node instances in Node::$nodes - * deprecated Twig_Environment::getLexer(), Twig_Environment::getParser(), Twig_Environment::getCompiler() - * deprecated Twig_Compiler::getFilename() - -* 1.24.2 (2016-09-01) - - * fixed static callables - * fixed a potential PHP warning when loading the cache - * fixed a case where the autoescaping does not work as expected - -* 1.24.1 (2016-05-30) - - * fixed reserved keywords (forbids true, false, null and none keywords for variables names) - * fixed support for PHP7 (Throwable support) - * marked the following methods as being internals on Twig_Environment: - getFunctions(), getFilters(), getTests(), getFunction(), getFilter(), getTest(), - getTokenParsers(), getTags(), getNodeVisitors(), getUnaryOperators(), getBinaryOperators(), - getFunctions(), getFilters(), getGlobals(), initGlobals(), initExtensions(), and initExtension() - -* 1.24.0 (2016-01-25) - - * adding support for the ?? operator - * fixed the defined test when used on a constant, a map, or a sequence - * undeprecated _self (should only be used to get the template name, not the template instance) - * fixed parsing on PHP7 - -* 1.23.3 (2016-01-11) - - * fixed typo - -* 1.23.2 (2015-01-11) - - * added versions in deprecated messages - * made file cache tolerant for trailing (back)slashes on directory configuration - * deprecated unused Twig_Node_Expression_ExtensionReference class - -* 1.23.1 (2015-11-05) - - * fixed some exception messages which triggered PHP warnings - * fixed BC on Twig_Test_NodeTestCase - -* 1.23.0 (2015-10-29) - - * deprecated the possibility to override an extension by registering another one with the same name - * deprecated Twig_ExtensionInterface::getGlobals() (added Twig_Extension_GlobalsInterface for BC) - * deprecated Twig_ExtensionInterface::initRuntime() (added Twig_Extension_InitRuntimeInterface for BC) - * deprecated Twig_Environment::computeAlternatives() - -* 1.22.3 (2015-10-13) - - * fixed regression when using null as a cache strategy - * improved performance when checking template freshness - * fixed warnings when loaded templates do not exist - * fixed template class name generation to prevent possible collisions - * fixed logic for custom escapers to call them even on integers and null values - * changed template cache names to take into account the Twig C extension - -* 1.22.2 (2015-09-22) - - * fixed a race condition in template loading - -* 1.22.1 (2015-09-15) - - * fixed regression in template_from_string - -* 1.22.0 (2015-09-13) - - * made Twig_Test_IntegrationTestCase more flexible - * added an option to force PHP bytecode invalidation when writing a compiled template into the cache - * fixed the profiler duration for the root node - * changed template cache names to take into account enabled extensions - * deprecated Twig_Environment::clearCacheFiles(), Twig_Environment::getCacheFilename(), - Twig_Environment::writeCacheFile(), and Twig_Environment::getTemplateClassPrefix() - * added a way to override the filesystem template cache system - * added a way to get the original template source from Twig_Template - -* 1.21.2 (2015-09-09) - - * fixed variable names for the deprecation triggering code - * fixed escaping strategy detection based on filename - * added Traversable support for replace, merge, and sort - * deprecated support for character by character replacement for the "replace" filter - -* 1.21.1 (2015-08-26) - - * fixed regression when using the deprecated Twig_Test_* classes - -* 1.21.0 (2015-08-24) - - * added deprecation notices for deprecated features - * added a deprecation "framework" for filters/functions/tests and test fixtures - -* 1.20.0 (2015-08-12) - - * forbid access to the Twig environment from templates and internal parts of Twig_Template - * fixed limited RCEs when in sandbox mode - * deprecated Twig_Template::getEnvironment() - * deprecated the _self variable for usage outside of the from and import tags - * added Twig_BaseNodeVisitor to ease the compatibility of node visitors - between 1.x and 2.x - -* 1.19.0 (2015-07-31) - - * fixed wrong error message when including an undefined template in a child template - * added support for variadic filters, functions, and tests - * added support for extra positional arguments in macros - * added ignore_missing flag to the source function - * fixed batch filter with zero items - * deprecated Twig_Environment::clearTemplateCache() - * fixed sandbox disabling when using the include function - -* 1.18.2 (2015-06-06) - - * fixed template/line guessing in exceptions for nested templates - * optimized the number of inodes and the size of realpath cache when using the cache - -* 1.18.1 (2015-04-19) - - * fixed memory leaks in the C extension - * deprecated Twig_Loader_String - * fixed the slice filter when used with a SimpleXMLElement object - * fixed filesystem loader when trying to load non-files (like directories) - -* 1.18.0 (2015-01-25) - - * fixed some error messages where the line was wrong (unknown variables or argument names) - * added a new way to customize the main Module node (via empty nodes) - * added Twig_Environment::createTemplate() to create a template from a string - * added a profiler - * fixed filesystem loader cache when different file paths are used for the same template - -* 1.17.0 (2015-01-14) - - * added a 'filename' autoescaping strategy, which dynamically chooses the - autoescaping strategy for a template based on template file extension. - -* 1.16.3 (2014-12-25) - - * fixed regression for dynamic parent templates - * fixed cache management with statcache - * fixed a regression in the slice filter - -* 1.16.2 (2014-10-17) - - * fixed timezone on dates as strings - * fixed 2-words test names when a custom node class is not used - * fixed macros when using an argument named like a PHP super global (like GET or POST) - * fixed date_modify when working with DateTimeImmutable - * optimized for loops - * fixed multi-byte characters handling in the split filter - * fixed a regression in the in operator - * fixed a regression in the slice filter - -* 1.16.1 (2014-10-10) - - * improved error reporting in a sandboxed template - * fixed missing error file/line information under certain circumstances - * fixed wrong error line number in some error messages - * fixed the in operator to use strict comparisons - * sped up the slice filter - * fixed for mb function overload mb_substr acting different - * fixed the attribute() function when passing a variable for the arguments - -* 1.16.0 (2014-07-05) - - * changed url_encode to always encode according to RFC 3986 - * fixed inheritance in a 'use'-hierarchy - * removed the __toString policy check when the sandbox is disabled - * fixed recursively calling blocks in templates with inheritance - -* 1.15.1 (2014-02-13) - - * fixed the conversion of the special '0000-00-00 00:00' date - * added an error message when trying to import an undefined block from a trait - * fixed a C extension crash when accessing defined but uninitialized property. - -* 1.15.0 (2013-12-06) - - * made ignoreStrictCheck in Template::getAttribute() works with __call() methods throwing BadMethodCallException - * added min and max functions - * added the round filter - * fixed a bug that prevented the optimizers to be enabled/disabled selectively - * fixed first and last filters for UTF-8 strings - * added a source function to include the content of a template without rendering it - * fixed the C extension sandbox behavior when get or set is prepend to method name - -* 1.14.2 (2013-10-30) - - * fixed error filename/line when an error occurs in an included file - * allowed operators that contain whitespaces to have more than one whitespace - * allowed tests to be made of 1 or 2 words (like "same as" or "divisible by") - -* 1.14.1 (2013-10-15) - - * made it possible to use named operators as variables - * fixed the possibility to have a variable named 'matches' - * added support for PHP 5.5 DateTimeInterface - -* 1.14.0 (2013-10-03) - - * fixed usage of the html_attr escaping strategy to avoid double-escaping with the html strategy - * added new operators: ends with, starts with, and matches - * fixed some compatibility issues with HHVM - * added a way to add custom escaping strategies - * fixed the C extension compilation on Windows - * fixed the batch filter when using a fill argument with an exact match of elements to batch - * fixed the filesystem loader cache when a template name exists in several namespaces - * fixed template_from_string when the template includes or extends other ones - * fixed a crash of the C extension on an edge case - -* 1.13.2 (2013-08-03) - - * fixed the error line number for an error occurs in and embedded template - * fixed crashes of the C extension on some edge cases - -* 1.13.1 (2013-06-06) - - * added the possibility to ignore the filesystem constructor argument in Twig_Loader_Filesystem - * fixed Twig_Loader_Chain::exists() for a loader which implements Twig_ExistsLoaderInterface - * adjusted backtrace call to reduce memory usage when an error occurs - * added support for object instances as the second argument of the constant test - * fixed the include function when used in an assignment - -* 1.13.0 (2013-05-10) - - * fixed getting a numeric-like item on a variable ('09' for instance) - * fixed getting a boolean or float key on an array, so it is consistent with PHP's array access: - `{{ array[false] }}` behaves the same as `echo $array[false];` (equals `$array[0]`) - * made the escape filter 20% faster for happy path (escaping string for html with UTF-8) - * changed ☃ to § in tests - * enforced usage of named arguments after positional ones - -* 1.12.3 (2013-04-08) - - * fixed a security issue in the filesystem loader where it was possible to include a template one - level above the configured path - * fixed fatal error that should be an exception when adding a filter/function/test too late - * added a batch filter - * added support for encoding an array as query string in the url_encode filter - -* 1.12.2 (2013-02-09) - - * fixed the timezone used by the date filter and function when the given date contains a timezone (like 2010-01-28T15:00:00+02:00) - * fixed globals when getGlobals is called early on - * added the first and last filter - -* 1.12.1 (2013-01-15) - - * added support for object instances as the second argument of the constant function - * relaxed globals management to avoid a BC break - * added support for {{ some_string[:2] }} - -* 1.12.0 (2013-01-08) - - * added verbatim as an alias for the raw tag to avoid confusion with the raw filter - * fixed registration of tests and functions as anonymous functions - * fixed globals management - -* 1.12.0-RC1 (2012-12-29) - - * added an include function (does the same as the include tag but in a more flexible way) - * added the ability to use any PHP callable to define filters, functions, and tests - * added a syntax error when using a loop variable that is not defined - * added the ability to set default values for macro arguments - * added support for named arguments for filters, tests, and functions - * moved filters/functions/tests syntax errors to the parser - * added support for extended ternary operator syntaxes - -* 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 - * fixed escaping when a project defines a function named html or js - * fixed chmod mode to apply the umask correctly - -* 1.8.2 (2012-05-30) - - * added the abs filter - * fixed a regression when using a number in template attributes - * fixed compiler when mbstring.func_overload is set to 2 - * fixed DateTimeZone support in date filter - -* 1.8.1 (2012-05-17) - - * fixed a regression when dealing with SimpleXMLElement instances in templates - * fixed "is_safe" value for the "dump" function when "html_errors" is not defined in php.ini - * switched to use mbstring whenever possible instead of iconv (you might need to update your encoding as mbstring and iconv encoding names sometimes differ) - -* 1.8.0 (2012-05-08) - - * enforced interface when adding tests, filters, functions, and node visitors from extensions - * fixed a side-effect of the date filter where the timezone might be changed - * simplified usage of the autoescape tag; the only (optional) argument is now the escaping strategy or false (with a BC layer) - * added a way to dynamically change the auto-escaping strategy according to the template "filename" - * changed the autoescape option to also accept a supported escaping strategy (for BC, true is equivalent to html) - * added an embed tag - -* 1.7.0 (2012-04-24) - - * fixed a PHP warning when using CIFS - * fixed template line number in some exceptions - * added an iterable test - * added an error when defining two blocks with the same name in a template - * added the preserves_safety option for filters - * fixed a PHP notice when trying to access a key on a non-object/array variable - * enhanced error reporting when the template file is an instance of SplFileInfo - * added Twig_Environment::mergeGlobals() - * added compilation checks to avoid misuses of the sandbox tag - * fixed filesystem loader freshness logic for high traffic websites - * fixed random function when charset is null - -* 1.6.5 (2012-04-11) - - * fixed a regression when a template only extends another one without defining any blocks - -* 1.6.4 (2012-04-02) - - * fixed PHP notice in Twig_Error::guessTemplateLine() introduced in 1.6.3 - * fixed performance when compiling large files - * optimized parent template creation when the template does not use dynamic inheritance - -* 1.6.3 (2012-03-22) - - * fixed usage of Z_ADDREF_P for PHP 5.2 in the C extension - * fixed compilation of numeric values used in templates when using a locale where the decimal separator is not a dot - * made the strategy used to guess the real template file name and line number in exception messages much faster and more accurate - -* 1.6.2 (2012-03-18) - - * fixed sandbox mode when used with inheritance - * added preserveKeys support for the slice filter - * fixed the date filter when a DateTime instance is passed with a specific timezone - * added a trim filter - -* 1.6.1 (2012-02-29) - - * fixed Twig C extension - * removed the creation of Twig_Markup instances when not needed - * added a way to set the default global timezone for dates - * fixed the slice filter on strings when the length is not specified - * fixed the creation of the cache directory in case of a race condition - -* 1.6.0 (2012-02-04) - - * fixed raw blocks when used with the whitespace trim option - * made a speed optimization to macro calls when imported via the "from" tag - * fixed globals, parsers, visitors, filters, tests, and functions management in Twig_Environment when a new one or new extension is added - * fixed the attribute function when passing arguments - * added slice notation support for the [] operator (syntactic sugar for the slice operator) - * added a slice filter - * added string support for the reverse filter - * fixed the empty test and the length filter for Twig_Markup instances - * added a date function to ease date comparison - * fixed unary operators precedence - * added recursive parsing support in the parser - * added string and integer handling for the random function - -* 1.5.1 (2012-01-05) - - * fixed a regression when parsing strings - -* 1.5.0 (2012-01-04) - - * added Traversable objects support for the join filter - -* 1.5.0-RC2 (2011-12-30) - - * added a way to set the default global date interval format - * fixed the date filter for DateInterval instances (setTimezone() does not exist for them) - * refactored Twig_Template::display() to ease its extension - * added a number_format filter - -* 1.5.0-RC1 (2011-12-26) - - * removed the need to quote hash keys - * allowed hash keys to be any expression - * added a do tag - * added a flush tag - * added support for dynamically named filters and functions - * added a dump function to help debugging templates - * added a nl2br filter - * added a random function - * added a way to change the default format for the date filter - * fixed the lexer when an operator ending with a letter ends a line - * added string interpolation support - * enhanced exceptions for unknown filters, functions, tests, and tags - -* 1.4.0 (2011-12-07) - - * fixed lexer when using big numbers (> PHP_INT_MAX) - * added missing preserveKeys argument to the reverse filter - * fixed macros containing filter tag calls - -* 1.4.0-RC2 (2011-11-27) - - * removed usage of Reflection in Twig_Template::getAttribute() - * added a C extension that can optionally replace Twig_Template::getAttribute() - * added negative timestamp support to the date filter - -* 1.4.0-RC1 (2011-11-20) - - * optimized variable access when using PHP 5.4 - * changed the precedence of the .. operator to be more consistent with languages that implements such a feature like Ruby - * added an Exception to Twig_Loader_Array::isFresh() method when the template does not exist to be consistent with other loaders - * added Twig_Function_Node to allow more complex functions to have their own Node class - * added Twig_Filter_Node to allow more complex filters to have their own Node class - * added Twig_Test_Node to allow more complex tests to have their own Node class - * added a better error message when a template is empty but contain a BOM - * fixed "in" operator for empty strings - * fixed the "defined" test and the "default" filter (now works with more than one call (foo.bar.foo) and for both values of the strict_variables option) - * changed the way extensions are loaded (addFilter/addFunction/addGlobal/addTest/addNodeVisitor/addTokenParser/addExtension can now be called in any order) - * added Twig_Environment::display() - * made the escape filter smarter when the encoding is not supported by PHP - * added a convert_encoding filter - * moved all node manipulations outside the compile() Node method - * made several speed optimizations - -* 1.3.0 (2011-10-08) - -no changes - -* 1.3.0-RC1 (2011-10-04) - - * added an optimization for the parent() function - * added cache reloading when auto_reload is true and an extension has been modified - * added the possibility to force the escaping of a string already marked as safe (instance of Twig_Markup) - * allowed empty templates to be used as traits - * added traits support for the "parent" function - -* 1.2.0 (2011-09-13) - -no changes - -* 1.2.0-RC1 (2011-09-10) - - * enhanced the exception when a tag remains unclosed - * added support for empty Countable objects for the "empty" test - * fixed algorithm that determines if a template using inheritance is valid (no output between block definitions) - * added better support for encoding problems when escaping a string (available as of PHP 5.4) - * added a way to ignore a missing template when using the "include" tag ({% include "foo" ignore missing %}) - * added support for an array of templates to the "include" and "extends" tags ({% include ['foo', 'bar'] %}) - * added support for bitwise operators in expressions - * added the "attribute" function to allow getting dynamic attributes on variables - * added Twig_Loader_Chain - * added Twig_Loader_Array::setTemplate() - * added an optimization for the set tag when used to capture a large chunk of static text - * changed name regex to match PHP one "[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*" (works for blocks, tags, functions, filters, and macros) - * removed the possibility to use the "extends" tag from a block - * added "if" modifier support to "for" loops - -* 1.1.2 (2011-07-30) - - * fixed json_encode filter on PHP 5.2 - * fixed regression introduced in 1.1.1 ({{ block(foo|lower) }}) - * fixed inheritance when using conditional parents - * fixed compilation of templates when the body of a child template is not empty - * fixed output when a macro throws an exception - * fixed a parsing problem when a large chunk of text is enclosed in a comment tag - * added PHPDoc for all Token parsers and Core extension functions - -* 1.1.1 (2011-07-17) - - * added a performance optimization in the Optimizer (also helps to lower the number of nested level calls) - * made some performance improvement for some edge cases - -* 1.1.0 (2011-06-28) - - * fixed json_encode filter - -* 1.1.0-RC3 (2011-06-24) - - * fixed method case-sensitivity when using the sandbox mode - * added timezone support for the date filter - * fixed possible security problems with NUL bytes - -* 1.1.0-RC2 (2011-06-16) - - * added an exception when the template passed to "use" is not a string - * made 'a.b is defined' not throw an exception if a is not defined (in strict mode) - * added {% line \d+ %} directive - -* 1.1.0-RC1 (2011-05-28) - -Flush your cache after upgrading. - - * fixed date filter when using a timestamp - * fixed the defined test for some cases - * fixed a parsing problem when a large chunk of text is enclosed in a raw tag - * added support for horizontal reuse of template blocks (see docs for more information) - * added whitespace control modifier to all tags (see docs for more information) - * added null as an alias for none (the null test is also an alias for the none test now) - * made TRUE, FALSE, NONE equivalent to their lowercase counterparts - * wrapped all compilation and runtime exceptions with Twig_Error_Runtime and added logic to guess the template name and line - * moved display() method to Twig_Template (generated templates should now use doDisplay() instead) - -* 1.0.0 (2011-03-27) - - * fixed output when using mbstring - * fixed duplicate call of methods when using the sandbox - * made the charset configurable for the escape filter - -* 1.0.0-RC2 (2011-02-21) - - * changed the way {% set %} works when capturing (the content is now marked as safe) - * added support for macro name in the endmacro tag - * make Twig_Error compatible with PHP 5.3.0 > - * fixed an infinite loop on some Windows configurations - * fixed the "length" filter for numbers - * fixed Template::getAttribute() as properties in PHP are case sensitive - * removed coupling between Twig_Node and Twig_Template - * fixed the ternary operator precedence rule - -* 1.0.0-RC1 (2011-01-09) - -Backward incompatibilities: - - * the "items" filter, which has been deprecated for quite a long time now, has been removed - * the "range" filter has been converted to a function: 0|range(10) -> range(0, 10) - * the "constant" filter has been converted to a function: {{ some_date|date('DATE_W3C'|constant) }} -> {{ some_date|date(constant('DATE_W3C')) }} - * the "cycle" filter has been converted to a function: {{ ['odd', 'even']|cycle(i) }} -> {{ cycle(['odd', 'even'], i) }} - * the "for" tag does not support "joined by" anymore - * the "autoescape" first argument is now "true"/"false" (instead of "on"/"off") - * the "parent" tag has been replaced by a "parent" function ({{ parent() }} instead of {% parent %}) - * the "display" tag has been replaced by a "block" function ({{ block('title') }} instead of {% display title %}) - * removed the grammar and simple token parser (moved to the Twig Extensions repository) - -Changes: - - * added "needs_context" option for filters and functions (the context is then passed as a first argument) - * added global variables support - * made macros return their value instead of echoing directly (fixes calling a macro in sandbox mode) - * added the "from" tag to import macros as functions - * added support for functions (a function is just syntactic sugar for a getAttribute() call) - * made macros callable when sandbox mode is enabled - * added an exception when a macro uses a reserved name - * the "default" filter now uses the "empty" test instead of just checking for null - * added the "empty" test - -* 0.9.10 (2010-12-16) - -Backward incompatibilities: - - * The Escaper extension is enabled by default, which means that all displayed - variables are now automatically escaped. You can revert to the previous - behavior by removing the extension via $env->removeExtension('escaper') - or just set the 'autoescape' option to 'false'. - * removed the "without loop" attribute for the "for" tag (not needed anymore - as the Optimizer take care of that for most cases) - * arrays and hashes have now a different syntax - * arrays keep the same syntax with square brackets: [1, 2] - * hashes now use curly braces (["a": "b"] should now be written as {"a": "b"}) - * support for "arrays with keys" and "hashes without keys" is not supported anymore ([1, "foo": "bar"] or {"foo": "bar", 1}) - * the i18n extension is now part of the Twig Extensions repository - -Changes: - - * added the merge filter - * removed 'is_escaper' option for filters (a left over from the previous version) -- you must use 'is_safe' now instead - * fixed usage of operators as method names (like is, in, and not) - * changed the order of execution for node visitors - * fixed default() filter behavior when used with strict_variables set to on - * fixed filesystem loader compatibility with PHAR files - * enhanced error messages when an unexpected token is parsed in an expression - * fixed filename not being added to syntax error messages - * added the autoescape option to enable/disable autoescaping - * removed the newline after a comment (mimics PHP behavior) - * added a syntax error exception when parent block is used on a template that does not extend another one - * made the Escaper extension enabled by default - * fixed sandbox extension when used with auto output escaping - * fixed escaper when wrapping a Twig_Node_Print (the original class must be preserved) - * added an Optimizer extension (enabled by default; optimizes "for" loops and "raw" filters) - * added priority to node visitors - -* 0.9.9 (2010-11-28) - -Backward incompatibilities: - * the self special variable has been renamed to _self - * the odd and even filters are now tests: - {{ foo|odd }} must now be written {{ foo is odd }} - * the "safe" filter has been renamed to "raw" - * in Node classes, - sub-nodes are now accessed via getNode() (instead of property access) - attributes via getAttribute() (instead of array access) - * the urlencode filter had been renamed to url_encode - * the include tag now merges the passed variables with the current context by default - (the old behavior is still possible by adding the "only" keyword) - * moved Exceptions to Twig_Error_* (Twig_SyntaxError/Twig_RuntimeError are now Twig_Error_Syntax/Twig_Error_Runtime) - * removed support for {{ 1 < i < 3 }} (use {{ i > 1 and i < 3 }} instead) - * the "in" filter has been removed ({{ a|in(b) }} should now be written {{ a in b }}) - -Changes: - * added file and line to Twig_Error_Runtime exceptions thrown from Twig_Template - * changed trans tag to accept any variable for the plural count - * fixed sandbox mode (__toString() method check was not enforced if called implicitly from complex statements) - * added the ** (power) operator - * changed the algorithm used for parsing expressions - * added the spaceless tag - * removed trim_blocks option - * added support for is*() methods for attributes (foo.bar now looks for foo->getBar() or foo->isBar()) - * changed all exceptions to extend Twig_Error - * fixed unary expressions ({{ not(1 or 0) }}) - * fixed child templates (with an extend tag) that uses one or more imports - * added support for {{ 1 not in [2, 3] }} (more readable than the current {{ not (1 in [2, 3]) }}) - * escaping has been rewritten - * the implementation of template inheritance has been rewritten - (blocks can now be called individually and still work with inheritance) - * fixed error handling for if tag when a syntax error occurs within a subparse process - * added a way to implement custom logic for resolving token parsers given a tag name - * fixed js escaper to be stricter (now uses a whilelist-based js escaper) - * added the following filers: "constant", "trans", "replace", "json_encode" - * added a "constant" test - * fixed objects with __toString() not being autoescaped - * fixed subscript expressions when calling __call() (methods now keep the case) - * added "test" feature (accessible via the "is" operator) - * removed the debug tag (should be done in an extension) - * fixed trans tag when no vars are used in plural form - * fixed race condition when writing template cache - * added the special _charset variable to reference the current charset - * added the special _context variable to reference the current context - * renamed self to _self (to avoid conflict) - * fixed Twig_Template::getAttribute() for protected properties - -* 0.9.8 (2010-06-28) - -Backward incompatibilities: - * the trans tag plural count is now attached to the plural tag: - old: `{% trans count %}...{% plural %}...{% endtrans %}` - new: `{% trans %}...{% plural count %}...{% endtrans %}` - - * added a way to translate strings coming from a variable ({% trans var %}) - * fixed trans tag when used with the Escaper extension - * fixed default cache umask - * removed Twig_Template instances from the debug tag output - * fixed objects with __isset() defined - * fixed set tag when used with a capture - * fixed type hinting for Twig_Environment::addFilter() method - -* 0.9.7 (2010-06-12) - -Backward incompatibilities: - * changed 'as' to '=' for the set tag ({% set title as "Title" %} must now be {% set title = "Title" %}) - * removed the sandboxed attribute of the include tag (use the new sandbox tag instead) - * refactored the Node system (if you have custom nodes, you will have to update them to use the new API) - - * added self as a special variable that refers to the current template (useful for importing macros from the current template) - * added Twig_Template instance support to the include tag - * added support for dynamic and conditional inheritance ({% extends some_var %} and {% extends standalone ? "minimum" : "base" %}) - * added a grammar sub-framework to ease the creation of custom tags - * fixed the for tag for large arrays (some loop variables are now only available for arrays and objects that implement the Countable interface) - * removed the Twig_Resource::resolveMissingFilter() method - * fixed the filter tag which did not apply filtering to included files - * added a bunch of unit tests - * added a bunch of phpdoc - * added a sandbox tag in the sandbox extension - * changed the date filter to support any date format supported by DateTime - * added strict_variable setting to throw an exception when an invalid variable is used in a template (disabled by default) - * added the lexer, parser, and compiler as arguments to the Twig_Environment constructor - * changed the cache option to only accepts an explicit path to a cache directory or false - * added a way to add token parsers, filters, and visitors without creating an extension - * added three interfaces: Twig_NodeInterface, Twig_TokenParserInterface, and Twig_FilterInterface - * changed the generated code to match the new coding standards - * fixed sandbox mode (__toString() method check was not enforced if called implicitly from a simple statement like {{ article }}) - * added an exception when a child template has a non-empty body (as it is always ignored when rendering) - -* 0.9.6 (2010-05-12) - - * fixed variables defined outside a loop and for which the value changes in a for loop - * fixed the test suite for PHP 5.2 and older versions of PHPUnit - * added support for __call() in expression resolution - * fixed node visiting for macros (macros are now visited by visitors as any other node) - * fixed nested block definitions with a parent call (rarely useful but nonetheless supported now) - * added the cycle filter - * fixed the Lexer when mbstring.func_overload is used with an mbstring.internal_encoding different from ASCII - * added a long-syntax for the set tag ({% set foo %}...{% endset %}) - * unit tests are now powered by PHPUnit - * added support for gettext via the `i18n` extension - * fixed twig_capitalize_string_filter() and fixed twig_length_filter() when used with UTF-8 values - * added a more useful exception if an if tag is not closed properly - * added support for escaping strategy in the autoescape tag - * fixed lexer when a template has a big chunk of text between/in a block - -* 0.9.5 (2010-01-20) - -As for any new release, don't forget to remove all cached templates after -upgrading. - -If you have defined custom filters, you MUST upgrade them for this release. To -upgrade, replace "array" with "new Twig_Filter_Function", and replace the -environment constant by the "needs_environment" option: - - // before - 'even' => array('twig_is_even_filter', false), - 'escape' => array('twig_escape_filter', true), - - // after - 'even' => new Twig_Filter_Function('twig_is_even_filter'), - 'escape' => new Twig_Filter_Function('twig_escape_filter', array('needs_environment' => true)), - -If you have created NodeTransformer classes, you will need to upgrade them to -the new interface (please note that the interface is not yet considered -stable). - - * fixed list nodes that did not extend the Twig_NodeListInterface - * added the "without loop" option to the for tag (it disables the generation of the loop variable) - * refactored node transformers to node visitors - * fixed automatic-escaping for blocks - * added a way to specify variables to pass to an included template - * changed the automatic-escaping rules to be more sensible and more configurable in custom filters (the documentation lists all the rules) - * improved the filter system to allow object methods to be used as filters - * changed the Array and String loaders to actually make use of the cache mechanism - * included the default filter function definitions in the extension class files directly (Core, Escaper) - * added the // operator (like the floor() PHP function) - * added the .. operator (as a syntactic sugar for the range filter when the step is 1) - * added the in operator (as a syntactic sugar for the in filter) - * added the following filters in the Core extension: in, range - * added support for arrays (same behavior as in PHP, a mix between lists and dictionaries, arrays and hashes) - * enhanced some error messages to provide better feedback in case of parsing errors - -* 0.9.4 (2009-12-02) - -If you have custom loaders, you MUST upgrade them for this release: The -Twig_Loader base class has been removed, and the Twig_LoaderInterface has also -been changed (see the source code for more information or the documentation). - - * added support for DateTime instances for the date filter - * fixed loop.last when the array only has one item - * made it possible to insert newlines in tag and variable blocks - * fixed a bug when a literal '\n' were present in a template text - * fixed bug when the filename of a template contains */ - * refactored loaders - -* 0.9.3 (2009-11-11) - -This release is NOT backward compatible with the previous releases. - - The loaders do not take the cache and autoReload arguments anymore. Instead, - the Twig_Environment class has two new options: cache and auto_reload. - Upgrading your code means changing this kind of code: - - $loader = new Twig_Loader_Filesystem('/path/to/templates', '/path/to/compilation_cache', true); - $twig = new Twig_Environment($loader); - - to something like this: - - $loader = new Twig_Loader_Filesystem('/path/to/templates'); - $twig = new Twig_Environment($loader, array( - 'cache' => '/path/to/compilation_cache', - 'auto_reload' => true, - )); - - * deprecated the "items" filter as it is not needed anymore - * made cache and auto_reload options of Twig_Environment instead of arguments of Twig_Loader - * optimized template loading speed - * removed output when an error occurs in a template and render() is used - * made major speed improvements for loops (up to 300% on even the smallest loops) - * added properties as part of the sandbox mode - * added public properties support (obj.item can now be the item property on the obj object) - * extended set tag to support expression as value ({% set foo as 'foo' ~ 'bar' %} ) - * fixed bug when \ was used in HTML - -* 0.9.2 (2009-10-29) - - * made some speed optimizations - * changed the cache extension to .php - * added a js escaping strategy - * added support for short block tag - * changed the filter tag to allow chained filters - * made lexer more flexible as you can now change the default delimiters - * added set tag - * changed default directory permission when cache dir does not exist (more secure) - * added macro support - * changed filters first optional argument to be a Twig_Environment instance instead of a Twig_Template instance - * made Twig_Autoloader::autoload() a static method - * avoid writing template file if an error occurs - * added $ escaping when outputting raw strings - * enhanced some error messages to ease debugging - * fixed empty cache files when the template contains an error - -* 0.9.1 (2009-10-14) - - * fixed a bug in PHP 5.2.6 - * fixed numbers with one than one decimal - * added support for method calls with arguments ({{ foo.bar('a', 43) }}) - * made small speed optimizations - * made minor tweaks to allow better extensibility and flexibility - -* 0.9.0 (2009-10-12) - - * Initial release diff --git a/lib/silex/vendor/twig/twig/LICENSE b/lib/silex/vendor/twig/twig/LICENSE deleted file mode 100644 index b6e17a1a6..000000000 --- a/lib/silex/vendor/twig/twig/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -Copyright (c) 2009-2017 by the Twig Team. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/silex/vendor/twig/twig/README.rst b/lib/silex/vendor/twig/twig/README.rst deleted file mode 100644 index 81737b0b2..000000000 --- a/lib/silex/vendor/twig/twig/README.rst +++ /dev/null @@ -1,15 +0,0 @@ -Twig, the flexible, fast, and secure template language for PHP -============================================================== - -Twig is a template language for PHP, released under the new BSD license (code -and documentation). - -Twig uses a syntax similar to the Django and Jinja template languages which -inspired the Twig runtime environment. - -More Information ----------------- - -Read the `documentation`_ for more information. - -.. _documentation: http://twig.sensiolabs.org/documentation diff --git a/lib/silex/vendor/twig/twig/composer.json b/lib/silex/vendor/twig/twig/composer.json deleted file mode 100644 index 09c1ea5e9..000000000 --- a/lib/silex/vendor/twig/twig/composer.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "twig/twig", - "type": "library", - "description": "Twig, the flexible, fast, and secure template language for PHP", - "keywords": ["templating"], - "homepage": "http://twig.sensiolabs.org", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Twig Team", - "homepage": "http://twig.sensiolabs.org/contributors", - "role": "Contributors" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - } - ], - "support": { - "forum": "https://groups.google.com/forum/#!forum/twig-users" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~3.3@dev", - "symfony/debug": "~2.7", - "psr/container": "^1.0" - }, - "autoload": { - "psr-0" : { - "Twig_" : "lib/" - }, - "psr-4" : { - "Twig\\" : "src/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.35-dev" - } - } -} diff --git a/lib/silex/vendor/twig/twig/doc/advanced.rst b/lib/silex/vendor/twig/twig/doc/advanced.rst deleted file mode 100644 index d86db501e..000000000 --- a/lib/silex/vendor/twig/twig/doc/advanced.rst +++ /dev/null @@ -1,962 +0,0 @@ -Extending Twig -============== - -.. caution:: - - This section describes how to extend Twig as of **Twig 1.12**. If you are - using an older version, read the :doc:`legacy` chapter - instead. - -Twig can be extended in many ways; you can add extra tags, filters, tests, -operators, global variables, and functions. You can even extend the parser -itself with node visitors. - -.. note:: - - The first section of this chapter describes how to extend Twig easily. If - you want to reuse your changes in different projects or if you want to - share them with others, you should then create an extension as described - in the following section. - -.. caution:: - - When extending Twig without creating an extension, Twig won't be able to - recompile your templates when the PHP code is updated. To see your changes - in real-time, either disable template caching or package your code into an - extension (see the next section of this chapter). - -Before extending Twig, you must understand the differences between all the -different possible extension points and when to use them. - -First, remember that Twig has two main language constructs: - -* ``{{ }}``: used to print the result of an expression evaluation; - -* ``{% %}``: used to execute statements. - -To understand why Twig exposes so many extension points, let's see how to -implement a *Lorem ipsum* generator (it needs to know the number of words to -generate). - -You can use a ``lipsum`` *tag*: - -.. code-block:: jinja - - {% lipsum 40 %} - -That works, but using a tag for ``lipsum`` is not a good idea for at least -three main reasons: - -* ``lipsum`` is not a language construct; -* The tag outputs something; -* The tag is not flexible as you cannot use it in an expression: - - .. code-block:: jinja - - {{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }} - -In fact, you rarely need to create tags; and that's good news because tags are -the most complex extension point of Twig. - -Now, let's use a ``lipsum`` *filter*: - -.. code-block:: jinja - - {{ 40|lipsum }} - -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 (so, ``40`` is an argument of the filter, not the value we want to -transform). - -Next, let's use a ``lipsum`` *function*: - -.. code-block:: jinja - - {{ lipsum(40) }} - -Here we go. For this specific example, the creation of a function is the -extension point to use. And you can use it anywhere an expression is accepted: - -.. code-block:: jinja - - {{ 'some text' ~ lipsum(40) ~ 'some more text' }} - - {% set lipsum = lipsum(40) %} - -Last but not the least, you can also use a *global* object with a method able -to generate lorem ipsum text: - -.. code-block:: jinja - - {{ text.lipsum(40) }} - -As a rule of thumb, use functions for frequently used features and global -objects for everything else. - -Keep in mind the following when you want to extend Twig: - -========== ========================== ========== ========================= -What? Implementation difficulty? How often? When? -========== ========================== ========== ========================= -*macro* trivial frequent Content generation -*global* trivial frequent Helper object -*function* trivial frequent Content generation -*filter* trivial frequent Value transformation -*tag* complex rare DSL language construct -*test* trivial rare Boolean decision -*operator* trivial rare Values transformation -========== ========================== ========== ========================= - -Globals -------- - -A global variable is like any other template variable, except that it's -available in all templates and macros:: - - $twig = new Twig_Environment($loader); - $twig->addGlobal('text', new Text()); - -You can then use the ``text`` variable anywhere in a template: - -.. code-block:: jinja - - {{ text.lipsum(40) }} - -Filters -------- - -Creating a filter is as simple as associating a name with a PHP callable:: - - // an anonymous function - $filter = new Twig_SimpleFilter('rot13', function ($string) { - return str_rot13($string); - }); - - // or a simple PHP function - $filter = new Twig_SimpleFilter('rot13', 'str_rot13'); - - // or a class static method - $filter = new Twig_SimpleFilter('rot13', array('SomeClass', 'rot13Filter')); - $filter = new Twig_SimpleFilter('rot13', 'SomeClass::rot13Filter'); - - // or a class method - $filter = new Twig_SimpleFilter('rot13', array($this, 'rot13Filter')); - // the one below needs a runtime implementation (see below for more information) - $filter = new Twig_SimpleFilter('rot13', array('SomeClass', 'rot13Filter')); - -The first argument passed to the ``Twig_SimpleFilter`` constructor is the name -of the filter you will use in templates and the second one is the PHP callable -to associate with it. - -Then, add the filter to your Twig environment:: - - $twig = new Twig_Environment($loader); - $twig->addFilter($filter); - -And here is how to use it in a template: - -.. code-block:: jinja - - {{ 'Twig'|rot13 }} - - {# will output Gjvt #} - -When called by Twig, the PHP callable receives the left side of the filter -(before the pipe ``|``) as the first argument and the extra arguments passed -to the filter (within parentheses ``()``) as extra arguments. - -For instance, the following code: - -.. code-block:: jinja - - {{ 'TWIG'|lower }} - {{ now|date('d/m/Y') }} - -is compiled to something like the following:: - - - - -The ``Twig_SimpleFilter`` class takes an array of options as its last -argument:: - - $filter = new Twig_SimpleFilter('rot13', 'str_rot13', $options); - -Environment-aware Filters -~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you want to access the current environment instance in your filter, set the -``needs_environment`` option to ``true``; Twig will pass the current -environment as the first argument to the filter call:: - - $filter = new Twig_SimpleFilter('rot13', function (Twig_Environment $env, $string) { - // get the current charset for instance - $charset = $env->getCharset(); - - return str_rot13($string); - }, array('needs_environment' => true)); - -Context-aware Filters -~~~~~~~~~~~~~~~~~~~~~ - -If you want to access the current context in your filter, set the -``needs_context`` option to ``true``; Twig will pass the current context as -the first argument to the filter call (or the second one if -``needs_environment`` is also set to ``true``):: - - $filter = new Twig_SimpleFilter('rot13', function ($context, $string) { - // ... - }, array('needs_context' => true)); - - $filter = new Twig_SimpleFilter('rot13', function (Twig_Environment $env, $context, $string) { - // ... - }, array('needs_context' => true, 'needs_environment' => true)); - -Automatic Escaping -~~~~~~~~~~~~~~~~~~ - -If automatic escaping is enabled, the output of the filter may be escaped -before printing. If your filter acts as an escaper (or explicitly outputs HTML -or JavaScript code), you will want the raw output to be printed. In such a -case, set the ``is_safe`` option:: - - $filter = new Twig_SimpleFilter('nl2br', 'nl2br', array('is_safe' => array('html'))); - -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_SimpleFilter('somefilter', 'somefilter', array('pre_escape' => 'html', 'is_safe' => array('html'))); - -Variadic Filters -~~~~~~~~~~~~~~~~ - -.. versionadded:: 1.19 - Support for variadic filters was added in Twig 1.19. - -When a filter should accept an arbitrary number of arguments, set the -``is_variadic`` option to ``true``; Twig will pass the extra arguments as the -last argument to the filter call as an array:: - - $filter = new Twig_SimpleFilter('thumbnail', function ($file, array $options = array()) { - // ... - }, array('is_variadic' => true)); - -Be warned that named arguments passed to a variadic filter cannot be checked -for validity as they will automatically end up in the option array. - -Dynamic Filters -~~~~~~~~~~~~~~~ - -A filter name containing the special ``*`` character is a dynamic filter as -the ``*`` can be any string:: - - $filter = new Twig_SimpleFilter('*_path', function ($name, $arguments) { - // ... - }); - -The following filters will be matched by the above defined dynamic filter: - -* ``product_path`` -* ``category_path`` - -A dynamic filter can define more than one dynamic parts:: - - $filter = new Twig_SimpleFilter('*_path_*', function ($name, $suffix, $arguments) { - // ... - }); - -The filter will receive all dynamic part values before the normal filter -arguments, but after the environment and the context. For instance, a call to -``'foo'|a_path_b()`` will result in the following arguments to be passed to -the filter: ``('a', 'b', 'foo')``. - -Deprecated Filters -~~~~~~~~~~~~~~~~~~ - -.. versionadded:: 1.21 - Support for deprecated filters was added in Twig 1.21. - -You can mark a filter as being deprecated by setting the ``deprecated`` option -to ``true``. You can also give an alternative filter that replaces the -deprecated one when that makes sense:: - - $filter = new Twig_SimpleFilter('obsolete', function () { - // ... - }, array('deprecated' => true, 'alternative' => 'new_one')); - -When a filter is deprecated, Twig emits a deprecation notice when compiling a -template using it. See :ref:`deprecation-notices` for more information. - -Functions ---------- - -Functions are defined in the exact same way as filters, but you need to create -an instance of ``Twig_SimpleFunction``:: - - $twig = new Twig_Environment($loader); - $function = new Twig_SimpleFunction('function_name', function () { - // ... - }); - $twig->addFunction($function); - -Functions support the same features as filters, except for the ``pre_escape`` -and ``preserves_safety`` options. - -Tests ------ - -Tests are defined in the exact same way as filters and functions, but you need -to create an instance of ``Twig_SimpleTest``:: - - $twig = new Twig_Environment($loader); - $test = new Twig_SimpleTest('test_name', function () { - // ... - }); - $twig->addTest($test); - -Tests allow you to create custom application specific logic for evaluating -boolean conditions. As a simple example, let's create a Twig test that checks if -objects are 'red':: - - $twig = new Twig_Environment($loader); - $test = new Twig_SimpleTest('red', function ($value) { - if (isset($value->color) && $value->color == 'red') { - return true; - } - if (isset($value->paint) && $value->paint == 'red') { - return true; - } - return false; - }); - $twig->addTest($test); - -Test functions should always return true/false. - -When creating tests you can use the ``node_class`` option to provide custom test -compilation. This is useful if your test can be compiled into PHP primitives. -This is used by many of the tests built into Twig:: - - $twig = new Twig_Environment($loader); - $test = new Twig_SimpleTest( - 'odd', - null, - array('node_class' => 'Twig_Node_Expression_Test_Odd')); - $twig->addTest($test); - - class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test - { - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('node')) - ->raw(' % 2 == 1') - ->raw(')') - ; - } - } - -The above example shows how you can create tests that use a node class. The -node class has access to one sub-node called 'node'. This sub-node contains the -value that is being tested. When the ``odd`` filter is used in code such as: - -.. code-block:: jinja - - {% if my_value is odd %} - -The ``node`` sub-node will contain an expression of ``my_value``. Node-based -tests also have access to the ``arguments`` node. This node will contain the -various other arguments that have been provided to your test. - -If you want to pass a variable number of positional or named arguments to the -test, set the ``is_variadic`` option to ``true``. Tests also support dynamic -name feature as filters and functions. - -Tags ----- - -One of the most exciting features of a template engine like Twig is the -possibility to define new language constructs. This is also the most complex -feature as you need to understand how Twig's internals work. - -Let's create a simple ``set`` tag that allows the definition of simple -variables from within a template. The tag can be used like follows: - -.. code-block:: jinja - - {% set name = "value" %} - - {{ name }} - - {# should output value #} - -.. note:: - - The ``set`` tag is part of the Core extension and as such is always - available. The built-in version is slightly more powerful and supports - multiple assignments by default (cf. the template designers chapter for - more information). - -Three steps are needed to define a new tag: - -* Defining a Token Parser class (responsible for parsing the template code); - -* Defining a Node class (responsible for converting the parsed code to PHP); - -* Registering the tag. - -Registering a new tag -~~~~~~~~~~~~~~~~~~~~~ - -Adding a tag is as simple as calling the ``addTokenParser`` method on the -``Twig_Environment`` instance:: - - $twig = new Twig_Environment($loader); - $twig->addTokenParser(new Project_Set_TokenParser()); - -Defining a Token Parser -~~~~~~~~~~~~~~~~~~~~~~~ - -Now, let's see the actual code of this class:: - - class Project_Set_TokenParser extends Twig_TokenParser - { - public function parse(Twig_Token $token) - { - $parser = $this->parser; - $stream = $parser->getStream(); - - $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - $stream->expect(Twig_Token::OPERATOR_TYPE, '='); - $value = $parser->getExpressionParser()->parseExpression(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return new Project_Set_Node($name, $value, $token->getLine(), $this->getTag()); - } - - public function getTag() - { - return 'set'; - } - } - -The ``getTag()`` method must return the tag we want to parse, here ``set``. - -The ``parse()`` method is invoked whenever the parser encounters a ``set`` -tag. It should return a ``Twig_Node`` instance that represents the node (the -``Project_Set_Node`` calls creating is explained in the next section). - -The parsing process is simplified thanks to a bunch of methods you can call -from the token stream (``$this->parser->getStream()``): - -* ``getCurrent()``: Gets the current token in the stream. - -* ``next()``: Moves to the next token in the stream, *but returns the old one*. - -* ``test($type)``, ``test($value)`` or ``test($type, $value)``: Determines whether - the current token is of a particular type or value (or both). The value may be an - array of several possible values. - -* ``expect($type[, $value[, $message]])``: If the current token isn't of the given - type/value a syntax error is thrown. Otherwise, if the type and value are correct, - the token is returned and the stream moves to the next token. - -* ``look()``: Looks at the next token without consuming it. - -Parsing expressions is done by calling the ``parseExpression()`` like we did for -the ``set`` tag. - -.. tip:: - - Reading the existing ``TokenParser`` classes is the best way to learn all - the nitty-gritty details of the parsing process. - -Defining a Node -~~~~~~~~~~~~~~~ - -The ``Project_Set_Node`` class itself is rather simple:: - - class Project_Set_Node extends Twig_Node - { - public function __construct($name, Twig_Node_Expression $value, $line, $tag = null) - { - parent::__construct(array('value' => $value), array('name' => $name), $line, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write('$context[\''.$this->getAttribute('name').'\'] = ') - ->subcompile($this->getNode('value')) - ->raw(";\n") - ; - } - } - -The compiler implements a fluid interface and provides methods that helps the -developer generate beautiful and readable PHP code: - -* ``subcompile()``: Compiles a node. - -* ``raw()``: Writes the given string as is. - -* ``write()``: Writes the given string by adding indentation at the beginning - of each line. - -* ``string()``: Writes a quoted string. - -* ``repr()``: Writes a PHP representation of a given value (see - ``Twig_Node_For`` for a usage example). - -* ``addDebugInfo()``: Adds the line of the original template file related to - the current node as a comment. - -* ``indent()``: Indents the generated code (see ``Twig_Node_Block`` for a - usage example). - -* ``outdent()``: Outdents the generated code (see ``Twig_Node_Block`` for a - usage example). - -.. _creating_extensions: - -Creating an Extension ---------------------- - -The main motivation for writing an extension is to move often used code into a -reusable class like adding support for internationalization. An extension can -define tags, filters, tests, operators, global variables, functions, and node -visitors. - -Most of the time, it is useful to create a single extension for your project, -to host all the specific tags and filters you want to add to Twig. - -.. tip:: - - When packaging your code into an extension, Twig is smart enough to - recompile your templates whenever you make a change to it (when - ``auto_reload`` is enabled). - -.. note:: - - Before writing your own extensions, have a look at the Twig official - extension repository: http://github.com/twigphp/Twig-extensions. - -An extension is a class that implements the following interface:: - - interface Twig_ExtensionInterface - { - /** - * Initializes the runtime environment. - * - * This is where you can load some file that contains filter functions for instance. - * - * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead - */ - function initRuntime(Twig_Environment $environment); - - /** - * Returns the token parser instances to add to the existing list. - * - * @return (Twig_TokenParserInterface|Twig_TokenParserBrokerInterface)[] - */ - function getTokenParsers(); - - /** - * Returns the node visitor instances to add to the existing list. - * - * @return Twig_NodeVisitorInterface[] - */ - function getNodeVisitors(); - - /** - * Returns a list of filters to add to the existing list. - * - * @return Twig_SimpleFilter[] - */ - function getFilters(); - - /** - * Returns a list of tests to add to the existing list. - * - * @return Twig_SimpleTest[] - */ - function getTests(); - - /** - * Returns a list of functions to add to the existing list. - * - * @return Twig_SimpleFunction[] - */ - function getFunctions(); - - /** - * Returns a list of operators to add to the existing list. - * - * @return array First array of unary operators, second array of binary operators - */ - function getOperators(); - - /** - * Returns a list of global variables to add to the existing list. - * - * @return array An array of global variables - * - * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead - */ - function getGlobals(); - - /** - * Returns the name of the extension. - * - * @return string The extension name - * - * @deprecated since 1.26 (to be removed in 2.0), not used anymore internally - */ - function getName(); - } - -To keep your extension class clean and lean, inherit from the built-in -``Twig_Extension`` class instead of implementing the interface as it provides -empty implementations for all methods: - - class Project_Twig_Extension extends Twig_Extension - { - } - -Of course, this extension does nothing for now. We will customize it in the -next sections. - -.. note:: - - Prior to Twig 1.26, you must implement the ``getName()`` method which must - return a unique identifier for the extension. - -Twig does not care where you save your extension on the filesystem, as all -extensions must be registered explicitly to be available in your templates. - -You can register an extension by using the ``addExtension()`` method on your -main ``Environment`` object:: - - $twig = new Twig_Environment($loader); - $twig->addExtension(new Project_Twig_Extension()); - -.. tip:: - - The Twig core extensions are great examples of how extensions work. - -Globals -~~~~~~~ - -Global variables can be registered in an extension via the ``getGlobals()`` -method:: - - class Project_Twig_Extension extends Twig_Extension implements Twig_Extension_GlobalsInterface - { - public function getGlobals() - { - return array( - 'text' => new Text(), - ); - } - - // ... - } - -Functions -~~~~~~~~~ - -Functions can be registered in an extension via the ``getFunctions()`` -method:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getFunctions() - { - return array( - new Twig_SimpleFunction('lipsum', 'generate_lipsum'), - ); - } - - // ... - } - -Filters -~~~~~~~ - -To add a filter to an extension, you need to override the ``getFilters()`` -method. This method must return an array of filters to add to the Twig -environment:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getFilters() - { - return array( - new Twig_SimpleFilter('rot13', 'str_rot13'), - ); - } - - // ... - } - -Tags -~~~~ - -Adding a tag in an extension can be done by overriding the -``getTokenParsers()`` method. This method must return an array of tags to add -to the Twig environment:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getTokenParsers() - { - return array(new Project_Set_TokenParser()); - } - - // ... - } - -In the above code, we have added a single new tag, defined by the -``Project_Set_TokenParser`` class. The ``Project_Set_TokenParser`` class is -responsible for parsing the tag and compiling it to PHP. - -Operators -~~~~~~~~~ - -The ``getOperators()`` methods lets you add new operators. Here is how to add -``!``, ``||``, and ``&&`` operators:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getOperators() - { - return array( - array( - '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), - ), - array( - '||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - ), - ); - } - - // ... - } - -Tests -~~~~~ - -The ``getTests()`` method lets you add new test functions:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getTests() - { - return array( - new Twig_SimpleTest('even', 'twig_test_even'), - ); - } - - // ... - } - -Definition vs Runtime -~~~~~~~~~~~~~~~~~~~~~ - -Twig filters, functions, and tests runtime implementations can be defined as -any valid PHP callable: - -* **functions/static methods**: Simple to implement and fast (used by all Twig - core extensions); but it is hard for the runtime to depend on external - objects; - -* **closures**: Simple to implement; - -* **object methods**: More flexible and required if your runtime code depends - on external objects. - -The simplest way to use methods is to define them on the extension itself:: - - class Project_Twig_Extension extends Twig_Extension - { - private $rot13Provider; - - public function __construct($rot13Provider) - { - $this->rot13Provider = $rot13Provider; - } - - public function getFunctions() - { - return array( - new Twig_SimpleFunction('rot13', array($this, 'rot13')), - ); - } - - public function rot13($value) - { - return $rot13Provider->rot13($value); - } - } - -This is very convenient but not recommended as it makes template compilation -depend on runtime dependencies even if they are not needed (think for instance -as a dependency that connects to a database engine). - -As of Twig 1.26, you can easily decouple the extension definitions from their -runtime implementations by registering a ``Twig_RuntimeLoaderInterface`` -instance on the environment that knows how to instantiate such runtime classes -(runtime classes must be autoload-able):: - - class RuntimeLoader implements Twig_RuntimeLoaderInterface - { - public function load($class) - { - // implement the logic to create an instance of $class - // and inject its dependencies - // most of the time, it means using your dependency injection container - if ('Project_Twig_RuntimeExtension' === $class) { - return new $class(new Rot13Provider()); - } else { - // ... - } - } - } - - $twig->addRuntimeLoader(new RuntimeLoader()); - -.. note:: - - As of Twig 1.32, Twig comes with a PSR-11 compatible runtime loader - (``Twig_ContainerRuntimeLoader``) that works on PHP 5.3+. - -It is now possible to move the runtime logic to a new -``Project_Twig_RuntimeExtension`` class and use it directly in the extension:: - - class Project_Twig_RuntimeExtension - { - private $rot13Provider; - - public function __construct($rot13Provider) - { - $this->rot13Provider = $rot13Provider; - } - - public function rot13($value) - { - return $rot13Provider->rot13($value); - } - } - - class Project_Twig_Extension extends Twig_Extension - { - public function getFunctions() - { - return array( - new Twig_SimpleFunction('rot13', array('Project_Twig_RuntimeExtension', 'rot13')), - // or - new Twig_SimpleFunction('rot13', 'Project_Twig_RuntimeExtension::rot13'), - ); - } - } - -Overloading ------------ - -To overload an already defined filter, test, operator, global variable, or -function, re-define it in an extension and register it **as late as -possible** (order matters):: - - class MyCoreExtension extends Twig_Extension - { - public function getFilters() - { - return array( - new Twig_SimpleFilter('date', array($this, 'dateFilter')), - ); - } - - public function dateFilter($timestamp, $format = 'F j, Y H:i') - { - // do something different from the built-in date filter - } - } - - $twig = new Twig_Environment($loader); - $twig->addExtension(new MyCoreExtension()); - -Here, we have overloaded the built-in ``date`` filter with a custom one. - -If you do the same on the ``Twig_Environment`` itself, beware that it takes -precedence over any other registered extensions:: - - $twig = new Twig_Environment($loader); - $twig->addFilter(new Twig_SimpleFilter('date', function ($timestamp, $format = 'F j, Y H:i') { - // do something different from the built-in date filter - })); - // the date filter will come from the above registration, not - // from the registered extension below - $twig->addExtension(new MyCoreExtension()); - -.. caution:: - - Note that overloading the built-in Twig elements is not recommended as it - might be confusing. - -Testing an Extension --------------------- - -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. - -.. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php -.. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Fixtures -.. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Node diff --git a/lib/silex/vendor/twig/twig/doc/advanced_legacy.rst b/lib/silex/vendor/twig/twig/doc/advanced_legacy.rst deleted file mode 100644 index 33e9f45a4..000000000 --- a/lib/silex/vendor/twig/twig/doc/advanced_legacy.rst +++ /dev/null @@ -1,885 +0,0 @@ -Extending Twig -============== - -.. caution:: - - This section describes how to extends Twig for versions **older than - 1.12**. If you are using a newer version, read the :doc:`newer` - chapter instead. - -Twig can be extended in many ways; you can add extra tags, filters, tests, -operators, global variables, and functions. You can even extend the parser -itself with node visitors. - -.. note:: - - The first section of this chapter describes how to extend Twig easily. If - you want to reuse your changes in different projects or if you want to - share them with others, you should then create an extension as described - in the following section. - -.. caution:: - - When extending Twig by calling methods on the Twig environment instance, - Twig won't be able to recompile your templates when the PHP code is - updated. To see your changes in real-time, either disable template caching - or package your code into an extension (see the next section of this - chapter). - -Before extending Twig, you must understand the differences between all the -different possible extension points and when to use them. - -First, remember that Twig has two main language constructs: - -* ``{{ }}``: used to print the result of an expression evaluation; - -* ``{% %}``: used to execute statements. - -To understand why Twig exposes so many extension points, let's see how to -implement a *Lorem ipsum* generator (it needs to know the number of words to -generate). - -You can use a ``lipsum`` *tag*: - -.. code-block:: jinja - - {% lipsum 40 %} - -That works, but using a tag for ``lipsum`` is not a good idea for at least -three main reasons: - -* ``lipsum`` is not a language construct; -* The tag outputs something; -* The tag is not flexible as you cannot use it in an expression: - - .. code-block:: jinja - - {{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }} - -In fact, you rarely need to create tags; and that's good news because tags are -the most complex extension point of Twig. - -Now, let's use a ``lipsum`` *filter*: - -.. code-block:: jinja - - {{ 40|lipsum }} - -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 (so, ``40`` is an argument of the filter, not the value we want to -transform). - -Next, let's use a ``lipsum`` *function*: - -.. code-block:: jinja - - {{ lipsum(40) }} - -Here we go. For this specific example, the creation of a function is the -extension point to use. And you can use it anywhere an expression is accepted: - -.. code-block:: jinja - - {{ 'some text' ~ ipsum(40) ~ 'some more text' }} - - {% set ipsum = ipsum(40) %} - -Last but not the least, you can also use a *global* object with a method able -to generate lorem ipsum text: - -.. code-block:: jinja - - {{ text.lipsum(40) }} - -As a rule of thumb, use functions for frequently used features and global -objects for everything else. - -Keep in mind the following when you want to extend Twig: - -========== ========================== ========== ========================= -What? Implementation difficulty? How often? When? -========== ========================== ========== ========================= -*macro* trivial frequent Content generation -*global* trivial frequent Helper object -*function* trivial frequent Content generation -*filter* trivial frequent Value transformation -*tag* complex rare DSL language construct -*test* trivial rare Boolean decision -*operator* trivial rare Values transformation -========== ========================== ========== ========================= - -Globals -------- - -A global variable is like any other template variable, except that it's -available in all templates and macros:: - - $twig = new Twig_Environment($loader); - $twig->addGlobal('text', new Text()); - -You can then use the ``text`` variable anywhere in a template: - -.. code-block:: jinja - - {{ text.lipsum(40) }} - -Filters -------- - -A filter is a regular PHP function or an object method that takes the left -side of the filter (before the pipe ``|``) as first argument and the extra -arguments passed to the filter (within parentheses ``()``) as extra arguments. - -Defining a filter is as easy as associating the filter name with a PHP -callable. For instance, let's say you have the following code in a template: - -.. code-block:: jinja - - {{ 'TWIG'|lower }} - -When compiling this template to PHP, Twig looks for the PHP callable -associated with the ``lower`` filter. The ``lower`` filter is a built-in Twig -filter, and it is simply mapped to the PHP ``strtolower()`` function. After -compilation, the generated PHP code is roughly equivalent to: - -.. code-block:: html+php - - - -As you can see, the ``'TWIG'`` string is passed as a first argument to the PHP -function. - -A filter can also take extra arguments like in the following example: - -.. code-block:: jinja - - {{ now|date('d/m/Y') }} - -In this case, the extra arguments are passed to the function after the main -argument, and the compiled code is equivalent to: - -.. code-block:: html+php - - - -Let's see how to create a new filter. - -In this section, we will create a ``rot13`` filter, which should return the -`rot13`_ transformation of a string. Here is an example of its usage and the -expected output: - -.. code-block:: jinja - - {{ "Twig"|rot13 }} - - {# should displays Gjvt #} - -Adding a filter is as simple as calling the ``addFilter()`` method on the -``Twig_Environment`` instance:: - - $twig = new Twig_Environment($loader); - $twig->addFilter('rot13', new Twig_Filter_Function('str_rot13')); - -The second argument of ``addFilter()`` is an instance of ``Twig_Filter``. -Here, we use ``Twig_Filter_Function`` as the filter is a PHP function. The -first argument passed to the ``Twig_Filter_Function`` constructor is the name -of the PHP function to call, here ``str_rot13``, a native PHP function. - -Let's say I now want to be able to add a prefix before the converted string: - -.. code-block:: jinja - - {{ "Twig"|rot13('prefix_') }} - - {# should displays prefix_Gjvt #} - -As the PHP ``str_rot13()`` function does not support this requirement, let's -create a new PHP function:: - - function project_compute_rot13($string, $prefix = '') - { - return $prefix.str_rot13($string); - } - -As you can see, the ``prefix`` argument of the filter is passed as an extra -argument to the ``project_compute_rot13()`` function. - -Adding this filter is as easy as before:: - - $twig->addFilter('rot13', new Twig_Filter_Function('project_compute_rot13')); - -For better encapsulation, a filter can also be defined as a static method of a -class. The ``Twig_Filter_Function`` class can also be used to register such -static methods as filters:: - - $twig->addFilter('rot13', new Twig_Filter_Function('SomeClass::rot13Filter')); - -.. tip:: - - In an extension, you can also define a filter as a static method of the - extension class. - -Environment aware Filters -~~~~~~~~~~~~~~~~~~~~~~~~~ - -The ``Twig_Filter`` classes take options as their last argument. For instance, -if you want access to the current environment instance in your filter, set the -``needs_environment`` option to ``true``:: - - $filter = new Twig_Filter_Function('str_rot13', array('needs_environment' => true)); - -Twig will then pass the current environment as the first argument to the -filter call:: - - function twig_compute_rot13(Twig_Environment $env, $string) - { - // get the current charset for instance - $charset = $env->getCharset(); - - return str_rot13($string); - } - -Automatic Escaping -~~~~~~~~~~~~~~~~~~ - -If automatic escaping is enabled, the output of the filter may be escaped -before printing. If your filter acts as an escaper (or explicitly outputs HTML -or JavaScript code), you will want the raw output to be printed. In such a -case, set the ``is_safe`` option:: - - $filter = new Twig_Filter_Function('nl2br', array('is_safe' => array('html'))); - -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'))); - -Dynamic Filters -~~~~~~~~~~~~~~~ - -.. versionadded:: 1.5 - Dynamic filters support was added in Twig 1.5. - -A filter name containing the special ``*`` character is a dynamic filter as -the ``*`` can be any string:: - - $twig->addFilter('*_path_*', new Twig_Filter_Function('twig_path')); - - function twig_path($name, $arguments) - { - // ... - } - -The following filters will be matched by the above defined dynamic filter: - -* ``product_path`` -* ``category_path`` - -A dynamic filter can define more than one dynamic parts:: - - $twig->addFilter('*_path_*', new Twig_Filter_Function('twig_path')); - - function twig_path($name, $suffix, $arguments) - { - // ... - } - -The filter will receive all dynamic part values before the normal filters -arguments. For instance, a call to ``'foo'|a_path_b()`` will result in the -following PHP call: ``twig_path('a', 'b', 'foo')``. - -Functions ---------- - -A function is a regular PHP function or an object method that can be called from -templates. - -.. code-block:: jinja - - {{ constant("DATE_W3C") }} - -When compiling this template to PHP, Twig looks for the PHP callable -associated with the ``constant`` function. The ``constant`` function is a built-in Twig -function, and it is simply mapped to the PHP ``constant()`` function. After -compilation, the generated PHP code is roughly equivalent to: - -.. code-block:: html+php - - - -Adding a function is similar to adding a filter. This can be done by calling the -``addFunction()`` method on the ``Twig_Environment`` instance:: - - $twig = new Twig_Environment($loader); - $twig->addFunction('functionName', new Twig_Function_Function('someFunction')); - -You can also expose extension methods as functions in your templates:: - - // $this is an object that implements Twig_ExtensionInterface. - $twig = new Twig_Environment($loader); - $twig->addFunction('otherFunction', new Twig_Function_Method($this, 'someMethod')); - -Functions also support ``needs_environment`` and ``is_safe`` parameters. - -Dynamic Functions -~~~~~~~~~~~~~~~~~ - -.. versionadded:: 1.5 - Dynamic functions support was added in Twig 1.5. - -A function name containing the special ``*`` character is a dynamic function -as the ``*`` can be any string:: - - $twig->addFunction('*_path', new Twig_Function_Function('twig_path')); - - function twig_path($name, $arguments) - { - // ... - } - -The following functions will be matched by the above defined dynamic function: - -* ``product_path`` -* ``category_path`` - -A dynamic function can define more than one dynamic parts:: - - $twig->addFilter('*_path_*', new Twig_Filter_Function('twig_path')); - - function twig_path($name, $suffix, $arguments) - { - // ... - } - -The function will receive all dynamic part values before the normal functions -arguments. For instance, a call to ``a_path_b('foo')`` will result in the -following PHP call: ``twig_path('a', 'b', 'foo')``. - -Tags ----- - -One of the most exciting feature of a template engine like Twig is the -possibility to define new language constructs. This is also the most complex -feature as you need to understand how Twig's internals work. - -Let's create a simple ``set`` tag that allows the definition of simple -variables from within a template. The tag can be used like follows: - -.. code-block:: jinja - - {% set name = "value" %} - - {{ name }} - - {# should output value #} - -.. note:: - - The ``set`` tag is part of the Core extension and as such is always - available. The built-in version is slightly more powerful and supports - multiple assignments by default (cf. the template designers chapter for - more information). - -Three steps are needed to define a new tag: - -* Defining a Token Parser class (responsible for parsing the template code); - -* Defining a Node class (responsible for converting the parsed code to PHP); - -* Registering the tag. - -Registering a new tag -~~~~~~~~~~~~~~~~~~~~~ - -Adding a tag is as simple as calling the ``addTokenParser`` method on the -``Twig_Environment`` instance:: - - $twig = new Twig_Environment($loader); - $twig->addTokenParser(new Project_Set_TokenParser()); - -Defining a Token Parser -~~~~~~~~~~~~~~~~~~~~~~~ - -Now, let's see the actual code of this class:: - - class Project_Set_TokenParser extends Twig_TokenParser - { - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $name = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(); - $this->parser->getStream()->expect(Twig_Token::OPERATOR_TYPE, '='); - $value = $this->parser->getExpressionParser()->parseExpression(); - - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return new Project_Set_Node($name, $value, $lineno, $this->getTag()); - } - - public function getTag() - { - return 'set'; - } - } - -The ``getTag()`` method must return the tag we want to parse, here ``set``. - -The ``parse()`` method is invoked whenever the parser encounters a ``set`` -tag. It should return a ``Twig_Node`` instance that represents the node (the -``Project_Set_Node`` calls creating is explained in the next section). - -The parsing process is simplified thanks to a bunch of methods you can call -from the token stream (``$this->parser->getStream()``): - -* ``getCurrent()``: Gets the current token in the stream. - -* ``next()``: Moves to the next token in the stream, *but returns the old one*. - -* ``test($type)``, ``test($value)`` or ``test($type, $value)``: Determines whether - the current token is of a particular type or value (or both). The value may be an - array of several possible values. - -* ``expect($type[, $value[, $message]])``: If the current token isn't of the given - type/value a syntax error is thrown. Otherwise, if the type and value are correct, - the token is returned and the stream moves to the next token. - -* ``look()``: Looks a the next token without consuming it. - -Parsing expressions is done by calling the ``parseExpression()`` like we did for -the ``set`` tag. - -.. tip:: - - Reading the existing ``TokenParser`` classes is the best way to learn all - the nitty-gritty details of the parsing process. - -Defining a Node -~~~~~~~~~~~~~~~ - -The ``Project_Set_Node`` class itself is rather simple:: - - class Project_Set_Node extends Twig_Node - { - public function __construct($name, Twig_Node_Expression $value, $lineno, $tag = null) - { - parent::__construct(array('value' => $value), array('name' => $name), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write('$context[\''.$this->getAttribute('name').'\'] = ') - ->subcompile($this->getNode('value')) - ->raw(";\n") - ; - } - } - -The compiler implements a fluid interface and provides methods that helps the -developer generate beautiful and readable PHP code: - -* ``subcompile()``: Compiles a node. - -* ``raw()``: Writes the given string as is. - -* ``write()``: Writes the given string by adding indentation at the beginning - of each line. - -* ``string()``: Writes a quoted string. - -* ``repr()``: Writes a PHP representation of a given value (see - ``Twig_Node_For`` for a usage example). - -* ``addDebugInfo()``: Adds the line of the original template file related to - the current node as a comment. - -* ``indent()``: Indents the generated code (see ``Twig_Node_Block`` for a - usage example). - -* ``outdent()``: Outdents the generated code (see ``Twig_Node_Block`` for a - usage example). - -.. _creating_extensions: - -Creating an Extension ---------------------- - -The main motivation for writing an extension is to move often used code into a -reusable class like adding support for internationalization. An extension can -define tags, filters, tests, operators, global variables, functions, and node -visitors. - -Creating an extension also makes for a better separation of code that is -executed at compilation time and code needed at runtime. As such, it makes -your code faster. - -Most of the time, it is useful to create a single extension for your project, -to host all the specific tags and filters you want to add to Twig. - -.. tip:: - - When packaging your code into an extension, Twig is smart enough to - recompile your templates whenever you make a change to it (when the - ``auto_reload`` is enabled). - -.. note:: - - Before writing your own extensions, have a look at the Twig official - extension repository: http://github.com/twigphp/Twig-extensions. - -An extension is a class that implements the following interface:: - - interface Twig_ExtensionInterface - { - /** - * Initializes the runtime environment. - * - * This is where you can load some file that contains filter functions for instance. - */ - function initRuntime(Twig_Environment $environment); - - /** - * Returns the token parser instances to add to the existing list. - * - * @return (Twig_TokenParserInterface|Twig_TokenParserBrokerInterface)[] - */ - function getTokenParsers(); - - /** - * Returns the node visitor instances to add to the existing list. - * - * @return Twig_NodeVisitorInterface[] - */ - function getNodeVisitors(); - - /** - * Returns a list of filters to add to the existing list. - * - * @return Twig_SimpleFilter[] - */ - function getFilters(); - - /** - * Returns a list of tests to add to the existing list. - * - * @return Twig_SimpleTest[] - */ - function getTests(); - - /** - * Returns a list of functions to add to the existing list. - * - * @return Twig_SimpleFunction[] - */ - function getFunctions(); - - /** - * Returns a list of operators to add to the existing list. - * - * @return array First array of unary operators, second array of binary operators - */ - function getOperators(); - - /** - * Returns a list of global variables to add to the existing list. - * - * @return array An array of global variables - */ - function getGlobals(); - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - function getName(); - } - -To keep your extension class clean and lean, it can inherit from the built-in -``Twig_Extension`` class instead of implementing the whole interface. That -way, you just need to implement the ``getName()`` method as the -``Twig_Extension`` provides empty implementations for all other methods. - -The ``getName()`` method must return a unique identifier for your extension. - -Now, with this information in mind, let's create the most basic extension -possible:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getName() - { - return 'project'; - } - } - -.. note:: - - Of course, this extension does nothing for now. We will customize it in - the next sections. - -Twig does not care where you save your extension on the filesystem, as all -extensions must be registered explicitly to be available in your templates. - -You can register an extension by using the ``addExtension()`` method on your -main ``Environment`` object:: - - $twig = new Twig_Environment($loader); - $twig->addExtension(new Project_Twig_Extension()); - -Of course, you need to first load the extension file by either using -``require_once()`` or by using an autoloader (see `spl_autoload_register()`_). - -.. tip:: - - The bundled extensions are great examples of how extensions work. - -Globals -~~~~~~~ - -Global variables can be registered in an extension via the ``getGlobals()`` -method:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getGlobals() - { - return array( - 'text' => new Text(), - ); - } - - // ... - } - -Functions -~~~~~~~~~ - -Functions can be registered in an extension via the ``getFunctions()`` -method:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getFunctions() - { - return array( - 'lipsum' => new Twig_Function_Function('generate_lipsum'), - ); - } - - // ... - } - -Filters -~~~~~~~ - -To add a filter to an extension, you need to override the ``getFilters()`` -method. This method must return an array of filters to add to the Twig -environment:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getFilters() - { - return array( - 'rot13' => new Twig_Filter_Function('str_rot13'), - ); - } - - // ... - } - -As you can see in the above code, the ``getFilters()`` method returns an array -where keys are the name of the filters (``rot13``) and the values the -definition of the filter (``new Twig_Filter_Function('str_rot13')``). - -As seen in the previous chapter, you can also define filters as static methods -on the extension class:: - -$twig->addFilter('rot13', new Twig_Filter_Function('Project_Twig_Extension::rot13Filter')); - -You can also use ``Twig_Filter_Method`` instead of ``Twig_Filter_Function`` -when defining a filter to use a method:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getFilters() - { - return array( - 'rot13' => new Twig_Filter_Method($this, 'rot13Filter'), - ); - } - - public function rot13Filter($string) - { - return str_rot13($string); - } - - // ... - } - -The first argument of the ``Twig_Filter_Method`` constructor is always -``$this``, the current extension object. The second one is the name of the -method to call. - -Using methods for filters is a great way to package your filter without -polluting the global namespace. This also gives the developer more flexibility -at the cost of a small overhead. - -Overriding default Filters -.......................... - -If some default core filters do not suit your needs, you can easily override -them by creating your own extension. Just use the same names as the one you -want to override:: - - class MyCoreExtension extends Twig_Extension - { - public function getFilters() - { - return array( - 'date' => new Twig_Filter_Method($this, 'dateFilter'), - // ... - ); - } - - public function dateFilter($timestamp, $format = 'F j, Y H:i') - { - return '...'.twig_date_format_filter($timestamp, $format); - } - - public function getName() - { - return 'project'; - } - } - -Here, we override the ``date`` filter with a custom one. Using this extension -is as simple as registering the ``MyCoreExtension`` extension by calling the -``addExtension()`` method on the environment instance:: - - $twig = new Twig_Environment($loader); - $twig->addExtension(new MyCoreExtension()); - -Tags -~~~~ - -Adding a tag in an extension can be done by overriding the -``getTokenParsers()`` method. This method must return an array of tags to add -to the Twig environment:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getTokenParsers() - { - return array(new Project_Set_TokenParser()); - } - - // ... - } - -In the above code, we have added a single new tag, defined by the -``Project_Set_TokenParser`` class. The ``Project_Set_TokenParser`` class is -responsible for parsing the tag and compiling it to PHP. - -Operators -~~~~~~~~~ - -The ``getOperators()`` methods allows to add new operators. Here is how to add -``!``, ``||``, and ``&&`` operators:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getOperators() - { - return array( - array( - '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), - ), - array( - '||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - ), - ); - } - - // ... - } - -Tests -~~~~~ - -The ``getTests()`` methods allows to add new test functions:: - - class Project_Twig_Extension extends Twig_Extension - { - public function getTests() - { - return array( - 'even' => new Twig_Test_Function('twig_test_even'), - ); - } - - // ... - } - -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 -.. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Fixtures -.. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Node diff --git a/lib/silex/vendor/twig/twig/doc/api.rst b/lib/silex/vendor/twig/twig/doc/api.rst deleted file mode 100644 index 8be2b8af8..000000000 --- a/lib/silex/vendor/twig/twig/doc/api.rst +++ /dev/null @@ -1,590 +0,0 @@ -Twig for Developers -=================== - -This chapter describes the API to Twig and not the template language. It will -be most useful as reference to those implementing the template interface to -the application and not those who are creating Twig templates. - -Basics ------- - -Twig uses a central object called the **environment** (of class -``Twig_Environment``). Instances of this class are used to store the -configuration and extensions, and are used to load templates from the file -system or other locations. - -Most applications will create one ``Twig_Environment`` object on application -initialization and use that to load templates. In some cases it's however -useful to have multiple environments side by side, if different configurations -are in use. - -The simplest way to configure Twig to load templates for your application -looks roughly like this:: - - require_once '/path/to/lib/Twig/Autoloader.php'; - Twig_Autoloader::register(); - - $loader = new Twig_Loader_Filesystem('/path/to/templates'); - $twig = new Twig_Environment($loader, array( - 'cache' => '/path/to/compilation_cache', - )); - -This will create a template environment with the default settings and a loader -that looks up the templates in the ``/path/to/templates/`` folder. Different -loaders are available and you can also write your own if you want to load -templates from a database or other resources. - -.. note:: - - Notice that the second argument of the environment is an array of options. - The ``cache`` option is a compilation cache directory, where Twig caches - the compiled templates to avoid the parsing phase for sub-sequent - requests. It is very different from the cache you might want to add for - the evaluated templates. For such a need, you can use any available PHP - cache library. - -Rendering Templates -------------------- - -To load a template from a Twig environment, call the ``load()`` method which -returns a ``Twig_TemplateWrapper`` instance:: - - $template = $twig->load('index.html'); - -.. note:: - - Before Twig 1.28, you should use ``loadTemplate()`` instead which returns a - ``Twig_Template`` instance. - -To render the template with some variables, call the ``render()`` method:: - - echo $template->render(array('the' => 'variables', 'go' => 'here')); - -.. note:: - - The ``display()`` method is a shortcut to output the template directly. - -You can also load and render the template in one fell swoop:: - - echo $twig->render('index.html', array('the' => 'variables', 'go' => 'here')); - -.. versionadded:: 1.28 - The possibility to render blocks from the API was added in Twig 1.28. - -If a template defines blocks, they can be rendered individually via the -``renderBlock()`` call:: - - echo $template->renderBlock('block_name', array('the' => 'variables', 'go' => 'here')); - -.. _environment_options: - -Environment Options -------------------- - -When creating a new ``Twig_Environment`` instance, you can pass an array of -options as the constructor second argument:: - - $twig = new Twig_Environment($loader, array('debug' => true)); - -The following options are available: - -* ``debug`` *boolean* - - When set to ``true``, the generated templates have a - ``__toString()`` method that you can use to display the generated nodes - (default to ``false``). - -* ``charset`` *string* (defaults to ``utf-8``) - - The charset used by the templates. - -* ``base_template_class`` *string* (defaults to ``Twig_Template``) - - The base template class to use for generated - templates. - -* ``cache`` *string* or ``false`` - - An absolute path where to store the compiled templates, or - ``false`` to disable caching (which is the default). - -* ``auto_reload`` *boolean* - - When developing with Twig, it's useful to recompile the - template whenever the source code changes. If you don't provide a value for - the ``auto_reload`` option, it will be determined automatically based on the - ``debug`` value. - -* ``strict_variables`` *boolean* - - If set to ``false``, Twig will silently ignore invalid - variables (variables and or attributes/methods that do not exist) and - replace them with a ``null`` value. When set to ``true``, Twig throws an - exception instead (default to ``false``). - -* ``autoescape`` *string* or *boolean* - - If set to ``true``, HTML 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). - - 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 name and must - return the escaping strategy to use -- the callback cannot be a function name - to avoid collision with built-in escaping strategies). - - As of Twig 1.17, the ``filename`` escaping strategy (renamed to ``name`` as - of Twig 1.27) determines the escaping strategy to use for a template based on - the template filename extension (this strategy does not incur any overhead at - runtime as auto-escaping is done at compilation time.) - -* ``optimizations`` *integer* - - A flag that indicates which optimizations to apply - (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to - disable). - -Loaders -------- - -Loaders are responsible for loading templates from a resource such as the file -system. - -Compilation Cache -~~~~~~~~~~~~~~~~~ - -All template loaders can cache the compiled templates on the filesystem for -future reuse. It speeds up Twig a lot as templates are only compiled once; and -the performance boost is even larger if you use a PHP accelerator such as APC. -See the ``cache`` and ``auto_reload`` options of ``Twig_Environment`` above -for more information. - -Built-in Loaders -~~~~~~~~~~~~~~~~ - -Here is a list of the built-in loaders Twig provides: - -``Twig_Loader_Filesystem`` -.......................... - -.. versionadded:: 1.10 - The ``prependPath()`` and support for namespaces were added in Twig 1.10. - -.. versionadded:: 1.27 - Relative paths support was added in Twig 1.27. - -``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($templateDir); - -It can also look for templates in an array of directories:: - - $loader = new Twig_Loader_Filesystem(array($templateDir1, $templateDir2)); - -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``. - -You can add or prepend paths via the ``addPath()`` and ``prependPath()`` -methods:: - - $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_Filesystem`` support absolute and relative paths. Using relative -paths is preferred as it makes the cache keys independent of the project root -directory (for instance, it allows warming the cache from a build server where -the directory might be different from the one used on production servers):: - - $loader = new Twig_Loader_Filesystem('templates', getcwd().'/..'); - -.. note:: - - When not passing the root path as a second argument, Twig uses ``getcwd()`` - for relative paths. - -``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:: - - When using the ``Array`` or ``String`` loaders 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 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.html" %}{% 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 -~~~~~~~~~~~~~~~~~~~~~~ - -All loaders implement the ``Twig_LoaderInterface``:: - - interface Twig_LoaderInterface - { - /** - * Gets the source code of a template, given its name. - * - * @param string $name string The name of the template to load - * - * @return string The template source code - * - * @deprecated since 1.27 (to be removed in 2.0), implement Twig_SourceContextLoaderInterface - */ - function getSource($name); - - /** - * Gets the cache key to use for the cache for a given template name. - * - * @param string $name string The name of the template to load - * - * @return string The cache key - */ - 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 - */ - function isFresh($name, $time); - } - -The ``isFresh()`` method must return ``true`` if the current cached template -is still fresh, given the last modification time, or ``false`` otherwise. - -.. note:: - - As of Twig 1.27, you should also implement - ``Twig_SourceContextLoaderInterface`` to avoid deprecation notices. - -.. 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 ----------------- - -Twig extensions are packages that add new features to Twig. Using an -extension is as simple as using the ``addExtension()`` method:: - - $twig->addExtension(new Twig_Extension_Sandbox()); - -Twig comes bundled with the following extensions: - -* *Twig_Extension_Core*: Defines all the core features of Twig. - -* *Twig_Extension_Escaper*: Adds automatic output-escaping and the possibility - to escape/unescape blocks of code. - -* *Twig_Extension_Sandbox*: Adds a sandbox mode to the default Twig - environment, making it safe to evaluate untrusted code. - -* *Twig_Extension_Profiler*: Enabled the built-in Twig profiler (as of Twig - 1.18). - -* *Twig_Extension_Optimizer*: Optimizes the node tree before compilation. - -The core, escaper, and optimizer extensions do not need to be added to the -Twig environment, as they are registered by default. - -Built-in Extensions -------------------- - -This section describes the features added by the built-in extensions. - -.. tip:: - - Read the chapter about extending Twig to learn how to create your own - extensions. - -Core Extension -~~~~~~~~~~~~~~ - -The ``core`` extension defines all the core features of Twig: - -* :doc:`Tags `; -* :doc:`Filters `; -* :doc:`Functions `; -* :doc:`Tests `. - -Escaper Extension -~~~~~~~~~~~~~~~~~ - -The ``escaper`` extension adds automatic output escaping to Twig. It defines a -tag, ``autoescape``, and a filter, ``raw``. - -When creating the escaper extension, you can switch on or off the global -output escaping strategy:: - - $escaper = new Twig_Extension_Escaper('html'); - $twig->addExtension($escaper); - -If set to ``html``, all variables in templates are escaped (using the ``html`` -escaping strategy), except those using the ``raw`` filter: - -.. code-block:: jinja - - {{ article.to_html|raw }} - -You can also change the escaping mode locally by using the ``autoescape`` tag -(see the :doc:`autoescape` doc for the syntax used before -Twig 1.8): - -.. code-block:: jinja - - {% autoescape 'html' %} - {{ var }} - {{ var|raw }} {# var won't be escaped #} - {{ var|escape }} {# var won't be double-escaped #} - {% endautoescape %} - -.. warning:: - - The ``autoescape`` tag has no effect on included files. - -The escaping rules are implemented as follows: - -* Literals (integers, booleans, arrays, ...) used in the template directly as - variables or filter arguments are never automatically escaped: - - .. code-block:: jinja - - {{ "Twig
" }} {# won't be escaped #} - - {% set text = "Twig
" %} - {{ text }} {# will be escaped #} - -* Expressions which the result is always a literal or a variable marked safe - are never automatically escaped: - - .. code-block:: jinja - - {{ foo ? "Twig
" : "
Twig" }} {# won't be escaped #} - - {% set text = "Twig
" %} - {{ foo ? text : "
Twig" }} {# will be escaped #} - - {% set text = "Twig
" %} - {{ foo ? text|raw : "
Twig" }} {# won't be escaped #} - - {% set text = "Twig
" %} - {{ foo ? text|escape : "
Twig" }} {# the result of the expression won't be escaped #} - -* Escaping is applied before printing, after any other filter is applied: - - .. code-block:: jinja - - {{ var|upper }} {# is equivalent to {{ var|upper|escape }} #} - -* The `raw` filter should only be used at the end of the filter chain: - - .. code-block:: jinja - - {{ var|raw|upper }} {# will be escaped #} - - {{ var|upper|raw }} {# won't be escaped #} - -* Automatic escaping is not applied if the last filter in the chain is marked - safe for the current context (e.g. ``html`` or ``js``). ``escape`` and - ``escape('html')`` are marked safe for HTML, ``escape('js')`` is marked - safe for JavaScript, ``raw`` is marked safe for everything. - - .. code-block:: jinja - - {% 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:: - - Note that autoescaping has some limitations as escaping is applied on - expressions after evaluation. For instance, when working with - concatenation, ``{{ foo|raw ~ bar }}`` won't give the expected result as - escaping is applied on the result of the concatenation, not on the - individual variables (so, the ``raw`` filter won't have any effect here). - -Sandbox Extension -~~~~~~~~~~~~~~~~~ - -The ``sandbox`` extension can be used to evaluate untrusted code. Access to -unsafe attributes and methods is prohibited. The sandbox security is managed -by a policy instance. By default, Twig comes with one policy class: -``Twig_Sandbox_SecurityPolicy``. This class allows you to white-list some -tags, filters, properties, and methods:: - - $tags = array('if'); - $filters = array('upper'); - $methods = array( - 'Article' => array('getTitle', 'getBody'), - ); - $properties = array( - 'Article' => array('title', 'body'), - ); - $functions = array('range'); - $policy = new Twig_Sandbox_SecurityPolicy($tags, $filters, $methods, $properties, $functions); - -With the previous configuration, the security policy will only allow usage of -the ``if`` tag, and the ``upper`` filter. Moreover, the templates will only be -able to call the ``getTitle()`` and ``getBody()`` methods on ``Article`` -objects, and the ``title`` and ``body`` public properties. Everything else -won't be allowed and will generate a ``Twig_Sandbox_SecurityError`` exception. - -The policy object is the first argument of the sandbox constructor:: - - $sandbox = new Twig_Extension_Sandbox($policy); - $twig->addExtension($sandbox); - -By default, the sandbox mode is disabled and should be enabled when including -untrusted template code by using the ``sandbox`` tag: - -.. code-block:: jinja - - {% sandbox %} - {% include 'user.html' %} - {% endsandbox %} - -You can sandbox all templates by passing ``true`` as the second argument of -the extension constructor:: - - $sandbox = new Twig_Extension_Sandbox($policy, true); - -Profiler Extension -~~~~~~~~~~~~~~~~~~ - -.. versionadded:: 1.18 - The Profile extension was added in Twig 1.18. - -The ``profiler`` extension enables a profiler for Twig templates; it should -only be used on your development machines as it adds some overhead:: - - $profile = new Twig_Profiler_Profile(); - $twig->addExtension(new Twig_Extension_Profiler($profile)); - - $dumper = new Twig_Profiler_Dumper_Text(); - echo $dumper->dump($profile); - -A profile contains information about time and memory consumption for template, -block, and macro executions. - -You can also dump the data in a `Blackfire.io `_ -compatible format:: - - $dumper = new Twig_Profiler_Dumper_Blackfire(); - file_put_contents('/path/to/profile.prof', $dumper->dump($profile)); - -Upload the profile to visualize it (create a `free account -`_ first): - -.. code-block:: sh - - blackfire --slot=7 upload /path/to/profile.prof - -Optimizer Extension -~~~~~~~~~~~~~~~~~~~ - -The ``optimizer`` extension optimizes the node tree before compilation:: - - $twig->addExtension(new Twig_Extension_Optimizer()); - -By default, all optimizations are turned on. You can select the ones you want -to enable by passing them to the constructor:: - - $optimizer = new Twig_Extension_Optimizer(Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR); - - $twig->addExtension($optimizer); - -Twig supports the following optimizations: - -* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_ALL``, enables all optimizations - (this is the default value). -* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_NONE``, disables all optimizations. - This reduces the compilation time, but it can increase the execution time - and the consumed memory. -* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_FOR``, optimizes the ``for`` tag by - removing the ``loop`` variable creation whenever possible. -* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_RAW_FILTER``, removes the ``raw`` - filter whenever possible. -* ``Twig_NodeVisitor_Optimizer::OPTIMIZE_VAR_ACCESS``, simplifies the creation - and access of variables in the compiled templates whenever possible. - -Exceptions ----------- - -Twig can throw exceptions: - -* ``Twig_Error``: The base exception for all errors. - -* ``Twig_Error_Syntax``: Thrown to tell the user that there is a problem with - the template syntax. - -* ``Twig_Error_Runtime``: Thrown when an error occurs at runtime (when a filter - does not exist for instance). - -* ``Twig_Error_Loader``: Thrown when an error occurs during template loading. - -* ``Twig_Sandbox_SecurityError``: Thrown when an unallowed tag, filter, or - method is called in a sandboxed template. diff --git a/lib/silex/vendor/twig/twig/doc/coding_standards.rst b/lib/silex/vendor/twig/twig/doc/coding_standards.rst deleted file mode 100644 index bf8ea91a4..000000000 --- a/lib/silex/vendor/twig/twig/doc/coding_standards.rst +++ /dev/null @@ -1,101 +0,0 @@ -Coding Standards -================ - -When writing Twig templates, we recommend you to follow these official coding -standards: - -* Put one (and only one) space after the start of a delimiter (``{{``, ``{%``, - and ``{#``) and before the end of a delimiter (``}}``, ``%}``, and ``#}``): - - .. code-block:: jinja - - {{ foo }} - {# comment #} - {% if foo %}{% endif %} - - When using the whitespace control character, do not put any spaces between - it and the delimiter: - - .. code-block:: jinja - - {{- foo -}} - {#- comment -#} - {%- if foo -%}{%- endif -%} - -* Put one (and only one) space before and after the following operators: - comparison operators (``==``, ``!=``, ``<``, ``>``, ``>=``, ``<=``), math - operators (``+``, ``-``, ``/``, ``*``, ``%``, ``//``, ``**``), logic - operators (``not``, ``and``, ``or``), ``~``, ``is``, ``in``, and the ternary - operator (``?:``): - - .. code-block:: jinja - - {{ 1 + 2 }} - {{ foo ~ bar }} - {{ true ? true : false }} - -* Put one (and only one) space after the ``:`` sign in hashes and ``,`` in - arrays and hashes: - - .. code-block:: jinja - - {{ [1, 2, 3] }} - {{ {'foo': 'bar'} }} - -* Do not put any spaces after an opening parenthesis and before a closing - parenthesis in expressions: - - .. code-block:: jinja - - {{ 1 + (2 * 3) }} - -* Do not put any spaces before and after string delimiters: - - .. code-block:: jinja - - {{ 'foo' }} - {{ "foo" }} - -* Do not put any spaces before and after the following operators: ``|``, - ``.``, ``..``, ``[]``: - - .. code-block:: jinja - - {{ foo|upper|lower }} - {{ user.name }} - {{ user[name] }} - {% for i in 1..12 %}{% endfor %} - -* Do not put any spaces before and after the parenthesis used for filter and - function calls: - - .. code-block:: jinja - - {{ foo|default('foo') }} - {{ range(1..10) }} - -* Do not put any spaces before and after the opening and the closing of arrays - and hashes: - - .. code-block:: jinja - - {{ [1, 2, 3] }} - {{ {'foo': 'bar'} }} - -* Use lower cased and underscored variable names: - - .. code-block:: jinja - - {% set foo = 'foo' %} - {% set foo_bar = 'foo' %} - -* Indent your code inside tags (use the same indentation as the one used for - the target language of the rendered template): - - .. code-block:: jinja - - {% block foo %} - {% if true %} - true - {% endif %} - {% endblock %} diff --git a/lib/silex/vendor/twig/twig/doc/deprecated.rst b/lib/silex/vendor/twig/twig/doc/deprecated.rst deleted file mode 100644 index 8b25cc410..000000000 --- a/lib/silex/vendor/twig/twig/doc/deprecated.rst +++ /dev/null @@ -1,224 +0,0 @@ -Deprecated Features -=================== - -This document lists all deprecated features in Twig. Deprecated features are -kept for backward compatibility and removed in the next major release (a -feature that was deprecated in Twig 1.x is removed in Twig 2.0). - -Deprecation Notices -------------------- - -As of Twig 1.21, Twig generates deprecation notices when a template uses -deprecated features. See :ref:`deprecation-notices` for more information. - -Macros ------- - -As of Twig 2.0, macros imported in a file are not available in child templates -anymore (via an ``include`` call for instance). You need to import macros -explicitly in each file where you are using them. - -Token Parsers -------------- - -* As of Twig 1.x, the token parser broker sub-system is deprecated. The - following class and interface will be removed in 2.0: - - * ``Twig_TokenParserBrokerInterface`` - * ``Twig_TokenParserBroker`` - -* As of Twig 1.27, ``Twig_Parser::getFilename()`` is deprecated. From a token - parser, use ``$this->parser->getStream()->getSourceContext()->getPath()`` instead. - -* As of Twig 1.27, ``Twig_Parser::getEnvironment()`` is deprecated. - -Extensions ----------- - -* As of Twig 1.x, the ability to remove an extension is deprecated and the - ``Twig_Environment::removeExtension()`` method will be removed in 2.0. - -* As of Twig 1.23, the ``Twig_ExtensionInterface::initRuntime()`` method is - deprecated. You have two options to avoid the deprecation notice: if you - implement this method to store the environment for your custom filters, - functions, or tests, use the ``needs_environment`` option instead; if you - have more complex needs, explicitly implement - ``Twig_Extension_InitRuntimeInterface`` (not recommended). - -* As of Twig 1.23, the ``Twig_ExtensionInterface::getGlobals()`` method is - deprecated. Implement ``Twig_Extension_GlobalsInterface`` to avoid - deprecation notices. - -* As of Twig 1.26, the ``Twig_ExtensionInterface::getName()`` method is - deprecated and it is not used internally anymore. - -PEAR ----- - -PEAR support has been discontinued in Twig 1.15.1, and no PEAR packages are -provided anymore. Use Composer instead. - -Filters -------- - -* As of Twig 1.x, use ``Twig_SimpleFilter`` to add a filter. The following - classes and interfaces will be removed in 2.0: - - * ``Twig_FilterInterface`` - * ``Twig_FilterCallableInterface`` - * ``Twig_Filter`` - * ``Twig_Filter_Function`` - * ``Twig_Filter_Method`` - * ``Twig_Filter_Node`` - -* As of Twig 2.x, the ``Twig_SimpleFilter`` class is deprecated and will be - removed in Twig 3.x (use ``Twig_Filter`` instead). In Twig 2.x, - ``Twig_SimpleFilter`` is just an alias for ``Twig_Filter``. - -Functions ---------- - -* As of Twig 1.x, use ``Twig_SimpleFunction`` to add a function. The following - classes and interfaces will be removed in 2.0: - - * ``Twig_FunctionInterface`` - * ``Twig_FunctionCallableInterface`` - * ``Twig_Function`` - * ``Twig_Function_Function`` - * ``Twig_Function_Method`` - * ``Twig_Function_Node`` - -* As of Twig 2.x, the ``Twig_SimpleFunction`` class is deprecated and will be - removed in Twig 3.x (use ``Twig_Function`` instead). In Twig 2.x, - ``Twig_SimpleFunction`` is just an alias for ``Twig_Function``. - -Tests ------ - -* As of Twig 1.x, use ``Twig_SimpleTest`` to add a test. The following classes - and interfaces will be removed in 2.0: - - * ``Twig_TestInterface`` - * ``Twig_TestCallableInterface`` - * ``Twig_Test`` - * ``Twig_Test_Function`` - * ``Twig_Test_Method`` - * ``Twig_Test_Node`` - -* As of Twig 2.x, the ``Twig_SimpleTest`` class is deprecated and will be - removed in Twig 3.x (use ``Twig_Test`` instead). In Twig 2.x, - ``Twig_SimpleTest`` is just an alias for ``Twig_Test``. - -* The ``sameas`` and ``divisibleby`` tests are deprecated in favor of ``same - as`` and ``divisible by`` respectively. - -Tags ----- - -* As of Twig 1.x, the ``raw`` tag is deprecated. You should use ``verbatim`` - instead. - -Nodes ------ - -* As of Twig 1.x, ``Node::toXml()`` is deprecated and will be removed in Twig - 2.0. - -* As of Twig 1.26, ``Node::$nodes`` should only contains ``Twig_Node`` - instances, storing a ``null`` value is deprecated and won't be possible in - Twig 2.x. - -* As of Twig 1.27, the ``filename`` attribute on ``Twig_Node_Module`` is - deprecated. Use ``getName()`` instead. - -* As of Twig 1.27, the ``Twig_Node::getFilename()/Twig_Node::getLine()`` - methods are deprecated, use - ``Twig_Node::getTemplateName()/Twig_Node::getTemplateLine()`` instead. - -Interfaces ----------- - -* As of Twig 2.x, the following interfaces are deprecated and empty (they will - be removed in Twig 3.0): - -* ``Twig_CompilerInterface`` (use ``Twig_Compiler`` instead) -* ``Twig_LexerInterface`` (use ``Twig_Lexer`` instead) -* ``Twig_NodeInterface`` (use ``Twig_Node`` instead) -* ``Twig_ParserInterface`` (use ``Twig_Parser`` instead) -* ``Twig_ExistsLoaderInterface`` (merged with ``Twig_LoaderInterface``) -* ``Twig_SourceContextLoaderInterface`` (merged with ``Twig_LoaderInterface``) -* ``Twig_TemplateInterface`` (use ``Twig_Template`` instead, and use - those constants Twig_Template::ANY_CALL, Twig_Template::ARRAY_CALL, - Twig_Template::METHOD_CALL) - -Compiler --------- - -* As of Twig 1.26, the ``Twig_Compiler::getFilename()`` has been deprecated. - You should not use it anyway as its values is not reliable. - -* As of Twig 1.27, the ``Twig_Compiler::addIndentation()`` has been deprecated. - Use ``Twig_Compiler::write('')`` instead. - -Loaders -------- - -* As of Twig 1.x, ``Twig_Loader_String`` is deprecated and will be removed in - 2.0. You can render a string via ``Twig_Environment::createTemplate()``. - -* As of Twig 1.27, ``Twig_LoaderInterface::getSource()`` is deprecated. - Implement ``Twig_SourceContextLoaderInterface`` instead and use - ``getSourceContext()``. - -Node Visitors -------------- - -* Because of the removal of ``Twig_NodeInterface`` in 2.0, you need to extend - ``Twig_BaseNodeVisitor`` instead of implementing ``Twig_NodeVisitorInterface`` - directly to make your node visitors compatible with both Twig 1.x and 2.x. - -Globals -------- - -* As of Twig 2.x, the ability to register a global variable after the runtime - or the extensions have been initialized is not possible anymore (but - changing the value of an already registered global is possible). - -* As of Twig 1.x, using the ``_self`` global variable to get access to the - current ``Twig_Template`` instance is deprecated; most usages only need the - current template name, which will continue to work in Twig 2.0. In Twig 2.0, - ``_self`` returns the current template name instead of the current - ``Twig_Template`` instance. If you are using ``{{ _self.templateName }}``, - just replace it with ``{{ _self }}``. - -Miscellaneous -------------- - -* As of Twig 1.x, ``Twig_Environment::clearTemplateCache()``, - ``Twig_Environment::writeCacheFile()``, - ``Twig_Environment::clearCacheFiles()``, - ``Twig_Environment::getCacheFilename()``, - ``Twig_Environment::getTemplateClassPrefix()``, - ``Twig_Environment::getLexer()``, ``Twig_Environment::getParser()``, and - ``Twig_Environment::getCompiler()`` are deprecated and will be removed in 2.0. - -* As of Twig 1.x, ``Twig_Template::getEnvironment()`` and - ``Twig_TemplateInterface::getEnvironment()`` are deprecated and will be - removed in 2.0. - -* As of Twig 1.21, setting the environment option ``autoescape`` to ``true`` is - deprecated and will be removed in 2.0. Use ``"html"`` instead. - -* As of Twig 1.27, ``Twig_Error::getTemplateFile()`` and - ``Twig_Error::setTemplateFile()`` are deprecated. Use - ``Twig_Error::getTemplateName()`` and ``Twig_Error::setTemplateName()`` - instead. - -* As of Twig 1.27, ``Twig_Template::getSource()`` is deprecated. Use - ``Twig_Template::getSourceContext()`` instead. - -* As of Twig 1.27, ``Twig_Parser::addHandler()`` and - ``Twig_Parser::addNodeVisitor()`` are deprecated and will be removed in 2.0. - -* As of Twig 1.29, some classes are marked as being final via the `@final` - annotation. Those classes will be marked as final in 2.0. diff --git a/lib/silex/vendor/twig/twig/doc/filters/abs.rst b/lib/silex/vendor/twig/twig/doc/filters/abs.rst deleted file mode 100644 index 22fa59d03..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/abs.rst +++ /dev/null @@ -1,18 +0,0 @@ -``abs`` -======= - -The ``abs`` filter returns the absolute value. - -.. code-block:: jinja - - {# number = -5 #} - - {{ number|abs }} - - {# outputs 5 #} - -.. note:: - - Internally, Twig uses the PHP `abs`_ function. - -.. _`abs`: http://php.net/abs diff --git a/lib/silex/vendor/twig/twig/doc/filters/batch.rst b/lib/silex/vendor/twig/twig/doc/filters/batch.rst deleted file mode 100644 index f8b6fa9d4..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/batch.rst +++ /dev/null @@ -1,51 +0,0 @@ -``batch`` -========= - -.. versionadded:: 1.12.3 - The ``batch`` filter was added in Twig 1.12.3. - -The ``batch`` filter "batches" items by returning a list of lists with the -given number of items. A second parameter can be provided and used to fill in -missing items: - -.. code-block:: jinja - - {% set items = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] %} - - - {% for row in items|batch(3, 'No item') %} - - {% for column in row %} - - {% endfor %} - - {% endfor %} -
{{ column }}
- -The above example will be rendered as: - -.. code-block:: jinja - - - - - - - - - - - - - - - - - -
abc
def
gNo itemNo item
- -Arguments ---------- - -* ``size``: The size of the batch; fractional numbers will be rounded up -* ``fill``: Used to fill in missing items diff --git a/lib/silex/vendor/twig/twig/doc/filters/capitalize.rst b/lib/silex/vendor/twig/twig/doc/filters/capitalize.rst deleted file mode 100644 index 10546a1f3..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/capitalize.rst +++ /dev/null @@ -1,11 +0,0 @@ -``capitalize`` -============== - -The ``capitalize`` filter capitalizes a value. The first character will be -uppercase, all others lowercase: - -.. code-block:: jinja - - {{ 'my first car'|capitalize }} - - {# outputs 'My first car' #} diff --git a/lib/silex/vendor/twig/twig/doc/filters/convert_encoding.rst b/lib/silex/vendor/twig/twig/doc/filters/convert_encoding.rst deleted file mode 100644 index f4ebe5807..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/convert_encoding.rst +++ /dev/null @@ -1,28 +0,0 @@ -``convert_encoding`` -==================== - -.. versionadded:: 1.4 - The ``convert_encoding`` filter was added in Twig 1.4. - -The ``convert_encoding`` filter converts a string from one encoding to -another. The first argument is the expected output charset and the second one -is the input charset: - -.. code-block:: jinja - - {{ data|convert_encoding('UTF-8', 'iso-2022-jp') }} - -.. note:: - - This filter relies on the `iconv`_ or `mbstring`_ extension, so one of - them must be installed. In case both are installed, `mbstring`_ is used by - default (Twig before 1.8.1 uses `iconv`_ by default). - -Arguments ---------- - -* ``to``: The output charset -* ``from``: The input charset - -.. _`iconv`: http://php.net/iconv -.. _`mbstring`: http://php.net/mbstring diff --git a/lib/silex/vendor/twig/twig/doc/filters/date.rst b/lib/silex/vendor/twig/twig/doc/filters/date.rst deleted file mode 100644 index 99a17ab75..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/date.rst +++ /dev/null @@ -1,100 +0,0 @@ -``date`` -======== - -.. versionadded:: 1.1 - The timezone support has been added in Twig 1.1. - -.. versionadded:: 1.5 - The default date format support has been added in Twig 1.5. - -.. 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 - - {{ post.published_at|date("m/d/Y") }} - -The format specifier is the same as supported by `date`_, -except when the filtered data is of type `DateInterval`_, when the format must conform to -`DateInterval::format`_ instead. - -The ``date`` filter accepts strings (it must be in a format supported by the -`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: - -.. code-block:: jinja - - {{ post.published_at|date("F jS \\a\\t g:ia") }} - -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") }} - -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 -``core`` extension instance. The first argument is the default format for -dates and the second one is the default format for date intervals: - -.. code-block:: php - - $twig = new Twig_Environment($loader); - $twig->getExtension('Twig_Extension_Core')->setDateFormat('d/m/Y', '%d days'); - - // before Twig 1.26 - $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 - - $twig = new Twig_Environment($loader); - $twig->getExtension('Twig_Extension_Core')->setTimezone('Europe/Paris'); - - // before Twig 1.26 - $twig->getExtension('core')->setTimezone('Europe/Paris'); - -Arguments ---------- - -* ``format``: The date format -* ``timezone``: The date timezone - -.. _`strtotime`: http://www.php.net/strtotime -.. _`DateTime`: http://www.php.net/DateTime -.. _`DateInterval`: http://www.php.net/DateInterval -.. _`date`: http://www.php.net/date -.. _`DateInterval::format`: http://www.php.net/DateInterval.format diff --git a/lib/silex/vendor/twig/twig/doc/filters/date_modify.rst b/lib/silex/vendor/twig/twig/doc/filters/date_modify.rst deleted file mode 100644 index add40b56b..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/date_modify.rst +++ /dev/null @@ -1,23 +0,0 @@ -``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` filter for formatting. - -Arguments ---------- - -* ``modifier``: The modifier - -.. _`strtotime`: http://www.php.net/strtotime -.. _`DateTime`: http://www.php.net/DateTime diff --git a/lib/silex/vendor/twig/twig/doc/filters/default.rst b/lib/silex/vendor/twig/twig/doc/filters/default.rst deleted file mode 100644 index 641ac6e75..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/default.rst +++ /dev/null @@ -1,33 +0,0 @@ -``default`` -=========== - -The ``default`` filter returns the passed default value if the value is -undefined or empty, otherwise the value of the variable: - -.. code-block:: jinja - - {{ var|default('var is not defined') }} - - {{ var.foo|default('foo item on var is not defined') }} - - {{ var['foo']|default('foo item on var is not defined') }} - - {{ ''|default('passed var is empty') }} - -When using the ``default`` filter on an expression that uses variables in some -method calls, be sure to use the ``default`` filter whenever a variable can be -undefined: - -.. code-block:: jinja - - {{ var.method(foo|default('foo'))|default('foo') }} - -.. note:: - - Read the documentation for the :doc:`defined<../tests/defined>` and - :doc:`empty<../tests/empty>` tests to learn more about their semantics. - -Arguments ---------- - -* ``default``: The default value diff --git a/lib/silex/vendor/twig/twig/doc/filters/escape.rst b/lib/silex/vendor/twig/twig/doc/filters/escape.rst deleted file mode 100644 index 21491343b..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/escape.rst +++ /dev/null @@ -1,119 +0,0 @@ -``escape`` -========== - -.. versionadded:: 1.9.0 - The ``css``, ``url``, and ``html_attr`` strategies were added in Twig - 1.9.0. - -.. versionadded:: 1.14.0 - The ability to define custom escapers was added in Twig 1.14.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 - - {{ user.username|escape }} - -For convenience, the ``e`` filter is defined as an alias: - -.. code-block:: jinja - - {{ user.username|e }} - -The ``escape`` filter can also be used in other contexts than HTML thanks to -an optional argument which defines the escaping strategy to use: - -.. code-block:: jinja - - {{ user.username|e }} - {# is equivalent to #} - {{ user.username|e('html') }} - -And here is how to escape variables included in JavaScript code: - -.. code-block:: jinja - - {{ 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 %} - -Custom Escapers ---------------- - -You can define custom escapers by calling the ``setEscaper()`` method on the -``core`` extension instance. The first argument is the escaper name (to be -used in the ``escape`` call) and the second one must be a valid PHP callable: - -.. code-block:: php - - $twig = new Twig_Environment($loader); - $twig->getExtension('Twig_Extension_Core')->setEscaper('csv', 'csv_escaper'); - - // before Twig 1.26 - $twig->getExtension('core')->setEscaper('csv', 'csv_escaper'); - -When called by Twig, the callable receives the Twig environment instance, the -string to escape, and the charset. - -.. note:: - - Built-in escapers cannot be overridden mainly they should be considered as - the final implementation and also for better performance. - -Arguments ---------- - -* ``strategy``: The escaping strategy -* ``charset``: The string charset - -.. _`htmlspecialchars`: http://php.net/htmlspecialchars diff --git a/lib/silex/vendor/twig/twig/doc/filters/first.rst b/lib/silex/vendor/twig/twig/doc/filters/first.rst deleted file mode 100644 index 674c1f9ed..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/first.rst +++ /dev/null @@ -1,25 +0,0 @@ -``first`` -========= - -.. versionadded:: 1.12.2 - The ``first`` filter was added in Twig 1.12.2. - -The ``first`` filter returns the first "element" of a sequence, a mapping, or -a string: - -.. code-block:: jinja - - {{ [1, 2, 3, 4]|first }} - {# outputs 1 #} - - {{ { a: 1, b: 2, c: 3, d: 4 }|first }} - {# outputs 1 #} - - {{ '1234'|first }} - {# outputs 1 #} - -.. note:: - - It also works with objects implementing the `Traversable`_ interface. - -.. _`Traversable`: http://php.net/manual/en/class.traversable.php diff --git a/lib/silex/vendor/twig/twig/doc/filters/format.rst b/lib/silex/vendor/twig/twig/doc/filters/format.rst deleted file mode 100644 index f8effd9a9..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/format.rst +++ /dev/null @@ -1,16 +0,0 @@ -``format`` -========== - -The ``format`` filter formats a given string by replacing the placeholders -(placeholders follows the `sprintf`_ notation): - -.. code-block:: jinja - - {{ "I like %s and %s."|format(foo, "bar") }} - - {# outputs I like foo and bar - if the foo parameter equals to the foo string. #} - -.. _`sprintf`: http://www.php.net/sprintf - -.. seealso:: :doc:`replace` diff --git a/lib/silex/vendor/twig/twig/doc/filters/index.rst b/lib/silex/vendor/twig/twig/doc/filters/index.rst deleted file mode 100644 index 8daa96118..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/index.rst +++ /dev/null @@ -1,37 +0,0 @@ -Filters -======= - -.. toctree:: - :maxdepth: 1 - - abs - batch - capitalize - convert_encoding - date - date_modify - default - escape - first - format - join - json_encode - keys - last - length - lower - merge - nl2br - number_format - raw - replace - reverse - round - slice - sort - split - striptags - title - trim - upper - url_encode diff --git a/lib/silex/vendor/twig/twig/doc/filters/join.rst b/lib/silex/vendor/twig/twig/doc/filters/join.rst deleted file mode 100644 index 2fab94528..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/join.rst +++ /dev/null @@ -1,23 +0,0 @@ -``join`` -======== - -The ``join`` filter returns a string which is the concatenation of the items -of a sequence: - -.. code-block:: jinja - - {{ [1, 2, 3]|join }} - {# returns 123 #} - -The separator between elements is an empty string per default, but you can -define it with the optional first parameter: - -.. code-block:: jinja - - {{ [1, 2, 3]|join('|') }} - {# outputs 1|2|3 #} - -Arguments ---------- - -* ``glue``: The separator diff --git a/lib/silex/vendor/twig/twig/doc/filters/json_encode.rst b/lib/silex/vendor/twig/twig/doc/filters/json_encode.rst deleted file mode 100644 index a39bb476e..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/json_encode.rst +++ /dev/null @@ -1,21 +0,0 @@ -``json_encode`` -=============== - -The ``json_encode`` filter returns the JSON representation of a value: - -.. code-block:: jinja - - {{ data|json_encode() }} - -.. note:: - - Internally, Twig uses the PHP `json_encode`_ function. - -Arguments ---------- - -* ``options``: A bitmask of `json_encode options`_ (``{{ - data|json_encode(constant('JSON_PRETTY_PRINT')) }}``) - -.. _`json_encode`: http://php.net/json_encode -.. _`json_encode options`: http://www.php.net/manual/en/json.constants.php diff --git a/lib/silex/vendor/twig/twig/doc/filters/keys.rst b/lib/silex/vendor/twig/twig/doc/filters/keys.rst deleted file mode 100644 index e4f090c6b..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/keys.rst +++ /dev/null @@ -1,11 +0,0 @@ -``keys`` -======== - -The ``keys`` filter returns the keys of an array. It is useful when you want to -iterate over the keys of an array: - -.. code-block:: jinja - - {% for key in array|keys %} - ... - {% endfor %} diff --git a/lib/silex/vendor/twig/twig/doc/filters/last.rst b/lib/silex/vendor/twig/twig/doc/filters/last.rst deleted file mode 100644 index 345b6573d..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/last.rst +++ /dev/null @@ -1,25 +0,0 @@ -``last`` -======== - -.. versionadded:: 1.12.2 - The ``last`` filter was added in Twig 1.12.2. - -The ``last`` filter returns the last "element" of a sequence, a mapping, or -a string: - -.. code-block:: jinja - - {{ [1, 2, 3, 4]|last }} - {# outputs 4 #} - - {{ { a: 1, b: 2, c: 3, d: 4 }|last }} - {# outputs 4 #} - - {{ '1234'|last }} - {# outputs 4 #} - -.. note:: - - It also works with objects implementing the `Traversable`_ interface. - -.. _`Traversable`: http://php.net/manual/en/class.traversable.php diff --git a/lib/silex/vendor/twig/twig/doc/filters/length.rst b/lib/silex/vendor/twig/twig/doc/filters/length.rst deleted file mode 100644 index 5620f3b3c..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/length.rst +++ /dev/null @@ -1,21 +0,0 @@ -``length`` -========== - -.. versionadded:: 1.33 - - Support for the ``__toString()`` magic method has been added in Twig 1.33. - -The ``length`` filter returns the number of items of a sequence or mapping, or -the length of a string. - -For objects that implement the ``Countable`` interface, ``length`` will use the -return value of the ``count()`` method. - -For objects that implement the ``__toString()`` magic method (and not ``Countable``), -it will return the length of the string provided by that method. - -.. code-block:: jinja - - {% if users|length > 10 %} - ... - {% endif %} diff --git a/lib/silex/vendor/twig/twig/doc/filters/lower.rst b/lib/silex/vendor/twig/twig/doc/filters/lower.rst deleted file mode 100644 index ef9faa90a..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/lower.rst +++ /dev/null @@ -1,10 +0,0 @@ -``lower`` -========= - -The ``lower`` filter converts a value to lowercase: - -.. code-block:: jinja - - {{ 'WELCOME'|lower }} - - {# outputs 'welcome' #} diff --git a/lib/silex/vendor/twig/twig/doc/filters/merge.rst b/lib/silex/vendor/twig/twig/doc/filters/merge.rst deleted file mode 100644 index 88780dd6f..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/merge.rst +++ /dev/null @@ -1,48 +0,0 @@ -``merge`` -========= - -The ``merge`` filter merges an array with another array: - -.. code-block:: jinja - - {% set values = [1, 2] %} - - {% set values = values|merge(['apple', 'orange']) %} - - {# values now contains [1, 2, 'apple', 'orange'] #} - -New values are added at the end of the existing ones. - -The ``merge`` filter also works on hashes: - -.. code-block:: jinja - - {% set items = { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'unknown' } %} - - {% set items = items|merge({ 'peugeot': 'car', 'renault': 'car' }) %} - - {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car', 'renault': 'car' } #} - -For hashes, the merging process occurs on the keys: if the key does not -already exist, it is added but if the key already exists, its value is -overridden. - -.. tip:: - - If you want to ensure that some values are defined in an array (by given - default values), reverse the two elements in the call: - - .. code-block:: jinja - - {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %} - - {% set items = { 'apple': 'unknown' }|merge(items) %} - - {# items now contains { 'apple': 'fruit', 'orange': 'fruit' } #} - -.. note:: - - Internally, Twig uses the PHP `array_merge`_ function. It supports - Traversable objects by transforming those to arrays. - -.. _`array_merge`: http://php.net/array_merge diff --git a/lib/silex/vendor/twig/twig/doc/filters/nl2br.rst b/lib/silex/vendor/twig/twig/doc/filters/nl2br.rst deleted file mode 100644 index 5c923e143..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/nl2br.rst +++ /dev/null @@ -1,22 +0,0 @@ -``nl2br`` -========= - -.. versionadded:: 1.5 - The ``nl2br`` filter was added in Twig 1.5. - -The ``nl2br`` filter inserts HTML line breaks before all newlines in a string: - -.. code-block:: jinja - - {{ "I like Twig.\nYou will like it too."|nl2br }} - {# outputs - - I like Twig.
- You will like it too. - - #} - -.. note:: - - The ``nl2br`` filter pre-escapes the input before applying the - transformation. diff --git a/lib/silex/vendor/twig/twig/doc/filters/number_format.rst b/lib/silex/vendor/twig/twig/doc/filters/number_format.rst deleted file mode 100644 index f9d6705e7..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/number_format.rst +++ /dev/null @@ -1,56 +0,0 @@ -``number_format`` -================= - -.. versionadded:: 1.5 - The ``number_format`` filter was added in Twig 1.5 - -The ``number_format`` filter formats numbers. It is a wrapper around PHP's -`number_format`_ function: - -.. code-block:: jinja - - {{ 200.35|number_format }} - -You can control the number of decimal places, decimal point, and thousands -separator using the additional arguments: - -.. code-block:: jinja - - {{ 9800.333|number_format(2, '.', ',') }} - -To format negative numbers, wrap the number with parentheses (needed because of -Twig's :ref:`precedence of operators `: - -.. code-block:: jinja - - {{ -9800.333|number_format(2, '.', ',') }} {# outputs : -9 #} - {{ (-9800.333)|number_format(2, '.', ',') }} {# outputs : -9,800.33 #} - -If no formatting options are provided then Twig will use the default formatting -options of: - -* 0 decimal places. -* ``.`` as the decimal point. -* ``,`` as the thousands separator. - -These defaults can be easily changed through the core extension: - -.. code-block:: php - - $twig = new Twig_Environment($loader); - $twig->getExtension('Twig_Extension_Core')->setNumberFormat(3, '.', ','); - - // before Twig 1.26 - $twig->getExtension('core')->setNumberFormat(3, '.', ','); - -The defaults set for ``number_format`` can be over-ridden upon each call using the -additional parameters. - -Arguments ---------- - -* ``decimal``: The number of decimal points to display -* ``decimal_point``: The character(s) to use for the decimal point -* ``thousand_sep``: The character(s) to use for the thousands separator - -.. _`number_format`: http://php.net/number_format diff --git a/lib/silex/vendor/twig/twig/doc/filters/raw.rst b/lib/silex/vendor/twig/twig/doc/filters/raw.rst deleted file mode 100644 index e5e5b12ec..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/raw.rst +++ /dev/null @@ -1,36 +0,0 @@ -``raw`` -======= - -The ``raw`` filter marks the value as being "safe", which means that in an -environment with automatic escaping enabled this variable will not be escaped -if ``raw`` is the last filter applied to it: - -.. code-block:: jinja - - {% autoescape %} - {{ var|raw }} {# var won't be escaped #} - {% endautoescape %} - -.. note:: - - Be careful when using the ``raw`` filter inside expressions: - - .. code-block:: jinja - - {% autoescape %} - {% set hello = 'Hello' %} - {% set hola = 'Hola' %} - - {{ false ? 'Hola' : hello|raw }} - does not render the same as - {{ false ? hola : hello|raw }} - but renders the same as - {{ (false ? hola : hello)|raw }} - {% endautoescape %} - - The first ternary statement is not escaped: ``hello`` is marked as being - safe and Twig does not escape static values (see - :doc:`escape<../tags/autoescape>`). In the second ternary statement, even - if ``hello`` is marked as safe, ``hola`` remains unsafe and so is the whole - expression. The third ternary statement is marked as safe and the result is - not escaped. diff --git a/lib/silex/vendor/twig/twig/doc/filters/replace.rst b/lib/silex/vendor/twig/twig/doc/filters/replace.rst deleted file mode 100644 index 8dbb74593..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/replace.rst +++ /dev/null @@ -1,19 +0,0 @@ -``replace`` -=========== - -The ``replace`` filter formats a given string by replacing the placeholders -(placeholders are free-form): - -.. code-block:: jinja - - {{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }} - - {# outputs I like foo and bar - if the foo parameter equals to the foo string. #} - -Arguments ---------- - -* ``from``: The placeholder values - -.. seealso:: :doc:`format` diff --git a/lib/silex/vendor/twig/twig/doc/filters/reverse.rst b/lib/silex/vendor/twig/twig/doc/filters/reverse.rst deleted file mode 100644 index 76fd2c1ab..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/reverse.rst +++ /dev/null @@ -1,47 +0,0 @@ -``reverse`` -=========== - -.. versionadded:: 1.6 - Support for strings has been added in Twig 1.6. - -The ``reverse`` filter reverses a sequence, a mapping, or a string: - -.. code-block:: jinja - - {% for user in users|reverse %} - ... - {% endfor %} - - {{ '1234'|reverse }} - - {# outputs 4321 #} - -.. tip:: - - For sequences and mappings, numeric keys are not preserved. To reverse - them as well, pass ``true`` as an argument to the ``reverse`` filter: - - .. code-block:: jinja - - {% for key, value in {1: "a", 2: "b", 3: "c"}|reverse %} - {{ key }}: {{ value }} - {%- endfor %} - - {# output: 0: c 1: b 2: a #} - - {% for key, value in {1: "a", 2: "b", 3: "c"}|reverse(true) %} - {{ key }}: {{ value }} - {%- endfor %} - - {# output: 3: c 2: b 1: a #} - -.. note:: - - It also works with objects implementing the `Traversable`_ interface. - -Arguments ---------- - -* ``preserve_keys``: Preserve keys when reversing a mapping or a sequence. - -.. _`Traversable`: http://php.net/Traversable diff --git a/lib/silex/vendor/twig/twig/doc/filters/round.rst b/lib/silex/vendor/twig/twig/doc/filters/round.rst deleted file mode 100644 index 2521cf16a..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/round.rst +++ /dev/null @@ -1,37 +0,0 @@ -``round`` -========= - -.. versionadded:: 1.15.0 - The ``round`` filter was added in Twig 1.15.0. - -The ``round`` filter rounds a number to a given precision: - -.. code-block:: jinja - - {{ 42.55|round }} - {# outputs 43 #} - - {{ 42.55|round(1, 'floor') }} - {# outputs 42.5 #} - -The ``round`` filter takes two optional arguments; the first one specifies the -precision (default is ``0``) and the second the rounding method (default is -``common``): - -* ``common`` rounds either up or down (rounds the value up to precision decimal - places away from zero, when it is half way there -- making 1.5 into 2 and - -1.5 into -2); - -* ``ceil`` always rounds up; - -* ``floor`` always rounds down. - -.. note:: - - The ``//`` operator is equivalent to ``|round(0, 'floor')``. - -Arguments ---------- - -* ``precision``: The rounding precision -* ``method``: The rounding method diff --git a/lib/silex/vendor/twig/twig/doc/filters/slice.rst b/lib/silex/vendor/twig/twig/doc/filters/slice.rst deleted file mode 100644 index 70bf139e6..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/slice.rst +++ /dev/null @@ -1,71 +0,0 @@ -``slice`` -=========== - -.. versionadded:: 1.6 - The ``slice`` filter was added in Twig 1.6. - -The ``slice`` filter extracts a slice of a sequence, a mapping, or a string: - -.. code-block:: jinja - - {% for i in [1, 2, 3, 4, 5]|slice(1, 2) %} - {# will iterate over 2 and 3 #} - {% endfor %} - - {{ '12345'|slice(1, 2) }} - - {# outputs 23 #} - -You can use any valid expression for both the start and the length: - -.. code-block:: jinja - - {% for i in [1, 2, 3, 4, 5]|slice(start, length) %} - {# ... #} - {% endfor %} - -As syntactic sugar, you can also use the ``[]`` notation: - -.. code-block:: jinja - - {% for i in [1, 2, 3, 4, 5][start:length] %} - {# ... #} - {% endfor %} - - {{ '12345'[1:2] }} {# will display "23" #} - - {# you can omit the first argument -- which is the same as 0 #} - {{ '12345'[:2] }} {# will display "12" #} - - {# you can omit the last argument -- which will select everything till the end #} - {{ '12345'[2:] }} {# will display "345" #} - -The ``slice`` filter works as the `array_slice`_ PHP function for arrays and -`mb_substr`_ for strings with a fallback to `substr`_. - -If the start is non-negative, the sequence will start at that start in the -variable. If start is negative, the sequence will start that far from the end -of the variable. - -If length is given and is positive, then the sequence will have up to that -many elements in it. If the variable is shorter than the length, then only the -available variable elements will be present. If length is given and is -negative then the sequence will stop that many elements from the end of the -variable. If it is omitted, then the sequence will have everything from offset -up until the end of the variable. - -.. note:: - - It also works with objects implementing the `Traversable`_ interface. - -Arguments ---------- - -* ``start``: The start of the slice -* ``length``: The size of the slice -* ``preserve_keys``: Whether to preserve key or not (when the input is an array) - -.. _`Traversable`: http://php.net/manual/en/class.traversable.php -.. _`array_slice`: http://php.net/array_slice -.. _`mb_substr` : http://php.net/mb-substr -.. _`substr`: http://php.net/substr diff --git a/lib/silex/vendor/twig/twig/doc/filters/sort.rst b/lib/silex/vendor/twig/twig/doc/filters/sort.rst deleted file mode 100644 index 350207f8e..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/sort.rst +++ /dev/null @@ -1,18 +0,0 @@ -``sort`` -======== - -The ``sort`` filter sorts an array: - -.. code-block:: jinja - - {% for user in users|sort %} - ... - {% endfor %} - -.. note:: - - Internally, Twig uses the PHP `asort`_ function to maintain index - association. It supports Traversable objects by transforming - those to arrays. - -.. _`asort`: http://php.net/asort diff --git a/lib/silex/vendor/twig/twig/doc/filters/split.rst b/lib/silex/vendor/twig/twig/doc/filters/split.rst deleted file mode 100644 index bbc6d798f..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/split.rst +++ /dev/null @@ -1,53 +0,0 @@ -``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 - - {% set foo = "one,two,three"|split(',') %} - {# foo contains ['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 - - {% set foo = "one,two,three,four,five"|split(',', 3) %} - {# foo contains ['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 - - {% set foo = "123"|split('') %} - {# foo contains ['1', '2', '3'] #} - - {% set bar = "aabbcc"|split('', 2) %} - {# bar contains ['aa', 'bb', 'cc'] #} - -.. note:: - - Internally, Twig uses the PHP `explode`_ or `str_split`_ (if delimiter is - empty) functions for string splitting. - -Arguments ---------- - -* ``delimiter``: The delimiter -* ``limit``: The limit argument - -.. _`explode`: http://php.net/explode -.. _`str_split`: http://php.net/str_split diff --git a/lib/silex/vendor/twig/twig/doc/filters/striptags.rst b/lib/silex/vendor/twig/twig/doc/filters/striptags.rst deleted file mode 100644 index 82953b7b6..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/striptags.rst +++ /dev/null @@ -1,29 +0,0 @@ -``striptags`` -============= - -The ``striptags`` filter strips SGML/XML tags and replace adjacent whitespace -by one space: - -.. code-block:: jinja - - {{ some_html|striptags }} - -You can also provide tags which should not be stripped: - -.. code-block:: jinja - - {{ some_html|striptags('

') }} - -In this example, the ``
``, ``
``, ``

``, and ``

`` tags won't be -removed from the string. - -.. note:: - - Internally, Twig uses the PHP `strip_tags`_ function. - -Arguments ---------- - -* ``allowable_tags``: Tags which should not be stripped - -.. _`strip_tags`: http://php.net/strip_tags diff --git a/lib/silex/vendor/twig/twig/doc/filters/title.rst b/lib/silex/vendor/twig/twig/doc/filters/title.rst deleted file mode 100644 index c5a318e85..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/title.rst +++ /dev/null @@ -1,11 +0,0 @@ -``title`` -========= - -The ``title`` filter returns a titlecased version of the value. Words will -start with uppercase letters, all remaining characters are lowercase: - -.. code-block:: jinja - - {{ 'my first car'|title }} - - {# outputs 'My First Car' #} diff --git a/lib/silex/vendor/twig/twig/doc/filters/trim.rst b/lib/silex/vendor/twig/twig/doc/filters/trim.rst deleted file mode 100644 index b598363c2..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/trim.rst +++ /dev/null @@ -1,45 +0,0 @@ -``trim`` -======== - -.. versionadded:: 1.32 - The ``side`` argument was added in Twig 1.32. - -.. versionadded:: 1.6.2 - The ``trim`` filter was added in Twig 1.6.2. - -The ``trim`` filter strips whitespace (or other characters) from the beginning -and end of a string: - -.. code-block:: jinja - - {{ ' I like Twig. '|trim }} - - {# outputs 'I like Twig.' #} - - {{ ' I like Twig.'|trim('.') }} - - {# outputs ' I like Twig' #} - - {{ ' I like Twig. '|trim(side='left') }} - - {# outputs 'I like Twig. ' #} - - {{ ' I like Twig. '|trim(' ', 'right') }} - - {# outputs ' I like Twig.' #} - -.. note:: - - Internally, Twig uses the PHP `trim`_, `ltrim`_, and `rtrim`_ functions. - -Arguments ---------- - -* ``character_mask``: The characters to strip - -* ``side``: The default is to strip from the left and the right (`both`) sides, but `left` - and `right` will strip from either the left side or right side only - -.. _`trim`: http://php.net/trim -.. _`ltrim`: http://php.net/ltrim -.. _`rtrim`: http://php.net/rtrim diff --git a/lib/silex/vendor/twig/twig/doc/filters/upper.rst b/lib/silex/vendor/twig/twig/doc/filters/upper.rst deleted file mode 100644 index 561cebe33..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/upper.rst +++ /dev/null @@ -1,10 +0,0 @@ -``upper`` -========= - -The ``upper`` filter converts a value to uppercase: - -.. code-block:: jinja - - {{ 'welcome'|upper }} - - {# outputs 'WELCOME' #} diff --git a/lib/silex/vendor/twig/twig/doc/filters/url_encode.rst b/lib/silex/vendor/twig/twig/doc/filters/url_encode.rst deleted file mode 100644 index 5944e59cd..000000000 --- a/lib/silex/vendor/twig/twig/doc/filters/url_encode.rst +++ /dev/null @@ -1,34 +0,0 @@ -``url_encode`` -============== - -.. versionadded:: 1.12.3 - Support for encoding an array as query string was added in Twig 1.12.3. - -.. versionadded:: 1.16.0 - The ``raw`` argument was removed in Twig 1.16.0. Twig now always encodes - according to RFC 3986. - -The ``url_encode`` filter percent encodes a given string as URL segment -or an array as query string: - -.. code-block:: jinja - - {{ "path-seg*ment"|url_encode }} - {# outputs "path-seg%2Ament" #} - - {{ "string with spaces"|url_encode }} - {# outputs "string%20with%20spaces" #} - - {{ {'param': 'value', 'foo': 'bar'}|url_encode }} - {# outputs "param=value&foo=bar" #} - -.. note:: - - Internally, Twig uses the PHP `urlencode`_ (or `rawurlencode`_ if you pass - ``true`` as the first parameter) or the `http_build_query`_ function. Note - that as of Twig 1.16.0, ``urlencode`` **always** uses ``rawurlencode`` (the - ``raw`` argument was removed.) - -.. _`urlencode`: http://php.net/urlencode -.. _`rawurlencode`: http://php.net/rawurlencode -.. _`http_build_query`: http://php.net/http_build_query diff --git a/lib/silex/vendor/twig/twig/doc/functions/attribute.rst b/lib/silex/vendor/twig/twig/doc/functions/attribute.rst deleted file mode 100644 index ceba96b05..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/attribute.rst +++ /dev/null @@ -1,26 +0,0 @@ -``attribute`` -============= - -.. versionadded:: 1.2 - The ``attribute`` function was added in Twig 1.2. - -The ``attribute`` function can be used to access a "dynamic" attribute of a -variable: - -.. code-block:: jinja - - {{ attribute(object, method) }} - {{ attribute(object, method, arguments) }} - {{ attribute(array, item) }} - -In addition, the ``defined`` test can check for the existence of a dynamic -attribute: - -.. code-block:: jinja - - {{ attribute(object, method) is defined ? 'Method exists' : 'Method does not exist' }} - -.. note:: - - The resolution algorithm is the same as the one used for the ``.`` - notation, except that the item can be any valid expression. diff --git a/lib/silex/vendor/twig/twig/doc/functions/block.rst b/lib/silex/vendor/twig/twig/doc/functions/block.rst deleted file mode 100644 index f5d683c73..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/block.rst +++ /dev/null @@ -1,41 +0,0 @@ -``block`` -========= - -.. versionadded: 1.28 - Using ``block`` with the ``defined`` test was added in Twig 1.28. - -.. versionadded: 1.28 - Support for the template argument was added in Twig 1.28. - -When a template uses inheritance and if you want to print a block multiple -times, use the ``block`` function: - -.. code-block:: jinja - - {% block title %}{% endblock %} - -

{{ block('title') }}

- - {% block body %}{% endblock %} - -The ``block`` function can also be used to display one block of another -template: - -.. code-block:: jinja - - {{ block("title", "common_blocks.twig") }} - -Use the ``defined`` test to check if a block exists in the context of the -current template: - -.. code-block:: jinja - - {% if block("footer") is defined %} - ... - {% endif %} - - {% if block("footer", "common_blocks.twig") is defined %} - ... - {% endif %} - -.. seealso:: :doc:`extends<../tags/extends>`, :doc:`parent<../functions/parent>` diff --git a/lib/silex/vendor/twig/twig/doc/functions/constant.rst b/lib/silex/vendor/twig/twig/doc/functions/constant.rst deleted file mode 100644 index 97aa5c8f3..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/constant.rst +++ /dev/null @@ -1,29 +0,0 @@ -``constant`` -============ - -.. versionadded: 1.12.1 - constant now accepts object instances as the second argument. - -.. versionadded: 1.28 - Using ``constant`` with the ``defined`` test was added in Twig 1.28. - -``constant`` returns the constant value for a given string: - -.. code-block:: jinja - - {{ some_date|date(constant('DATE_W3C')) }} - {{ constant('Namespace\\Classname::CONSTANT_NAME') }} - -As of 1.12.1 you can read constants from object instances as well: - -.. code-block:: jinja - - {{ constant('RSS', date) }} - -Use the ``defined`` test to check if a constant is defined: - -.. code-block:: jinja - - {% if constant('SOME_CONST') is defined %} - ... - {% endif %} diff --git a/lib/silex/vendor/twig/twig/doc/functions/cycle.rst b/lib/silex/vendor/twig/twig/doc/functions/cycle.rst deleted file mode 100644 index e34349323..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/cycle.rst +++ /dev/null @@ -1,28 +0,0 @@ -``cycle`` -========= - -The ``cycle`` function cycles on an array of values: - -.. code-block:: jinja - - {% set start_year = date() | date('Y') %} - {% set end_year = start_year + 5 %} - - {% for year in start_year..end_year %} - {{ cycle(['odd', 'even'], loop.index0) }} - {% endfor %} - -The array can contain any number of values: - -.. code-block:: jinja - - {% set fruits = ['apple', 'orange', 'citrus'] %} - - {% for i in 0..10 %} - {{ cycle(fruits, i) }} - {% endfor %} - -Arguments ---------- - -* ``position``: The cycle position diff --git a/lib/silex/vendor/twig/twig/doc/functions/date.rst b/lib/silex/vendor/twig/twig/doc/functions/date.rst deleted file mode 100644 index 158dd6a65..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/date.rst +++ /dev/null @@ -1,55 +0,0 @@ -``date`` -======== - -.. versionadded:: 1.6 - The date function has been added in Twig 1.6. - -.. versionadded:: 1.6.1 - The default timezone support has been added in Twig 1.6.1. - -Converts an argument to a date to allow date comparison: - -.. code-block:: jinja - - {% if date(user.created_at) < date('-2days') %} - {# do something #} - {% endif %} - -The argument must be in one of PHP’s supported `date and time formats`_. - -You can pass a timezone as the second argument: - -.. code-block:: jinja - - {% if date(user.created_at) < date('-2days', 'Europe/Paris') %} - {# do something #} - {% endif %} - -If no argument is passed, the function returns the current date: - -.. code-block:: jinja - - {% if date(user.created_at) < date() %} - {# always! #} - {% endif %} - -.. note:: - - You can set the default timezone globally by calling ``setTimezone()`` on - the ``core`` extension instance: - - .. code-block:: php - - $twig = new Twig_Environment($loader); - $twig->getExtension('Twig_Extension_Core')->setTimezone('Europe/Paris'); - - // before Twig 1.26 - $twig->getExtension('core')->setTimezone('Europe/Paris'); - -Arguments ---------- - -* ``date``: The date -* ``timezone``: The timezone - -.. _`date and time formats`: http://php.net/manual/en/datetime.formats.php diff --git a/lib/silex/vendor/twig/twig/doc/functions/dump.rst b/lib/silex/vendor/twig/twig/doc/functions/dump.rst deleted file mode 100644 index a231f089e..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/dump.rst +++ /dev/null @@ -1,69 +0,0 @@ -``dump`` -======== - -.. versionadded:: 1.5 - The ``dump`` function was added in Twig 1.5. - -The ``dump`` function dumps information about a template variable. This is -mostly useful to debug a template that does not behave as expected by -introspecting its variables: - -.. code-block:: jinja - - {{ dump(user) }} - -.. note:: - - The ``dump`` function is not available by default. You must add the - ``Twig_Extension_Debug`` extension explicitly when creating your Twig - environment:: - - $twig = new Twig_Environment($loader, array( - 'debug' => true, - // ... - )); - $twig->addExtension(new Twig_Extension_Debug()); - - Even when enabled, the ``dump`` function won't display anything if the - ``debug`` option on the environment is not enabled (to avoid leaking debug - information on a production server). - -In an HTML context, wrap the output with a ``pre`` tag to make it easier to -read: - -.. code-block:: jinja - -
-        {{ dump(user) }}
-    
- -.. tip:: - - Using a ``pre`` tag is not needed when `XDebug`_ is enabled and - ``html_errors`` is ``on``; as a bonus, the output is also nicer with - XDebug enabled. - -You can debug several variables by passing them as additional arguments: - -.. code-block:: jinja - - {{ dump(user, categories) }} - -If you don't pass any value, all variables from the current context are -dumped: - -.. code-block:: jinja - - {{ dump() }} - -.. note:: - - Internally, Twig uses the PHP `var_dump`_ function. - -Arguments ---------- - -* ``context``: The context to dump - -.. _`XDebug`: http://xdebug.org/docs/display -.. _`var_dump`: http://php.net/var_dump diff --git a/lib/silex/vendor/twig/twig/doc/functions/include.rst b/lib/silex/vendor/twig/twig/doc/functions/include.rst deleted file mode 100644 index 2f88ed776..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/include.rst +++ /dev/null @@ -1,84 +0,0 @@ -``include`` -=========== - -.. versionadded:: 1.12 - The ``include`` function was added in Twig 1.12. - -The ``include`` function returns the rendered content of a template: - -.. code-block:: jinja - - {{ include('template.html') }} - {{ include(some_var) }} - -Included templates have access to the variables of the active context. - -If you are using the filesystem loader, the templates are looked for in the -paths defined by it. - -The context is passed by default to the template but you can also pass -additional variables: - -.. code-block:: jinja - - {# template.html will have access to the variables from the current context and the additional ones provided #} - {{ include('template.html', {foo: 'bar'}) }} - -You can disable access to the context by setting ``with_context`` to -``false``: - -.. code-block:: jinja - - {# only the foo variable will be accessible #} - {{ include('template.html', {foo: 'bar'}, with_context = false) }} - -.. code-block:: jinja - - {# no variables will be accessible #} - {{ include('template.html', with_context = false) }} - -And if the expression evaluates to a ``Twig_Template`` or a -``Twig_TemplateWrapper`` instance, Twig will use it directly:: - - // {{ include(template) }} - - // deprecated as of Twig 1.28 - $template = $twig->loadTemplate('some_template.twig'); - - // as of Twig 1.28 - $template = $twig->load('some_template.twig'); - - $twig->display('template.twig', array('template' => $template)); - -When you set the ``ignore_missing`` flag, Twig will return an empty string if -the template does not exist: - -.. code-block:: jinja - - {{ include('sidebar.html', ignore_missing = true) }} - -You can also provide a list of templates that are checked for existence before -inclusion. The first template that exists will be rendered: - -.. code-block:: jinja - - {{ include(['page_detailed.html', 'page.html']) }} - -If ``ignore_missing`` is set, it will fall back to rendering nothing if none -of the templates exist, otherwise it will throw an exception. - -When including a template created by an end user, you should consider -sandboxing it: - -.. code-block:: jinja - - {{ include('page.html', sandboxed = true) }} - -Arguments ---------- - -* ``template``: The template to render -* ``variables``: The variables to pass to the template -* ``with_context``: Whether to pass the current context variables or not -* ``ignore_missing``: Whether to ignore missing templates or not -* ``sandboxed``: Whether to sandbox the template or not diff --git a/lib/silex/vendor/twig/twig/doc/functions/index.rst b/lib/silex/vendor/twig/twig/doc/functions/index.rst deleted file mode 100644 index 07214a76c..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -Functions -========= - -.. toctree:: - :maxdepth: 1 - - attribute - block - constant - cycle - date - dump - include - max - min - parent - random - range - source - template_from_string diff --git a/lib/silex/vendor/twig/twig/doc/functions/max.rst b/lib/silex/vendor/twig/twig/doc/functions/max.rst deleted file mode 100644 index 6f3cfc535..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/max.rst +++ /dev/null @@ -1,20 +0,0 @@ -``max`` -======= - -.. versionadded:: 1.15 - The ``max`` function was added in Twig 1.15. - -``max`` returns the biggest value of a sequence or a set of values: - -.. code-block:: jinja - - {{ max(1, 3, 2) }} - {{ max([1, 3, 2]) }} - -When called with a mapping, max ignores keys and only compares values: - -.. code-block:: jinja - - {{ max({2: "e", 1: "a", 3: "b", 5: "d", 4: "c"}) }} - {# returns "e" #} - diff --git a/lib/silex/vendor/twig/twig/doc/functions/min.rst b/lib/silex/vendor/twig/twig/doc/functions/min.rst deleted file mode 100644 index 7b6a65e10..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/min.rst +++ /dev/null @@ -1,20 +0,0 @@ -``min`` -======= - -.. versionadded:: 1.15 - The ``min`` function was added in Twig 1.15. - -``min`` returns the lowest value of a sequence or a set of values: - -.. code-block:: jinja - - {{ min(1, 3, 2) }} - {{ min([1, 3, 2]) }} - -When called with a mapping, min ignores keys and only compares values: - -.. code-block:: jinja - - {{ min({2: "e", 3: "a", 1: "b", 5: "d", 4: "c"}) }} - {# returns "a" #} - diff --git a/lib/silex/vendor/twig/twig/doc/functions/parent.rst b/lib/silex/vendor/twig/twig/doc/functions/parent.rst deleted file mode 100644 index f5bd20010..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/parent.rst +++ /dev/null @@ -1,20 +0,0 @@ -``parent`` -========== - -When a template uses inheritance, it's possible to render the contents of the -parent block when overriding a block by using the ``parent`` function: - -.. code-block:: jinja - - {% extends "base.html" %} - - {% block sidebar %} -

Table Of Contents

- ... - {{ parent() }} - {% endblock %} - -The ``parent()`` call will return the content of the ``sidebar`` block as -defined in the ``base.html`` template. - -.. seealso:: :doc:`extends<../tags/extends>`, :doc:`block<../functions/block>`, :doc:`block<../tags/block>` diff --git a/lib/silex/vendor/twig/twig/doc/functions/random.rst b/lib/silex/vendor/twig/twig/doc/functions/random.rst deleted file mode 100644 index 168e74f8f..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/random.rst +++ /dev/null @@ -1,29 +0,0 @@ -``random`` -========== - -.. versionadded:: 1.5 - The ``random`` function was added in Twig 1.5. - -.. versionadded:: 1.6 - String and integer handling was added in Twig 1.6. - -The ``random`` function returns a random value depending on the supplied -parameter type: - -* a random item from a sequence; -* a random character from a string; -* a random integer between 0 and the integer parameter (inclusive). - -.. code-block:: jinja - - {{ random(['apple', 'orange', 'citrus']) }} {# example output: orange #} - {{ random('ABC') }} {# example output: C #} - {{ random() }} {# example output: 15386094 (works as the native PHP mt_rand function) #} - {{ random(5) }} {# example output: 3 #} - -Arguments ---------- - -* ``values``: The values - -.. _`mt_rand`: http://php.net/mt_rand diff --git a/lib/silex/vendor/twig/twig/doc/functions/range.rst b/lib/silex/vendor/twig/twig/doc/functions/range.rst deleted file mode 100644 index 5c9db0892..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/range.rst +++ /dev/null @@ -1,58 +0,0 @@ -``range`` -========= - -Returns a list containing an arithmetic progression of integers: - -.. code-block:: jinja - - {% for i in range(0, 3) %} - {{ i }}, - {% endfor %} - - {# outputs 0, 1, 2, 3, #} - -When step is given (as the third parameter), it specifies the increment (or -decrement for negative values): - -.. code-block:: jinja - - {% for i in range(0, 6, 2) %} - {{ i }}, - {% endfor %} - - {# outputs 0, 2, 4, 6, #} - -.. note:: - - Note that if the start is greater than the end, ``range`` assumes a step of - ``-1``: - - .. code-block:: jinja - - {% for i in range(3, 0) %} - {{ i }}, - {% endfor %} - - {# outputs 3, 2, 1, 0, #} - -The Twig built-in ``..`` operator is just syntactic sugar for the ``range`` -function (with a step of ``1``, or ``-1`` if the start is greater than the end): - -.. code-block:: jinja - - {% for i in 0..3 %} - {{ i }}, - {% endfor %} - -.. tip:: - - The ``range`` function works as the native PHP `range`_ function. - -Arguments ---------- - -* ``low``: The first value of the sequence. -* ``high``: The highest possible value of the sequence. -* ``step``: The increment between elements of the sequence. - -.. _`range`: http://php.net/range diff --git a/lib/silex/vendor/twig/twig/doc/functions/source.rst b/lib/silex/vendor/twig/twig/doc/functions/source.rst deleted file mode 100644 index 3c921b1cf..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/source.rst +++ /dev/null @@ -1,32 +0,0 @@ -``source`` -========== - -.. versionadded:: 1.15 - The ``source`` function was added in Twig 1.15. - -.. versionadded:: 1.18.3 - The ``ignore_missing`` flag was added in Twig 1.18.3. - -The ``source`` function returns the content of a template without rendering it: - -.. code-block:: jinja - - {{ source('template.html') }} - {{ source(some_var) }} - -When you set the ``ignore_missing`` flag, Twig will return an empty string if -the template does not exist: - -.. code-block:: jinja - - {{ source('template.html', ignore_missing = true) }} - -The function uses the same template loaders as the ones used to include -templates. So, if you are using the filesystem loader, the templates are looked -for in the paths defined by it. - -Arguments ---------- - -* ``name``: The name of the template to read -* ``ignore_missing``: Whether to ignore missing templates or not diff --git a/lib/silex/vendor/twig/twig/doc/functions/template_from_string.rst b/lib/silex/vendor/twig/twig/doc/functions/template_from_string.rst deleted file mode 100644 index ce6a60dc0..000000000 --- a/lib/silex/vendor/twig/twig/doc/functions/template_from_string.rst +++ /dev/null @@ -1,32 +0,0 @@ -``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`` function, you can use it with any tag or function that - takes a template as an argument (like the ``embed`` or ``extends`` tags). - -Arguments ---------- - -* ``template``: The template diff --git a/lib/silex/vendor/twig/twig/doc/index.rst b/lib/silex/vendor/twig/twig/doc/index.rst deleted file mode 100644 index 358bd738e..000000000 --- a/lib/silex/vendor/twig/twig/doc/index.rst +++ /dev/null @@ -1,19 +0,0 @@ -Twig -==== - -.. toctree:: - :maxdepth: 2 - - intro - installation - templates - api - advanced - internals - deprecated - recipes - coding_standards - tags/index - filters/index - functions/index - tests/index diff --git a/lib/silex/vendor/twig/twig/doc/installation.rst b/lib/silex/vendor/twig/twig/doc/installation.rst deleted file mode 100644 index afdcf1659..000000000 --- a/lib/silex/vendor/twig/twig/doc/installation.rst +++ /dev/null @@ -1,116 +0,0 @@ -Installation -============ - -You have multiple ways to install Twig. - -Installing the Twig PHP package -------------------------------- - -Installing via Composer (recommended) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Install `Composer`_ and run the following command to get the latest version: - -.. code-block:: bash - - composer require twig/twig:~1.0 - -Installing from the tarball release -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -1. Download the most recent tarball from the `download page`_ -2. Verify the integrity of the tarball http://fabien.potencier.org/article/73/signing-project-releases -3. Unpack the tarball -4. Move the files somewhere in your project - -Installing the development version -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. code-block:: bash - - git clone git://github.com/twigphp/Twig.git - -Installing the PEAR package -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. note:: - - Using PEAR for installing Twig is deprecated and Twig 1.15.1 was the last - version published on the PEAR channel; use Composer instead. - -.. code-block:: bash - - pear channel-discover pear.twig-project.org - pear install twig/Twig - -Installing the C extension --------------------------- - -.. versionadded:: 1.4 - The C extension was added in Twig 1.4. - -.. note:: - - The C extension is **optional** but it brings some nice performance - improvements. Note that the extension is not a replacement for the PHP - code; it only implements a small part of the PHP code to improve the - performance at runtime; you must still install the regular PHP code. - -Twig comes with a C extension that enhances the performance of the Twig -runtime engine; install it like any other PHP extensions: - -.. code-block:: bash - - cd ext/twig - phpize - ./configure - make - make install - -.. note:: - - You can also install the C extension via PEAR (note that this method is - deprecated and newer versions of Twig are not available on the PEAR - channel): - - .. code-block:: bash - - pear channel-discover pear.twig-project.org - pear install twig/CTwig - -For Windows: - -1. Setup the build environment following the `PHP documentation`_ -2. Put Twig's C extension source code into ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\ext\twig`` -3. Use the ``configure --disable-all --enable-cli --enable-twig=shared`` command instead of step 14 -4. ``nmake`` -5. Copy the ``C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release_TS\php_twig.dll`` file to your PHP setup. - -.. tip:: - - For Windows ZendServer, ZTS is not enabled as mentioned in `Zend Server - FAQ`_. - - You have to use ``configure --disable-all --disable-zts --enable-cli - --enable-twig=shared`` to be able to build the twig C extension for - ZendServer. - - The built DLL will be available in - ``C:\\php-sdk\\phpdev\\vcXX\\x86\\php-source-directory\\Release`` - -Finally, enable the extension in your ``php.ini`` configuration file: - -.. code-block:: ini - - extension=twig.so #For Unix systems - extension=php_twig.dll #For Windows systems - -And from now on, Twig will automatically compile your templates to take -advantage of the C extension. Note that this extension does not replace the -PHP code but only provides an optimized version of the -``Twig_Template::getAttribute()`` method. - -.. _`download page`: https://github.com/twigphp/Twig/tags -.. _`Composer`: https://getcomposer.org/download/ -.. _`PHP documentation`: https://wiki.php.net/internals/windows/stepbystepbuild -.. _`Zend Server FAQ`: http://www.zend.com/en/products/server/faq#faqD6 diff --git a/lib/silex/vendor/twig/twig/doc/internals.rst b/lib/silex/vendor/twig/twig/doc/internals.rst deleted file mode 100644 index fec65e00e..000000000 --- a/lib/silex/vendor/twig/twig/doc/internals.rst +++ /dev/null @@ -1,142 +0,0 @@ -Twig Internals -============== - -Twig is very extensible and you can easily hack it. Keep in mind that you -should probably try to create an extension before hacking the core, as most -features and enhancements can be handled with extensions. This chapter is also -useful for people who want to understand how Twig works under the hood. - -How does Twig work? -------------------- - -The rendering of a Twig template can be summarized into four key steps: - -* **Load** the template: If the template is already compiled, load it and go - to the *evaluation* step, otherwise: - - * First, the **lexer** tokenizes the template source code into small pieces - for easier processing; - * Then, the **parser** converts the token stream into a meaningful tree - of nodes (the Abstract Syntax Tree); - * Eventually, the *compiler* transforms the AST into PHP code. - -* **Evaluate** the template: It basically means calling the ``display()`` - method of the compiled template and passing it the context. - -The Lexer ---------- - -The lexer tokenizes a template source code into a token stream (each token is -an instance of ``Twig_Token``, and the stream is an instance of -``Twig_TokenStream``). The default lexer recognizes 13 different token types: - -* ``Twig_Token::BLOCK_START_TYPE``, ``Twig_Token::BLOCK_END_TYPE``: Delimiters for blocks (``{% %}``) -* ``Twig_Token::VAR_START_TYPE``, ``Twig_Token::VAR_END_TYPE``: Delimiters for variables (``{{ }}``) -* ``Twig_Token::TEXT_TYPE``: A text outside an expression; -* ``Twig_Token::NAME_TYPE``: A name in an expression; -* ``Twig_Token::NUMBER_TYPE``: A number in an expression; -* ``Twig_Token::STRING_TYPE``: A string in an expression; -* ``Twig_Token::OPERATOR_TYPE``: An operator; -* ``Twig_Token::PUNCTUATION_TYPE``: A punctuation sign; -* ``Twig_Token::INTERPOLATION_START_TYPE``, ``Twig_Token::INTERPOLATION_END_TYPE`` (as of Twig 1.5): Delimiters for string interpolation; -* ``Twig_Token::EOF_TYPE``: Ends of template. - -You can manually convert a source code into a token stream by calling the -``tokenize()`` method of an environment:: - - $stream = $twig->tokenize(new Twig_Source($source, $identifier)); - -.. versionadded:: 1.27 - ``Twig_Source`` was introduced in version 1.27, pass the source and the - identifier directly on previous versions. - -As the stream has a ``__toString()`` method, you can have a textual -representation of it by echoing the object:: - - echo $stream."\n"; - -Here is the output for the ``Hello {{ name }}`` template: - -.. code-block:: text - - TEXT_TYPE(Hello ) - VAR_START_TYPE() - NAME_TYPE(name) - VAR_END_TYPE() - EOF_TYPE() - -.. note:: - - The default lexer (``Twig_Lexer``) can be changed by calling - the ``setLexer()`` method:: - - $twig->setLexer($lexer); - -The Parser ----------- - -The parser converts the token stream into an AST (Abstract Syntax Tree), or a -node tree (an instance of ``Twig_Node_Module``). The core extension defines -the basic nodes like: ``for``, ``if``, ... and the expression nodes. - -You can manually convert a token stream into a node tree by calling the -``parse()`` method of an environment:: - - $nodes = $twig->parse($stream); - -Echoing the node object gives you a nice representation of the tree:: - - echo $nodes."\n"; - -Here is the output for the ``Hello {{ name }}`` template: - -.. code-block:: text - - Twig_Node_Module( - Twig_Node_Text(Hello ) - Twig_Node_Print( - Twig_Node_Expression_Name(name) - ) - ) - -.. note:: - - The default parser (``Twig_TokenParser``) can be changed by calling the - ``setParser()`` method:: - - $twig->setParser($parser); - -The Compiler ------------- - -The last step is done by the compiler. It takes a node tree as an input and -generates PHP code usable for runtime execution of the template. - -You can manually compile a node tree to PHP code with the ``compile()`` method -of an environment:: - - $php = $twig->compile($nodes); - -The generated template for a ``Hello {{ name }}`` template reads as follows -(the actual output can differ depending on the version of Twig you are -using):: - - /* Hello {{ name }} */ - class __TwigTemplate_1121b6f109fe93ebe8c6e22e3712bceb extends Twig_Template - { - protected function doDisplay(array $context, array $blocks = array()) - { - // line 1 - echo "Hello "; - echo twig_escape_filter($this->env, (isset($context["name"]) ? $context["name"] : null), "html", null, true); - } - - // some more code - } - -.. note:: - - The default compiler (``Twig_Compiler``) can be changed by calling the - ``setCompiler()`` method:: - - $twig->setCompiler($compiler); diff --git a/lib/silex/vendor/twig/twig/doc/intro.rst b/lib/silex/vendor/twig/twig/doc/intro.rst deleted file mode 100644 index d631430f7..000000000 --- a/lib/silex/vendor/twig/twig/doc/intro.rst +++ /dev/null @@ -1,86 +0,0 @@ -Introduction -============ - -This is the documentation for Twig, the flexible, fast, and secure template -engine for PHP. - -If you have any exposure to other text-based template languages, such as -Smarty, Django, or Jinja, you should feel right at home with Twig. It's both -designer and developer friendly by sticking to PHP's principles and adding -functionality useful for templating environments. - -The key-features are... - -* *Fast*: Twig compiles templates down to plain optimized PHP code. The - overhead compared to regular PHP code was reduced to the very minimum. - -* *Secure*: Twig has a sandbox mode to evaluate untrusted template code. This - allows Twig to be used as a template language for applications where users - may modify the template design. - -* *Flexible*: Twig is powered by a flexible lexer and parser. This allows the - developer to define their own custom tags and filters, and to create their own DSL. - -Twig is used by many Open-Source projects like Symfony, Drupal8, eZPublish, -phpBB, Piwik, OroCRM; and many frameworks have support for it as well like -Slim, Yii, Laravel, Codeigniter and Kohana — just to name a few. - -Prerequisites -------------- - -Twig needs at least **PHP 5.2.7** to run. As of 1.34, the minimum requirement -was bumped to **PHP 5.3.3**. - -Installation ------------- - -The recommended way to install Twig is via Composer: - -.. code-block:: bash - - composer require "twig/twig:~1.0" - -.. note:: - - To learn more about the other installation methods, read the - :doc:`installation` chapter; it also explains how to install - the Twig C extension. - -Basic API Usage ---------------- - -This section gives you a brief introduction to the PHP API for Twig. - -.. code-block:: php - - require_once '/path/to/vendor/autoload.php'; - - $loader = new Twig_Loader_Array(array( - 'index' => 'Hello {{ name }}!', - )); - $twig = new Twig_Environment($loader); - - echo $twig->render('index', array('name' => 'Fabien')); - -Twig uses a loader (``Twig_Loader_Array``) to locate templates, and an -environment (``Twig_Environment``) to store the configuration. - -The ``render()`` method loads the template passed as a first argument and -renders it with the variables passed as a second argument. - -As templates are generally stored on the filesystem, Twig also comes with a -filesystem loader:: - - $loader = new Twig_Loader_Filesystem('/path/to/templates'); - $twig = new Twig_Environment($loader, array( - 'cache' => '/path/to/compilation_cache', - )); - - echo $twig->render('index.html', array('name' => 'Fabien')); - -.. tip:: - - If you are not using Composer, use the Twig built-in autoloader:: - - require_once '/path/to/lib/Twig/Autoloader.php'; - Twig_Autoloader::register(); diff --git a/lib/silex/vendor/twig/twig/doc/recipes.rst b/lib/silex/vendor/twig/twig/doc/recipes.rst deleted file mode 100644 index b3ba7f4d7..000000000 --- a/lib/silex/vendor/twig/twig/doc/recipes.rst +++ /dev/null @@ -1,568 +0,0 @@ -Recipes -======= - -.. _deprecation-notices: - -Displaying Deprecation Notices ------------------------------- - -.. versionadded:: 1.21 - This works as of Twig 1.21. - -Deprecated features generate deprecation notices (via a call to the -``trigger_error()`` PHP function). By default, they are silenced and never -displayed nor logged. - -To easily remove all deprecated feature usages from your templates, write and -run a script along the lines of the following:: - - require_once __DIR__.'/vendor/autoload.php'; - - $twig = create_your_twig_env(); - - $deprecations = new Twig_Util_DeprecationCollector($twig); - - print_r($deprecations->collectDir(__DIR__.'/templates')); - -The ``collectDir()`` method compiles all templates found in a directory, -catches deprecation notices, and return them. - -.. tip:: - - If your templates are not stored on the filesystem, use the ``collect()`` - method instead. ``collect()`` takes a ``Traversable`` which must return - template names as keys and template contents as values (as done by - ``Twig_Util_TemplateDirIterator``). - -However, this code won't find all deprecations (like using deprecated some Twig -classes). To catch all notices, register a custom error handler like the one -below:: - - $deprecations = array(); - set_error_handler(function ($type, $msg) use (&$deprecations) { - if (E_USER_DEPRECATED === $type) { - $deprecations[] = $msg; - } - }); - - // run your application - - print_r($deprecations); - -Note that most deprecation notices are triggered during **compilation**, so -they won't be generated when templates are already cached. - -.. tip:: - - If you want to manage the deprecation notices from your PHPUnit tests, have - a look at the `symfony/phpunit-bridge - `_ package, which eases the - process a lot. - -Making a Layout conditional ---------------------------- - -Working with Ajax means that the same content is sometimes displayed as is, -and sometimes decorated with a layout. As Twig layout template names can be -any valid expression, you can pass a variable that evaluates to ``true`` when -the request is made via Ajax and choose the layout accordingly: - -.. code-block:: jinja - - {% extends request.ajax ? "base_ajax.html" : "base.html" %} - - {% block content %} - This is the content to be displayed. - {% endblock %} - -Making an Include dynamic -------------------------- - -When including a template, its name does not need to be a string. For -instance, the name can depend on the value of a variable: - -.. code-block:: jinja - - {% include var ~ '_foo.html' %} - -If ``var`` evaluates to ``index``, the ``index_foo.html`` template will be -rendered. - -As a matter of fact, the template name can be any valid expression, such as -the following: - -.. code-block:: jinja - - {% include var|default('index') ~ '_foo.html' %} - -Overriding a Template that also extends itself ----------------------------------------------- - -A template can be customized in two different ways: - -* *Inheritance*: A template *extends* a parent template and overrides some - blocks; - -* *Replacement*: If you use the filesystem loader, Twig loads the first - template it finds in a list of configured directories; a template found in a - directory *replaces* another one from a directory further in the list. - -But how do you combine both: *replace* a template that also extends itself -(aka a template in a directory further in the list)? - -Let's say that your templates are loaded from both ``.../templates/mysite`` -and ``.../templates/default`` in this order. The ``page.twig`` template, -stored in ``.../templates/default`` reads as follows: - -.. code-block:: jinja - - {# page.twig #} - {% extends "layout.twig" %} - - {% block content %} - {% endblock %} - -You can replace this template by putting a file with the same name in -``.../templates/mysite``. And if you want to extend the original template, you -might be tempted to write the following: - -.. code-block:: jinja - - {# page.twig in .../templates/mysite #} - {% extends "page.twig" %} {# from .../templates/default #} - -Of course, this will not work as Twig will always load the template from -``.../templates/mysite``. - -It turns out it is possible to get this to work, by adding a directory right -at the end of your template directories, which is the parent of all of the -other directories: ``.../templates`` in our case. This has the effect of -making every template file within our system uniquely addressable. Most of the -time you will use the "normal" paths, but in the special case of wanting to -extend a template with an overriding version of itself we can reference its -parent's full, unambiguous template path in the extends tag: - -.. code-block:: jinja - - {# page.twig in .../templates/mysite #} - {% extends "default/page.twig" %} {# from .../templates #} - -.. note:: - - This recipe was inspired by the following Django wiki page: - http://code.djangoproject.com/wiki/ExtendingTemplates - -Customizing the Syntax ----------------------- - -Twig allows some syntax customization for the block delimiters. It's not -recommended to use this feature as templates will be tied with your custom -syntax. But for specific projects, it can make sense to change the defaults. - -To change the block delimiters, you need to create your own lexer object:: - - $twig = new Twig_Environment(); - - $lexer = new Twig_Lexer($twig, array( - 'tag_comment' => array('{#', '#}'), - 'tag_block' => array('{%', '%}'), - 'tag_variable' => array('{{', '}}'), - 'interpolation' => array('#{', '}'), - )); - $twig->setLexer($lexer); - -Here are some configuration example that simulates some other template engines -syntax:: - - // Ruby erb syntax - $lexer = new Twig_Lexer($twig, array( - 'tag_comment' => array('<%#', '%>'), - 'tag_block' => array('<%', '%>'), - 'tag_variable' => array('<%=', '%>'), - )); - - // SGML Comment Syntax - $lexer = new Twig_Lexer($twig, array( - 'tag_comment' => array(''), - 'tag_block' => array(''), - 'tag_variable' => array('${', '}'), - )); - - // Smarty like - $lexer = new Twig_Lexer($twig, array( - 'tag_comment' => array('{*', '*}'), - 'tag_block' => array('{', '}'), - 'tag_variable' => array('{$', '}'), - )); - -Using dynamic Object Properties -------------------------------- - -When Twig encounters a variable like ``article.title``, it tries to find a -``title`` public property in the ``article`` object. - -It also works if the property does not exist but is rather defined dynamically -thanks to the magic ``__get()`` method; you just need to also implement the -``__isset()`` magic method like shown in the following snippet of code:: - - class Article - { - public function __get($name) - { - if ('title' == $name) { - return 'The title'; - } - - // throw some kind of error - } - - public function __isset($name) - { - if ('title' == $name) { - return true; - } - - return false; - } - } - -Accessing the parent Context in Nested Loops --------------------------------------------- - -Sometimes, when using nested loops, you need to access the parent context. The -parent context is always accessible via the ``loop.parent`` variable. For -instance, if you have the following template data:: - - $data = array( - 'topics' => array( - 'topic1' => array('Message 1 of topic 1', 'Message 2 of topic 1'), - 'topic2' => array('Message 1 of topic 2', 'Message 2 of topic 2'), - ), - ); - -And the following template to display all messages in all topics: - -.. code-block:: jinja - - {% for topic, messages in topics %} - * {{ loop.index }}: {{ topic }} - {% for message in messages %} - - {{ loop.parent.loop.index }}.{{ loop.index }}: {{ message }} - {% endfor %} - {% endfor %} - -The output will be similar to: - -.. code-block:: text - - * 1: topic1 - - 1.1: The message 1 of topic 1 - - 1.2: The message 2 of topic 1 - * 2: topic2 - - 2.1: The message 1 of topic 2 - - 2.2: The message 2 of topic 2 - -In the inner loop, the ``loop.parent`` variable is used to access the outer -context. So, the index of the current ``topic`` defined in the outer for loop -is accessible via the ``loop.parent.loop.index`` variable. - -Defining undefined Functions and Filters on the Fly ---------------------------------------------------- - -When a function (or a filter) is not defined, Twig defaults to throw a -``Twig_Error_Syntax`` exception. However, it can also call a `callback`_ (any -valid PHP callable) which should return a function (or a filter). - -For filters, register callbacks with ``registerUndefinedFilterCallback()``. -For functions, use ``registerUndefinedFunctionCallback()``:: - - // auto-register all native PHP functions as Twig functions - // don't try this at home as it's not secure at all! - $twig->registerUndefinedFunctionCallback(function ($name) { - if (function_exists($name)) { - return new Twig_SimpleFunction($name, $name); - } - - return false; - }); - -If the callable is not able to return a valid function (or filter), it must -return ``false``. - -If you register more than one callback, Twig will call them in turn until one -does not return ``false``. - -.. tip:: - - As the resolution of functions and filters is done during compilation, - there is no overhead when registering these callbacks. - -Validating the Template Syntax ------------------------------- - -When template code is provided by a third-party (through a web interface for -instance), it might be interesting to validate the template syntax before -saving it. If the template code is stored in a `$template` variable, here is -how you can do it:: - - try { - $twig->parse($twig->tokenize(new Twig_Source($template))); - - // the $template is valid - } catch (Twig_Error_Syntax $e) { - // $template contains one or more syntax errors - } - -If you iterate over a set of files, you can pass the filename to the -``tokenize()`` method to get the filename in the exception message:: - - foreach ($files as $file) { - try { - $twig->parse($twig->tokenize(new Twig_Source($template, $file->getFilename(), $file))); - - // the $template is valid - } catch (Twig_Error_Syntax $e) { - // $template contains one or more syntax errors - } - } - -.. versionadded:: 1.27 - ``Twig_Source`` was introduced in version 1.27, pass the source and the - identifier directly on previous versions. - -.. note:: - - This method won't catch any sandbox policy violations because the policy - is enforced during template rendering (as Twig needs the context for some - checks like allowed methods on objects). - -Refreshing modified Templates when OPcache or APC is enabled ------------------------------------------------------------- - -When using OPcache with ``opcache.validate_timestamps`` set to ``0`` or APC -with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing the template -cache won't update the cache. - -To get around this, force Twig to invalidate the bytecode cache:: - - $twig = new Twig_Environment($loader, array( - 'cache' => new Twig_Cache_Filesystem('/some/cache/path', Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION), - // ... - )); - -.. note:: - - Before Twig 1.22, you should extend ``Twig_Environment`` instead:: - - class OpCacheAwareTwigEnvironment extends Twig_Environment - { - protected function writeCacheFile($file, $content) - { - parent::writeCacheFile($file, $content); - - // Compile cached file into bytecode cache - if (function_exists('opcache_invalidate')) { - opcache_invalidate($file, true); - } elseif (function_exists('apc_compile_file')) { - apc_compile_file($file); - } - } - } - -Reusing a stateful Node Visitor -------------------------------- - -When attaching a visitor to a ``Twig_Environment`` instance, Twig uses it to -visit *all* templates it compiles. If you need to keep some state information -around, you probably want to reset it when visiting a new template. - -This can be easily achieved with the following code:: - - protected $someTemplateState = array(); - - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Module) { - // reset the state as we are entering a new template - $this->someTemplateState = array(); - } - - // ... - - return $node; - } - -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, Twig_SourceContextLoaderInterface - { - 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_SourceContextLoaderInterface as of Twig 1.27 - public function getSourceContext($name) - { - if (false === $source = $this->getValue('source', $name)) { - throw new Twig_Error_Loader(sprintf('Template "%s" does not exist.', $name)); - } - - return new Twig_Source($source, $name); - } - - // 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. - -Loading a Template from a String --------------------------------- - -From a template, you can easily load a template stored in a string via the -``template_from_string`` function (available as of Twig 1.11 via the -``Twig_Extension_StringLoader`` extension): - -.. code-block:: jinja - - {{ include(template_from_string("Hello {{ name }}")) }} - -From PHP, it's also possible to load a template stored in a string via -``Twig_Environment::createTemplate()`` (available as of Twig 1.18):: - - $template = $twig->createTemplate('hello {{ name }}'); - echo $template->render(array('name' => 'Fabien')); - -.. note:: - - Never use the ``Twig_Loader_String`` loader, which has severe limitations. - -Using Twig and AngularJS in the same Templates ----------------------------------------------- - -Mixing different template syntaxes in the same file is not a recommended -practice as both AngularJS and Twig use the same delimiters in their syntax: -``{{`` and ``}}``. - -Still, if you want to use AngularJS and Twig in the same template, there are -two ways to make it work depending on the amount of AngularJS you need to -include in your templates: - -* Escaping the AngularJS delimiters by wrapping AngularJS sections with the - ``{% verbatim %}`` tag or by escaping each delimiter via ``{{ '{{' }}`` and - ``{{ '}}' }}``; - -* Changing the delimiters of one of the template engines (depending on which - engine you introduced last): - - * For AngularJS, change the interpolation tags using the - ``interpolateProvider`` service, for instance at the module initialization - time: - - .. code-block:: javascript - - angular.module('myApp', []).config(function($interpolateProvider) { - $interpolateProvider.startSymbol('{[').endSymbol(']}'); - }); - - * For Twig, change the delimiters via the ``tag_variable`` Lexer option: - - .. code-block:: php - - $env->setLexer(new Twig_Lexer($env, array( - 'tag_variable' => array('{[', ']}'), - ))); - -.. _callback: http://www.php.net/manual/en/function.is-callable.php diff --git a/lib/silex/vendor/twig/twig/doc/tags/autoescape.rst b/lib/silex/vendor/twig/twig/doc/tags/autoescape.rst deleted file mode 100644 index 8aa8c75d1..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/autoescape.rst +++ /dev/null @@ -1,81 +0,0 @@ -``autoescape`` -============== - -Whether automatic escaping is enabled or not, you can mark a section of a -template to be escaped or not by using the ``autoescape`` tag: - -.. code-block:: jinja - - {% autoescape %} - Everything will be automatically escaped in this block - using the HTML strategy - {% endautoescape %} - - {% autoescape 'html' %} - Everything will be automatically escaped in this block - using the HTML strategy - {% endautoescape %} - - {% autoescape 'js' %} - Everything will be automatically escaped in this block - using the js escaping strategy - {% endautoescape %} - - {% autoescape false %} - Everything will be outputted as is in this block - {% endautoescape %} - -.. note:: - - Before Twig 1.8, the syntax was different: - - .. code-block:: jinja - - {% autoescape true %} - Everything will be automatically escaped in this block - using the HTML strategy - {% endautoescape %} - - {% autoescape false %} - Everything will be outputted as is in this block - {% endautoescape %} - - {% autoescape true js %} - Everything will be automatically escaped in this block - using the js escaping strategy - {% endautoescape %} - -When automatic escaping is enabled everything is escaped by default except for -values explicitly marked as safe. Those can be marked in the template by using -the :doc:`raw<../filters/raw>` filter: - -.. code-block:: jinja - - {% autoescape %} - {{ safe_value|raw }} - {% endautoescape %} - -Functions returning template data (like :doc:`macros` and -:doc:`parent<../functions/parent>`) always return safe markup. - -.. note:: - - Twig is smart enough to not escape an already escaped value by the - :doc:`escape<../filters/escape>` filter. - -.. note:: - - Twig does not escape static expressions: - - .. code-block:: jinja - - {% set hello = "Hello" %} - {{ hello }} - {{ "world" }} - - Will be rendered "Hello **world**". - -.. note:: - - The chapter :doc:`Twig for Developers<../api>` gives more information - about when and how automatic escaping is applied. diff --git a/lib/silex/vendor/twig/twig/doc/tags/block.rst b/lib/silex/vendor/twig/twig/doc/tags/block.rst deleted file mode 100644 index e38048232..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/block.rst +++ /dev/null @@ -1,11 +0,0 @@ -``block`` -========= - -Blocks are used for inheritance and act as placeholders and replacements at -the same time. They are documented in detail in the documentation for the -:doc:`extends<../tags/extends>` tag. - -Block names should consist of alphanumeric characters, and underscores. Dashes -are not permitted. - -.. seealso:: :doc:`block<../functions/block>`, :doc:`parent<../functions/parent>`, :doc:`use<../tags/use>`, :doc:`extends<../tags/extends>` diff --git a/lib/silex/vendor/twig/twig/doc/tags/do.rst b/lib/silex/vendor/twig/twig/doc/tags/do.rst deleted file mode 100644 index 1c344e302..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/do.rst +++ /dev/null @@ -1,12 +0,0 @@ -``do`` -====== - -.. versionadded:: 1.5 - The ``do`` tag was added in Twig 1.5. - -The ``do`` tag works exactly like the regular variable expression (``{{ ... -}}``) just that it doesn't print anything: - -.. code-block:: jinja - - {% do 1 + 2 %} diff --git a/lib/silex/vendor/twig/twig/doc/tags/embed.rst b/lib/silex/vendor/twig/twig/doc/tags/embed.rst deleted file mode 100644 index 66fc21b5f..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/embed.rst +++ /dev/null @@ -1,178 +0,0 @@ -``embed`` -========= - -.. versionadded:: 1.8 - The ``embed`` tag was added in Twig 1.8. - -The ``embed`` tag combines the behaviour of :doc:`include` and -:doc:`extends`. -It allows you to include another template's contents, just like ``include`` -does. But it also allows you to override any block defined inside the -included template, like when extending a template. - -Think of an embedded template as a "micro layout skeleton". - -.. code-block:: jinja - - {% embed "teasers_skeleton.twig" %} - {# These blocks are defined in "teasers_skeleton.twig" #} - {# and we override them right here: #} - {% block left_teaser %} - Some content for the left teaser box - {% endblock %} - {% block right_teaser %} - Some content for the right teaser box - {% endblock %} - {% endembed %} - -The ``embed`` tag takes the idea of template inheritance to the level of -content fragments. While template inheritance allows for "document skeletons", -which are filled with life by child templates, the ``embed`` tag allows you to -create "skeletons" for smaller units of content and re-use and fill them -anywhere you like. - -Since the use case may not be obvious, let's look at a simplified example. -Imagine a base template shared by multiple HTML pages, defining a single block -named "content": - -.. code-block:: text - - ┌─── page layout ─────────────────────┐ - │ │ - │ ┌── block "content" ──┐ │ - │ │ │ │ - │ │ │ │ - │ │ (child template to │ │ - │ │ put content here) │ │ - │ │ │ │ - │ │ │ │ - │ └─────────────────────┘ │ - │ │ - └─────────────────────────────────────┘ - -Some pages ("foo" and "bar") share the same content structure - -two vertically stacked boxes: - -.. code-block:: text - - ┌─── page layout ─────────────────────┐ - │ │ - │ ┌── block "content" ──┐ │ - │ │ ┌─ block "top" ───┐ │ │ - │ │ │ │ │ │ - │ │ └─────────────────┘ │ │ - │ │ ┌─ block "bottom" ┐ │ │ - │ │ │ │ │ │ - │ │ └─────────────────┘ │ │ - │ └─────────────────────┘ │ - │ │ - └─────────────────────────────────────┘ - -While other pages ("boom" and "baz") share a different content structure - -two boxes side by side: - -.. code-block:: text - - ┌─── page layout ─────────────────────┐ - │ │ - │ ┌── block "content" ──┐ │ - │ │ │ │ - │ │ ┌ block ┐ ┌ block ┐ │ │ - │ │ │"left" │ │"right"│ │ │ - │ │ │ │ │ │ │ │ - │ │ │ │ │ │ │ │ - │ │ └───────┘ └───────┘ │ │ - │ └─────────────────────┘ │ - │ │ - └─────────────────────────────────────┘ - -Without the ``embed`` tag, you have two ways to design your templates: - - * Create two "intermediate" base templates that extend the master layout - template: one with vertically stacked boxes to be used by the "foo" and - "bar" pages and another one with side-by-side boxes for the "boom" and - "baz" pages. - - * Embed the markup for the top/bottom and left/right boxes into each page - template directly. - -These two solutions do not scale well because they each have a major drawback: - - * The first solution may indeed work for this simplified example. But imagine - we add a sidebar, which may again contain different, recurring structures - of content. Now we would need to create intermediate base templates for - all occurring combinations of content structure and sidebar structure... - and so on. - - * The second solution involves duplication of common code with all its negative - consequences: any change involves finding and editing all affected copies - of the structure, correctness has to be verified for each copy, copies may - go out of sync by careless modifications etc. - -In such a situation, the ``embed`` tag comes in handy. The common layout -code can live in a single base template, and the two different content structures, -let's call them "micro layouts" go into separate templates which are embedded -as necessary: - -Page template ``foo.twig``: - -.. code-block:: jinja - - {% extends "layout_skeleton.twig" %} - - {% block content %} - {% embed "vertical_boxes_skeleton.twig" %} - {% block top %} - Some content for the top box - {% endblock %} - - {% block bottom %} - Some content for the bottom box - {% endblock %} - {% endembed %} - {% endblock %} - -And here is the code for ``vertical_boxes_skeleton.twig``: - -.. code-block:: html+jinja - -
- {% block top %} - Top box default content - {% endblock %} -
- -
- {% block bottom %} - Bottom box default content - {% endblock %} -
- -The goal of the ``vertical_boxes_skeleton.twig`` template being to factor -out the HTML markup for the boxes. - -The ``embed`` tag takes the exact same arguments as the ``include`` tag: - -.. code-block:: jinja - - {% embed "base" with {'foo': 'bar'} %} - ... - {% endembed %} - - {% embed "base" with {'foo': 'bar'} only %} - ... - {% endembed %} - - {% embed "base" ignore missing %} - ... - {% endembed %} - -.. warning:: - - As embedded templates do not have "names", auto-escaping strategies based - on the template name won't work as expected if you change the context (for - instance, if you embed a CSS/JavaScript template into an HTML one). In that - case, explicitly set the default auto-escaping strategy with the - ``autoescape`` tag. - -.. seealso:: :doc:`include<../tags/include>` diff --git a/lib/silex/vendor/twig/twig/doc/tags/extends.rst b/lib/silex/vendor/twig/twig/doc/tags/extends.rst deleted file mode 100644 index 8bf29c4f9..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/extends.rst +++ /dev/null @@ -1,272 +0,0 @@ -``extends`` -=========== - -The ``extends`` tag can be used to extend a template from another one. - -.. note:: - - Like PHP, Twig does not support multiple inheritance. So you can only have - one extends tag called per rendering. However, Twig supports horizontal - :doc:`reuse`. - -Let's define a base template, ``base.html``, which defines a simple HTML -skeleton document: - -.. code-block:: html+jinja - - - - - {% block head %} - - {% block title %}{% endblock %} - My Webpage - {% endblock %} - - -
{% block content %}{% endblock %}
- - - - -In this example, the :doc:`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. - -Child Template --------------- - -A child template might look like this: - -.. code-block:: jinja - - {% extends "base.html" %} - - {% block title %}Index{% endblock %} - {% block head %} - {{ parent() }} - - {% endblock %} - {% block content %} -

Index

-

- Welcome on my awesome homepage. -

- {% endblock %} - -The ``extends`` tag is the key here. It tells the template engine that this -template "extends" another template. When the template system evaluates this -template, first it locates the parent. The extends tag should be the first tag -in the template. - -Note that since the child template doesn't define the ``footer`` block, the -value from the parent template is used instead. - -You can't define multiple ``block`` tags with the same name in the same -template. This limitation exists because a block tag works in "both" -directions. That is, a block tag doesn't just provide a hole to fill - it also -defines the content that fills the hole in the *parent*. If there were two -similarly-named ``block`` tags in a template, that template's parent wouldn't -know which one of the blocks' content to use. - -If you want to print a block multiple times you can however use the -``block`` function: - -.. code-block:: jinja - - {% block title %}{% endblock %} -

{{ block('title') }}

- {% block body %}{% endblock %} - -Parent Blocks -------------- - -It's possible to render the contents of the parent block by using the -:doc:`parent<../functions/parent>` function. This gives back the results of -the parent block: - -.. code-block:: jinja - - {% block sidebar %} -

Table Of Contents

- ... - {{ parent() }} - {% endblock %} - -Named Block End-Tags --------------------- - -Twig allows you to put the name of the block after the end tag for better -readability: - -.. code-block:: jinja - - {% block sidebar %} - {% block inner_sidebar %} - ... - {% endblock inner_sidebar %} - {% endblock sidebar %} - -Of course, the name after the ``endblock`` word must match the block name. - -Block Nesting and Scope ------------------------ - -Blocks can be nested for more complex layouts. Per default, blocks have access -to variables from outer scopes: - -.. code-block:: jinja - - {% for item in seq %} -
  • {% block loop_item %}{{ item }}{% endblock %}
  • - {% endfor %} - -Block Shortcuts ---------------- - -For blocks with little content, it's possible to use a shortcut syntax. The -following constructs do the same thing: - -.. code-block:: jinja - - {% block title %} - {{ page_title|title }} - {% endblock %} - -.. code-block:: jinja - - {% block title page_title|title %} - -Dynamic Inheritance -------------------- - -Twig supports dynamic inheritance by using a variable as the base template: - -.. code-block:: jinja - - {% extends some_var %} - -If the variable evaluates to a ``Twig_Template`` or a ``Twig_TemplateWrapper`` -instance, Twig will use it as the parent template:: - - // {% extends layout %} - - // deprecated as of Twig 1.28 - $layout = $twig->loadTemplate('some_layout_template.twig'); - - // as of Twig 1.28 - $layout = $twig->load('some_layout_template.twig'); - - $twig->display('template.twig', array('layout' => $layout)); - -.. versionadded:: 1.2 - The possibility to pass an array of templates has been added in Twig 1.2. - -You can also provide a list of templates that are checked for existence. The -first template that exists will be used as a parent: - -.. code-block:: jinja - - {% extends ['layout.html', 'base_layout.html'] %} - -Conditional Inheritance ------------------------ - -As the template name for the parent can be any valid Twig expression, it's -possible to make the inheritance mechanism conditional: - -.. code-block:: jinja - - {% extends standalone ? "minimum.html" : "base.html" %} - -In this example, the template will extend the "minimum.html" layout template -if the ``standalone`` variable evaluates to ``true``, and "base.html" -otherwise. - -How do 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 works and more -importantly, how it does not work: - -.. code-block:: jinja - - {# base.twig #} - - {% for post in posts %} - {% block post %} -

    {{ post.title }}

    -

    {{ post.body }}

    - {% 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 %} -
    -
    {{ post.title }}
    -
    {{ post.text }}
    -
    - {% 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 %} -
    -
    {{ post.title }}
    -
    {{ post.text }}
    -
    - {% endfor %} - -Let's take another example: a block included within an ``if`` statement: - -.. code-block:: jinja - - {% if posts is empty %} - {% block head %} - {{ parent() }} - - - {% 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 %} - - {% endif %} - {% endblock head %} - -.. seealso:: :doc:`block<../functions/block>`, :doc:`block<../tags/block>`, :doc:`parent<../functions/parent>`, :doc:`use<../tags/use>` diff --git a/lib/silex/vendor/twig/twig/doc/tags/filter.rst b/lib/silex/vendor/twig/twig/doc/tags/filter.rst deleted file mode 100644 index 82ca5c62f..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/filter.rst +++ /dev/null @@ -1,21 +0,0 @@ -``filter`` -========== - -Filter sections allow you to apply regular Twig filters on a block of template -data. Just wrap the code in the special ``filter`` section: - -.. code-block:: jinja - - {% filter upper %} - This text becomes uppercase - {% endfilter %} - -You can also chain filters: - -.. code-block:: jinja - - {% filter lower|escape %} - SOME TEXT - {% endfilter %} - - {# outputs "<strong>some text</strong>" #} diff --git a/lib/silex/vendor/twig/twig/doc/tags/flush.rst b/lib/silex/vendor/twig/twig/doc/tags/flush.rst deleted file mode 100644 index 55ef593a9..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/flush.rst +++ /dev/null @@ -1,17 +0,0 @@ -``flush`` -========= - -.. versionadded:: 1.5 - The flush tag was added in Twig 1.5. - -The ``flush`` tag tells Twig to flush the output buffer: - -.. code-block:: jinja - - {% flush %} - -.. note:: - - Internally, Twig uses the PHP `flush`_ function. - -.. _`flush`: http://php.net/flush diff --git a/lib/silex/vendor/twig/twig/doc/tags/for.rst b/lib/silex/vendor/twig/twig/doc/tags/for.rst deleted file mode 100644 index 0673b5511..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/for.rst +++ /dev/null @@ -1,172 +0,0 @@ -``for`` -======= - -Loop over each item in a sequence. For example, to display a list of users -provided in a variable called ``users``: - -.. code-block:: jinja - -

    Members

    -
      - {% for user in users %} -
    • {{ user.username|e }}
    • - {% endfor %} -
    - -.. note:: - - A sequence can be either an array or an object implementing the - ``Traversable`` interface. - -If you do need to iterate over a sequence of numbers, you can use the ``..`` -operator: - -.. code-block:: jinja - - {% for i in 0..10 %} - * {{ i }} - {% endfor %} - -The above snippet of code would print all numbers from 0 to 10. - -It can be also useful with letters: - -.. code-block:: jinja - - {% for letter in 'a'..'z' %} - * {{ letter }} - {% endfor %} - -The ``..`` operator can take any expression at both sides: - -.. code-block:: jinja - - {% for letter in 'a'|upper..'z'|upper %} - * {{ letter }} - {% endfor %} - -.. tip: - - If you need a step different from 1, you can use the ``range`` function - instead. - -The `loop` variable -------------------- - -Inside of a ``for`` loop block you can access some special variables: - -===================== ============================================================= -Variable Description -===================== ============================================================= -``loop.index`` The current iteration of the loop. (1 indexed) -``loop.index0`` The current iteration of the loop. (0 indexed) -``loop.revindex`` The number of iterations from the end of the loop (1 indexed) -``loop.revindex0`` The number of iterations from the end of the loop (0 indexed) -``loop.first`` True if first iteration -``loop.last`` True if last iteration -``loop.length`` The number of items in the sequence -``loop.parent`` The parent context -===================== ============================================================= - -.. code-block:: jinja - - {% for user in users %} - {{ loop.index }} - {{ user.username }} - {% endfor %} - -.. note:: - - The ``loop.length``, ``loop.revindex``, ``loop.revindex0``, and - ``loop.last`` variables are only available for PHP arrays, or objects that - implement the ``Countable`` interface. They are also not available when - looping with a condition. - -.. versionadded:: 1.2 - The ``if`` modifier support has been added in Twig 1.2. - -Adding a condition ------------------- - -Unlike in PHP, it's not possible to ``break`` or ``continue`` in a loop. You -can however filter the sequence during iteration which allows you to skip -items. The following example skips all the users which are not active: - -.. code-block:: jinja - -
      - {% for user in users if user.active %} -
    • {{ user.username|e }}
    • - {% endfor %} -
    - -The advantage is that the special loop variable will count correctly thus not -counting the users not iterated over. Keep in mind that properties like -``loop.last`` will not be defined when using loop conditions. - -.. note:: - - Using the ``loop`` variable within the condition is not recommended as it - will probably not be doing what you expect it to. For instance, adding a - condition like ``loop.index > 4`` won't work as the index is only - incremented when the condition is true (so the condition will never - match). - -The `else` Clause ------------------ - -If no iteration took place because the sequence was empty, you can render a -replacement block by using ``else``: - -.. code-block:: jinja - -
      - {% for user in users %} -
    • {{ user.username|e }}
    • - {% else %} -
    • no user found
    • - {% endfor %} -
    - -Iterating over Keys -------------------- - -By default, a loop iterates over the values of the sequence. You can iterate -on keys by using the ``keys`` filter: - -.. code-block:: jinja - -

    Members

    -
      - {% for key in users|keys %} -
    • {{ key }}
    • - {% endfor %} -
    - -Iterating over Keys and Values ------------------------------- - -You can also access both keys and values: - -.. code-block:: jinja - -

    Members

    -
      - {% for key, user in users %} -
    • {{ key }}: {{ user.username|e }}
    • - {% endfor %} -
    - -Iterating over a Subset ------------------------ - -You might want to iterate over a subset of values. This can be achieved using -the :doc:`slice <../filters/slice>` filter: - -.. code-block:: jinja - -

    Top Ten Members

    -
      - {% for user in users|slice(0, 10) %} -
    • {{ user.username|e }}
    • - {% endfor %} -
    diff --git a/lib/silex/vendor/twig/twig/doc/tags/from.rst b/lib/silex/vendor/twig/twig/doc/tags/from.rst deleted file mode 100644 index 39334fdde..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/from.rst +++ /dev/null @@ -1,8 +0,0 @@ -``from`` -======== - -The ``from`` tag imports :doc:`macro<../tags/macro>` names into the current -namespace. The tag is documented in detail in the documentation for the -:doc:`import<../tags/import>` tag. - -.. seealso:: :doc:`macro<../tags/macro>`, :doc:`import<../tags/import>` diff --git a/lib/silex/vendor/twig/twig/doc/tags/if.rst b/lib/silex/vendor/twig/twig/doc/tags/if.rst deleted file mode 100644 index 12edf980d..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/if.rst +++ /dev/null @@ -1,76 +0,0 @@ -``if`` -====== - -The ``if`` statement in Twig is comparable with the if statements of PHP. - -In the simplest form you can use it to test if an expression evaluates to -``true``: - -.. code-block:: jinja - - {% if online == false %} -

    Our website is in maintenance mode. Please, come back later.

    - {% endif %} - -You can also test if an array is not empty: - -.. code-block:: jinja - - {% if users %} -
      - {% for user in users %} -
    • {{ user.username|e }}
    • - {% endfor %} -
    - {% endif %} - -.. note:: - - If you want to test if the variable is defined, use ``if users is - defined`` instead. - -You can also use ``not`` to check for values that evaluate to ``false``: - -.. code-block:: jinja - - {% if not user.subscribed %} -

    You are not subscribed to our mailing list.

    - {% endif %} - -For multiple conditions, ``and`` and ``or`` can be used: - -.. code-block:: jinja - - {% if temperature > 18 and temperature < 27 %} -

    It's a nice day for a walk in the park.

    - {% endif %} - -For multiple branches ``elseif`` and ``else`` can be used like in PHP. You can -use more complex ``expressions`` there too: - -.. code-block:: jinja - - {% if kenny.sick %} - Kenny is sick. - {% elseif kenny.dead %} - You killed Kenny! You bastard!!! - {% else %} - Kenny looks okay --- so far - {% endif %} - -.. note:: - - The rules to determine if an expression is ``true`` or ``false`` are the - same as in PHP; here are the edge cases rules: - - ====================== ==================== - Value Boolean evaluation - ====================== ==================== - empty string false - numeric zero false - whitespace-only string true - empty array false - null false - non-empty array true - object true - ====================== ==================== diff --git a/lib/silex/vendor/twig/twig/doc/tags/import.rst b/lib/silex/vendor/twig/twig/doc/tags/import.rst deleted file mode 100644 index 21a1e1980..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/import.rst +++ /dev/null @@ -1,57 +0,0 @@ -``import`` -========== - -Twig supports putting often used code into :doc:`macros<../tags/macro>`. These -macros can go into different templates and get imported from there. - -There are two ways to import templates. You can import the complete template -into a variable or request specific macros from it. - -Imagine we have a helper module that renders forms (called ``forms.html``): - -.. code-block:: jinja - - {% macro input(name, value, type, size) %} - - {% endmacro %} - - {% macro textarea(name, value, rows, cols) %} - - {% endmacro %} - -The easiest and most flexible is importing the whole module into a variable. -That way you can access the attributes: - -.. code-block:: jinja - - {% import 'forms.html' as forms %} - -
    -
    Username
    -
    {{ forms.input('username') }}
    -
    Password
    -
    {{ forms.input('password', null, 'password') }}
    -
    -

    {{ forms.textarea('comment') }}

    - -Alternatively you can import names from the template into the current -namespace: - -.. code-block:: jinja - - {% from 'forms.html' import input as input_field, textarea %} - -
    -
    Username
    -
    {{ input_field('username') }}
    -
    Password
    -
    {{ input_field('password', '', 'password') }}
    -
    -

    {{ textarea('comment') }}

    - -.. tip:: - - 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/lib/silex/vendor/twig/twig/doc/tags/include.rst b/lib/silex/vendor/twig/twig/doc/tags/include.rst deleted file mode 100644 index 24ff24db6..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/include.rst +++ /dev/null @@ -1,90 +0,0 @@ -``include`` -=========== - -The ``include`` statement includes a template and returns the rendered content -of that file into the current namespace: - -.. code-block:: jinja - - {% include 'header.html' %} - Body - {% include 'footer.html' %} - -Included templates have access to the variables of the active context. - -If you are using the filesystem loader, the templates are looked for in the -paths defined by it. - -You can add additional variables by passing them after the ``with`` keyword: - -.. code-block:: jinja - - {# template.html will have access to the variables from the current context and the additional ones provided #} - {% include 'template.html' with {'foo': 'bar'} %} - - {% set vars = {'foo': 'bar'} %} - {% include 'template.html' with vars %} - -You can disable access to the context by appending the ``only`` keyword: - -.. code-block:: jinja - - {# only the foo variable will be accessible #} - {% include 'template.html' with {'foo': 'bar'} only %} - -.. code-block:: jinja - - {# no variables will be accessible #} - {% include 'template.html' only %} - -.. tip:: - - When including a template created by an end user, you should consider - sandboxing it. More information in the :doc:`Twig for Developers<../api>` - chapter and in the :doc:`sandbox<../tags/sandbox>` tag documentation. - -The template name can be any valid Twig expression: - -.. code-block:: jinja - - {% include some_var %} - {% include ajax ? 'ajax.html' : 'not_ajax.html' %} - -And if the expression evaluates to a ``Twig_Template`` or a -``Twig_TemplateWrapper`` instance, Twig will use it directly:: - - // {% include template %} - - // deprecated as of Twig 1.28 - $template = $twig->loadTemplate('some_template.twig'); - - // as of Twig 1.28 - $template = $twig->load('some_template.twig'); - - $twig->display('template.twig', array('template' => $template)); - -.. versionadded:: 1.2 - The ``ignore missing`` feature has been added in Twig 1.2. - -You can mark an include with ``ignore missing`` in which case Twig will ignore -the statement if the template to be included does not exist. It has to be -placed just after the template name. Here some valid examples: - -.. code-block:: jinja - - {% include 'sidebar.html' ignore missing %} - {% include 'sidebar.html' ignore missing with {'foo': 'bar'} %} - {% include 'sidebar.html' ignore missing only %} - -.. versionadded:: 1.2 - The possibility to pass an array of templates has been added in Twig 1.2. - -You can also provide a list of templates that are checked for existence before -inclusion. The first template that exists will be included: - -.. code-block:: jinja - - {% include ['page_detailed.html', 'page.html'] %} - -If ``ignore missing`` is given, it will fall back to rendering nothing if none -of the templates exist, otherwise it will throw an exception. diff --git a/lib/silex/vendor/twig/twig/doc/tags/index.rst b/lib/silex/vendor/twig/twig/doc/tags/index.rst deleted file mode 100644 index dbe2459e3..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/index.rst +++ /dev/null @@ -1,25 +0,0 @@ -Tags -==== - -.. toctree:: - :maxdepth: 1 - - autoescape - block - do - embed - extends - filter - flush - for - from - if - import - include - macro - sandbox - set - spaceless - use - verbatim - with diff --git a/lib/silex/vendor/twig/twig/doc/tags/macro.rst b/lib/silex/vendor/twig/twig/doc/tags/macro.rst deleted file mode 100644 index a8aa76fd9..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/macro.rst +++ /dev/null @@ -1,103 +0,0 @@ -``macro`` -========= - -Macros are comparable with functions in regular programming languages. They -are useful to put often used HTML idioms into reusable elements to not repeat -yourself. - -Here is a small example of a macro that renders a form element: - -.. code-block:: jinja - - {% macro input(name, value, type, size) %} - - {% endmacro %} - -Macros differ from native PHP functions in a few ways: - -* Default argument values are defined by using the ``default`` filter in the - macro body; - -* Arguments of a macro are always optional. - -* If extra positional arguments are passed to a macro, they end up in the - special ``varargs`` variable as a list of values. - -But as with PHP functions, macros don't have access to the current template -variables. - -.. tip:: - - You can pass the whole context as an argument by using the special - ``_context`` variable. - -Import ------- - -Macros can be defined in any template, and need to be "imported" before being -used (see the documentation for the :doc:`import<../tags/import>` tag for more -information): - -.. code-block:: jinja - - {% import "forms.html" as forms %} - -The above ``import`` call imports the "forms.html" file (which can contain only -macros, or a template and some macros), and import the functions as items of -the ``forms`` variable. - -The macro can then be called at will: - -.. code-block:: jinja - -

    {{ forms.input('username') }}

    -

    {{ forms.input('password', null, 'password') }}

    - -If macros are defined and used in the same template, you can use the -special ``_self`` variable to import them: - -.. code-block:: jinja - - {% import _self as forms %} - -

    {{ forms.input('username') }}

    - -.. warning:: - - 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. - -When you want to use a macro in another macro from the same file, you need to -import it locally: - -.. code-block:: jinja - - {% macro input(name, value, type, size) %} - - {% endmacro %} - - {% macro wrapped_input(name, value, type, size) %} - {% import _self as forms %} - -
    - {{ forms.input(name, value, type, size) }} -
    - {% endmacro %} - -Named Macro End-Tags --------------------- - -Twig allows you to put the name of the macro after the end tag for better -readability: - -.. code-block:: jinja - - {% macro input() %} - ... - {% endmacro input %} - -Of course, the name after the ``endmacro`` word must match the macro name. - -.. seealso:: :doc:`from<../tags/from>`, :doc:`import<../tags/import>` diff --git a/lib/silex/vendor/twig/twig/doc/tags/sandbox.rst b/lib/silex/vendor/twig/twig/doc/tags/sandbox.rst deleted file mode 100644 index e186726c2..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/sandbox.rst +++ /dev/null @@ -1,30 +0,0 @@ -``sandbox`` -=========== - -The ``sandbox`` tag can be used to enable the sandboxing mode for an included -template, when sandboxing is not enabled globally for the Twig environment: - -.. code-block:: jinja - - {% sandbox %} - {% include 'user.html' %} - {% endsandbox %} - -.. warning:: - - The ``sandbox`` tag is only available when the sandbox extension is - enabled (see the :doc:`Twig for Developers<../api>` chapter). - -.. note:: - - 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: - - .. code-block:: jinja - - {% sandbox %} - {% for i in 1..2 %} - {{ i }} - {% endfor %} - {% endsandbox %} diff --git a/lib/silex/vendor/twig/twig/doc/tags/set.rst b/lib/silex/vendor/twig/twig/doc/tags/set.rst deleted file mode 100644 index 3eba239a9..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/set.rst +++ /dev/null @@ -1,78 +0,0 @@ -``set`` -======= - -Inside code blocks you can also assign values to variables. Assignments use -the ``set`` tag and can have multiple targets. - -Here is how you can assign the ``bar`` value to the ``foo`` variable: - -.. code-block:: jinja - - {% set foo = 'bar' %} - -After the ``set`` call, the ``foo`` variable is available in the template like -any other ones: - -.. code-block:: jinja - - {# displays bar #} - {{ foo }} - -The assigned value can be any valid :ref:`Twig expressions -`: - -.. code-block:: jinja - - {% set foo = [1, 2] %} - {% set foo = {'foo': 'bar'} %} - {% set foo = 'foo' ~ 'bar' %} - -Several variables can be assigned in one block: - -.. code-block:: jinja - - {% set foo, bar = 'foo', 'bar' %} - - {# is equivalent to #} - - {% set foo = 'foo' %} - {% set bar = 'bar' %} - -The ``set`` tag can also be used to 'capture' chunks of text: - -.. code-block:: jinja - - {% set foo %} - - {% endset %} - -.. caution:: - - If you enable automatic output escaping, Twig will only consider the - content to be safe when capturing chunks of text. - -.. note:: - - Note that loops are scoped in Twig; therefore a variable declared inside a - ``for`` loop is not accessible outside the loop itself: - - .. code-block:: jinja - - {% for item in list %} - {% set foo = item %} - {% endfor %} - - {# foo is NOT available #} - - If you want to access the variable, just declare it before the loop: - - .. code-block:: jinja - - {% set foo = "" %} - {% for item in list %} - {% set foo = item %} - {% endfor %} - - {# foo is available #} diff --git a/lib/silex/vendor/twig/twig/doc/tags/spaceless.rst b/lib/silex/vendor/twig/twig/doc/tags/spaceless.rst deleted file mode 100644 index b39cb27ef..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/spaceless.rst +++ /dev/null @@ -1,37 +0,0 @@ -``spaceless`` -============= - -Use the ``spaceless`` tag to remove whitespace *between HTML tags*, not -whitespace within HTML tags or whitespace in plain text: - -.. code-block:: jinja - - {% spaceless %} -
    - foo -
    - {% endspaceless %} - - {# output will be
    foo
    #} - -This tag is not meant to "optimize" the size of the generated HTML content but -merely to avoid extra whitespace between HTML tags to avoid browser rendering -quirks under some circumstances. - -.. tip:: - - If you want to optimize the size of the generated HTML content, gzip - compress the output instead. - -.. tip:: - - If you want to create a tag that actually removes all extra whitespace in - an HTML string, be warned that this is not as easy as it seems to be - (think of ``textarea`` or ``pre`` tags for instance). Using a third-party - library like Tidy is probably a better idea. - -.. tip:: - - For more information on whitespace control, read the - :ref:`dedicated section ` of the documentation and learn how - you can also use the whitespace control modifier on your tags. diff --git a/lib/silex/vendor/twig/twig/doc/tags/use.rst b/lib/silex/vendor/twig/twig/doc/tags/use.rst deleted file mode 100644 index a6fdefb46..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/use.rst +++ /dev/null @@ -1,124 +0,0 @@ -``use`` -======= - -.. versionadded:: 1.1 - Horizontal reuse was added in Twig 1.1. - -.. note:: - - Horizontal reuse is an advanced Twig feature that is hardly ever needed in - regular templates. It is mainly used by projects that need to make - template blocks reusable without using inheritance. - -Template inheritance is one of the most powerful features of Twig but it is -limited to single inheritance; a template can only extend one other template. -This limitation makes template inheritance simple to understand and easy to -debug: - -.. code-block:: jinja - - {% extends "base.html" %} - - {% block title %}{% endblock %} - {% block content %}{% endblock %} - -Horizontal reuse is a way to achieve the same goal as multiple inheritance, -but without the associated complexity: - -.. code-block:: jinja - - {% extends "base.html" %} - - {% use "blocks.html" %} - - {% block title %}{% endblock %} - {% block content %}{% endblock %} - -The ``use`` statement tells Twig to import the blocks defined in -``blocks.html`` into the current template (it's like macros, but for blocks): - -.. code-block:: jinja - - {# blocks.html #} - - {% block sidebar %}{% endblock %} - -In this example, the ``use`` statement imports the ``sidebar`` block into the -main template. The code is mostly equivalent to the following one (the -imported blocks are not outputted automatically): - -.. code-block:: jinja - - {% extends "base.html" %} - - {% block sidebar %}{% endblock %} - {% block title %}{% endblock %} - {% block content %}{% endblock %} - -.. note:: - - The ``use`` tag only imports a template if it does not extend another - template, if it does not define macros, and if the body is empty. But it - can *use* other templates. - -.. note:: - - Because ``use`` statements are resolved independently of the context - passed to the template, the template reference cannot be an expression. - -The main template can also override any imported block. If the template -already defines the ``sidebar`` block, then the one defined in ``blocks.html`` -is ignored. To avoid name conflicts, you can rename imported blocks: - -.. code-block:: jinja - - {% extends "base.html" %} - - {% use "blocks.html" with sidebar as base_sidebar, title as base_title %} - - {% block sidebar %}{% endblock %} - {% block title %}{% endblock %} - {% block content %}{% endblock %} - -.. versionadded:: 1.3 - The ``parent()`` support was added in Twig 1.3. - -The ``parent()`` function automatically determines the correct inheritance -tree, so it can be used when overriding a block defined in an imported -template: - -.. code-block:: jinja - - {% extends "base.html" %} - - {% use "blocks.html" %} - - {% block sidebar %} - {{ parent() }} - {% endblock %} - - {% block title %}{% endblock %} - {% block content %}{% endblock %} - -In this example, ``parent()`` will correctly call the ``sidebar`` block from -the ``blocks.html`` template. - -.. tip:: - - In Twig 1.2, renaming allows you to simulate inheritance by calling the - "parent" block: - - .. code-block:: jinja - - {% extends "base.html" %} - - {% use "blocks.html" with sidebar as parent_sidebar %} - - {% block sidebar %} - {{ block('parent_sidebar') }} - {% endblock %} - -.. note:: - - You can use as many ``use`` statements as you want in any given template. - If two imported templates define the same block, the latest one wins. diff --git a/lib/silex/vendor/twig/twig/doc/tags/verbatim.rst b/lib/silex/vendor/twig/twig/doc/tags/verbatim.rst deleted file mode 100644 index fe61ca1b0..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/verbatim.rst +++ /dev/null @@ -1,24 +0,0 @@ -``verbatim`` -============ - -.. versionadded:: 1.12 - The ``verbatim`` tag was added in Twig 1.12 (it was named ``raw`` before). - -The ``verbatim`` tag marks sections as being raw text that should not be -parsed. For example to put Twig syntax as example into a template you can use -this snippet: - -.. code-block:: jinja - - {% verbatim %} -
      - {% for item in seq %} -
    • {{ item }}
    • - {% endfor %} -
    - {% endverbatim %} - -.. note:: - - The ``verbatim`` tag works in the exact same way as the old ``raw`` tag, - but was renamed to avoid confusion with the ``raw`` filter. \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/doc/tags/with.rst b/lib/silex/vendor/twig/twig/doc/tags/with.rst deleted file mode 100644 index 815b06992..000000000 --- a/lib/silex/vendor/twig/twig/doc/tags/with.rst +++ /dev/null @@ -1,44 +0,0 @@ -``with`` -======== - -.. versionadded:: 1.28 - The ``with`` tag was added in Twig 1.28. - -Use the ``with`` tag to create a new inner scope. Variables set within this -scope are not visible outside of the scope: - -.. code-block:: jinja - - {% with %} - {% set foo = 42 %} - {{ foo }} foo is 42 here - {% endwith %} - foo is not visible here any longer - -Instead of defining variables at the beginning of the scope, you can pass a -hash of variables you want to define in the ``with`` tag; the previous example -is equivalent to the following one: - -.. code-block:: jinja - - {% with { foo: 42 } %} - {{ foo }} foo is 42 here - {% endwith %} - foo is not visible here any longer - - {# it works with any expression that resolves to a hash #} - {% set vars = { foo: 42 } %} - {% with vars %} - ... - {% endwith %} - -By default, the inner scope has access to the outer scope context; you can -disable this behavior by appending the ``only`` keyword: - -.. code-block:: jinja - - {% set bar = 'bar' %} - {% with { foo: 42 } only %} - {# only foo is defined #} - {# bar is not defined #} - {% endwith %} diff --git a/lib/silex/vendor/twig/twig/doc/templates.rst b/lib/silex/vendor/twig/twig/doc/templates.rst deleted file mode 100644 index 3d60779a0..000000000 --- a/lib/silex/vendor/twig/twig/doc/templates.rst +++ /dev/null @@ -1,909 +0,0 @@ -Twig for Template Designers -=========================== - -This document describes the syntax and semantics of the template engine and -will be most useful as reference to those creating Twig templates. - -Synopsis --------- - -A template is simply a text file. It can generate any text-based format (HTML, -XML, CSV, LaTeX, etc.). It doesn't have a specific extension, ``.html`` or -``.xml`` are just fine. - -A template contains **variables** or **expressions**, which get replaced with -values when the template is evaluated, and **tags**, which control the logic -of the template. - -Below is a minimal template that illustrates a few basics. We will cover further -details later on: - -.. code-block:: html+jinja - - - - - My Webpage - - - - -

    My Webpage

    - {{ a_variable }} - - - -There are two kinds of delimiters: ``{% ... %}`` and ``{{ ... }}``. The first -one is used to execute statements such as for-loops, the latter prints the -result of an expression to the template. - -IDEs Integration ----------------- - -Many IDEs support syntax highlighting and auto-completion for Twig: - -* *Textmate* via the `Twig bundle`_ -* *Vim* via the `Jinja syntax plugin`_ or the `vim-twig 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 Twig highlight/syntax check mode -* *Notepad++* via the `Notepad++ Twig Highlighter`_ -* *Emacs* via `web-mode.el`_ -* *Atom* via the `PHP-twig for atom`_ -* *Visual Studio Code* via the `Twig pack`_ - -Also, `TwigFiddle`_ is an online service that allows you to execute Twig templates -from a browser; it supports all versions of Twig. - -Variables ---------- - -The application passes variables to the templates for manipulation in the -template. Variables may have attributes or elements you can access, -too. The visual representation of a variable depends heavily on the application providing -it. - -You can use a dot (``.``) to access attributes of a variable (methods or -properties of a PHP object, or items of a PHP array), or the so-called -"subscript" syntax (``[]``): - -.. code-block:: jinja - - {{ 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 - variable but the print statement. When accessing variables inside tags, - don't put the braces around them. - -If a variable or attribute does not exist, you will receive a ``null`` value -when the ``strict_variables`` option is set to ``false``; alternatively, if ``strict_variables`` -is set, Twig will throw an error (see :ref:`environment options`). - -.. sidebar:: Implementation - - For convenience's sake ``foo.bar`` does the following things on the PHP - layer: - - * check if ``foo`` is an array and ``bar`` a valid element; - * if not, and if ``foo`` is an object, check that ``bar`` is a valid property; - * if not, and if ``foo`` is an object, check that ``bar`` is a valid method - (even if ``bar`` is the constructor - use ``__construct()`` instead); - * if not, and if ``foo`` is an object, check that ``getBar`` is a valid method; - * if not, and if ``foo`` is an object, check that ``isBar`` is a valid method; - * if not, return a ``null`` value. - - ``foo['bar']`` on the other hand only works with PHP arrays: - - * check if ``foo`` is an array and ``bar`` a valid element; - * if not, return a ``null`` value. - -.. note:: - - If you want to access a dynamic attribute of a variable, use the - :doc:`attribute` function instead. - -Global Variables -~~~~~~~~~~~~~~~~ - -The following variables are always available in templates: - -* ``_self``: references the current template; -* ``_context``: references the current context; -* ``_charset``: references the current charset. - -Setting Variables -~~~~~~~~~~~~~~~~~ - -You can assign values to variables inside code blocks. Assignments use the -:doc:`set` tag: - -.. code-block:: jinja - - {% set foo = 'foo' %} - {% set foo = [1, 2] %} - {% set foo = {'foo': 'bar'} %} - -Filters -------- - -Variables can be modified by **filters**. Filters are separated from the -variable by a pipe symbol (``|``) and may have optional arguments in -parentheses. Multiple filters can be chained. The output of one filter is -applied to the next. - -The following example removes all HTML tags from the ``name`` and title-cases -it: - -.. code-block:: jinja - - {{ name|striptags|title }} - -Filters that accept arguments have parentheses around the arguments. This -example will join a list by commas: - -.. code-block:: jinja - - {{ list|join(', ') }} - -To apply a filter on a section of code, wrap it in the -:doc:`filter` tag: - -.. code-block:: jinja - - {% filter upper %} - This text becomes uppercase - {% endfilter %} - -Go to the :doc:`filters` page to learn more about built-in -filters. - -Functions ---------- - -Functions can be called to generate content. Functions are called by their -name followed by parentheses (``()``) and may have arguments. - -For instance, the ``range`` function returns a list containing an arithmetic -progression of integers: - -.. code-block:: jinja - - {% for i in range(0, 3) %} - {{ i }}, - {% endfor %} - -Go to the :doc:`functions` page to learn more about the -built-in functions. - -Named Arguments ---------------- - -.. versionadded:: 1.12 - Support for named arguments was added in Twig 1.12. - -.. code-block:: jinja - - {% for i in range(low=1, high=10, step=2) %} - {{ i }}, - {% endfor %} - -Using named arguments makes your templates more explicit about the meaning of -the values you pass as arguments: - -.. code-block:: jinja - - {{ data|convert_encoding('UTF-8', 'iso-2022-jp') }} - - {# versus #} - - {{ data|convert_encoding(from='iso-2022-jp', to='UTF-8') }} - -Named arguments also allow you to skip some arguments for which you don't want -to change the default value: - -.. code-block:: jinja - - {# the first argument is the date format, which defaults to the global date format if null is passed #} - {{ "now"|date(null, "Europe/Paris") }} - - {# or skip the format value by using a named argument for the time zone #} - {{ "now"|date(timezone="Europe/Paris") }} - -You can also use both positional and named arguments in one call, in which -case positional arguments must always come before named arguments: - -.. code-block:: jinja - - {{ "now"|date('d/m/Y H:i', timezone="Europe/Paris") }} - -.. tip:: - - Each function and filter documentation page has a section where the names - of all arguments are listed when supported. - -Control Structure ------------------ - -A control structure refers to all those things that control the flow of a -program - conditionals (i.e. ``if``/``elseif``/``else``), ``for``-loops, as -well as things like blocks. Control structures appear inside ``{% ... %}`` -blocks. - -For example, to display a list of users provided in a variable called -``users``, use the :doc:`for` tag: - -.. code-block:: jinja - -

    Members

    -
      - {% for user in users %} -
    • {{ user.username|e }}
    • - {% endfor %} -
    - -The :doc:`if` tag can be used to test an expression: - -.. code-block:: jinja - - {% if users|length > 0 %} -
      - {% for user in users %} -
    • {{ user.username|e }}
    • - {% endfor %} -
    - {% endif %} - -Go to the :doc:`tags` page to learn more about the built-in tags. - -Comments --------- - -To comment-out part of a line in a template, use the comment syntax ``{# ... -#}``. This is useful for debugging or to add information for other template -designers or yourself: - -.. code-block:: jinja - - {# note: disabled template because we no longer use this - {% for user in users %} - ... - {% endfor %} - #} - -Including other Templates -------------------------- - -The :doc:`include` function is useful to include a template -and return the rendered content of that template into the current one: - -.. code-block:: jinja - - {{ include('sidebar.html') }} - -By default, included templates have access to the same context as the template -which includes them. This means that any variable defined in the main template -will be available in the included template too: - -.. code-block:: jinja - - {% for box in boxes %} - {{ include('render_box.html') }} - {% endfor %} - -The included template ``render_box.html`` is able to access the ``box`` variable. - -The filename of the template depends on the template loader. For instance, the -``Twig_Loader_Filesystem`` allows you to access other templates by giving the -filename. You can access templates in subdirectories with a slash: - -.. code-block:: jinja - - {{ include('sections/articles/sidebar.html') }} - -This behavior depends on the application embedding Twig. - -Template Inheritance --------------------- - -The most powerful part of Twig is template inheritance. Template inheritance -allows you to build a base "skeleton" template that contains all the common -elements of your site and defines **blocks** that child templates can -override. - -Sounds complicated but it is very basic. It's easier to understand it by -starting with an example. - -Let's define a base template, ``base.html``, which defines a simple HTML -skeleton document that you might use for a simple two-column page: - -.. code-block:: html+jinja - - - - - {% block head %} - - {% block title %}{% endblock %} - My Webpage - {% endblock %} - - -
    {% block content %}{% endblock %}
    - - - - -In this example, the :doc:`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. - -A child template might look like this: - -.. code-block:: jinja - - {% extends "base.html" %} - - {% block title %}Index{% endblock %} - {% block head %} - {{ parent() }} - - {% endblock %} - {% block content %} -

    Index

    -

    - Welcome to my awesome homepage. -

    - {% endblock %} - -The :doc:`extends` tag is the key here. It tells the template -engine that this template "extends" another template. When the template system -evaluates this template, first it locates the parent. The extends tag should -be the first tag in the template. - -Note that since the child template doesn't define the ``footer`` block, the -value from the parent template is used instead. - -It's possible to render the contents of the parent block by using the -:doc:`parent` function. This gives back the results of the -parent block: - -.. code-block:: jinja - - {% block sidebar %} -

    Table Of Contents

    - ... - {{ parent() }} - {% endblock %} - -.. tip:: - - The documentation page for the :doc:`extends` tag describes - more advanced features like block nesting, scope, dynamic inheritance, and - conditional inheritance. - -.. note:: - - Twig also supports multiple inheritance with the so called horizontal reuse - with the help of the :doc:`use` tag. This is an advanced feature - hardly ever needed in regular templates. - -HTML Escaping -------------- - -When generating HTML from templates, there's always a risk that a variable -will include characters that affect the resulting HTML. There are two -approaches: manually escaping each variable or automatically escaping -everything by default. - -Twig supports both, automatic escaping is enabled by default. - -The automatic escaping strategy can be configured via the -:ref:`autoescape` option and defaults to ``html``. - -Working with Manual Escaping -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -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` 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: - -.. code-block:: jinja - - {{ user.username|e('js') }} - {{ user.username|e('css') }} - {{ user.username|e('url') }} - {{ user.username|e('html_attr') }} - -Working with Automatic Escaping -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Whether automatic escaping is enabled or not, you can mark a section of a -template to be escaped or not by using the :doc:`autoescape` -tag: - -.. code-block:: jinja - - {% 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 --------- - -It is sometimes desirable or even necessary to have Twig ignore parts it would -otherwise handle as variables or blocks. For example if the default syntax is -used and you want to use ``{{`` as raw string in the template and not start a -variable you have to use a trick. - -The easiest way is to output the variable delimiter (``{{``) by using a variable -expression: - -.. code-block:: jinja - - {{ '{{' }} - -For bigger sections it makes sense to mark a block -:doc:`verbatim`. - -Macros ------- - -.. versionadded:: 1.12 - Support for default argument values was added in Twig 1.12. - -Macros are comparable with functions in regular programming languages. They -are useful to reuse often used HTML fragments to not repeat yourself. - -A macro is defined via the :doc:`macro` tag. Here is a small example -(subsequently called ``forms.html``) of a macro that renders a form element: - -.. code-block:: jinja - - {% macro input(name, value, type, size) %} - - {% endmacro %} - -Macros can be defined in any template, and need to be "imported" via the -:doc:`import` tag before being used: - -.. code-block:: jinja - - {% import "forms.html" as forms %} - -

    {{ forms.input('username') }}

    - -Alternatively, you can import individual macro names from a template into the -current namespace via the :doc:`from` tag and optionally alias them: - -.. code-block:: jinja - - {% from 'forms.html' import input as input_field %} - -
    -
    Username
    -
    {{ input_field('username') }}
    -
    Password
    -
    {{ input_field('password', '', 'password') }}
    -
    - -A default value can also be defined for macro arguments when not provided in a -macro call: - -.. code-block:: jinja - - {% macro input(name, value = "", type = "text", size = 20) %} - - {% endmacro %} - -If extra positional arguments are passed to a macro call, they end up in the -special ``varargs`` variable as a list of values. - -.. _twig-expressions: - -Expressions ------------ - -Twig allows expressions everywhere. These work very similar to regular PHP and -even if you're not working with PHP you should feel comfortable with it. - -.. note:: - - The operator precedence is as follows, with the lowest-precedence - operators listed first: ``b-and``, ``b-xor``, ``b-or``, ``or``, ``and``, - ``==``, ``!=``, ``<``, ``>``, ``>=``, ``<=``, ``in``, ``matches``, - ``starts with``, ``ends with``, ``..``, ``+``, ``-``, ``~``, ``*``, ``/``, - ``//``, ``%``, ``is``, ``**``, ``|``, ``[]``, and ``.``: - - .. code-block:: jinja - - {% set greeting = 'Hello ' %} - {% set name = 'Fabien' %} - - {{ greeting ~ name|lower }} {# Hello fabien #} - - {# use parenthesis to change precedence #} - {{ (greeting ~ name)|lower }} {# hello fabien #} - -Literals -~~~~~~~~ - -.. versionadded:: 1.5 - Support for hash keys as names and expressions was added in Twig 1.5. - -The simplest form of expressions are literals. Literals are representations -for PHP types such as strings, numbers, and arrays. The following literals -exist: - -* ``"Hello World"``: Everything between two double or single quotes is a - string. They are useful whenever you need a string in the template (for - example as arguments to function calls, filters or just to extend or include - a template). A string can contain a delimiter if it is preceded by a - backslash (``\``) -- like in ``'It\'s good'``. If the string contains a - backslash (e.g. ``'c:\Program Files'``) escape it by doubling it - (e.g. ``'c:\\Program Files'``). - -* ``42`` / ``42.23``: Integers and floating point numbers are created by just - writing the number down. If a dot is present the number is a float, - otherwise an integer. - -* ``["foo", "bar"]``: Arrays are defined by a sequence of expressions - separated by a comma (``,``) and wrapped with squared brackets (``[]``). - -* ``{"foo": "bar"}``: Hashes are defined by a list of keys and values - separated by a comma (``,``) and wrapped with curly braces (``{}``): - - .. code-block:: jinja - - {# keys as string #} - { 'foo': 'foo', 'bar': 'bar' } - - {# keys as names (equivalent to the previous hash) -- as of Twig 1.5 #} - { foo: 'foo', bar: 'bar' } - - {# keys as integer #} - { 2: 'foo', 4: 'bar' } - - {# keys as expressions (the expression must be enclosed into parentheses) -- as of Twig 1.5 #} - {% set foo = 'foo' %} - { (foo): 'foo', (1 + 1): 'bar', (foo ~ 'b'): 'baz' } - -* ``true`` / ``false``: ``true`` represents the true value, ``false`` - represents the false value. - -* ``null``: ``null`` represents no specific value. This is the value returned - when a variable does not exist. ``none`` is an alias for ``null``. - -Arrays and hashes can be nested: - -.. code-block:: jinja - - {% 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 -~~~~ - -Twig allows you to calculate with values. This is rarely useful in templates -but exists for completeness' sake. The following operators are supported: - -* ``+``: Adds two objects together (the operands are casted to numbers). ``{{ - 1 + 1 }}`` is ``2``. - -* ``-``: Subtracts the second number from the first one. ``{{ 3 - 2 }}`` is - ``1``. - -* ``/``: Divides two numbers. The returned value will be a floating point - number. ``{{ 1 / 2 }}`` is ``{{ 0.5 }}``. - -* ``%``: Calculates the remainder of an integer division. ``{{ 11 % 7 }}`` is - ``4``. - -* ``//``: Divides two numbers and returns the floored integer result. ``{{ 20 - // 7 }}`` is ``2``, ``{{ -20 // 7 }}`` is ``-3`` (this is just syntactic - sugar for the :doc:`round` filter). - -* ``*``: Multiplies the left operand with the right one. ``{{ 2 * 2 }}`` would - return ``4``. - -* ``**``: Raises the left operand to the power of the right operand. ``{{ 2 ** - 3 }}`` would return ``8``. - -Logic -~~~~~ - -You can combine multiple expressions with the following operators: - -* ``and``: Returns true if the left and the right operands are both true. - -* ``or``: Returns true if the left or the right operand is true. - -* ``not``: Negates a statement. - -* ``(expr)``: Groups an expression. - -.. note:: - - Twig also support bitwise operators (``b-and``, ``b-xor``, and ``b-or``). - -.. note:: - - Operators are case sensitive. - -Comparisons -~~~~~~~~~~~ - -The following comparison operators are supported in any expression: ``==``, -``!=``, ``<``, ``>``, ``>=``, and ``<=``. - -You can also check if a string ``starts with`` or ``ends with`` another -string: - -.. code-block:: jinja - - {% if 'Fabien' starts with 'F' %} - {% endif %} - - {% if 'Fabien' ends with 'n' %} - {% endif %} - -.. note:: - - For complex string comparisons, the ``matches`` operator allows you to use - `regular expressions`_: - - .. code-block:: jinja - - {% if phone matches '/^[\\d\\.]+$/' %} - {% endif %} - -Containment Operator -~~~~~~~~~~~~~~~~~~~~ - -The ``in`` operator performs containment test. - -It returns ``true`` if the left operand is contained in the right: - -.. code-block:: jinja - - {# returns true #} - - {{ 1 in [1, 2, 3] }} - - {{ 'cd' in 'abcde' }} - -.. tip:: - - You can use this filter to perform a containment test on strings, arrays, - or objects implementing the ``Traversable`` interface. - -To perform a negative test, use the ``not in`` operator: - -.. code-block:: jinja - - {% if 1 not in [1, 2, 3] %} - - {# is equivalent to #} - {% if not (1 in [1, 2, 3]) %} - -Test Operator -~~~~~~~~~~~~~ - -The ``is`` operator performs tests. Tests can be used to test a variable against -a common expression. The right operand is name of the test: - -.. code-block:: jinja - - {# find out if a variable is odd #} - - {{ name is odd }} - -Tests can accept arguments too: - -.. code-block:: jinja - - {% if post.status is constant('Post::PUBLISHED') %} - -Tests can be negated by using the ``is not`` operator: - -.. code-block:: jinja - - {% if post.status is not constant('Post::PUBLISHED') %} - - {# is equivalent to #} - {% if not (post.status is constant('Post::PUBLISHED')) %} - -Go to the :doc:`tests` page to learn more about the built-in -tests. - -Other Operators -~~~~~~~~~~~~~~~ - -.. versionadded:: 1.12.0 - Support for the extended ternary operator was added in Twig 1.12.0. - -The following operators don't fit into any of the other categories: - -* ``|``: Applies a filter. - -* ``..``: Creates a sequence based on the operand before and after the operator - (this is just syntactic sugar for the :doc:`range` function): - - .. code-block:: jinja - - {{ 1..5 }} - - {# equivalent to #} - {{ range(1, 5) }} - - Note that you must use parentheses when combining it with the filter operator - due to the :ref:`operator precedence rules `: - - .. code-block:: jinja - - (1..5)|join(', ') - -* ``~``: Converts all operands into strings and concatenates them. ``{{ "Hello - " ~ name ~ "!" }}`` would return (assuming ``name`` is ``'John'``) ``Hello - John!``. - -* ``.``, ``[]``: Gets an attribute of an object. - -* ``?:``: The ternary operator: - - .. code-block:: jinja - - {{ foo ? 'yes' : 'no' }} - - {# as of Twig 1.12.0 #} - {{ foo ?: 'no' }} is the same as {{ foo ? foo : 'no' }} - {{ foo ? 'yes' }} is the same as {{ foo ? 'yes' : '' }} - -* ``??``: The null-coalescing operator: - - .. code-block:: jinja - - {# returns the value of foo if it is defined and not null, 'no' otherwise #} - {{ foo ?? 'no' }} - -String Interpolation -~~~~~~~~~~~~~~~~~~~~ - -.. versionadded:: 1.5 - String interpolation was added in Twig 1.5. - -String interpolation (``#{expression}``) allows any valid expression to appear -within a *double-quoted string*. The result of evaluating that expression is -inserted into the string: - -.. code-block:: jinja - - {{ "foo #{bar} baz" }} - {{ "foo #{1 + 2} baz" }} - -.. _templates-whitespace-control: - -Whitespace Control ------------------- - -.. versionadded:: 1.1 - Tag level whitespace control was added in Twig 1.1. - -The first newline after a template tag is removed automatically (like in PHP.) -Whitespace is not further modified by the template engine, so each whitespace -(spaces, tabs, newlines etc.) is returned unchanged. - -Use the ``spaceless`` tag to remove whitespace *between HTML tags*: - -.. code-block:: jinja - - {% spaceless %} -
    - foo bar -
    - {% endspaceless %} - - {# output will be
    foo bar
    #} - -In addition to the spaceless tag you can also control whitespace on a per tag -level. By using the whitespace control modifier on your tags, you can trim -leading and or trailing whitespace: - -.. code-block:: jinja - - {% set value = 'no spaces' %} - {#- No leading/trailing whitespace -#} - {%- if true -%} - {{- value -}} - {%- endif -%} - - {# output 'no spaces' #} - -The above sample shows the default whitespace control modifier, and how you can -use it to remove whitespace around tags. Trimming space will consume all whitespace -for that side of the tag. It is possible to use whitespace trimming on one side -of a tag: - -.. code-block:: jinja - - {% set value = 'no spaces' %} -
  • {{- value }}
  • - - {# outputs '
  • no spaces
  • ' #} - -Extensions ----------- - -Twig can be easily extended. - -If you are looking for new tags, filters, or functions, have a look at the Twig official -`extension repository`_. - -If you want to create your own, read the :ref:`Creating an -Extension` chapter. - -.. _`Twig bundle`: https://github.com/Anomareh/PHP-Twig.tmbundle -.. _`Jinja syntax plugin`: http://jinja.pocoo.org/docs/integration/#vim -.. _`vim-twig plugin`: https://github.com/lumiliet/vim-twig -.. _`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/twigphp/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 -.. _`web-mode.el`: http://web-mode.org/ -.. _`regular expressions`: http://php.net/manual/en/pcre.pattern.php -.. _`PHP-twig for atom`: https://github.com/reesef/php-twig -.. _`TwigFiddle`: http://twigfiddle.com/ -.. _`Twig pack`: https://marketplace.visualstudio.com/items?itemName=bajdzis.vscode-twig-pack diff --git a/lib/silex/vendor/twig/twig/doc/tests/constant.rst b/lib/silex/vendor/twig/twig/doc/tests/constant.rst deleted file mode 100644 index 8d0724a80..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/constant.rst +++ /dev/null @@ -1,22 +0,0 @@ -``constant`` -============ - -.. versionadded: 1.13.1 - constant now accepts object instances as the second argument. - -``constant`` checks if a variable has the exact same value as a constant. You -can use either global constants or class constants: - -.. code-block:: jinja - - {% if post.status is constant('Post::PUBLISHED') %} - the status attribute is exactly the same as Post::PUBLISHED - {% endif %} - -You can test constants from object instances as well: - -.. code-block:: jinja - - {% if post.status is constant('PUBLISHED', post) %} - the status attribute is exactly the same as Post::PUBLISHED - {% endif %} diff --git a/lib/silex/vendor/twig/twig/doc/tests/defined.rst b/lib/silex/vendor/twig/twig/doc/tests/defined.rst deleted file mode 100644 index 702ce7256..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/defined.rst +++ /dev/null @@ -1,30 +0,0 @@ -``defined`` -=========== - -``defined`` checks if a variable is defined in the current context. This is very -useful if you use the ``strict_variables`` option: - -.. code-block:: jinja - - {# defined works with variable names #} - {% if foo is defined %} - ... - {% endif %} - - {# and attributes on variables names #} - {% if foo.bar is defined %} - ... - {% endif %} - - {% if foo['bar'] is defined %} - ... - {% endif %} - -When using the ``defined`` test on an expression that uses variables in some -method calls, be sure that they are all defined first: - -.. code-block:: jinja - - {% if var is defined and foo.method(var) is defined %} - ... - {% endif %} diff --git a/lib/silex/vendor/twig/twig/doc/tests/divisibleby.rst b/lib/silex/vendor/twig/twig/doc/tests/divisibleby.rst deleted file mode 100644 index 6c693b2b4..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/divisibleby.rst +++ /dev/null @@ -1,14 +0,0 @@ -``divisible by`` -================ - -.. versionadded:: 1.14.2 - The ``divisible by`` test was added in Twig 1.14.2 as an alias for - ``divisibleby``. - -``divisible by`` checks if a variable is divisible by a number: - -.. code-block:: jinja - - {% if loop.index is divisible by(3) %} - ... - {% endif %} diff --git a/lib/silex/vendor/twig/twig/doc/tests/empty.rst b/lib/silex/vendor/twig/twig/doc/tests/empty.rst deleted file mode 100644 index 639cdcc39..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/empty.rst +++ /dev/null @@ -1,22 +0,0 @@ -``empty`` -========= - -.. versionadded:: 1.33 - - Support for the ``__toString()`` magic method has been added in Twig 1.33. - -``empty`` checks if a variable is an empty string, an empty array, an empty -hash, exactly ``false``, or exactly ``null``. - -For objects that implement the ``Countable`` interface, ``empty`` will check the -return value of the ``count()`` method. - -For objects that implement the ``__toString()`` magic method (and not ``Countable``), -it will check if an empty string is returned. - -.. code-block:: jinja - - {% if foo is empty %} - ... - {% endif %} - diff --git a/lib/silex/vendor/twig/twig/doc/tests/even.rst b/lib/silex/vendor/twig/twig/doc/tests/even.rst deleted file mode 100644 index 6ab5cc39a..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/even.rst +++ /dev/null @@ -1,10 +0,0 @@ -``even`` -======== - -``even`` returns ``true`` if the given number is even: - -.. code-block:: jinja - - {{ var is even }} - -.. seealso:: :doc:`odd<../tests/odd>` diff --git a/lib/silex/vendor/twig/twig/doc/tests/index.rst b/lib/silex/vendor/twig/twig/doc/tests/index.rst deleted file mode 100644 index c63208ee7..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/index.rst +++ /dev/null @@ -1,15 +0,0 @@ -Tests -===== - -.. toctree:: - :maxdepth: 1 - - constant - defined - divisibleby - empty - even - iterable - null - odd - sameas diff --git a/lib/silex/vendor/twig/twig/doc/tests/iterable.rst b/lib/silex/vendor/twig/twig/doc/tests/iterable.rst deleted file mode 100644 index 89a172f74..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/iterable.rst +++ /dev/null @@ -1,19 +0,0 @@ -``iterable`` -============ - -.. versionadded:: 1.7 - The iterable test was added in Twig 1.7. - -``iterable`` checks if a variable is an array or a traversable object: - -.. code-block:: jinja - - {# evaluates to true if the foo variable is iterable #} - {% if users is iterable %} - {% for user in users %} - Hello {{ user }}! - {% endfor %} - {% else %} - {# users is probably a string #} - Hello {{ users }}! - {% endif %} diff --git a/lib/silex/vendor/twig/twig/doc/tests/null.rst b/lib/silex/vendor/twig/twig/doc/tests/null.rst deleted file mode 100644 index 44eec62e5..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/null.rst +++ /dev/null @@ -1,12 +0,0 @@ -``null`` -======== - -``null`` returns ``true`` if the variable is ``null``: - -.. code-block:: jinja - - {{ var is null }} - -.. note:: - - ``none`` is an alias for ``null``. diff --git a/lib/silex/vendor/twig/twig/doc/tests/odd.rst b/lib/silex/vendor/twig/twig/doc/tests/odd.rst deleted file mode 100644 index 9eece7776..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/odd.rst +++ /dev/null @@ -1,10 +0,0 @@ -``odd`` -======= - -``odd`` returns ``true`` if the given number is odd: - -.. code-block:: jinja - - {{ var is odd }} - -.. seealso:: :doc:`even<../tests/even>` diff --git a/lib/silex/vendor/twig/twig/doc/tests/sameas.rst b/lib/silex/vendor/twig/twig/doc/tests/sameas.rst deleted file mode 100644 index 16f904d5c..000000000 --- a/lib/silex/vendor/twig/twig/doc/tests/sameas.rst +++ /dev/null @@ -1,14 +0,0 @@ -``same as`` -=========== - -.. versionadded:: 1.14.2 - The ``same as`` test was added in Twig 1.14.2 as an alias for ``sameas``. - -``same as`` checks if a variable is the same as another variable. -This is the equivalent to ``===`` in PHP: - -.. code-block:: jinja - - {% if foo.attribute is same as(false) %} - the foo attribute really is the 'false' PHP value - {% endif %} diff --git a/lib/silex/vendor/twig/twig/exclude.txt b/lib/silex/vendor/twig/twig/exclude.txt deleted file mode 100644 index 93b1e13b7..000000000 --- a/lib/silex/vendor/twig/twig/exclude.txt +++ /dev/null @@ -1,5 +0,0 @@ -# -# The following source files are not re-distributed with the "build" of the application -# since they are used solely for constructing other files during the build process -# -test \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/ext/twig/.gitignore b/lib/silex/vendor/twig/twig/ext/twig/.gitignore deleted file mode 100644 index 56ea76cc2..000000000 --- a/lib/silex/vendor/twig/twig/ext/twig/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -*.sw* -.deps -Makefile -Makefile.fragments -Makefile.global -Makefile.objects -acinclude.m4 -aclocal.m4 -build/ -config.cache -config.guess -config.h -config.h.in -config.log -config.nice -config.status -config.sub -configure -configure.in -install-sh -libtool -ltmain.sh -missing -mkinstalldirs -run-tests.php -twig.loT -.libs/ -modules/ -twig.la -twig.lo diff --git a/lib/silex/vendor/twig/twig/ext/twig/config.m4 b/lib/silex/vendor/twig/twig/ext/twig/config.m4 deleted file mode 100644 index 83486be4c..000000000 --- a/lib/silex/vendor/twig/twig/ext/twig/config.m4 +++ /dev/null @@ -1,8 +0,0 @@ -dnl config.m4 for extension twig - -PHP_ARG_ENABLE(twig, whether to enable twig support, -[ --enable-twig Enable twig support]) - -if test "$PHP_TWIG" != "no"; then - PHP_NEW_EXTENSION(twig, twig.c, $ext_shared) -fi diff --git a/lib/silex/vendor/twig/twig/ext/twig/config.w32 b/lib/silex/vendor/twig/twig/ext/twig/config.w32 deleted file mode 100644 index cb287b99b..000000000 --- a/lib/silex/vendor/twig/twig/ext/twig/config.w32 +++ /dev/null @@ -1,8 +0,0 @@ -// vim:ft=javascript - -ARG_ENABLE("twig", "Twig support", "no"); - -if (PHP_TWIG != "no") { - AC_DEFINE('HAVE_TWIG', 1); - EXTENSION('twig', 'twig.c'); -} diff --git a/lib/silex/vendor/twig/twig/ext/twig/php_twig.h b/lib/silex/vendor/twig/twig/ext/twig/php_twig.h deleted file mode 100644 index 7fc1601e8..000000000 --- a/lib/silex/vendor/twig/twig/ext/twig/php_twig.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Twig Extension | - +----------------------------------------------------------------------+ - | Copyright (c) 2011 Derick Rethans | - +----------------------------------------------------------------------+ - | Redistribution and use in source and binary forms, with or without | - | modification, are permitted provided that the conditions mentioned | - | in the accompanying LICENSE file are met (BSD-3-Clause). | - +----------------------------------------------------------------------+ - | Author: Derick Rethans | - +----------------------------------------------------------------------+ - */ - -#ifndef PHP_TWIG_H -#define PHP_TWIG_H - -#define PHP_TWIG_VERSION "1.35.0" - -#include "php.h" - -extern zend_module_entry twig_module_entry; -#define phpext_twig_ptr &twig_module_entry -#ifndef PHP_WIN32 -zend_module_entry *get_module(void); -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -PHP_FUNCTION(twig_template_get_attributes); -PHP_RSHUTDOWN_FUNCTION(twig); - -#endif diff --git a/lib/silex/vendor/twig/twig/ext/twig/twig.c b/lib/silex/vendor/twig/twig/ext/twig/twig.c deleted file mode 100644 index 6173c0067..000000000 --- a/lib/silex/vendor/twig/twig/ext/twig/twig.c +++ /dev/null @@ -1,1215 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Twig Extension | - +----------------------------------------------------------------------+ - | Copyright (c) 2011 Derick Rethans | - +----------------------------------------------------------------------+ - | Redistribution and use in source and binary forms, with or without | - | modification, are permitted provided that the conditions mentioned | - | in the accompanying LICENSE file are met (BSD-3-Clause). | - +----------------------------------------------------------------------+ - | Author: Derick Rethans | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_twig.h" -#include "ext/standard/php_var.h" -#include "ext/standard/php_string.h" -#include "ext/standard/php_smart_str.h" -#include "ext/spl/spl_exceptions.h" - -#include "Zend/zend_object_handlers.h" -#include "Zend/zend_interfaces.h" -#include "Zend/zend_exceptions.h" - -#ifndef Z_ADDREF_P -#define Z_ADDREF_P(pz) (pz)->refcount++ -#endif - -#ifndef E_USER_DEPRECATED -#define E_USER_DEPRECATED (1<<14L) -#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) - ZEND_ARG_INFO(0, item) - ZEND_ARG_INFO(0, arguments) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, isDefinedTest) -ZEND_END_ARG_INFO() - -#ifndef PHP_FE_END -#define PHP_FE_END { NULL, NULL, NULL} -#endif - -static const zend_function_entry twig_functions[] = { - PHP_FE(twig_template_get_attributes, twig_template_get_attribute_args) - PHP_FE_END -}; - -PHP_RSHUTDOWN_FUNCTION(twig) -{ -#if ZEND_DEBUG - CG(unclean_shutdown) = 0; /* get rid of PHPUnit's exit() and report memleaks */ -#endif - return SUCCESS; -} - -zend_module_entry twig_module_entry = { - STANDARD_MODULE_HEADER, - "twig", - twig_functions, - NULL, - NULL, - NULL, - PHP_RSHUTDOWN(twig), - NULL, - PHP_TWIG_VERSION, - STANDARD_MODULE_PROPERTIES -}; - - -#ifdef COMPILE_DL_TWIG -ZEND_GET_MODULE(twig) -#endif - -static int TWIG_ARRAY_KEY_EXISTS(zval *array, zval *key) -{ - if (Z_TYPE_P(array) != IS_ARRAY) { - return 0; - } - - switch (Z_TYPE_P(key)) { - case IS_NULL: - return zend_hash_exists(Z_ARRVAL_P(array), "", 1); - - case IS_BOOL: - case IS_DOUBLE: - convert_to_long(key); - case IS_LONG: - return zend_hash_index_exists(Z_ARRVAL_P(array), Z_LVAL_P(key)); - - default: - convert_to_string(key); - return zend_symtable_exists(Z_ARRVAL_P(array), Z_STRVAL_P(key), Z_STRLEN_P(key) + 1); - } -} - -static int TWIG_INSTANCE_OF(zval *object, zend_class_entry *interface TSRMLS_DC) -{ - if (Z_TYPE_P(object) != IS_OBJECT) { - return 0; - } - return instanceof_function(Z_OBJCE_P(object), interface TSRMLS_CC); -} - -static int TWIG_INSTANCE_OF_USERLAND(zval *object, char *interface TSRMLS_DC) -{ - zend_class_entry **pce; - if (Z_TYPE_P(object) != IS_OBJECT) { - return 0; - } - if (zend_lookup_class(interface, strlen(interface), &pce TSRMLS_CC) == FAILURE) { - return 0; - } - return instanceof_function(Z_OBJCE_P(object), *pce TSRMLS_CC); -} - -static zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) -{ - zend_class_entry *ce = Z_OBJCE_P(object); - zval *retval; - - if (Z_TYPE_P(object) == IS_OBJECT) { - SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(&object, ce, NULL, "offsetget", &retval, offset); - - zval_ptr_dtor(&offset); - - if (!retval) { - if (!EG(exception)) { - zend_error(E_ERROR, "Undefined offset for object of type %s used as array.", ce->name); - } - return NULL; - } - - return retval; - } - return NULL; -} - -static int TWIG_ISSET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) -{ - zend_class_entry *ce = Z_OBJCE_P(object); - zval *retval; - - if (Z_TYPE_P(object) == IS_OBJECT) { - SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(&object, ce, NULL, "offsetexists", &retval, offset); - - zval_ptr_dtor(&offset); - - if (!retval) { - if (!EG(exception)) { - zend_error(E_ERROR, "Undefined offset for object of type %s used as array.", ce->name); - } - return 0; - } - - return (retval && Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval)); - } - return 0; -} - -static char *TWIG_STRTOLOWER(const char *str, int str_len) -{ - char *item_dup; - - item_dup = estrndup(str, str_len); - php_strtolower(item_dup, str_len); - return item_dup; -} - -static zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments TSRMLS_DC) -{ - zend_fcall_info fci; - zval ***args = NULL; - int arg_count = 0; - HashTable *table; - HashPosition pos; - int i = 0; - zval *retval_ptr; - zval *zfunction; - - if (arguments) { - table = HASH_OF(arguments); - args = safe_emalloc(sizeof(zval **), table->nNumOfElements, 0); - - zend_hash_internal_pointer_reset_ex(table, &pos); - - while (zend_hash_get_current_data_ex(table, (void **)&args[i], &pos) == SUCCESS) { - i++; - zend_hash_move_forward_ex(table, &pos); - } - arg_count = table->nNumOfElements; - } - - MAKE_STD_ZVAL(zfunction); - ZVAL_STRING(zfunction, function, 1); - fci.size = sizeof(fci); - fci.function_table = EG(function_table); - fci.function_name = zfunction; - fci.symbol_table = NULL; -#if PHP_VERSION_ID >= 50300 - fci.object_ptr = object; -#else - fci.object_pp = &object; -#endif - fci.retval_ptr_ptr = &retval_ptr; - fci.param_count = arg_count; - fci.params = args; - fci.no_separation = 0; - - if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - ALLOC_INIT_ZVAL(retval_ptr); - ZVAL_BOOL(retval_ptr, 0); - } - - if (args) { - efree(fci.params); - } - FREE_DTOR(zfunction); - return retval_ptr; -} - -static int TWIG_CALL_BOOLEAN(zval *object, char *functionName TSRMLS_DC) -{ - zval *ret; - int res; - - ret = TWIG_CALL_USER_FUNC_ARRAY(object, functionName, NULL TSRMLS_CC); - res = Z_LVAL_P(ret); - zval_ptr_dtor(&ret); - return res; -} - -static zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name TSRMLS_DC) -{ - zval **tmp_zval; - zend_class_entry *ce; - - if (class == NULL || Z_TYPE_P(class) != IS_OBJECT) { - return NULL; - } - - ce = zend_get_class_entry(class TSRMLS_CC); -#if PHP_VERSION_ID >= 50400 - tmp_zval = zend_std_get_static_property(ce, prop_name, strlen(prop_name), 0, NULL TSRMLS_CC); -#else - tmp_zval = zend_std_get_static_property(ce, prop_name, strlen(prop_name), 0 TSRMLS_CC); -#endif - return *tmp_zval; -} - -static zval *TWIG_GET_ARRAY_ELEMENT_ZVAL(zval *class, zval *prop_name TSRMLS_DC) -{ - zval **tmp_zval; - - if (class == NULL || Z_TYPE_P(class) != IS_ARRAY) { - if (class != NULL && Z_TYPE_P(class) == IS_OBJECT && TWIG_INSTANCE_OF(class, zend_ce_arrayaccess TSRMLS_CC)) { - // array access object - return TWIG_GET_ARRAYOBJECT_ELEMENT(class, prop_name TSRMLS_CC); - } - return NULL; - } - - switch(Z_TYPE_P(prop_name)) { - case IS_NULL: - zend_hash_find(HASH_OF(class), "", 1, (void**) &tmp_zval); - return *tmp_zval; - - case IS_BOOL: - case IS_DOUBLE: - convert_to_long(prop_name); - case IS_LONG: - zend_hash_index_find(HASH_OF(class), Z_LVAL_P(prop_name), (void **) &tmp_zval); - return *tmp_zval; - - case IS_STRING: - zend_symtable_find(HASH_OF(class), Z_STRVAL_P(prop_name), Z_STRLEN_P(prop_name) + 1, (void**) &tmp_zval); - return *tmp_zval; - } - - return NULL; -} - -static zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length TSRMLS_DC) -{ - zval **tmp_zval; - - if (class == NULL/* || Z_TYPE_P(class) != IS_ARRAY*/) { - return NULL; - } - - if (class != NULL && Z_TYPE_P(class) == IS_OBJECT && TWIG_INSTANCE_OF(class, zend_ce_arrayaccess TSRMLS_CC)) { - // array access object - zval *tmp_name_zval; - zval *tmp_ret_zval; - - 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); - FREE_DTOR(tmp_name_zval); - return tmp_ret_zval; - } - - if (zend_symtable_find(HASH_OF(class), prop_name, prop_name_length+1, (void**)&tmp_zval) == SUCCESS) { - return *tmp_zval; - } - return NULL; -} - -static zval *TWIG_PROPERTY(zval *object, zval *propname TSRMLS_DC) -{ - zval *tmp = NULL; - - 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); -#else - tmp = Z_OBJ_HT_P(object)->read_property(object, propname, BP_VAR_IS TSRMLS_CC); -#endif - if (tmp == EG(uninitialized_zval_ptr)) { - ZVAL_NULL(tmp); - } - } - return tmp; -} - -static int TWIG_HAS_PROPERTY(zval *object, zval *propname TSRMLS_DC) -{ - if (Z_OBJ_HT_P(object)->has_property) { -#if PHP_VERSION_ID >= 50400 - return Z_OBJ_HT_P(object)->has_property(object, propname, 0, NULL TSRMLS_CC); -#else - return Z_OBJ_HT_P(object)->has_property(object, propname, 0 TSRMLS_CC); -#endif - } - return 0; -} - -static 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; -} - -static zval *TWIG_PROPERTY_CHAR(zval *object, char *propname TSRMLS_DC) -{ - zval *tmp_name_zval, *tmp; - - ALLOC_INIT_ZVAL(tmp_name_zval); - ZVAL_STRING(tmp_name_zval, propname, 1); - tmp = TWIG_PROPERTY(object, tmp_name_zval TSRMLS_CC); - FREE_DTOR(tmp_name_zval); - return tmp; -} - -static zval *TWIG_CALL_S(zval *object, char *method, char *arg0 TSRMLS_DC) -{ - zend_fcall_info fci; - zval **args[1]; - zval *argument; - zval *zfunction; - zval *retval_ptr; - - MAKE_STD_ZVAL(argument); - ZVAL_STRING(argument, arg0, 1); - args[0] = &argument; - - MAKE_STD_ZVAL(zfunction); - ZVAL_STRING(zfunction, method, 1); - fci.size = sizeof(fci); - fci.function_table = EG(function_table); - fci.function_name = zfunction; - fci.symbol_table = NULL; -#if PHP_VERSION_ID >= 50300 - fci.object_ptr = object; -#else - fci.object_pp = &object; -#endif - fci.retval_ptr_ptr = &retval_ptr; - fci.param_count = 1; - fci.params = args; - fci.no_separation = 0; - - if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - FREE_DTOR(zfunction); - zval_ptr_dtor(&argument); - return 0; - } - FREE_DTOR(zfunction); - zval_ptr_dtor(&argument); - return retval_ptr; -} - -static int TWIG_CALL_SB(zval *object, char *method, char *arg0 TSRMLS_DC) -{ - zval *retval_ptr; - int success; - - retval_ptr = TWIG_CALL_S(object, method, arg0 TSRMLS_CC); - success = (retval_ptr && (Z_TYPE_P(retval_ptr) == IS_BOOL) && Z_LVAL_P(retval_ptr)); - - if (retval_ptr) { - zval_ptr_dtor(&retval_ptr); - } - - return success; -} - -static int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2 TSRMLS_DC) -{ - zend_fcall_info fci; - zval **args[2]; - zval *zfunction; - zval *retval_ptr; - int success; - - args[0] = &arg1; - args[1] = &arg2; - - MAKE_STD_ZVAL(zfunction); - ZVAL_STRING(zfunction, method, 1); - fci.size = sizeof(fci); - fci.function_table = EG(function_table); - fci.function_name = zfunction; - fci.symbol_table = NULL; -#if PHP_VERSION_ID >= 50300 - fci.object_ptr = object; -#else - fci.object_pp = &object; -#endif - fci.retval_ptr_ptr = &retval_ptr; - fci.param_count = 2; - fci.params = args; - fci.no_separation = 0; - - if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - FREE_DTOR(zfunction); - return 0; - } - - FREE_DTOR(zfunction); - - success = (retval_ptr && (Z_TYPE_P(retval_ptr) == IS_BOOL) && Z_LVAL_P(retval_ptr)); - if (retval_ptr) { - zval_ptr_dtor(&retval_ptr); - } - - return success; -} - -#ifndef Z_SET_REFCOUNT_P -# define Z_SET_REFCOUNT_P(pz, rc) pz->refcount = rc -# define Z_UNSET_ISREF_P(pz) pz->is_ref = 0 -#endif - -static void TWIG_NEW(zval *object, char *class, zval *arg0, zval *arg1 TSRMLS_DC) -{ - zend_class_entry **pce; - - if (zend_lookup_class(class, strlen(class), &pce TSRMLS_CC) == FAILURE) { - return; - } - - Z_TYPE_P(object) = IS_OBJECT; - object_init_ex(object, *pce); - Z_SET_REFCOUNT_P(object, 1); - Z_UNSET_ISREF_P(object); - - TWIG_CALL_ZZ(object, "__construct", arg0, arg1 TSRMLS_CC); -} - -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; - APPLY_TSRMLS_FETCH(); - - buf = va_arg(args, smart_str*); - joiner = va_arg(args, char*); - - if (buf->len != 0) { - smart_str_appends(buf, joiner); - } - - if (hash_key->nKeyLength == 0) { - smart_str_append_long(buf, (long) hash_key->h); - } else { - char *key, *tmp_str; - int key_len, tmp_len; - key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC); - tmp_str = php_str_to_str_ex(key, key_len, "\0", 1, "' . \"\\0\" . '", 12, &tmp_len, 0, NULL); - - smart_str_appendl(buf, tmp_str, tmp_len); - efree(key); - efree(tmp_str); - } - - return 0; -} - -static 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) APPLY_TSRMLS_CC, twig_add_array_key_to_string, 2, &collector, joiner); - smart_str_0(&collector); - - return collector.c; -} - -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; - - 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 APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) -{ - zend_class_entry *ce; - zval *retval; - char *item; - size_t item_len; - zend_function *mptr = (zend_function *) pDest; - APPLY_TSRMLS_FETCH(); - - if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)) { - return 0; - } - - ce = *va_arg(args, zend_class_entry**); - retval = va_arg(args, zval*); - - item_len = strlen(mptr->common.function_name); - item = estrndup(mptr->common.function_name, item_len); - php_strtolower(item, item_len); - - if (strcmp("getenvironment", item) == 0) { - zend_class_entry **twig_template_ce; - if (zend_lookup_class("Twig_Template", strlen("Twig_Template"), &twig_template_ce TSRMLS_CC) == FAILURE) { - return 0; - } - if (instanceof_function(ce, *twig_template_ce TSRMLS_CC)) { - return 0; - } - } - - add_assoc_stringl_ex(retval, item, item_len+1, item, item_len, 0); - - return 0; -} - -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; - char *class_name, *prop_name; - zend_property_info *pptr = (zend_property_info *) pDest; - APPLY_TSRMLS_FETCH(); - - if (!(pptr->flags & ZEND_ACC_PUBLIC) || (pptr->flags & ZEND_ACC_STATIC)) { - return 0; - } - - 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; -} - -static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name TSRMLS_DC) -{ - zval *class_info, *class_methods, *class_properties; - zend_class_entry *class_ce; - - class_ce = zend_get_class_entry(object TSRMLS_CC); - - ALLOC_INIT_ZVAL(class_info); - ALLOC_INIT_ZVAL(class_methods); - ALLOC_INIT_ZVAL(class_properties); - array_init(class_info); - 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 APPLY_TSRMLS_CC, twig_add_method_to_class, 2, &class_ce, class_methods); - zend_hash_apply_with_arguments(&class_ce->properties_info APPLY_TSRMLS_CC, twig_add_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); -} - -/* {{{ proto mixed twig_template_get_attributes(TwigTemplate template, mixed object, mixed item, array arguments, string type, boolean isDefinedTest, boolean ignoreStrictCheck) - A C implementation of TwigTemplate::getAttribute() */ -PHP_FUNCTION(twig_template_get_attributes) -{ - zval *template; - zval *object; - char *item; - int item_len; - zval *zitem, ztmpitem; - zval *arguments = NULL; - zval *ret = NULL; - char *type = NULL; - int type_len = 0; - zend_bool isDefinedTest = 0; - zend_bool ignoreStrictCheck = 0; - int free_ret = 0; - zval *tmp_self_cache; - char *class_name = NULL; - zval *tmp_class; - char *type_name; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ozz|asbb", &template, &object, &zitem, &arguments, &type, &type_len, &isDefinedTest, &ignoreStrictCheck) == FAILURE) { - return; - } - - // convert the item to a string - ztmpitem = *zitem; - zval_copy_ctor(&ztmpitem); - convert_to_string(&ztmpitem); - item_len = Z_STRLEN(ztmpitem); - item = estrndup(Z_STRVAL(ztmpitem), item_len); - zval_dtor(&ztmpitem); - - if (!type) { - type = "any"; - } - -/* - // array - if (Twig_Template::METHOD_CALL !== $type) { - $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item; - - if ((is_array($object) && array_key_exists($arrayItem, $object)) - || ($object instanceof ArrayAccess && isset($object[$arrayItem])) - ) { - if ($isDefinedTest) { - return true; - } - - return $object[$arrayItem]; - } -*/ - - - if (strcmp("method", type) != 0) { - if ((TWIG_ARRAY_KEY_EXISTS(object, zitem)) - || (TWIG_INSTANCE_OF(object, zend_ce_arrayaccess TSRMLS_CC) && TWIG_ISSET_ARRAYOBJECT_ELEMENT(object, zitem TSRMLS_CC)) - ) { - - if (isDefinedTest) { - efree(item); - RETURN_TRUE; - } - - ret = TWIG_GET_ARRAY_ELEMENT_ZVAL(object, zitem TSRMLS_CC); - - if (!ret) { - ret = &EG(uninitialized_zval); - } - RETVAL_ZVAL(ret, 1, 0); - if (free_ret) { - zval_ptr_dtor(&ret); - } - efree(item); - return; - } -/* - if (Twig_Template::ARRAY_CALL === $type) { - if ($isDefinedTest) { - return false; - } - if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { - return null; - } -*/ - if (strcmp("array", type) == 0 || Z_TYPE_P(object) != IS_OBJECT) { - if (isDefinedTest) { - efree(item); - RETURN_FALSE; - } - if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { - efree(item); - return; - } -/* - if ($object instanceof ArrayAccess) { - $message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist', $arrayItem, get_class($object)); - } elseif (is_object($object)) { - $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface', $item, get_class($object)); - } elseif (is_array($object)) { - if (empty($object)) { - $message = sprintf('Key "%s" does not exist as the array is empty', $arrayItem); - } else { - $message = sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object))); - } - } elseif (Twig_Template::ARRAY_CALL === $type) { - if (null === $object) { - $message = sprintf('Impossible to access a key ("%s") on a null variable', $item); - } else { - $message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object); - } - } elseif (null === $object) { - $message = sprintf('Impossible to access an attribute ("%s") on a null variable', $item); - } else { - $message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s")', $item, gettype($object), $object); - } - throw new Twig_Error_Runtime($message, -1, $this->getTemplateName()); - } - } -*/ - if (TWIG_INSTANCE_OF(object, zend_ce_arrayaccess TSRMLS_CC)) { - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" in object with ArrayAccess of class \"%s\" does not exist.", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); - } else if (Z_TYPE_P(object) == IS_OBJECT) { - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to access a key \"%s\" on an object of class \"%s\" that does not implement ArrayAccess interface.", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); - } else if (Z_TYPE_P(object) == IS_ARRAY) { - if (0 == zend_hash_num_elements(Z_ARRVAL_P(object))) { - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" does not exist as the array is empty.", item); - } else { - char *array_keys = TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC); - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist.", item, array_keys); - efree(array_keys); - } - } else { - char *type_name = zend_zval_type_name(object); - Z_ADDREF_P(object); - if (Z_TYPE_P(object) == IS_NULL) { - convert_to_string(object); - TWIG_RUNTIME_ERROR(template TSRMLS_CC, - (strcmp("array", type) == 0) - ? "Impossible to access a key (\"%s\") on a %s variable." - : "Impossible to access an attribute (\"%s\") on a %s variable.", - item, type_name); - } else { - convert_to_string(object); - TWIG_RUNTIME_ERROR(template TSRMLS_CC, - (strcmp("array", type) == 0) - ? "Impossible to access a key (\"%s\") on a %s variable (\"%s\")." - : "Impossible to access an attribute (\"%s\") on a %s variable (\"%s\").", - item, type_name, Z_STRVAL_P(object)); - } - zval_ptr_dtor(&object); - } - efree(item); - return; - } - } - -/* - if (!is_object($object)) { - if ($isDefinedTest) { - return false; - } -*/ - - if (Z_TYPE_P(object) != IS_OBJECT) { - if (isDefinedTest) { - efree(item); - RETURN_FALSE; - } -/* - if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { - return null; - } - - if (null === $object) { - $message = sprintf('Impossible to invoke a method ("%s") on a null variable', $item); - } else { - $message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object); - } - - throw new Twig_Error_Runtime($message, -1, $this->getTemplateName()); - } -*/ - if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { - efree(item); - return; - } - - type_name = zend_zval_type_name(object); - Z_ADDREF_P(object); - if (Z_TYPE_P(object) == IS_NULL) { - convert_to_string_ex(&object); - - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable.", item, type_name); - } else { - convert_to_string_ex(&object); - - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable (\"%s\").", item, type_name, Z_STRVAL_P(object)); - } - - zval_ptr_dtor(&object); - efree(item); - return; - } -/* - $class = get_class($object); -*/ - - class_name = TWIG_GET_CLASS_NAME(object TSRMLS_CC); - tmp_self_cache = TWIG_GET_STATIC_PROPERTY(template, "cache" TSRMLS_CC); - tmp_class = TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name) TSRMLS_CC); - - if (!tmp_class) { - twig_add_class_to_cache(tmp_self_cache, object, class_name TSRMLS_CC); - tmp_class = TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name) TSRMLS_CC); - } - efree(class_name); - -/* - // object property - if (Twig_Template::METHOD_CALL !== $type && !$object instanceof Twig_Template) { - if (isset($object->$item) || array_key_exists((string) $item, $object)) { - if ($isDefinedTest) { - return true; - } - - if ($this->env->hasExtension('Twig_Extension_Sandbox')) { - $this->env->getExtension('Twig_Extension_Sandbox')->checkPropertyAllowed($object, $item); - } - - return $object->$item; - } - } -*/ - if (strcmp("method", type) != 0 && !TWIG_INSTANCE_OF_USERLAND(object, "Twig_Template" TSRMLS_CC)) { - zval *tmp_properties, *tmp_item; - - tmp_properties = TWIG_GET_ARRAY_ELEMENT(tmp_class, "properties", strlen("properties") TSRMLS_CC); - tmp_item = TWIG_GET_ARRAY_ELEMENT(tmp_properties, item, item_len TSRMLS_CC); - - if (tmp_item || TWIG_HAS_PROPERTY(object, zitem TSRMLS_CC) || TWIG_HAS_DYNAMIC_PROPERTY(object, item, item_len TSRMLS_CC)) { - if (isDefinedTest) { - efree(item); - RETURN_TRUE; - } - if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "hasExtension", "Twig_Extension_Sandbox" TSRMLS_CC)) { - TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "Twig_Extension_Sandbox" TSRMLS_CC), "checkPropertyAllowed", object, zitem TSRMLS_CC); - } - if (EG(exception)) { - efree(item); - return; - } - - ret = TWIG_PROPERTY(object, zitem TSRMLS_CC); - efree(item); - RETURN_ZVAL(ret, 1, 0); - } - } -/* - // object method - if (!isset(self::$cache[$class]['methods'])) { - if ($object instanceof self) { - $ref = new ReflectionClass($class); - $methods = array(); - - foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) { - $methodName = strtolower($refMethod->name); - - // Accessing the environment from templates is forbidden to prevent untrusted changes to the environment - if ('getenvironment' !== $methodName) { - $methods[$methodName] = true; - } - } - - self::$cache[$class]['methods'] = $methods; - } else { - self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object))); - } - } - - $call = false; - $lcItem = strtolower($item); - if (isset(self::$cache[$class]['methods'][$lcItem])) { - $method = (string) $item; - } elseif (isset(self::$cache[$class]['methods']['get'.$lcItem])) { - $method = 'get'.$item; - } elseif (isset(self::$cache[$class]['methods']['is'.$lcItem])) { - $method = 'is'.$item; - } elseif (isset(self::$cache[$class]['methods']['__call'])) { - $method = (string) $item; - $call = true; -*/ - { - int call = 0; - char *lcItem = TWIG_STRTOLOWER(item, item_len); - int lcItem_length; - char *method = NULL; - char *methodForDeprecation = NULL; - char *tmp_method_name_get; - char *tmp_method_name_is; - zval *zmethod; - zval *tmp_methods; - - lcItem_length = strlen(lcItem); - tmp_method_name_get = emalloc(4 + lcItem_length); - tmp_method_name_is = emalloc(3 + lcItem_length); - - sprintf(tmp_method_name_get, "get%s", lcItem); - sprintf(tmp_method_name_is, "is%s", lcItem); - - tmp_methods = TWIG_GET_ARRAY_ELEMENT(tmp_class, "methods", strlen("methods") TSRMLS_CC); - methodForDeprecation = emalloc(item_len + 1); - sprintf(methodForDeprecation, "%s", item); - - if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, lcItem, lcItem_length TSRMLS_CC)) { - method = item; - } else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, tmp_method_name_get, lcItem_length + 3 TSRMLS_CC)) { - method = tmp_method_name_get; - } else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, tmp_method_name_is, lcItem_length + 2 TSRMLS_CC)) { - method = tmp_method_name_is; - } else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, "__call", 6 TSRMLS_CC)) { - method = item; - call = 1; -/* - } else { - if ($isDefinedTest) { - return false; - } - - if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { - return null; - } - - throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist.', $item, get_class($object)), -1, $this->getTemplateName()); - } - - if ($isDefinedTest) { - return true; - } -*/ - } else { - efree(tmp_method_name_get); - efree(tmp_method_name_is); - efree(lcItem); - - if (isDefinedTest) { - efree(item); - RETURN_FALSE; - } - if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { - efree(item); - return; - } - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Neither the property \"%s\" nor one of the methods \"%s()\", \"get%s()\"/\"is%s()\" or \"__call()\" exist and have public access in class \"%s\".", item, item, item, item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); - efree(item); - return; - } - - if (isDefinedTest) { - efree(tmp_method_name_get); - efree(tmp_method_name_is); - efree(lcItem);efree(item); - RETURN_TRUE; - } -/* - if ($this->env->hasExtension('Twig_Extension_Sandbox')) { - $this->env->getExtension('Twig_Extension_Sandbox')->checkMethodAllowed($object, $method); - } -*/ - MAKE_STD_ZVAL(zmethod); - ZVAL_STRING(zmethod, method, 1); - if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "hasExtension", "Twig_Extension_Sandbox" TSRMLS_CC)) { - TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "Twig_Extension_Sandbox" TSRMLS_CC), "checkMethodAllowed", object, zmethod TSRMLS_CC); - } - zval_ptr_dtor(&zmethod); - if (EG(exception)) { - efree(tmp_method_name_get); - efree(tmp_method_name_is); - efree(lcItem);efree(item); - return; - } -/* - // Some objects throw exceptions when they have __call, and the method we try - // to call is not supported. If ignoreStrictCheck is true, we should return null. - try { - $ret = call_user_func_array(array($object, $method), $arguments); - } catch (BadMethodCallException $e) { - if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) { - return null; - } - throw $e; - } -*/ - ret = TWIG_CALL_USER_FUNC_ARRAY(object, method, arguments TSRMLS_CC); - if (EG(exception) && TWIG_INSTANCE_OF(EG(exception), spl_ce_BadMethodCallException TSRMLS_CC)) { - if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { - efree(tmp_method_name_get); - efree(tmp_method_name_is); - efree(lcItem);efree(item); - zend_clear_exception(TSRMLS_C); - return; - } - } - free_ret = 1; - efree(tmp_method_name_get); - efree(tmp_method_name_is); - efree(lcItem); -/* - // @deprecated in 1.28 - if ($object instanceof Twig_TemplateInterface) { - $self = $object->getTemplateName() === $this->getTemplateName(); - $message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName()); - if ('renderBlock' === $method || 'displayBlock' === $method) { - $message .= sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template'); - } elseif ('hasBlock' === $method) { - $message .= sprintf(' Use "block("%s"%s) is defined" instead).', $arguments[0], $self ? '' : ', template'); - } elseif ('render' === $method || 'display' === $method) { - $message .= sprintf(' Use include("%s") instead).', $object->getTemplateName()); - } - @trigger_error($message, E_USER_DEPRECATED); - - return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset()); - } - - return $ret; -*/ - efree(item); - // 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)) { - int self; - int old_error_reporting; - zval *object_filename; - zval *this_filename; - zval *filename_func; - char *deprecation_message_complement = NULL; - char *deprecation_message = NULL; - - MAKE_STD_ZVAL(object_filename); - MAKE_STD_ZVAL(this_filename); - MAKE_STD_ZVAL(filename_func); - - // Get templates names - ZVAL_STRINGL(filename_func, "getTemplateName", sizeof("getTemplateName")-1, 1); - call_user_function(EG(function_table), &object, filename_func, object_filename, 0, 0 TSRMLS_CC); - ZVAL_STRINGL(filename_func, "getTemplateName", sizeof("getTemplateName")-1, 1); - call_user_function(EG(function_table), &template, filename_func, this_filename, 0, 0 TSRMLS_CC); - - self = (strcmp(Z_STRVAL_P(object_filename), Z_STRVAL_P(this_filename)) == 0); - - if (strcmp(methodForDeprecation, "renderBlock") == 0 || strcmp(methodForDeprecation, "displayBlock") == 0) { - zval **arg0; - zend_hash_index_find(HASH_OF(arguments), 0, (void **) &arg0); - asprintf( - &deprecation_message_complement, - " Use block(\"%s\"%s) instead).", - Z_STRVAL_PP(arg0), - self ? "" : ", template" - ); - } else if (strcmp(methodForDeprecation, "hasBlock") == 0) { - zval **arg0; - zend_hash_index_find(HASH_OF(arguments), 0, (void **) &arg0); - asprintf( - &deprecation_message_complement, - " Use \"block(\"%s\"%s) is defined\" instead).", - Z_STRVAL_PP(arg0), - self ? "" : ", template" - ); - } else if (strcmp(methodForDeprecation, "render") == 0 || strcmp(methodForDeprecation, "display") == 0) { - asprintf( - &deprecation_message_complement, - " Use include(\"%s\") instead).", - Z_STRVAL_P(object_filename) - ); - } else { - deprecation_message_complement = (char*)calloc(0, sizeof(char)); - } - - asprintf( - &deprecation_message, - "Calling \"%s\" on template \"%s\" from template \"%s\" is deprecated since version 1.28 and won't be supported anymore in 2.0.%s", - methodForDeprecation, - Z_STRVAL_P(object_filename), - Z_STRVAL_P(this_filename), - deprecation_message_complement - ); - - old_error_reporting = EG(error_reporting); - EG(error_reporting) = 0; - zend_error(E_USER_DEPRECATED, "%s", deprecation_message); - EG(error_reporting) = old_error_reporting; - - FREE_DTOR(filename_func) - FREE_DTOR(object_filename) - FREE_DTOR(this_filename) - free(deprecation_message); - free(deprecation_message_complement); - - if (Z_STRLEN_P(ret) != 0) { - 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); - } - efree(methodForDeprecation); - return; - } - } - - RETVAL_ZVAL(ret, 1, 0); - if (free_ret) { - zval_ptr_dtor(&ret); - } - } - - efree(methodForDeprecation); - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Autoloader.php b/lib/silex/vendor/twig/twig/lib/Twig/Autoloader.php deleted file mode 100644 index 212af5445..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Autoloader.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * @deprecated since 1.21 and will be removed in 2.0. Use Composer instead. 2.0. - */ -class Twig_Autoloader -{ - /** - * Registers Twig_Autoloader as an SPL autoloader. - * - * @param bool $prepend whether to prepend the autoloader or not - */ - public static function register($prepend = false) - { - @trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED); - - if (PHP_VERSION_ID < 50300) { - spl_autoload_register(array(__CLASS__, 'autoload')); - } else { - spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); - } - } - - /** - * Handles autoloading of classes. - * - * @param string $class a class name - */ - public static function autoload($class) - { - if (0 !== strpos($class, 'Twig')) { - return; - } - - if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) { - require $file; - } - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/BaseNodeVisitor.php b/lib/silex/vendor/twig/twig/lib/Twig/BaseNodeVisitor.php deleted file mode 100644 index d8ef02fb2..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/BaseNodeVisitor.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface -{ - final public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) - { - if (!$node instanceof Twig_Node) { - throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.'); - } - - return $this->doEnterNode($node, $env); - } - - final public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) - { - if (!$node instanceof Twig_Node) { - throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.'); - } - - return $this->doLeaveNode($node, $env); - } - - /** - * Called before child nodes are visited. - * - * @return Twig_Node The modified node - */ - abstract protected function doEnterNode(Twig_Node $node, Twig_Environment $env); - - /** - * Called after child nodes are visited. - * - * @return Twig_Node|false The modified node or false if the node must be removed - */ - abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env); -} - -class_alias('Twig_BaseNodeVisitor', 'Twig\NodeVisitor\AbstractNodeVisitor', false); -class_exists('Twig_Environment'); -class_exists('Twig_Node'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Cache/Filesystem.php b/lib/silex/vendor/twig/twig/lib/Twig/Cache/Filesystem.php deleted file mode 100644 index 65976282b..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Cache/Filesystem.php +++ /dev/null @@ -1,93 +0,0 @@ - - */ -class Twig_Cache_Filesystem implements Twig_CacheInterface -{ - const FORCE_BYTECODE_INVALIDATION = 1; - - private $directory; - private $options; - - /** - * @param $directory string The root cache directory - * @param $options int A set of options - */ - public function __construct($directory, $options = 0) - { - $this->directory = rtrim($directory, '\/').'/'; - $this->options = $options; - } - - public function generateKey($name, $className) - { - $hash = hash('sha256', $className); - - return $this->directory.$hash[0].$hash[1].'/'.$hash.'.php'; - } - - public function load($key) - { - if (file_exists($key)) { - @include_once $key; - } - } - - public function write($key, $content) - { - $dir = dirname($key); - if (!is_dir($dir)) { - if (false === @mkdir($dir, 0777, true)) { - if (PHP_VERSION_ID >= 50300) { - clearstatcache(true, $dir); - } - if (!is_dir($dir)) { - throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir)); - } - } - } elseif (!is_writable($dir)) { - throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir)); - } - - $tmpFile = tempnam($dir, basename($key)); - if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $key)) { - @chmod($key, 0666 & ~umask()); - - if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) { - // Compile cached file into bytecode cache - if (function_exists('opcache_invalidate')) { - opcache_invalidate($key, true); - } elseif (function_exists('apc_compile_file')) { - apc_compile_file($key); - } - } - - return; - } - - throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key)); - } - - public function getTimestamp($key) - { - if (!file_exists($key)) { - return 0; - } - - return (int) @filemtime($key); - } -} - -class_alias('Twig_Cache_Filesystem', 'Twig\Cache\FilesystemCache', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Cache/Null.php b/lib/silex/vendor/twig/twig/lib/Twig/Cache/Null.php deleted file mode 100644 index 69d1d2f98..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Cache/Null.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class Twig_Cache_Null implements Twig_CacheInterface -{ - public function generateKey($name, $className) - { - return ''; - } - - public function write($key, $content) - { - } - - public function load($key) - { - } - - public function getTimestamp($key) - { - return 0; - } -} - -class_alias('Twig_Cache_Null', 'Twig\Cache\NullCache', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/CacheInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/CacheInterface.php deleted file mode 100644 index 776808bfe..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/CacheInterface.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ -interface Twig_CacheInterface -{ - /** - * Generates a cache key for the given template class name. - * - * @param string $name The template name - * @param string $className The template class name - * - * @return string - */ - public function generateKey($name, $className); - - /** - * Writes the compiled template to cache. - * - * @param string $key The cache key - * @param string $content The template representation as a PHP class - */ - public function write($key, $content); - - /** - * Loads a template from the cache. - * - * @param string $key The cache key - */ - public function load($key); - - /** - * Returns the modification timestamp of a key. - * - * @param string $key The cache key - * - * @return int - */ - public function getTimestamp($key); -} - -class_alias('Twig_CacheInterface', 'Twig\Cache\CacheInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Compiler.php b/lib/silex/vendor/twig/twig/lib/Twig/Compiler.php deleted file mode 100644 index e90bc987d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Compiler.php +++ /dev/null @@ -1,284 +0,0 @@ - - */ -class Twig_Compiler implements Twig_CompilerInterface -{ - protected $lastLine; - protected $source; - protected $indentation; - protected $env; - protected $debugInfo = array(); - protected $sourceOffset; - protected $sourceLine; - protected $filename; - - public function __construct(Twig_Environment $env) - { - $this->env = $env; - } - - /** - * @deprecated since 1.25 (to be removed in 2.0) - */ - public function getFilename() - { - @trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED); - - return $this->filename; - } - - /** - * Returns the environment instance related to this compiler. - * - * @return Twig_Environment - */ - public function getEnvironment() - { - return $this->env; - } - - /** - * Gets the current PHP code after compilation. - * - * @return string The PHP code - */ - public function getSource() - { - return $this->source; - } - - /** - * Compiles a node. - * - * @param Twig_NodeInterface $node The node to compile - * @param int $indentation The current indentation - * - * @return $this - */ - public function compile(Twig_NodeInterface $node, $indentation = 0) - { - $this->lastLine = null; - $this->source = ''; - $this->debugInfo = array(); - $this->sourceOffset = 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) { - // to be removed in 2.0 - $this->filename = $node->getTemplateName(); - } - - $node->compile($this); - - return $this; - } - - public function subcompile(Twig_NodeInterface $node, $raw = true) - { - if (false === $raw) { - $this->source .= str_repeat(' ', $this->indentation * 4); - } - - $node->compile($this); - - return $this; - } - - /** - * Adds a raw string to the compiled code. - * - * @param string $string The string - * - * @return $this - */ - public function raw($string) - { - $this->source .= $string; - - return $this; - } - - /** - * Writes a string to the compiled code by adding indentation. - * - * @return $this - */ - public function write() - { - $strings = func_get_args(); - foreach ($strings as $string) { - $this->source .= str_repeat(' ', $this->indentation * 4).$string; - } - - return $this; - } - - /** - * Appends an indentation to the current PHP code after compilation. - * - * @return $this - * - * @deprecated since 1.27 (to be removed in 2.0). - */ - public function addIndentation() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use write(\'\') instead.', E_USER_DEPRECATED); - - $this->source .= str_repeat(' ', $this->indentation * 4); - - return $this; - } - - /** - * Adds a quoted string to the compiled code. - * - * @param string $value The string - * - * @return $this - */ - public function string($value) - { - $this->source .= sprintf('"%s"', addcslashes($value, "\0\t\"\$\\")); - - return $this; - } - - /** - * Returns a PHP representation of a given value. - * - * @param mixed $value The value to convert - * - * @return $this - */ - public function repr($value) - { - if (is_int($value) || is_float($value)) { - if (false !== $locale = setlocale(LC_NUMERIC, '0')) { - setlocale(LC_NUMERIC, 'C'); - } - - $this->raw($value); - - if (false !== $locale) { - setlocale(LC_NUMERIC, $locale); - } - } elseif (null === $value) { - $this->raw('null'); - } elseif (is_bool($value)) { - $this->raw($value ? 'true' : 'false'); - } elseif (is_array($value)) { - $this->raw('array('); - $first = true; - foreach ($value as $key => $v) { - if (!$first) { - $this->raw(', '); - } - $first = false; - $this->repr($key); - $this->raw(' => '); - $this->repr($v); - } - $this->raw(')'); - } else { - $this->string($value); - } - - return $this; - } - - /** - * Adds debugging information. - * - * @return $this - */ - public function addDebugInfo(Twig_NodeInterface $node) - { - if ($node->getTemplateLine() != $this->lastLine) { - $this->write(sprintf("// line %d\n", $node->getTemplateLine())); - - // when mbstring.func_overload is set to 2 - // mb_substr_count() replaces substr_count() - // but they have different signatures! - if (((int) ini_get('mbstring.func_overload')) & 2) { - @trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED); - - // this is much slower than the "right" version - $this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n"); - } else { - $this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset); - } - $this->sourceOffset = strlen($this->source); - $this->debugInfo[$this->sourceLine] = $node->getTemplateLine(); - - $this->lastLine = $node->getTemplateLine(); - } - - return $this; - } - - public function getDebugInfo() - { - ksort($this->debugInfo); - - return $this->debugInfo; - } - - /** - * Indents the generated code. - * - * @param int $step The number of indentation to add - * - * @return $this - */ - public function indent($step = 1) - { - $this->indentation += $step; - - return $this; - } - - /** - * Outdents the generated code. - * - * @param int $step The number of indentation to remove - * - * @return $this - * - * @throws LogicException When trying to outdent too much so the indentation would become negative - */ - public function outdent($step = 1) - { - // can't outdent by more steps than the current indentation level - if ($this->indentation < $step) { - throw new LogicException('Unable to call outdent() as the indentation would become negative.'); - } - - $this->indentation -= $step; - - return $this; - } - - public function getVarName() - { - return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false)); - } -} - -class_alias('Twig_Compiler', 'Twig\Compiler', false); -class_exists('Twig_Node'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/CompilerInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/CompilerInterface.php deleted file mode 100644 index 42872c9cd..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/CompilerInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_CompilerInterface -{ - /** - * Compiles a node. - * - * @return $this - */ - public function compile(Twig_NodeInterface $node); - - /** - * Gets the current PHP code after compilation. - * - * @return string The PHP code - */ - public function getSource(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php b/lib/silex/vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php deleted file mode 100644 index 814ab58bc..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @author Robin Chalas - */ -class Twig_ContainerRuntimeLoader implements Twig_RuntimeLoaderInterface -{ - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - public function load($class) - { - if ($this->container->has($class)) { - return $this->container->get($class); - } - } -} - -class_alias('Twig_ContainerRuntimeLoader', 'Twig\RuntimeLoader\ContainerRuntimeLoader', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Environment.php b/lib/silex/vendor/twig/twig/lib/Twig/Environment.php deleted file mode 100644 index 5de2f27fd..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Environment.php +++ /dev/null @@ -1,1600 +0,0 @@ - - */ -class Twig_Environment -{ - const VERSION = '1.35.0'; - const VERSION_ID = 13500; - const MAJOR_VERSION = 1; - const MINOR_VERSION = 35; - const RELEASE_VERSION = 0; - const EXTRA_VERSION = ''; - - protected $charset; - protected $loader; - protected $debug; - protected $autoReload; - protected $cache; - protected $lexer; - protected $parser; - protected $compiler; - protected $baseTemplateClass; - protected $extensions; - protected $parsers; - protected $visitors; - protected $filters; - protected $tests; - protected $functions; - protected $globals; - protected $runtimeInitialized = false; - protected $extensionInitialized = false; - protected $loadedTemplates; - protected $strictVariables; - protected $unaryOperators; - protected $binaryOperators; - protected $templateClassPrefix = '__TwigTemplate_'; - protected $functionCallbacks = array(); - protected $filterCallbacks = array(); - protected $staging; - - private $originalCache; - private $bcWriteCacheFile = false; - private $bcGetCacheFilename = false; - private $lastModifiedExtension = 0; - private $extensionsByClass = array(); - private $runtimeLoaders = array(); - private $runtimes = array(); - private $optionsHash; - private $loading = array(); - - /** - * Constructor. - * - * Available options: - * - * * debug: When set to true, it automatically set "auto_reload" to true as - * well (default to false). - * - * * charset: The charset used by the templates (default to UTF-8). - * - * * base_template_class: The base template class to use for generated - * templates (default to Twig_Template). - * - * * cache: An absolute path where to store the compiled templates, - * a Twig_Cache_Interface implementation, - * or false to disable compilation cache (default). - * - * * auto_reload: Whether to reload the template if the original source changed. - * If you don't provide the auto_reload option, it will be - * determined automatically based on the debug value. - * - * * strict_variables: Whether to ignore invalid variables in templates - * (default to false). - * - * * autoescape: Whether to enable auto-escaping (default to html): - * * false: disable auto-escaping - * * true: equivalent to html - * * html, js: set the autoescaping to one of the supported strategies - * * name: set the autoescaping strategy based on the template name extension - * * PHP callback: a PHP callback that returns an escaping strategy based on the template "name" - * - * * optimizations: A flag that indicates which optimizations to apply - * (default to -1 which means that all optimizations are enabled; - * set it to 0 to disable). - * - * @param Twig_LoaderInterface $loader - * @param array $options An array of options - */ - public function __construct(Twig_LoaderInterface $loader = null, $options = array()) - { - if (null !== $loader) { - $this->setLoader($loader); - } else { - @trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated since version 1.21.', E_USER_DEPRECATED); - } - - $options = array_merge(array( - 'debug' => false, - 'charset' => 'UTF-8', - 'base_template_class' => 'Twig_Template', - 'strict_variables' => false, - 'autoescape' => 'html', - 'cache' => false, - 'auto_reload' => null, - 'optimizations' => -1, - ), $options); - - $this->debug = (bool) $options['debug']; - $this->charset = strtoupper($options['charset']); - $this->baseTemplateClass = $options['base_template_class']; - $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload']; - $this->strictVariables = (bool) $options['strict_variables']; - $this->setCache($options['cache']); - - $this->addExtension(new Twig_Extension_Core()); - $this->addExtension(new Twig_Extension_Escaper($options['autoescape'])); - $this->addExtension(new Twig_Extension_Optimizer($options['optimizations'])); - $this->staging = new Twig_Extension_Staging(); - - // For BC - if (is_string($this->originalCache)) { - $r = new ReflectionMethod($this, 'writeCacheFile'); - if ($r->getDeclaringClass()->getName() !== __CLASS__) { - @trigger_error('The Twig_Environment::writeCacheFile method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED); - - $this->bcWriteCacheFile = true; - } - - $r = new ReflectionMethod($this, 'getCacheFilename'); - if ($r->getDeclaringClass()->getName() !== __CLASS__) { - @trigger_error('The Twig_Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED); - - $this->bcGetCacheFilename = true; - } - } - } - - /** - * Gets the base template class for compiled templates. - * - * @return string The base template class name - */ - public function getBaseTemplateClass() - { - return $this->baseTemplateClass; - } - - /** - * Sets the base template class for compiled templates. - * - * @param string $class The base template class name - */ - public function setBaseTemplateClass($class) - { - $this->baseTemplateClass = $class; - $this->updateOptionsHash(); - } - - /** - * Enables debugging mode. - */ - public function enableDebug() - { - $this->debug = true; - $this->updateOptionsHash(); - } - - /** - * Disables debugging mode. - */ - public function disableDebug() - { - $this->debug = false; - $this->updateOptionsHash(); - } - - /** - * Checks if debug mode is enabled. - * - * @return bool true if debug mode is enabled, false otherwise - */ - public function isDebug() - { - return $this->debug; - } - - /** - * Enables the auto_reload option. - */ - public function enableAutoReload() - { - $this->autoReload = true; - } - - /** - * Disables the auto_reload option. - */ - public function disableAutoReload() - { - $this->autoReload = false; - } - - /** - * Checks if the auto_reload option is enabled. - * - * @return bool true if auto_reload is enabled, false otherwise - */ - public function isAutoReload() - { - return $this->autoReload; - } - - /** - * Enables the strict_variables option. - */ - public function enableStrictVariables() - { - $this->strictVariables = true; - $this->updateOptionsHash(); - } - - /** - * Disables the strict_variables option. - */ - public function disableStrictVariables() - { - $this->strictVariables = false; - $this->updateOptionsHash(); - } - - /** - * Checks if the strict_variables option is enabled. - * - * @return bool true if strict_variables is enabled, false otherwise - */ - public function isStrictVariables() - { - return $this->strictVariables; - } - - /** - * Gets the current cache implementation. - * - * @param bool $original Whether to return the original cache option or the real cache instance - * - * @return Twig_CacheInterface|string|false A Twig_CacheInterface implementation, - * an absolute path to the compiled templates, - * or false to disable cache - */ - public function getCache($original = true) - { - return $original ? $this->originalCache : $this->cache; - } - - /** - * Sets the current cache implementation. - * - * @param Twig_CacheInterface|string|false $cache A Twig_CacheInterface implementation, - * an absolute path to the compiled templates, - * or false to disable cache - */ - public function setCache($cache) - { - if (is_string($cache)) { - $this->originalCache = $cache; - $this->cache = new Twig_Cache_Filesystem($cache); - } elseif (false === $cache) { - $this->originalCache = $cache; - $this->cache = new Twig_Cache_Null(); - } elseif (null === $cache) { - @trigger_error('Using "null" as the cache strategy is deprecated since version 1.23 and will be removed in Twig 2.0.', E_USER_DEPRECATED); - $this->originalCache = false; - $this->cache = new Twig_Cache_Null(); - } elseif ($cache instanceof Twig_CacheInterface) { - $this->originalCache = $this->cache = $cache; - } else { - throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_CacheInterface implementation.')); - } - } - - /** - * Gets the cache filename for a given template. - * - * @param string $name The template name - * - * @return string|false The cache file name or false when caching is disabled - * - * @deprecated since 1.22 (to be removed in 2.0) - */ - public function getCacheFilename($name) - { - @trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); - - $key = $this->cache->generateKey($name, $this->getTemplateClass($name)); - - return !$key ? false : $key; - } - - /** - * Gets the template class associated with the given string. - * - * The generated template class is based on the following parameters: - * - * * The cache key for the given template; - * * The currently enabled extensions; - * * Whether the Twig C extension is available or not; - * * PHP version; - * * Twig version; - * * Options with what environment was created. - * - * @param string $name The name for which to calculate the template class name - * @param int|null $index The index if it is an embedded template - * - * @return string The template class name - */ - public function getTemplateClass($name, $index = null) - { - $key = $this->getLoader()->getCacheKey($name).$this->optionsHash; - - return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index); - } - - /** - * Gets the template class prefix. - * - * @return string The template class prefix - * - * @deprecated since 1.22 (to be removed in 2.0) - */ - public function getTemplateClassPrefix() - { - @trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); - - return $this->templateClassPrefix; - } - - /** - * Renders a template. - * - * @param string $name The template name - * @param array $context An array of parameters to pass to the template - * - * @return string The rendered template - * - * @throws Twig_Error_Loader When the template cannot be found - * @throws Twig_Error_Syntax When an error occurred during compilation - * @throws Twig_Error_Runtime When an error occurred during rendering - */ - public function render($name, array $context = array()) - { - return $this->loadTemplate($name)->render($context); - } - - /** - * Displays a template. - * - * @param string $name The template name - * @param array $context An array of parameters to pass to the template - * - * @throws Twig_Error_Loader When the template cannot be found - * @throws Twig_Error_Syntax When an error occurred during compilation - * @throws Twig_Error_Runtime When an error occurred during rendering - */ - public function display($name, array $context = array()) - { - $this->loadTemplate($name)->display($context); - } - - /** - * Loads a template. - * - * @param string|Twig_TemplateWrapper|Twig_Template $name The template name - * - * @throws Twig_Error_Loader When the template cannot be found - * @throws Twig_Error_Runtime When a previously generated cache is corrupted - * @throws Twig_Error_Syntax When an error occurred during compilation - * - * @return Twig_TemplateWrapper - */ - public function load($name) - { - if ($name instanceof Twig_TemplateWrapper) { - return $name; - } - - if ($name instanceof Twig_Template) { - return new Twig_TemplateWrapper($this, $name); - } - - return new Twig_TemplateWrapper($this, $this->loadTemplate($name)); - } - - /** - * Loads a template internal representation. - * - * This method is for internal use only and should never be called - * directly. - * - * @param string $name The template name - * @param int $index The index if it is an embedded template - * - * @return Twig_TemplateInterface A template instance representing the given template name - * - * @throws Twig_Error_Loader When the template cannot be found - * @throws Twig_Error_Runtime When a previously generated cache is corrupted - * @throws Twig_Error_Syntax When an error occurred during compilation - * - * @internal - */ - public function loadTemplate($name, $index = null) - { - $cls = $mainCls = $this->getTemplateClass($name); - if (null !== $index) { - $cls .= '_'.$index; - } - - if (isset($this->loadedTemplates[$cls])) { - return $this->loadedTemplates[$cls]; - } - - if (!class_exists($cls, false)) { - if ($this->bcGetCacheFilename) { - $key = $this->getCacheFilename($name); - } else { - $key = $this->cache->generateKey($name, $mainCls); - } - - if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) { - $this->cache->load($key); - } - - if (!class_exists($cls, false)) { - $loader = $this->getLoader(); - if (!$loader instanceof Twig_SourceContextLoaderInterface) { - $source = new Twig_Source($loader->getSource($name), $name); - } else { - $source = $loader->getSourceContext($name); - } - - $content = $this->compileSource($source); - - if ($this->bcWriteCacheFile) { - $this->writeCacheFile($key, $content); - } else { - $this->cache->write($key, $content); - $this->cache->load($key); - } - - if (!class_exists($mainCls, false)) { - /* Last line of defense if either $this->bcWriteCacheFile was used, - * $this->cache is implemented as a no-op or we have a race condition - * where the cache was cleared between the above calls to write to and load from - * the cache. - */ - eval('?>'.$content); - } - } - - if (!class_exists($cls, false)) { - throw new Twig_Error_Runtime(sprintf('Failed to load Twig template "%s", index "%s": cache is corrupted.', $name, $index), -1, $source); - } - } - - if (!$this->runtimeInitialized) { - $this->initRuntime(); - } - - if (isset($this->loading[$cls])) { - throw new Twig_Error_Runtime(sprintf('Circular reference detected for Twig template "%s", path: %s.', $name, implode(' -> ', array_merge($this->loading, array($name))))); - } - - $this->loading[$cls] = $name; - - try { - $this->loadedTemplates[$cls] = new $cls($this); - unset($this->loading[$cls]); - } catch (\Exception $e) { - unset($this->loading[$cls]); - - throw $e; - } - - return $this->loadedTemplates[$cls]; - } - - /** - * Creates a template from source. - * - * This method should not be used as a generic way to load templates. - * - * @param string $template The template name - * - * @return Twig_Template A template instance representing the given template name - * - * @throws Twig_Error_Loader When the template cannot be found - * @throws Twig_Error_Syntax When an error occurred during compilation - */ - public function createTemplate($template) - { - $name = sprintf('__string_template__%s', hash('sha256', $template, false)); - - $loader = new Twig_Loader_Chain(array( - new Twig_Loader_Array(array($name => $template)), - $current = $this->getLoader(), - )); - - $this->setLoader($loader); - try { - $template = $this->loadTemplate($name); - } catch (Exception $e) { - $this->setLoader($current); - - throw $e; - } catch (Throwable $e) { - $this->setLoader($current); - - throw $e; - } - $this->setLoader($current); - - return $template; - } - - /** - * Returns true if the template is still fresh. - * - * Besides checking the loader for freshness information, - * this method also checks if the enabled extensions have - * not changed. - * - * @param string $name The template name - * @param int $time The last modification time of the cached template - * - * @return bool true if the template is fresh, false otherwise - */ - public function isTemplateFresh($name, $time) - { - if (0 === $this->lastModifiedExtension) { - foreach ($this->extensions as $extension) { - $r = new ReflectionObject($extension); - if (file_exists($r->getFileName()) && ($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) { - $this->lastModifiedExtension = $extensionTime; - } - } - } - - return $this->lastModifiedExtension <= $time && $this->getLoader()->isFresh($name, $time); - } - - /** - * Tries to load a template consecutively from an array. - * - * Similar to loadTemplate() but it also accepts Twig_TemplateInterface instances and an array - * of templates where each is tried to be loaded. - * - * @param string|Twig_Template|array $names A template or an array of templates to try consecutively - * - * @return Twig_Template - * - * @throws Twig_Error_Loader When none of the templates can be found - * @throws Twig_Error_Syntax When an error occurred during compilation - */ - public function resolveTemplate($names) - { - if (!is_array($names)) { - $names = array($names); - } - - foreach ($names as $name) { - if ($name instanceof Twig_Template) { - return $name; - } - - try { - return $this->loadTemplate($name); - } catch (Twig_Error_Loader $e) { - } - } - - if (1 === count($names)) { - throw $e; - } - - throw new Twig_Error_Loader(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names))); - } - - /** - * Clears the internal template cache. - * - * @deprecated since 1.18.3 (to be removed in 2.0) - */ - public function clearTemplateCache() - { - @trigger_error(sprintf('The %s method is deprecated since version 1.18.3 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); - - $this->loadedTemplates = array(); - } - - /** - * Clears the template cache files on the filesystem. - * - * @deprecated since 1.22 (to be removed in 2.0) - */ - public function clearCacheFiles() - { - @trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); - - if (is_string($this->originalCache)) { - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->originalCache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - if ($file->isFile()) { - @unlink($file->getPathname()); - } - } - } - } - - /** - * Gets the Lexer instance. - * - * @return Twig_LexerInterface - * - * @deprecated since 1.25 (to be removed in 2.0) - */ - public function getLexer() - { - @trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED); - - if (null === $this->lexer) { - $this->lexer = new Twig_Lexer($this); - } - - return $this->lexer; - } - - public function setLexer(Twig_LexerInterface $lexer) - { - $this->lexer = $lexer; - } - - /** - * Tokenizes a source code. - * - * @param string|Twig_Source $source The template source code - * @param string $name The template name (deprecated) - * - * @return Twig_TokenStream - * - * @throws Twig_Error_Syntax When the code is syntactically wrong - */ - public function tokenize($source, $name = null) - { - if (!$source instanceof Twig_Source) { - @trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED); - $source = new Twig_Source($source, $name); - } - - if (null === $this->lexer) { - $this->lexer = new Twig_Lexer($this); - } - - return $this->lexer->tokenize($source); - } - - /** - * Gets the Parser instance. - * - * @return Twig_ParserInterface - * - * @deprecated since 1.25 (to be removed in 2.0) - */ - public function getParser() - { - @trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED); - - if (null === $this->parser) { - $this->parser = new Twig_Parser($this); - } - - return $this->parser; - } - - public function setParser(Twig_ParserInterface $parser) - { - $this->parser = $parser; - } - - /** - * Converts a token stream to a node tree. - * - * @return Twig_Node_Module - * - * @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong - */ - public function parse(Twig_TokenStream $stream) - { - if (null === $this->parser) { - $this->parser = new Twig_Parser($this); - } - - return $this->parser->parse($stream); - } - - /** - * Gets the Compiler instance. - * - * @return Twig_CompilerInterface - * - * @deprecated since 1.25 (to be removed in 2.0) - */ - public function getCompiler() - { - @trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED); - - if (null === $this->compiler) { - $this->compiler = new Twig_Compiler($this); - } - - return $this->compiler; - } - - public function setCompiler(Twig_CompilerInterface $compiler) - { - $this->compiler = $compiler; - } - - /** - * Compiles a node and returns the PHP code. - * - * @return string The compiled PHP source code - */ - public function compile(Twig_NodeInterface $node) - { - if (null === $this->compiler) { - $this->compiler = new Twig_Compiler($this); - } - - return $this->compiler->compile($node)->getSource(); - } - - /** - * Compiles a template source code. - * - * @param string|Twig_Source $source The template source code - * @param string $name The template name (deprecated) - * - * @return string The compiled PHP source code - * - * @throws Twig_Error_Syntax When there was an error during tokenizing, parsing or compiling - */ - public function compileSource($source, $name = null) - { - if (!$source instanceof Twig_Source) { - @trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED); - $source = new Twig_Source($source, $name); - } - - try { - return $this->compile($this->parse($this->tokenize($source))); - } catch (Twig_Error $e) { - $e->setSourceContext($source); - throw $e; - } catch (Exception $e) { - throw new Twig_Error_Syntax(sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $source, $e); - } - } - - public function setLoader(Twig_LoaderInterface $loader) - { - if (!$loader instanceof Twig_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_')) { - @trigger_error(sprintf('Twig loader "%s" should implement Twig_SourceContextLoaderInterface since version 1.27.', get_class($loader)), E_USER_DEPRECATED); - } - - $this->loader = $loader; - } - - /** - * Gets the Loader instance. - * - * @return Twig_LoaderInterface - */ - public function getLoader() - { - if (null === $this->loader) { - throw new LogicException('You must set a loader first.'); - } - - return $this->loader; - } - - /** - * Sets the default template charset. - * - * @param string $charset The default charset - */ - public function setCharset($charset) - { - $this->charset = strtoupper($charset); - } - - /** - * Gets the default template charset. - * - * @return string The default charset - */ - public function getCharset() - { - return $this->charset; - } - - /** - * Initializes the runtime environment. - * - * @deprecated since 1.23 (to be removed in 2.0) - */ - public function initRuntime() - { - $this->runtimeInitialized = true; - - foreach ($this->getExtensions() as $name => $extension) { - if (!$extension instanceof Twig_Extension_InitRuntimeInterface) { - $m = new ReflectionMethod($extension, 'initRuntime'); - - if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) { - @trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the Twig_Environment instance in filters, functions, or tests; or explicitly implement Twig_Extension_InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED); - } - } - - $extension->initRuntime($this); - } - } - - /** - * Returns true if the given extension is registered. - * - * @param string $class The extension class name - * - * @return bool Whether the extension is registered or not - */ - public function hasExtension($class) - { - $class = ltrim($class, '\\'); - if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) { - // For BC/FC with namespaced aliases - $class = new ReflectionClass($class); - $class = $class->name; - } - - if (isset($this->extensions[$class])) { - if ($class !== get_class($this->extensions[$class])) { - @trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED); - } - - return true; - } - - return isset($this->extensionsByClass[$class]); - } - - /** - * Adds a runtime loader. - */ - public function addRuntimeLoader(Twig_RuntimeLoaderInterface $loader) - { - $this->runtimeLoaders[] = $loader; - } - - /** - * Gets an extension by class name. - * - * @param string $class The extension class name - * - * @return Twig_ExtensionInterface - */ - public function getExtension($class) - { - $class = ltrim($class, '\\'); - if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) { - // For BC/FC with namespaced aliases - $class = new ReflectionClass($class); - $class = $class->name; - } - - if (isset($this->extensions[$class])) { - if ($class !== get_class($this->extensions[$class])) { - @trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED); - } - - return $this->extensions[$class]; - } - - if (!isset($this->extensionsByClass[$class])) { - throw new Twig_Error_Runtime(sprintf('The "%s" extension is not enabled.', $class)); - } - - return $this->extensionsByClass[$class]; - } - - /** - * Returns the runtime implementation of a Twig element (filter/function/test). - * - * @param string $class A runtime class name - * - * @return object The runtime implementation - * - * @throws Twig_Error_Runtime When the template cannot be found - */ - public function getRuntime($class) - { - if (isset($this->runtimes[$class])) { - return $this->runtimes[$class]; - } - - foreach ($this->runtimeLoaders as $loader) { - if (null !== $runtime = $loader->load($class)) { - return $this->runtimes[$class] = $runtime; - } - } - - throw new Twig_Error_Runtime(sprintf('Unable to load the "%s" runtime.', $class)); - } - - public function addExtension(Twig_ExtensionInterface $extension) - { - if ($this->extensionInitialized) { - throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName())); - } - - $class = get_class($extension); - if ($class !== $extension->getName()) { - if (isset($this->extensions[$extension->getName()])) { - unset($this->extensions[$extension->getName()], $this->extensionsByClass[$class]); - @trigger_error(sprintf('The possibility to register the same extension twice ("%s") is deprecated since version 1.23 and will be removed in Twig 2.0. Use proper PHP inheritance instead.', $extension->getName()), E_USER_DEPRECATED); - } - } - - $this->lastModifiedExtension = 0; - $this->extensionsByClass[$class] = $extension; - $this->extensions[$extension->getName()] = $extension; - $this->updateOptionsHash(); - } - - /** - * Removes an extension by name. - * - * This method is deprecated and you should not use it. - * - * @param string $name The extension name - * - * @deprecated since 1.12 (to be removed in 2.0) - */ - public function removeExtension($name) - { - @trigger_error(sprintf('The %s method is deprecated since version 1.12 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); - - if ($this->extensionInitialized) { - throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name)); - } - - $class = ltrim($name, '\\'); - if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) { - // For BC/FC with namespaced aliases - $class = new ReflectionClass($class); - $class = $class->name; - } - - if (isset($this->extensions[$class])) { - if ($class !== get_class($this->extensions[$class])) { - @trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED); - } - - unset($this->extensions[$class]); - } - - unset($this->extensions[$class]); - $this->updateOptionsHash(); - } - - /** - * Registers an array of extensions. - * - * @param array $extensions An array of extensions - */ - public function setExtensions(array $extensions) - { - foreach ($extensions as $extension) { - $this->addExtension($extension); - } - } - - /** - * Returns all registered extensions. - * - * @return Twig_ExtensionInterface[] An array of extensions (keys are for internal usage only and should not be relied on) - */ - public function getExtensions() - { - return $this->extensions; - } - - public function addTokenParser(Twig_TokenParserInterface $parser) - { - if ($this->extensionInitialized) { - throw new LogicException('Unable to add a token parser as extensions have already been initialized.'); - } - - $this->staging->addTokenParser($parser); - } - - /** - * Gets the registered Token Parsers. - * - * @return Twig_TokenParserBrokerInterface - * - * @internal - */ - public function getTokenParsers() - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - return $this->parsers; - } - - /** - * Gets registered tags. - * - * Be warned that this method cannot return tags defined by Twig_TokenParserBrokerInterface classes. - * - * @return Twig_TokenParserInterface[] - * - * @internal - */ - public function getTags() - { - $tags = array(); - foreach ($this->getTokenParsers()->getParsers() as $parser) { - if ($parser instanceof Twig_TokenParserInterface) { - $tags[$parser->getTag()] = $parser; - } - } - - return $tags; - } - - public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) - { - if ($this->extensionInitialized) { - throw new LogicException('Unable to add a node visitor as extensions have already been initialized.'); - } - - $this->staging->addNodeVisitor($visitor); - } - - /** - * Gets the registered Node Visitors. - * - * @return Twig_NodeVisitorInterface[] - * - * @internal - */ - public function getNodeVisitors() - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - return $this->visitors; - } - - /** - * Registers a Filter. - * - * @param string|Twig_SimpleFilter $name The filter name or a Twig_SimpleFilter instance - * @param Twig_FilterInterface|Twig_SimpleFilter $filter - */ - public function addFilter($name, $filter = null) - { - if (!$name instanceof Twig_SimpleFilter && !($filter instanceof Twig_SimpleFilter || $filter instanceof Twig_FilterInterface)) { - throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter.'); - } - - if ($name instanceof Twig_SimpleFilter) { - $filter = $name; - $name = $filter->getName(); - } else { - @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated since version 1.21. Pass an instance of "Twig_SimpleFilter" instead when defining filter "%s".', __METHOD__, $name), E_USER_DEPRECATED); - } - - if ($this->extensionInitialized) { - throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $name)); - } - - $this->staging->addFilter($name, $filter); - } - - /** - * Get a filter by name. - * - * Subclasses may override this method and load filters differently; - * so no list of filters is available. - * - * @param string $name The filter name - * - * @return Twig_Filter|false A Twig_Filter instance or false if the filter does not exist - * - * @internal - */ - public function getFilter($name) - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - if (isset($this->filters[$name])) { - return $this->filters[$name]; - } - - foreach ($this->filters as $pattern => $filter) { - $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count); - - if ($count) { - if (preg_match('#^'.$pattern.'$#', $name, $matches)) { - array_shift($matches); - $filter->setArguments($matches); - - return $filter; - } - } - } - - foreach ($this->filterCallbacks as $callback) { - if (false !== $filter = call_user_func($callback, $name)) { - return $filter; - } - } - - return false; - } - - public function registerUndefinedFilterCallback($callable) - { - $this->filterCallbacks[] = $callable; - } - - /** - * Gets the registered Filters. - * - * Be warned that this method cannot return filters defined with registerUndefinedFilterCallback. - * - * @return Twig_FilterInterface[] - * - * @see registerUndefinedFilterCallback - * - * @internal - */ - public function getFilters() - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - return $this->filters; - } - - /** - * Registers a Test. - * - * @param string|Twig_SimpleTest $name The test name or a Twig_SimpleTest instance - * @param Twig_TestInterface|Twig_SimpleTest $test A Twig_TestInterface instance or a Twig_SimpleTest instance - */ - public function addTest($name, $test = null) - { - if (!$name instanceof Twig_SimpleTest && !($test instanceof Twig_SimpleTest || $test instanceof Twig_TestInterface)) { - throw new LogicException('A test must be an instance of Twig_TestInterface or Twig_SimpleTest.'); - } - - if ($name instanceof Twig_SimpleTest) { - $test = $name; - $name = $test->getName(); - } else { - @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated since version 1.21. Pass an instance of "Twig_SimpleTest" instead when defining test "%s".', __METHOD__, $name), E_USER_DEPRECATED); - } - - if ($this->extensionInitialized) { - throw new LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $name)); - } - - $this->staging->addTest($name, $test); - } - - /** - * Gets the registered Tests. - * - * @return Twig_TestInterface[] - * - * @internal - */ - public function getTests() - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - return $this->tests; - } - - /** - * Gets a test by name. - * - * @param string $name The test name - * - * @return Twig_Test|false A Twig_Test instance or false if the test does not exist - * - * @internal - */ - public function getTest($name) - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - if (isset($this->tests[$name])) { - return $this->tests[$name]; - } - - return false; - } - - /** - * Registers a Function. - * - * @param string|Twig_SimpleFunction $name The function name or a Twig_SimpleFunction instance - * @param Twig_FunctionInterface|Twig_SimpleFunction $function - */ - public function addFunction($name, $function = null) - { - if (!$name instanceof Twig_SimpleFunction && !($function instanceof Twig_SimpleFunction || $function instanceof Twig_FunctionInterface)) { - throw new LogicException('A function must be an instance of Twig_FunctionInterface or Twig_SimpleFunction.'); - } - - if ($name instanceof Twig_SimpleFunction) { - $function = $name; - $name = $function->getName(); - } else { - @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated since version 1.21. Pass an instance of "Twig_SimpleFunction" instead when defining function "%s".', __METHOD__, $name), E_USER_DEPRECATED); - } - - if ($this->extensionInitialized) { - throw new LogicException(sprintf('Unable to add function "%s" as extensions have already been initialized.', $name)); - } - - $this->staging->addFunction($name, $function); - } - - /** - * Get a function by name. - * - * Subclasses may override this method and load functions differently; - * so no list of functions is available. - * - * @param string $name function name - * - * @return Twig_Function|false A Twig_Function instance or false if the function does not exist - * - * @internal - */ - public function getFunction($name) - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - if (isset($this->functions[$name])) { - return $this->functions[$name]; - } - - foreach ($this->functions as $pattern => $function) { - $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count); - - if ($count) { - if (preg_match('#^'.$pattern.'$#', $name, $matches)) { - array_shift($matches); - $function->setArguments($matches); - - return $function; - } - } - } - - foreach ($this->functionCallbacks as $callback) { - if (false !== $function = call_user_func($callback, $name)) { - return $function; - } - } - - return false; - } - - public function registerUndefinedFunctionCallback($callable) - { - $this->functionCallbacks[] = $callable; - } - - /** - * Gets registered functions. - * - * Be warned that this method cannot return functions defined with registerUndefinedFunctionCallback. - * - * @return Twig_FunctionInterface[] - * - * @see registerUndefinedFunctionCallback - * - * @internal - */ - public function getFunctions() - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - return $this->functions; - } - - /** - * Registers a Global. - * - * New globals can be added before compiling or rendering a template; - * but after, you can only update existing globals. - * - * @param string $name The global name - * @param mixed $value The global value - */ - public function addGlobal($name, $value) - { - if ($this->extensionInitialized || $this->runtimeInitialized) { - if (null === $this->globals) { - $this->globals = $this->initGlobals(); - } - - if (!array_key_exists($name, $this->globals)) { - // The deprecation notice must be turned into the following exception in Twig 2.0 - @trigger_error(sprintf('Registering global variable "%s" at runtime or when the extensions have already been initialized is deprecated since version 1.21.', $name), E_USER_DEPRECATED); - //throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name)); - } - } - - if ($this->extensionInitialized || $this->runtimeInitialized) { - // update the value - $this->globals[$name] = $value; - } else { - $this->staging->addGlobal($name, $value); - } - } - - /** - * Gets the registered Globals. - * - * @return array An array of globals - * - * @internal - */ - public function getGlobals() - { - if (!$this->runtimeInitialized && !$this->extensionInitialized) { - return $this->initGlobals(); - } - - if (null === $this->globals) { - $this->globals = $this->initGlobals(); - } - - return $this->globals; - } - - /** - * Merges a context with the defined globals. - * - * @param array $context An array representing the context - * - * @return array The context merged with the globals - */ - public function mergeGlobals(array $context) - { - // we don't use array_merge as the context being generally - // bigger than globals, this code is faster. - foreach ($this->getGlobals() as $key => $value) { - if (!array_key_exists($key, $context)) { - $context[$key] = $value; - } - } - - return $context; - } - - /** - * Gets the registered unary Operators. - * - * @return array An array of unary operators - * - * @internal - */ - public function getUnaryOperators() - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - return $this->unaryOperators; - } - - /** - * Gets the registered binary Operators. - * - * @return array An array of binary operators - * - * @internal - */ - public function getBinaryOperators() - { - if (!$this->extensionInitialized) { - $this->initExtensions(); - } - - return $this->binaryOperators; - } - - /** - * @deprecated since 1.23 (to be removed in 2.0) - */ - public function computeAlternatives($name, $items) - { - @trigger_error(sprintf('The %s method is deprecated since version 1.23 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); - - return Twig_Error_Syntax::computeAlternatives($name, $items); - } - - /** - * @internal - */ - protected function initGlobals() - { - $globals = array(); - foreach ($this->extensions as $name => $extension) { - if (!$extension instanceof Twig_Extension_GlobalsInterface) { - $m = new ReflectionMethod($extension, 'getGlobals'); - - if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) { - @trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing Twig_Extension_GlobalsInterface is deprecated since version 1.23.', $name), E_USER_DEPRECATED); - } - } - - $extGlob = $extension->getGlobals(); - if (!is_array($extGlob)) { - throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension))); - } - - $globals[] = $extGlob; - } - - $globals[] = $this->staging->getGlobals(); - - return call_user_func_array('array_merge', $globals); - } - - /** - * @internal - */ - protected function initExtensions() - { - if ($this->extensionInitialized) { - return; - } - - $this->parsers = new Twig_TokenParserBroker(array(), array(), false); - $this->filters = array(); - $this->functions = array(); - $this->tests = array(); - $this->visitors = array(); - $this->unaryOperators = array(); - $this->binaryOperators = array(); - - foreach ($this->extensions as $extension) { - $this->initExtension($extension); - } - $this->initExtension($this->staging); - // Done at the end only, so that an exception during initialization does not mark the environment as initialized when catching the exception - $this->extensionInitialized = true; - } - - /** - * @internal - */ - protected function initExtension(Twig_ExtensionInterface $extension) - { - // filters - foreach ($extension->getFilters() as $name => $filter) { - if ($filter instanceof Twig_SimpleFilter) { - $name = $filter->getName(); - } else { - @trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated since version 1.21. Use Twig_SimpleFilter instead.', get_class($filter), $name), E_USER_DEPRECATED); - } - - $this->filters[$name] = $filter; - } - - // functions - foreach ($extension->getFunctions() as $name => $function) { - if ($function instanceof Twig_SimpleFunction) { - $name = $function->getName(); - } else { - @trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated since version 1.21. Use Twig_SimpleFunction instead.', get_class($function), $name), E_USER_DEPRECATED); - } - - $this->functions[$name] = $function; - } - - // tests - foreach ($extension->getTests() as $name => $test) { - if ($test instanceof Twig_SimpleTest) { - $name = $test->getName(); - } else { - @trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated since version 1.21. Use Twig_SimpleTest instead.', get_class($test), $name), E_USER_DEPRECATED); - } - - $this->tests[$name] = $test; - } - - // token parsers - foreach ($extension->getTokenParsers() as $parser) { - if ($parser instanceof Twig_TokenParserInterface) { - $this->parsers->addTokenParser($parser); - } elseif ($parser instanceof Twig_TokenParserBrokerInterface) { - @trigger_error('Registering a Twig_TokenParserBrokerInterface instance is deprecated since version 1.21.', E_USER_DEPRECATED); - - $this->parsers->addTokenParserBroker($parser); - } else { - throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances.'); - } - } - - // node visitors - foreach ($extension->getNodeVisitors() as $visitor) { - $this->visitors[] = $visitor; - } - - // operators - if ($operators = $extension->getOperators()) { - if (!is_array($operators)) { - throw new InvalidArgumentException(sprintf('"%s::getOperators()" must return an array with operators, got "%s".', get_class($extension), is_object($operators) ? get_class($operators) : gettype($operators).(is_resource($operators) ? '' : '#'.$operators))); - } - - if (2 !== count($operators)) { - throw new InvalidArgumentException(sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', get_class($extension), count($operators))); - } - - $this->unaryOperators = array_merge($this->unaryOperators, $operators[0]); - $this->binaryOperators = array_merge($this->binaryOperators, $operators[1]); - } - } - - /** - * @deprecated since 1.22 (to be removed in 2.0) - */ - protected function writeCacheFile($file, $content) - { - $this->cache->write($file, $content); - } - - private function updateOptionsHash() - { - $hashParts = array_merge( - array_keys($this->extensions), - array( - (int) function_exists('twig_template_get_attributes'), - PHP_MAJOR_VERSION, - PHP_MINOR_VERSION, - self::VERSION, - (int) $this->debug, - $this->baseTemplateClass, - (int) $this->strictVariables, - ) - ); - $this->optionsHash = implode(':', $hashParts); - } -} - -class_alias('Twig_Environment', 'Twig\Environment', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Error.php b/lib/silex/vendor/twig/twig/lib/Twig/Error.php deleted file mode 100644 index 787e0d095..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Error.php +++ /dev/null @@ -1,363 +0,0 @@ - - */ -class Twig_Error extends Exception -{ - protected $lineno; - // to be renamed to name in 2.0 - protected $filename; - protected $rawMessage; - protected $previous; - - private $sourcePath; - private $sourceCode; - - /** - * Constructor. - * - * Set both the line number and the name 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 name to null to enable its automatic guessing. - * - * By default, automatic guessing is enabled. - * - * @param string $message The error message - * @param int $lineno The template line where the error occurred - * @param Twig_Source|string|null $source The source context where the error occurred - * @param Exception $previous The previous exception - */ - public function __construct($message, $lineno = -1, $source = null, Exception $previous = null) - { - if (null === $source) { - $name = null; - } elseif (!$source instanceof Twig_Source) { - // for compat with the Twig C ext., passing the template name as string is accepted - $name = $source; - } else { - $name = $source->getName(); - $this->sourceCode = $source->getCode(); - $this->sourcePath = $source->getPath(); - } - if (PHP_VERSION_ID < 50300) { - $this->previous = $previous; - parent::__construct(''); - } else { - parent::__construct('', 0, $previous); - } - - $this->lineno = $lineno; - $this->filename = $name; - - if (-1 === $lineno || null === $name || null === $this->sourcePath) { - $this->guessTemplateInfo(); - } - - $this->rawMessage = $message; - - $this->updateRepr(); - } - - /** - * Gets the raw message. - * - * @return string The raw message - */ - public function getRawMessage() - { - return $this->rawMessage; - } - - /** - * Gets the logical name where the error occurred. - * - * @return string The name - * - * @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead. - */ - public function getTemplateFile() - { - @trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->filename; - } - - /** - * Sets the logical name where the error occurred. - * - * @param string $name The name - * - * @deprecated since 1.27 (to be removed in 2.0). Use setSourceContext() instead. - */ - public function setTemplateFile($name) - { - @trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), E_USER_DEPRECATED); - - $this->filename = $name; - - $this->updateRepr(); - } - - /** - * Gets the logical name where the error occurred. - * - * @return string The name - * - * @deprecated since 1.29 (to be removed in 2.0). Use getSourceContext() instead. - */ - public function getTemplateName() - { - @trigger_error(sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->filename; - } - - /** - * Sets the logical name where the error occurred. - * - * @param string $name The name - * - * @deprecated since 1.29 (to be removed in 2.0). Use setSourceContext() instead. - */ - public function setTemplateName($name) - { - @trigger_error(sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), E_USER_DEPRECATED); - - $this->filename = $name; - $this->sourceCode = $this->sourcePath = null; - - $this->updateRepr(); - } - - /** - * Gets the template line where the error occurred. - * - * @return int The template line - */ - public function getTemplateLine() - { - return $this->lineno; - } - - /** - * Sets the template line where the error occurred. - * - * @param int $lineno The template line - */ - public function setTemplateLine($lineno) - { - $this->lineno = $lineno; - - $this->updateRepr(); - } - - /** - * Gets the source context of the Twig template where the error occurred. - * - * @return Twig_Source|null - */ - public function getSourceContext() - { - return $this->filename ? new Twig_Source($this->sourceCode, $this->filename, $this->sourcePath) : null; - } - - /** - * Sets the source context of the Twig template where the error occurred. - */ - public function setSourceContext(Twig_Source $source = null) - { - if (null === $source) { - $this->sourceCode = $this->filename = $this->sourcePath = null; - } else { - $this->sourceCode = $source->getCode(); - $this->filename = $source->getName(); - $this->sourcePath = $source->getPath(); - } - - $this->updateRepr(); - } - - public function guess() - { - $this->guessTemplateInfo(); - $this->updateRepr(); - } - - /** - * For PHP < 5.3.0, provides access to the getPrevious() method. - * - * @param string $method The method name - * @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) - { - if ('getprevious' == strtolower($method)) { - return $this->previous; - } - - throw new BadMethodCallException(sprintf('Method "Twig_Error::%s()" does not exist.', $method)); - } - - public function appendMessage($rawMessage) - { - $this->rawMessage .= $rawMessage; - $this->updateRepr(); - } - - /** - * @internal - */ - protected function updateRepr() - { - $this->message = $this->rawMessage; - - if ($this->sourcePath && $this->lineno > 0) { - $this->file = $this->sourcePath; - $this->line = $this->lineno; - - return; - } - - $dot = false; - if ('.' === substr($this->message, -1)) { - $this->message = substr($this->message, 0, -1); - $dot = true; - } - - $questionMark = false; - if ('?' === substr($this->message, -1)) { - $this->message = substr($this->message, 0, -1); - $questionMark = true; - } - - if ($this->filename) { - if (is_string($this->filename) || (is_object($this->filename) && method_exists($this->filename, '__toString'))) { - $name = sprintf('"%s"', $this->filename); - } else { - $name = json_encode($this->filename); - } - $this->message .= sprintf(' in %s', $name); - } - - if ($this->lineno && $this->lineno >= 0) { - $this->message .= sprintf(' at line %d', $this->lineno); - } - - if ($dot) { - $this->message .= '.'; - } - - if ($questionMark) { - $this->message .= '?'; - } - } - - /** - * @internal - */ - protected function guessTemplateInfo() - { - $template = null; - $templateClass = null; - - if (PHP_VERSION_ID >= 50306) { - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT); - } else { - $backtrace = debug_backtrace(); - } - - foreach ($backtrace as $trace) { - if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) { - $currentClass = get_class($trace['object']); - $isEmbedContainer = 0 === strpos($templateClass, $currentClass); - if (null === $this->filename || ($this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer)) { - $template = $trace['object']; - $templateClass = get_class($trace['object']); - } - } - } - - // update template name - if (null !== $template && null === $this->filename) { - $this->filename = $template->getTemplateName(); - } - - // update template path if any - if (null !== $template && null === $this->sourcePath) { - $src = $template->getSourceContext(); - $this->sourceCode = $src->getCode(); - $this->sourcePath = $src->getPath(); - } - - if (null === $template || $this->lineno > -1) { - return; - } - - $r = new ReflectionObject($template); - $file = $r->getFileName(); - - $exceptions = array($e = $this); - while (($e instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) { - $exceptions[] = $e; - } - - while ($e = array_pop($exceptions)) { - $traces = $e->getTrace(); - array_unshift($traces, array('file' => $e->getFile(), 'line' => $e->getLine())); - - while ($trace = array_shift($traces)) { - if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) { - continue; - } - - foreach ($template->getDebugInfo() as $codeLine => $templateLine) { - if ($codeLine <= $trace['line']) { - // update template line - $this->lineno = $templateLine; - - return; - } - } - } - } - } -} - -class_alias('Twig_Error', 'Twig\Error\Error', false); -class_exists('Twig_Source'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Error/Loader.php b/lib/silex/vendor/twig/twig/lib/Twig/Error/Loader.php deleted file mode 100644 index df566dd78..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Error/Loader.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class Twig_Error_Loader extends Twig_Error -{ - public function __construct($message, $lineno = -1, $source = null, Exception $previous = null) - { - if (PHP_VERSION_ID < 50300) { - $this->previous = $previous; - Exception::__construct(''); - } else { - Exception::__construct('', 0, $previous); - } - $this->appendMessage($message); - $this->setTemplateLine(false); - } -} - -class_alias('Twig_Error_Loader', 'Twig\Error\LoaderError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Error/Runtime.php b/lib/silex/vendor/twig/twig/lib/Twig/Error/Runtime.php deleted file mode 100644 index 3b24ad3a4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Error/Runtime.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ -class Twig_Error_Runtime extends Twig_Error -{ -} - -class_alias('Twig_Error_Runtime', 'Twig\Error\RuntimeError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Error/Syntax.php b/lib/silex/vendor/twig/twig/lib/Twig/Error/Syntax.php deleted file mode 100644 index 9d09f2179..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Error/Syntax.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -class Twig_Error_Syntax extends Twig_Error -{ - /** - * Tweaks the error message to include suggestions. - * - * @param string $name The original name of the item that does not exist - * @param array $items An array of possible items - */ - public function addSuggestions($name, array $items) - { - if (!$alternatives = self::computeAlternatives($name, $items)) { - return; - } - - $this->appendMessage(sprintf(' Did you mean "%s"?', implode('", "', $alternatives))); - } - - /** - * @internal - * - * To be merged with the addSuggestions() method in 2.0. - */ - public static function computeAlternatives($name, $items) - { - $alternatives = array(); - foreach ($items as $item) { - $lev = levenshtein($name, $item); - if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { - $alternatives[$item] = $lev; - } - } - asort($alternatives); - - return array_keys($alternatives); - } -} - -class_alias('Twig_Error_Syntax', 'Twig\Error\SyntaxError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php deleted file mode 100644 index 968cb21a4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -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 bool If the template source code is handled by this loader or not - */ - public function exists($name); -} - -class_alias('Twig_ExistsLoaderInterface', 'Twig\Loader\ExistsLoaderInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/ExpressionParser.php b/lib/silex/vendor/twig/twig/lib/Twig/ExpressionParser.php deleted file mode 100644 index 4906f903e..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/ExpressionParser.php +++ /dev/null @@ -1,741 +0,0 @@ - - * - * @internal - */ -class Twig_ExpressionParser -{ - const OPERATOR_LEFT = 1; - const OPERATOR_RIGHT = 2; - - protected $parser; - protected $unaryOperators; - protected $binaryOperators; - - private $env; - - public function __construct(Twig_Parser $parser, $env = null) - { - $this->parser = $parser; - - if ($env instanceof Twig_Environment) { - $this->env = $env; - $this->unaryOperators = $env->getUnaryOperators(); - $this->binaryOperators = $env->getBinaryOperators(); - } else { - @trigger_error('Passing the operators as constructor arguments to '.__METHOD__.' is deprecated since version 1.27. Pass the environment instead.', E_USER_DEPRECATED); - - $this->env = $parser->getEnvironment(); - $this->unaryOperators = func_get_arg(1); - $this->binaryOperators = func_get_arg(2); - } - } - - public function parseExpression($precedence = 0) - { - $expr = $this->getPrimary(); - $token = $this->parser->getCurrentToken(); - while ($this->isBinary($token) && $this->binaryOperators[$token->getValue()]['precedence'] >= $precedence) { - $op = $this->binaryOperators[$token->getValue()]; - $this->parser->getStream()->next(); - - if ('is not' === $token->getValue()) { - $expr = $this->parseNotTestExpression($expr); - } elseif ('is' === $token->getValue()) { - $expr = $this->parseTestExpression($expr); - } elseif (isset($op['callable'])) { - $expr = call_user_func($op['callable'], $this->parser, $expr); - } else { - $expr1 = $this->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']); - $class = $op['class']; - $expr = new $class($expr, $expr1, $token->getLine()); - } - - $token = $this->parser->getCurrentToken(); - } - - if (0 === $precedence) { - return $this->parseConditionalExpression($expr); - } - - return $expr; - } - - protected function getPrimary() - { - $token = $this->parser->getCurrentToken(); - - if ($this->isUnary($token)) { - $operator = $this->unaryOperators[$token->getValue()]; - $this->parser->getStream()->next(); - $expr = $this->parseExpression($operator['precedence']); - $class = $operator['class']; - - return $this->parsePostfixExpression(new $class($expr, $token->getLine())); - } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) { - $this->parser->getStream()->next(); - $expr = $this->parseExpression(); - $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed'); - - return $this->parsePostfixExpression($expr); - } - - return $this->parsePrimaryExpression(); - } - - protected function parseConditionalExpression($expr) - { - while ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, '?')) { - if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) { - $expr2 = $this->parseExpression(); - if ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) { - $expr3 = $this->parseExpression(); - } else { - $expr3 = new Twig_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine()); - } - } else { - $expr2 = $expr; - $expr3 = $this->parseExpression(); - } - - $expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine()); - } - - return $expr; - } - - protected function isUnary(Twig_Token $token) - { - return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]); - } - - protected function isBinary(Twig_Token $token) - { - return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]); - } - - public function parsePrimaryExpression() - { - $token = $this->parser->getCurrentToken(); - switch ($token->getType()) { - case Twig_Token::NAME_TYPE: - $this->parser->getStream()->next(); - switch ($token->getValue()) { - case 'true': - case 'TRUE': - $node = new Twig_Node_Expression_Constant(true, $token->getLine()); - break; - - case 'false': - case 'FALSE': - $node = new Twig_Node_Expression_Constant(false, $token->getLine()); - break; - - case 'none': - case 'NONE': - case 'null': - case 'NULL': - $node = new Twig_Node_Expression_Constant(null, $token->getLine()); - break; - - default: - if ('(' === $this->parser->getCurrentToken()->getValue()) { - $node = $this->getFunctionNode($token->getValue(), $token->getLine()); - } else { - $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine()); - } - } - break; - - case Twig_Token::NUMBER_TYPE: - $this->parser->getStream()->next(); - $node = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); - break; - - case Twig_Token::STRING_TYPE: - case Twig_Token::INTERPOLATION_START_TYPE: - $node = $this->parseStringExpression(); - break; - - case Twig_Token::OPERATOR_TYPE: - if (preg_match(Twig_Lexer::REGEX_NAME, $token->getValue(), $matches) && $matches[0] == $token->getValue()) { - // in this context, string operators are variable names - $this->parser->getStream()->next(); - $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine()); - break; - } elseif (isset($this->unaryOperators[$token->getValue()])) { - $class = $this->unaryOperators[$token->getValue()]['class']; - - $ref = new ReflectionClass($class); - $negClass = 'Twig_Node_Expression_Unary_Neg'; - $posClass = 'Twig_Node_Expression_Unary_Pos'; - if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) { - throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext()); - } - - $this->parser->getStream()->next(); - $expr = $this->parsePrimaryExpression(); - - $node = new $class($expr, $token->getLine()); - break; - } - - default: - if ($token->test(Twig_Token::PUNCTUATION_TYPE, '[')) { - $node = $this->parseArrayExpression(); - } 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->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext()); - } - } - - return $this->parsePostfixExpression($node); - } - - public function parseStringExpression() - { - $stream = $this->parser->getStream(); - - $nodes = array(); - // a string cannot be followed by another string in a single expression - $nextCanBeString = true; - while (true) { - if ($nextCanBeString && $token = $stream->nextIf(Twig_Token::STRING_TYPE)) { - $nodes[] = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); - $nextCanBeString = false; - } elseif ($stream->nextIf(Twig_Token::INTERPOLATION_START_TYPE)) { - $nodes[] = $this->parseExpression(); - $stream->expect(Twig_Token::INTERPOLATION_END_TYPE); - $nextCanBeString = true; - } else { - break; - } - } - - $expr = array_shift($nodes); - foreach ($nodes as $node) { - $expr = new Twig_Node_Expression_Binary_Concat($expr, $node, $node->getTemplateLine()); - } - - return $expr; - } - - public function parseArrayExpression() - { - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected'); - - $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine()); - $first = true; - while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) { - if (!$first) { - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma'); - - // trailing ,? - if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) { - break; - } - } - $first = false; - - $node->addElement($this->parseExpression()); - } - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed'); - - return $node; - } - - public function parseHashExpression() - { - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected'); - - $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine()); - $first = true; - while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) { - if (!$first) { - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma'); - - // trailing ,? - if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) { - break; - } - } - $first = false; - - // a hash key can be: - // - // * a number -- 12 - // * a string -- 'a' - // * a name, which is equivalent to a string -- a - // * an expression, which must be enclosed in parentheses -- (1 + 2) - if (($token = $stream->nextIf(Twig_Token::STRING_TYPE)) || ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) || $token = $stream->nextIf(Twig_Token::NUMBER_TYPE)) { - $key = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); - } elseif ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) { - $key = $this->parseExpression(); - } 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->getValue()), $current->getLine(), $stream->getSourceContext()); - } - - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)'); - $value = $this->parseExpression(); - - $node->addElement($value, $key); - } - $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed'); - - return $node; - } - - public function parsePostfixExpression($node) - { - while (true) { - $token = $this->parser->getCurrentToken(); - if ($token->getType() == Twig_Token::PUNCTUATION_TYPE) { - if ('.' == $token->getValue() || '[' == $token->getValue()) { - $node = $this->parseSubscriptExpression($node); - } elseif ('|' == $token->getValue()) { - $node = $this->parseFilterExpression($node); - } else { - break; - } - } else { - break; - } - } - - return $node; - } - - public function getFunctionNode($name, $line) - { - switch ($name) { - case 'parent': - $this->parseArguments(); - if (!count($this->parser->getBlockStack())) { - throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden.', $line, $this->parser->getStream()->getSourceContext()); - } - - 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, $this->parser->getStream()->getSourceContext()); - } - - return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line); - case 'block': - $args = $this->parseArguments(); - if (count($args) < 1) { - throw new Twig_Error_Syntax('The "block" function takes one argument (the block name).', $line, $this->parser->getStream()->getSourceContext()); - } - - return new Twig_Node_Expression_BlockReference($args->getNode(0), count($args) > 1 ? $args->getNode(1) : null, $line); - case 'attribute': - $args = $this->parseArguments(); - if (count($args) < 2) { - throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getStream()->getSourceContext()); - } - - return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line); - default: - if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) { - $arguments = new Twig_Node_Expression_Array(array(), $line); - foreach ($this->parseArguments() as $n) { - $arguments->addElement($n); - } - - $node = new Twig_Node_Expression_MethodCall($alias['node'], $alias['name'], $arguments, $line); - $node->setAttribute('safe', true); - - return $node; - } - - $args = $this->parseArguments(true); - $class = $this->getFunctionNodeClass($name, $line); - - return new $class($name, $args, $line); - } - } - - public function parseSubscriptExpression($node) - { - $stream = $this->parser->getStream(); - $token = $stream->next(); - $lineno = $token->getLine(); - $arguments = new Twig_Node_Expression_Array(array(), $lineno); - $type = Twig_Template::ANY_CALL; - if ($token->getValue() == '.') { - $token = $stream->next(); - if ( - $token->getType() == Twig_Token::NAME_TYPE - || - $token->getType() == Twig_Token::NUMBER_TYPE - || - ($token->getType() == Twig_Token::OPERATOR_TYPE && preg_match(Twig_Lexer::REGEX_NAME, $token->getValue())) - ) { - $arg = new Twig_Node_Expression_Constant($token->getValue(), $lineno); - - if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) { - $type = Twig_Template::METHOD_CALL; - foreach ($this->parseArguments() as $n) { - $arguments->addElement($n); - } - } - } else { - throw new Twig_Error_Syntax('Expected name or number.', $lineno, $stream->getSourceContext()); - } - - if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) { - if (!$arg instanceof Twig_Node_Expression_Constant) { - throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s").', $node->getAttribute('name')), $token->getLine(), $stream->getSourceContext()); - } - - $name = $arg->getAttribute('value'); - - if ($this->parser->isReservedMacroName($name)) { - throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext()); - } - - $node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno); - $node->setAttribute('safe', true); - - return $node; - } - } else { - $type = Twig_Template::ARRAY_CALL; - - // slice? - $slice = false; - if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ':')) { - $slice = true; - $arg = new Twig_Node_Expression_Constant(0, $token->getLine()); - } else { - $arg = $this->parseExpression(); - } - - if ($stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) { - $slice = true; - } - - if ($slice) { - if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) { - $length = new Twig_Node_Expression_Constant(null, $token->getLine()); - } else { - $length = $this->parseExpression(); - } - - $class = $this->getFilterNodeClass('slice', $token->getLine()); - $arguments = new Twig_Node(array($arg, $length)); - $filter = new $class($node, new Twig_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine()); - - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']'); - - return $filter; - } - - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']'); - } - - return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno); - } - - public function parseFilterExpression($node) - { - $this->parser->getStream()->next(); - - return $this->parseFilterExpressionRaw($node); - } - - public function parseFilterExpressionRaw($node, $tag = null) - { - while (true) { - $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE); - - $name = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); - if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) { - $arguments = new Twig_Node(); - } else { - $arguments = $this->parseArguments(true); - } - - $class = $this->getFilterNodeClass($name->getAttribute('value'), $token->getLine()); - - $node = new $class($node, $name, $arguments, $token->getLine(), $tag); - - if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '|')) { - break; - } - - $this->parser->getStream()->next(); - } - - return $node; - } - - /** - * Parses arguments. - * - * @param bool $namedArguments Whether to allow named arguments or not - * @param bool $definition Whether we are parsing arguments for a function definition - * - * @return Twig_Node - * - * @throws Twig_Error_Syntax - */ - public function parseArguments($namedArguments = false, $definition = false) - { - $args = array(); - $stream = $this->parser->getStream(); - - $stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis'); - while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ')')) { - if (!empty($args)) { - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma'); - } - - if ($definition) { - $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'An argument must be a name'); - $value = new Twig_Node_Expression_Name($token->getValue(), $this->parser->getCurrentToken()->getLine()); - } else { - $value = $this->parseExpression(); - } - - $name = null; - if ($namedArguments && $token = $stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) { - if (!$value instanceof Twig_Node_Expression_Name) { - throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given.', get_class($value)), $token->getLine(), $stream->getSourceContext()); - } - $name = $value->getAttribute('name'); - - if ($definition) { - $value = $this->parsePrimaryExpression(); - - if (!$this->checkConstantExpression($value)) { - throw new Twig_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $stream->getSourceContext()); - } - } else { - $value = $this->parseExpression(); - } - } - - if ($definition) { - if (null === $name) { - $name = $value->getAttribute('name'); - $value = new Twig_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine()); - } - $args[$name] = $value; - } else { - if (null === $name) { - $args[] = $value; - } else { - $args[$name] = $value; - } - } - } - $stream->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis'); - - return new Twig_Node($args); - } - - public function parseAssignmentExpression() - { - $stream = $this->parser->getStream(); - $targets = array(); - while (true) { - $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to'); - $value = $token->getValue(); - if (in_array(strtolower($value), array('true', 'false', 'none', 'null'))) { - throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext()); - } - $targets[] = new Twig_Node_Expression_AssignName($value, $token->getLine()); - - if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { - break; - } - } - - return new Twig_Node($targets); - } - - public function parseMultitargetExpression() - { - $targets = array(); - while (true) { - $targets[] = $this->parseExpression(); - if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { - break; - } - } - - return new Twig_Node($targets); - } - - private function parseNotTestExpression(Twig_NodeInterface $node) - { - return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($node), $this->parser->getCurrentToken()->getLine()); - } - - private function parseTestExpression(Twig_NodeInterface $node) - { - $stream = $this->parser->getStream(); - list($name, $test) = $this->getTest($node->getTemplateLine()); - - $class = $this->getTestNodeClass($test); - $arguments = null; - if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) { - $arguments = $this->parser->getExpressionParser()->parseArguments(true); - } - - return new $class($node, $name, $arguments, $this->parser->getCurrentToken()->getLine()); - } - - private function getTest($line) - { - $stream = $this->parser->getStream(); - $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - - if ($test = $this->env->getTest($name)) { - return array($name, $test); - } - - if ($stream->test(Twig_Token::NAME_TYPE)) { - // try 2-words tests - $name = $name.' '.$this->parser->getCurrentToken()->getValue(); - - if ($test = $this->env->getTest($name)) { - $stream->next(); - - return array($name, $test); - } - } - - $e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $stream->getSourceContext()); - $e->addSuggestions($name, array_keys($this->env->getTests())); - - throw $e; - } - - private function getTestNodeClass($test) - { - if ($test instanceof Twig_SimpleTest && $test->isDeprecated()) { - $stream = $this->parser->getStream(); - $message = sprintf('Twig Test "%s" is deprecated', $test->getName()); - if (!is_bool($test->getDeprecatedVersion())) { - $message .= sprintf(' since version %s', $test->getDeprecatedVersion()); - } - if ($test->getAlternative()) { - $message .= sprintf('. Use "%s" instead', $test->getAlternative()); - } - $src = $stream->getSourceContext(); - $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $stream->getCurrent()->getLine()); - - @trigger_error($message, E_USER_DEPRECATED); - } - - if ($test instanceof Twig_SimpleTest) { - return $test->getNodeClass(); - } - - return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test'; - } - - protected function getFunctionNodeClass($name, $line) - { - if (false === $function = $this->env->getFunction($name)) { - $e = new Twig_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser->getStream()->getSourceContext()); - $e->addSuggestions($name, array_keys($this->env->getFunctions())); - - throw $e; - } - - if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) { - $message = sprintf('Twig Function "%s" is deprecated', $function->getName()); - if (!is_bool($function->getDeprecatedVersion())) { - $message .= sprintf(' since version %s', $function->getDeprecatedVersion()); - } - if ($function->getAlternative()) { - $message .= sprintf('. Use "%s" instead', $function->getAlternative()); - } - $src = $this->parser->getStream()->getSourceContext(); - $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line); - - @trigger_error($message, E_USER_DEPRECATED); - } - - if ($function instanceof Twig_SimpleFunction) { - return $function->getNodeClass(); - } - - return $function instanceof Twig_Function_Node ? $function->getClass() : 'Twig_Node_Expression_Function'; - } - - protected function getFilterNodeClass($name, $line) - { - if (false === $filter = $this->env->getFilter($name)) { - $e = new Twig_Error_Syntax(sprintf('Unknown "%s" filter.', $name), $line, $this->parser->getStream()->getSourceContext()); - $e->addSuggestions($name, array_keys($this->env->getFilters())); - - throw $e; - } - - if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) { - $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName()); - if (!is_bool($filter->getDeprecatedVersion())) { - $message .= sprintf(' since version %s', $filter->getDeprecatedVersion()); - } - if ($filter->getAlternative()) { - $message .= sprintf('. Use "%s" instead', $filter->getAlternative()); - } - $src = $this->parser->getStream()->getSourceContext(); - $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line); - - @trigger_error($message, E_USER_DEPRECATED); - } - - if ($filter instanceof Twig_SimpleFilter) { - return $filter->getNodeClass(); - } - - return $filter instanceof Twig_Filter_Node ? $filter->getClass() : 'Twig_Node_Expression_Filter'; - } - - // checks that the node only contains "constant" elements - protected function checkConstantExpression(Twig_NodeInterface $node) - { - if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array - || $node instanceof Twig_Node_Expression_Unary_Neg || $node instanceof Twig_Node_Expression_Unary_Pos - )) { - return false; - } - - foreach ($node as $n) { - if (!$this->checkConstantExpression($n)) { - return false; - } - } - - return true; - } -} - -class_alias('Twig_ExpressionParser', 'Twig\ExpressionParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension.php deleted file mode 100644 index 38084495f..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension.php +++ /dev/null @@ -1,69 +0,0 @@ -escapers[$strategy] = $callable; - } - - /** - * Gets all defined escapers. - * - * @return array An array of escapers - */ - public function getEscapers() - { - return $this->escapers; - } - - /** - * Sets the default format to be used by the date filter. - * - * @param string $format The default date format string - * @param string $dateIntervalFormat The default date interval format string - */ - public function setDateFormat($format = null, $dateIntervalFormat = null) - { - if (null !== $format) { - $this->dateFormats[0] = $format; - } - - if (null !== $dateIntervalFormat) { - $this->dateFormats[1] = $dateIntervalFormat; - } - } - - /** - * Gets the default format to be used by the date filter. - * - * @return array The default date format string and the default date interval format string - */ - public function getDateFormat() - { - return $this->dateFormats; - } - - /** - * Sets the default timezone to be used by the date filter. - * - * @param DateTimeZone|string $timezone The default timezone string or a DateTimeZone object - */ - public function setTimezone($timezone) - { - $this->timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone); - } - - /** - * Gets the default timezone to be used by the date filter. - * - * @return DateTimeZone The default timezone currently in use - */ - public function getTimezone() - { - if (null === $this->timezone) { - $this->timezone = new DateTimeZone(date_default_timezone_get()); - } - - return $this->timezone; - } - - /** - * Sets the default format to be used by the number_format filter. - * - * @param int $decimal the number of decimal places to use - * @param string $decimalPoint the character(s) to use for the decimal point - * @param string $thousandSep the character(s) to use for the thousands separator - */ - public function setNumberFormat($decimal, $decimalPoint, $thousandSep) - { - $this->numberFormat = array($decimal, $decimalPoint, $thousandSep); - } - - /** - * Get the default format used by the number_format filter. - * - * @return array The arguments for number_format() - */ - public function getNumberFormat() - { - return $this->numberFormat; - } - - public function getTokenParsers() - { - return array( - new Twig_TokenParser_For(), - new Twig_TokenParser_If(), - new Twig_TokenParser_Extends(), - new Twig_TokenParser_Include(), - new Twig_TokenParser_Block(), - new Twig_TokenParser_Use(), - new Twig_TokenParser_Filter(), - new Twig_TokenParser_Macro(), - new Twig_TokenParser_Import(), - new Twig_TokenParser_From(), - new Twig_TokenParser_Set(), - new Twig_TokenParser_Spaceless(), - new Twig_TokenParser_Flush(), - new Twig_TokenParser_Do(), - new Twig_TokenParser_Embed(), - new Twig_TokenParser_With(), - ); - } - - public function getFilters() - { - $filters = array( - // formatting filters - new Twig_SimpleFilter('date', 'twig_date_format_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('format', 'sprintf'), - new Twig_SimpleFilter('replace', 'twig_replace_filter'), - new Twig_SimpleFilter('number_format', 'twig_number_format_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('abs', 'abs'), - new Twig_SimpleFilter('round', 'twig_round'), - - // encoding - new Twig_SimpleFilter('url_encode', 'twig_urlencode_filter'), - new Twig_SimpleFilter('json_encode', 'twig_jsonencode_filter'), - new Twig_SimpleFilter('convert_encoding', 'twig_convert_encoding'), - - // string filters - new Twig_SimpleFilter('title', 'twig_title_string_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('capitalize', 'twig_capitalize_string_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('upper', 'strtoupper'), - new Twig_SimpleFilter('lower', 'strtolower'), - new Twig_SimpleFilter('striptags', 'strip_tags'), - new Twig_SimpleFilter('trim', 'twig_trim_filter'), - new Twig_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))), - - // array helpers - new Twig_SimpleFilter('join', 'twig_join_filter'), - new Twig_SimpleFilter('split', 'twig_split_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('sort', 'twig_sort_filter'), - new Twig_SimpleFilter('merge', 'twig_array_merge'), - new Twig_SimpleFilter('batch', 'twig_array_batch'), - - // string/array filters - new Twig_SimpleFilter('reverse', 'twig_reverse_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('length', 'twig_length_filter', array('needs_environment' => true)), - new Twig_SimpleFilter('slice', 'twig_slice', array('needs_environment' => true)), - new Twig_SimpleFilter('first', 'twig_first', array('needs_environment' => true)), - new Twig_SimpleFilter('last', 'twig_last', array('needs_environment' => true)), - - // iteration and runtime - new Twig_SimpleFilter('default', '_twig_default_filter', array('node_class' => 'Twig_Node_Expression_Filter_Default')), - new Twig_SimpleFilter('keys', 'twig_get_array_keys_filter'), - - // escaping - new Twig_SimpleFilter('escape', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')), - new Twig_SimpleFilter('e', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')), - ); - - if (function_exists('mb_get_info')) { - $filters[] = new Twig_SimpleFilter('upper', 'twig_upper_filter', array('needs_environment' => true)); - $filters[] = new Twig_SimpleFilter('lower', 'twig_lower_filter', array('needs_environment' => true)); - } - - return $filters; - } - - public function getFunctions() - { - return array( - new Twig_SimpleFunction('max', 'max'), - new Twig_SimpleFunction('min', 'min'), - new Twig_SimpleFunction('range', 'range'), - new Twig_SimpleFunction('constant', 'twig_constant'), - new Twig_SimpleFunction('cycle', 'twig_cycle'), - new Twig_SimpleFunction('random', 'twig_random', array('needs_environment' => true)), - new Twig_SimpleFunction('date', 'twig_date_converter', array('needs_environment' => true)), - new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))), - new Twig_SimpleFunction('source', 'twig_source', array('needs_environment' => true, 'is_safe' => array('all'))), - ); - } - - public function getTests() - { - return array( - new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')), - new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')), - new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')), - new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas', 'deprecated' => '1.21', 'alternative' => 'same as')), - new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')), - new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')), - new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')), - new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby', 'deprecated' => '1.21', 'alternative' => 'divisible by')), - new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')), - new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')), - new Twig_SimpleTest('empty', 'twig_test_empty'), - new Twig_SimpleTest('iterable', 'twig_test_iterable'), - ); - } - - public function getOperators() - { - return array( - array( - 'not' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), - '-' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'), - '+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'), - ), - array( - '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), - '>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '>=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'matches' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Matches', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'starts with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_StartsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'ends with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_EndsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '*' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mul', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '/' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Div', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '//' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'is' => array('precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'is not' => array('precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT), - '??' => array('precedence' => 300, 'class' => 'Twig_Node_Expression_NullCoalesce', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT), - ), - ); - } - - public function getName() - { - return 'core'; - } -} - -/** - * Cycles over a value. - * - * @param ArrayAccess|array $values - * @param int $position The cycle position - * - * @return string The next value in the cycle - */ -function twig_cycle($values, $position) -{ - if (!is_array($values) && !$values instanceof ArrayAccess) { - return $values; - } - - return $values[$position % count($values)]; -} - -/** - * Returns a random value depending on the supplied parameter type: - * - a random item from a Traversable or array - * - a random character from a string - * - a random integer between 0 and the integer parameter. - * - * @param Twig_Environment $env - * @param Traversable|array|int|float|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) - * - * @return mixed A random value from the given sequence - */ -function twig_random(Twig_Environment $env, $values = null) -{ - if (null === $values) { - return mt_rand(); - } - - if (is_int($values) || is_float($values)) { - return $values < 0 ? mt_rand($values, 0) : mt_rand(0, $values); - } - - if ($values instanceof Traversable) { - $values = iterator_to_array($values); - } elseif (is_string($values)) { - if ('' === $values) { - return ''; - } - if (null !== $charset = $env->getCharset()) { - if ('UTF-8' !== $charset) { - $values = twig_convert_encoding($values, 'UTF-8', $charset); - } - - // unicode version of str_split() - // split at all positions, but not after the start and not before the end - $values = preg_split('/(? $value) { - $values[$i] = twig_convert_encoding($value, $charset, 'UTF-8'); - } - } - } else { - return $values[mt_rand(0, strlen($values) - 1)]; - } - } - - if (!is_array($values)) { - return $values; - } - - if (0 === count($values)) { - throw new Twig_Error_Runtime('The random function cannot pick from an empty array.'); - } - - return $values[array_rand($values, 1)]; -} - -/** - * Converts a date to the given format. - * - *
    - *   {{ post.published_at|date("m/d/Y") }}
    - * 
    - * - * @param Twig_Environment $env - * @param DateTime|DateTimeInterface|DateInterval|string $date A date - * @param string|null $format The target format, null to use the default - * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged - * - * @return string The formatted date - */ -function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $timezone = null) -{ - if (null === $format) { - $formats = $env->getExtension('Twig_Extension_Core')->getDateFormat(); - $format = $date instanceof DateInterval ? $formats[1] : $formats[0]; - } - - if ($date instanceof DateInterval) { - return $date->format($format); - } - - return twig_date_converter($env, $date, $timezone)->format($format); -} - -/** - * Returns a new date object modified. - * - *
    - *   {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
    - * 
    - * - * @param Twig_Environment $env - * @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); - $resultDate = $date->modify($modifier); - - // This is a hack to ensure PHP 5.2 support and support for DateTimeImmutable - // DateTime::modify does not return the modified DateTime object < 5.3.0 - // and DateTimeImmutable does not modify $date. - return null === $resultDate ? $date : $resultDate; -} - -/** - * Converts an input to a DateTime instance. - * - *
    - *    {% if date(user.created_at) < date('+2days') %}
    - *      {# do something #}
    - *    {% endif %}
    - * 
    - * - * @param Twig_Environment $env - * @param DateTime|DateTimeInterface|string|null $date A date - * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged - * - * @return DateTime A DateTime instance - */ -function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null) -{ - // determine the timezone - if (false !== $timezone) { - if (null === $timezone) { - $timezone = $env->getExtension('Twig_Extension_Core')->getTimezone(); - } elseif (!$timezone instanceof DateTimeZone) { - $timezone = new DateTimeZone($timezone); - } - } - - // immutable dates - if ($date instanceof DateTimeImmutable) { - return false !== $timezone ? $date->setTimezone($timezone) : $date; - } - - if ($date instanceof DateTime || $date instanceof DateTimeInterface) { - $date = clone $date; - if (false !== $timezone) { - $date->setTimezone($timezone); - } - - return $date; - } - - if (null === $date || 'now' === $date) { - return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('Twig_Extension_Core')->getTimezone()); - } - - $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, $env->getExtension('Twig_Extension_Core')->getTimezone()); - } - - if (false !== $timezone) { - $date->setTimezone($timezone); - } - - return $date; -} - -/** - * Replaces strings within a string. - * - * @param string $str String to replace in - * @param array|Traversable $from Replace values - * @param string|null $to Replace to, deprecated (@see http://php.net/manual/en/function.strtr.php) - * - * @return string - */ -function twig_replace_filter($str, $from, $to = null) -{ - if ($from instanceof Traversable) { - $from = iterator_to_array($from); - } elseif (is_string($from) && is_string($to)) { - @trigger_error('Using "replace" with character by character replacement is deprecated since version 1.22 and will be removed in Twig 2.0', E_USER_DEPRECATED); - - return strtr($str, $from, $to); - } elseif (!is_array($from)) { - throw new Twig_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', is_object($from) ? get_class($from) : gettype($from))); - } - - return strtr($str, $from); -} - -/** - * Rounds a number. - * - * @param int|float $value The value to round - * @param int|float $precision The rounding precision - * @param string $method The method to use for rounding - * - * @return int|float The rounded number - */ -function twig_round($value, $precision = 0, $method = 'common') -{ - if ('common' == $method) { - return round($value, $precision); - } - - if ('ceil' != $method && 'floor' != $method) { - throw new Twig_Error_Runtime('The round filter only supports the "common", "ceil", and "floor" methods.'); - } - - return $method($value * pow(10, $precision)) / pow(10, $precision); -} - -/** - * Number format filter. - * - * All of the formatting options can be left null, in that case the defaults will - * be used. Supplying any of the parameters will override the defaults set in the - * environment object. - * - * @param Twig_Environment $env - * @param mixed $number A float/int/string of the number to format - * @param int $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 - * - * @return string The formatted number - */ -function twig_number_format_filter(Twig_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null) -{ - $defaults = $env->getExtension('Twig_Extension_Core')->getNumberFormat(); - if (null === $decimal) { - $decimal = $defaults[0]; - } - - if (null === $decimalPoint) { - $decimalPoint = $defaults[1]; - } - - if (null === $thousandSep) { - $thousandSep = $defaults[2]; - } - - return number_format((float) $number, $decimal, $decimalPoint, $thousandSep); -} - -/** - * URL encodes (RFC 3986) a string as a path segment or an array as a query string. - * - * @param string|array $url A URL or an array of query parameters - * - * @return string The URL encoded value - */ -function twig_urlencode_filter($url) -{ - if (is_array($url)) { - if (defined('PHP_QUERY_RFC3986')) { - return http_build_query($url, '', '&', PHP_QUERY_RFC3986); - } - - return http_build_query($url, '', '&'); - } - - return rawurlencode($url); -} - -if (PHP_VERSION_ID < 50300) { - /** - * JSON encodes a variable. - * - * @param mixed $value the value to encode - * @param int $options Not used on PHP 5.2.x - * - * @return mixed The JSON encoded value - */ - function twig_jsonencode_filter($value, $options = 0) - { - if ($value instanceof Twig_Markup) { - $value = (string) $value; - } elseif (is_array($value)) { - array_walk_recursive($value, '_twig_markup2string'); - } - - return json_encode($value); - } -} else { - /** - * JSON encodes a variable. - * - * @param mixed $value the value to encode - * @param int $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT - * - * @return mixed The JSON encoded value - */ - function twig_jsonencode_filter($value, $options = 0) - { - if ($value instanceof Twig_Markup) { - $value = (string) $value; - } elseif (is_array($value)) { - array_walk_recursive($value, '_twig_markup2string'); - } - - return json_encode($value, $options); - } -} - -function _twig_markup2string(&$value) -{ - if ($value instanceof Twig_Markup) { - $value = (string) $value; - } -} - -/** - * Merges an array with another one. - * - *
    - *  {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
    - *
    - *  {% set items = items|merge({ 'peugeot': 'car' }) %}
    - *
    - *  {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
    - * 
    - * - * @param array|Traversable $arr1 An array - * @param array|Traversable $arr2 An array - * - * @return array The merged array - */ -function twig_array_merge($arr1, $arr2) -{ - if ($arr1 instanceof Traversable) { - $arr1 = iterator_to_array($arr1); - } elseif (!is_array($arr1)) { - throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', gettype($arr1))); - } - - if ($arr2 instanceof Traversable) { - $arr2 = iterator_to_array($arr2); - } elseif (!is_array($arr2)) { - throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', gettype($arr2))); - } - - return array_merge($arr1, $arr2); -} - -/** - * Slices a variable. - * - * @param Twig_Environment $env - * @param mixed $item A variable - * @param int $start Start of the slice - * @param int $length Size of the slice - * @param bool $preserveKeys Whether to preserve key or not (when the input is an array) - * - * @return mixed The sliced variable - */ -function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false) -{ - if ($item instanceof Traversable) { - while ($item instanceof IteratorAggregate) { - $item = $item->getIterator(); - } - - if ($start >= 0 && $length >= 0 && $item instanceof Iterator) { - try { - return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys); - } catch (OutOfBoundsException $exception) { - return array(); - } - } - - $item = iterator_to_array($item, $preserveKeys); - } - - if (is_array($item)) { - return array_slice($item, $start, $length, $preserveKeys); - } - - $item = (string) $item; - - if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) { - return (string) mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset); - } - - return (string) (null === $length ? substr($item, $start) : substr($item, $start, $length)); -} - -/** - * Returns the first element of the item. - * - * @param Twig_Environment $env - * @param mixed $item A variable - * - * @return mixed The first element of the item - */ -function twig_first(Twig_Environment $env, $item) -{ - $elements = twig_slice($env, $item, 0, 1, false); - - return is_string($elements) ? $elements : current($elements); -} - -/** - * Returns the last element of the item. - * - * @param Twig_Environment $env - * @param mixed $item A variable - * - * @return mixed The last element of the item - */ -function twig_last(Twig_Environment $env, $item) -{ - $elements = twig_slice($env, $item, -1, 1, false); - - return is_string($elements) ? $elements : current($elements); -} - -/** - * Joins the values to a string. - * - * The separator between elements is an empty string per default, you can define it with the optional parameter. - * - *
    - *  {{ [1, 2, 3]|join('|') }}
    - *  {# returns 1|2|3 #}
    - *
    - *  {{ [1, 2, 3]|join }}
    - *  {# returns 123 #}
    - * 
    - * - * @param array $value An array - * @param string $glue The separator - * - * @return string The concatenated string - */ -function twig_join_filter($value, $glue = '') -{ - if ($value instanceof Traversable) { - $value = iterator_to_array($value, false); - } - - return implode($glue, (array) $value); -} - -/** - * Splits the string into an array. - * - *
    - *  {{ "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] #}
    - * 
    - * - * @param Twig_Environment $env - * @param string $value A string - * @param string $delimiter The delimiter - * @param int $limit The limit - * - * @return array The split string as an array - */ -function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = null) -{ - if (!empty($delimiter)) { - return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit); - } - - if (!function_exists('mb_get_info') || null === $charset = $env->getCharset()) { - return str_split($value, null === $limit ? 1 : $limit); - } - - if ($limit <= 1) { - return preg_split('/(? - * {% for key in array|keys %} - * {# ... #} - * {% endfor %} - * - * - * @param array $array An array - * - * @return array The keys - */ -function twig_get_array_keys_filter($array) -{ - if ($array instanceof Traversable) { - while ($array instanceof IteratorAggregate) { - $array = $array->getIterator(); - } - - if ($array instanceof Iterator) { - $keys = array(); - $array->rewind(); - while ($array->valid()) { - $keys[] = $array->key(); - $array->next(); - } - - return $keys; - } - - $keys = array(); - foreach ($array as $key => $item) { - $keys[] = $key; - } - - return $keys; - } - - if (!is_array($array)) { - return array(); - } - - return array_keys($array); -} - -/** - * Reverses a variable. - * - * @param Twig_Environment $env - * @param array|Traversable|string $item An array, a Traversable instance, or a string - * @param bool $preserveKeys Whether to preserve key or not - * - * @return mixed The reversed input - */ -function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false) -{ - if ($item instanceof Traversable) { - return array_reverse(iterator_to_array($item), $preserveKeys); - } - - if (is_array($item)) { - return array_reverse($item, $preserveKeys); - } - - if (null !== $charset = $env->getCharset()) { - $string = (string) $item; - - if ('UTF-8' !== $charset) { - $item = twig_convert_encoding($string, 'UTF-8', $charset); - } - - preg_match_all('/./us', $item, $matches); - - $string = implode('', array_reverse($matches[0])); - - if ('UTF-8' !== $charset) { - $string = twig_convert_encoding($string, $charset, 'UTF-8'); - } - - return $string; - } - - return strrev((string) $item); -} - -/** - * Sorts an array. - * - * @param array|Traversable $array - * - * @return array - */ -function twig_sort_filter($array) -{ - if ($array instanceof Traversable) { - $array = iterator_to_array($array); - } elseif (!is_array($array)) { - throw new Twig_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array))); - } - - asort($array); - - return $array; -} - -/** - * @internal - */ -function twig_in_filter($value, $compare) -{ - if (is_array($compare)) { - return in_array($value, $compare, is_object($value) || is_resource($value)); - } elseif (is_string($compare) && (is_string($value) || is_int($value) || is_float($value))) { - return '' === $value || false !== strpos($compare, (string) $value); - } elseif ($compare instanceof Traversable) { - if (is_object($value) || is_resource($value)) { - foreach ($compare as $item) { - if ($item === $value) { - return true; - } - } - } else { - foreach ($compare as $item) { - if ($item == $value) { - return true; - } - } - } - - return false; - } - - return false; -} - -/** - * Returns a trimmed string. - * - * @return string - * - * @throws Twig_Error_Runtime When an invalid trimming side is used (not a string or not 'left', 'right', or 'both') - */ -function twig_trim_filter($string, $characterMask = null, $side = 'both') -{ - if (null === $characterMask) { - $characterMask = " \t\n\r\0\x0B"; - } - - switch ($side) { - case 'both': - return trim($string, $characterMask); - case 'left': - return ltrim($string, $characterMask); - case 'right': - return rtrim($string, $characterMask); - default: - throw new Twig_Error_Runtime('Trimming side must be "left", "right" or "both".'); - } -} - -/** - * Escapes a string. - * - * @param Twig_Environment $env - * @param mixed $string The value to be escaped - * @param string $strategy The escaping strategy - * @param string $charset The charset - * @param bool $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false) - * - * @return string - */ -function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false) -{ - if ($autoescape && $string instanceof Twig_Markup) { - return $string; - } - - if (!is_string($string)) { - if (is_object($string) && method_exists($string, '__toString')) { - $string = (string) $string; - } elseif (in_array($strategy, array('html', 'js', 'css', 'html_attr', 'url'))) { - return $string; - } - } - - if (null === $charset) { - $charset = $env->getCharset(); - } - - switch ($strategy) { - case 'html': - // see http://php.net/htmlspecialchars - - // Using a static variable to avoid initializing the array - // each time the function is called. Moving the declaration on the - // top of the function slow downs other escaping strategies. - static $htmlspecialcharsCharsets = array( - 'ISO-8859-1' => true, 'ISO8859-1' => true, - 'ISO-8859-15' => true, 'ISO8859-15' => true, - 'utf-8' => true, 'UTF-8' => true, - 'CP866' => true, 'IBM866' => true, '866' => true, - 'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true, - '1251' => true, - 'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true, - 'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true, - 'BIG5' => true, '950' => true, - 'GB2312' => true, '936' => true, - 'BIG5-HKSCS' => true, - 'SHIFT_JIS' => true, 'SJIS' => true, '932' => true, - 'EUC-JP' => true, 'EUCJP' => true, - 'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true, - ); - - if (isset($htmlspecialcharsCharsets[$charset])) { - return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset); - } - - if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) { - // cache the lowercase variant for future iterations - $htmlspecialcharsCharsets[$charset] = true; - - return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset); - } - - $string = twig_convert_encoding($string, 'UTF-8', $charset); - $string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); - - return twig_convert_encoding($string, $charset, 'UTF-8'); - - case 'js': - // escape all non-alphanumeric characters - // into their \xHH or \uHHHH representations - if ('UTF-8' !== $charset) { - $string = twig_convert_encoding($string, 'UTF-8', $charset); - } - - if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) { - 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)) { - 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)) { - 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'); - } - - return $string; - - case 'url': - if (PHP_VERSION_ID < 50300) { - return str_replace('%7E', '~', rawurlencode($string)); - } - - return rawurlencode($string); - - default: - static $escapers; - - if (null === $escapers) { - $escapers = $env->getExtension('Twig_Extension_Core')->getEscapers(); - } - - if (isset($escapers[$strategy])) { - return call_user_func($escapers[$strategy], $env, $string, $charset); - } - - $validStrategies = implode(', ', array_merge(array('html', 'js', 'url', 'css', 'html_attr'), array_keys($escapers))); - - throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: %s).', $strategy, $validStrategies)); - } -} - -/** - * @internal - */ -function twig_escape_filter_is_safe(Twig_Node $filterArgs) -{ - foreach ($filterArgs as $arg) { - if ($arg instanceof Twig_Node_Expression_Constant) { - return array($arg->getAttribute('value')); - } - - return array(); - } - - return array('html'); -} - -if (function_exists('mb_convert_encoding')) { - function twig_convert_encoding($string, $to, $from) - { - return mb_convert_encoding($string, $to, $from); - } -} elseif (function_exists('iconv')) { - function twig_convert_encoding($string, $to, $from) - { - return iconv($from, $to, $string); - } -} else { - function twig_convert_encoding($string, $to, $from) - { - throw new Twig_Error_Runtime('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).'); - } -} - -function _twig_escape_js_callback($matches) -{ - $char = $matches[0]; - - // \xHH - if (!isset($char[1])) { - return '\\x'.strtoupper(substr('00'.bin2hex($char), -2)); - } - - // \uHHHH - $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8'); - $char = strtoupper(bin2hex($char)); - - if (4 >= strlen($char)) { - return sprintf('\u%04s', $char); - } - - return sprintf('\u%04s\u%04s', substr($char, 0, -4), substr($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 -if (function_exists('mb_get_info')) { - /** - * Returns the length of a variable. - * - * @param Twig_Environment $env - * @param mixed $thing A variable - * - * @return int The length of the value - */ - function twig_length_filter(Twig_Environment $env, $thing) - { - if (null === $thing) { - return 0; - } - - if (is_scalar($thing)) { - return mb_strlen($thing, $env->getCharset()); - } - - if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) { - return mb_strlen((string) $thing, $env->getCharset()); - } - - if ($thing instanceof \Countable || is_array($thing)) { - return count($thing); - } - - return 1; - } - - /** - * Converts a string to uppercase. - * - * @param Twig_Environment $env - * @param string $string A string - * - * @return string The uppercased string - */ - function twig_upper_filter(Twig_Environment $env, $string) - { - if (null !== $charset = $env->getCharset()) { - return mb_strtoupper($string, $charset); - } - - return strtoupper($string); - } - - /** - * Converts a string to lowercase. - * - * @param Twig_Environment $env - * @param string $string A string - * - * @return string The lowercased string - */ - function twig_lower_filter(Twig_Environment $env, $string) - { - if (null !== $charset = $env->getCharset()) { - return mb_strtolower($string, $charset); - } - - return strtolower($string); - } - - /** - * Returns a titlecased string. - * - * @param Twig_Environment $env - * @param string $string A string - * - * @return string The titlecased string - */ - function twig_title_string_filter(Twig_Environment $env, $string) - { - if (null !== $charset = $env->getCharset()) { - return mb_convert_case($string, MB_CASE_TITLE, $charset); - } - - return ucwords(strtolower($string)); - } - - /** - * Returns a capitalized string. - * - * @param Twig_Environment $env - * @param string $string A string - * - * @return string The capitalized string - */ - function twig_capitalize_string_filter(Twig_Environment $env, $string) - { - if (null !== $charset = $env->getCharset()) { - return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset); - } - - return ucfirst(strtolower($string)); - } -} -// and byte fallback -else { - /** - * Returns the length of a variable. - * - * @param Twig_Environment $env - * @param mixed $thing A variable - * - * @return int The length of the value - */ - function twig_length_filter(Twig_Environment $env, $thing) - { - if (null === $thing) { - return 0; - } - - if (is_scalar($thing)) { - return strlen($thing); - } - - if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) { - return strlen((string) $thing); - } - - if ($thing instanceof \Countable || is_array($thing)) { - return count($thing); - } - - return 1; - } - - /** - * Returns a titlecased string. - * - * @param Twig_Environment $env - * @param string $string A string - * - * @return string The titlecased string - */ - function twig_title_string_filter(Twig_Environment $env, $string) - { - return ucwords(strtolower($string)); - } - - /** - * Returns a capitalized string. - * - * @param Twig_Environment $env - * @param string $string A string - * - * @return string The capitalized string - */ - function twig_capitalize_string_filter(Twig_Environment $env, $string) - { - return ucfirst(strtolower($string)); - } -} - -/** - * @internal - */ -function twig_ensure_traversable($seq) -{ - if ($seq instanceof Traversable || is_array($seq)) { - return $seq; - } - - return array(); -} - -/** - * Checks if a variable is empty. - * - *
    - * {# evaluates to true if the foo variable is null, false, or the empty string #}
    - * {% if foo is empty %}
    - *     {# ... #}
    - * {% endif %}
    - * 
    - * - * @param mixed $value A variable - * - * @return bool true if the value is empty, false otherwise - */ -function twig_test_empty($value) -{ - if ($value instanceof Countable) { - return 0 == count($value); - } - - if (is_object($value) && method_exists($value, '__toString')) { - return '' === (string) $value; - } - - return '' === $value || false === $value || null === $value || array() === $value; -} - -/** - * Checks if a variable is traversable. - * - *
    - * {# evaluates to true if the foo variable is an array or a traversable object #}
    - * {% if foo is traversable %}
    - *     {# ... #}
    - * {% endif %}
    - * 
    - * - * @param mixed $value A variable - * - * @return bool true if the value is traversable - */ -function twig_test_iterable($value) -{ - return $value instanceof Traversable || is_array($value); -} - -/** - * Renders a template. - * - * @param Twig_Environment $env - * @param array $context - * @param string|array $template The template to render or an array of templates to try consecutively - * @param array $variables The variables to pass to the template - * @param bool $withContext - * @param bool $ignoreMissing Whether to ignore missing templates or not - * @param bool $sandboxed Whether to sandbox the template or not - * - * @return string The rendered template - */ -function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false) -{ - $alreadySandboxed = false; - $sandbox = null; - if ($withContext) { - $variables = array_merge($context, $variables); - } - - if ($isSandboxed = $sandboxed && $env->hasExtension('Twig_Extension_Sandbox')) { - $sandbox = $env->getExtension('Twig_Extension_Sandbox'); - if (!$alreadySandboxed = $sandbox->isSandboxed()) { - $sandbox->enableSandbox(); - } - } - - $result = null; - try { - $result = $env->resolveTemplate($template)->render($variables); - } catch (Twig_Error_Loader $e) { - if (!$ignoreMissing) { - if ($isSandboxed && !$alreadySandboxed) { - $sandbox->disableSandbox(); - } - - throw $e; - } - } catch (Throwable $e) { - if ($isSandboxed && !$alreadySandboxed) { - $sandbox->disableSandbox(); - } - - throw $e; - } catch (Exception $e) { - if ($isSandboxed && !$alreadySandboxed) { - $sandbox->disableSandbox(); - } - - throw $e; - } - - if ($isSandboxed && !$alreadySandboxed) { - $sandbox->disableSandbox(); - } - - return $result; -} - -/** - * Returns a template content without rendering it. - * - * @param Twig_Environment $env - * @param string $name The template name - * @param bool $ignoreMissing Whether to ignore missing templates or not - * - * @return string The template source - */ -function twig_source(Twig_Environment $env, $name, $ignoreMissing = false) -{ - $loader = $env->getLoader(); - try { - if (!$loader instanceof Twig_SourceContextLoaderInterface) { - return $loader->getSource($name); - } else { - return $loader->getSourceContext($name)->getCode(); - } - } catch (Twig_Error_Loader $e) { - if (!$ignoreMissing) { - throw $e; - } - } -} - -/** - * Provides the ability to get constants from instances as well as class/global constants. - * - * @param string $constant The name of the constant - * @param null|object $object The object to get the constant from - * - * @return string - */ -function twig_constant($constant, $object = null) -{ - if (null !== $object) { - $constant = get_class($object).'::'.$constant; - } - - return constant($constant); -} - -/** - * Checks if a constant exists. - * - * @param string $constant The name of the constant - * @param null|object $object The object to get the constant from - * - * @return bool - */ -function twig_constant_is_defined($constant, $object = null) -{ - if (null !== $object) { - $constant = get_class($object).'::'.$constant; - } - - return defined($constant); -} - -/** - * Batches item. - * - * @param array $items An array of items - * @param int $size The size of the batch - * @param mixed $fill A value used to fill missing items - * - * @return array - */ -function twig_array_batch($items, $size, $fill = null) -{ - if ($items instanceof Traversable) { - $items = iterator_to_array($items, false); - } - - $size = ceil($size); - - $result = array_chunk($items, $size, true); - - if (null !== $fill && !empty($result)) { - $last = count($result) - 1; - if ($fillCount = $size - count($result[$last])) { - $result[$last] = array_merge( - $result[$last], - array_fill(0, $fillCount, $fill) - ); - } - } - - return $result; -} - -class_alias('Twig_Extension_Core', 'Twig\Extension\CoreExtension', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Debug.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/Debug.php deleted file mode 100644 index d0cd1962b..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Debug.php +++ /dev/null @@ -1,67 +0,0 @@ - $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)), - ); - } - - public function getName() - { - return 'debug'; - } -} - -function twig_var_dump(Twig_Environment $env, $context) -{ - if (!$env->isDebug()) { - return; - } - - ob_start(); - - $count = func_num_args(); - if (2 === $count) { - $vars = array(); - foreach ($context as $key => $value) { - if (!$value instanceof Twig_Template) { - $vars[$key] = $value; - } - } - - var_dump($vars); - } else { - for ($i = 2; $i < $count; ++$i) { - var_dump(func_get_arg($i)); - } - } - - return ob_get_clean(); -} - -class_alias('Twig_Extension_Debug', 'Twig\Extension\DebugExtension', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Escaper.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/Escaper.php deleted file mode 100644 index 46c2d84b6..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Escaper.php +++ /dev/null @@ -1,112 +0,0 @@ -setDefaultStrategy($defaultStrategy); - } - - public function getTokenParsers() - { - return array(new Twig_TokenParser_AutoEscape()); - } - - public function getNodeVisitors() - { - return array(new Twig_NodeVisitor_Escaper()); - } - - public function getFilters() - { - return array( - new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))), - ); - } - - /** - * Sets the default strategy to use when not defined by the user. - * - * The strategy can be a valid PHP callback that takes the template - * name as an argument and returns the strategy to use. - * - * @param string|false|callable $defaultStrategy An escaping strategy - */ - public function setDefaultStrategy($defaultStrategy) - { - // for BC - if (true === $defaultStrategy) { - @trigger_error('Using "true" as the default strategy is deprecated since version 1.21. Use "html" instead.', E_USER_DEPRECATED); - - $defaultStrategy = 'html'; - } - - if ('filename' === $defaultStrategy) { - @trigger_error('Using "filename" as the default strategy is deprecated since version 1.27. Use "name" instead.', E_USER_DEPRECATED); - - $defaultStrategy = 'name'; - } - - if ('name' === $defaultStrategy) { - $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess'); - } - - $this->defaultStrategy = $defaultStrategy; - } - - /** - * Gets the default strategy to use when not defined by the user. - * - * @param string $name The template name - * - * @return string|false The default strategy to use for the template - */ - public function getDefaultStrategy($name) - { - // disable string callables to avoid calling a function named html or js, - // or any other upcoming escaping strategy - if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) { - return call_user_func($this->defaultStrategy, $name); - } - - return $this->defaultStrategy; - } - - public function getName() - { - return 'escaper'; - } -} - -/** - * Marks a variable as being safe. - * - * @param string $string A PHP variable - * - * @return string - */ -function twig_raw_filter($string) -{ - return $string; -} - -class_alias('Twig_Extension_Escaper', 'Twig\Extension\EscaperExtension', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php deleted file mode 100644 index 922cd2c93..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -interface Twig_Extension_GlobalsInterface -{ -} - -class_alias('Twig_Extension_GlobalsInterface', 'Twig\Extension\GlobalsInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php deleted file mode 100644 index 1549862f4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -interface Twig_Extension_InitRuntimeInterface -{ -} - -class_alias('Twig_Extension_InitRuntimeInterface', 'Twig\Extension\InitRuntimeInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Optimizer.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/Optimizer.php deleted file mode 100644 index 6c62e3efc..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Optimizer.php +++ /dev/null @@ -1,35 +0,0 @@ -optimizers = $optimizers; - } - - public function getNodeVisitors() - { - return array(new Twig_NodeVisitor_Optimizer($this->optimizers)); - } - - public function getName() - { - return 'optimizer'; - } -} - -class_alias('Twig_Extension_Optimizer', 'Twig\Extension\OptimizerExtension', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Profiler.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/Profiler.php deleted file mode 100644 index fcfc002ba..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Profiler.php +++ /dev/null @@ -1,49 +0,0 @@ -actives[] = $profile; - } - - public function enter(Twig_Profiler_Profile $profile) - { - $this->actives[0]->addProfile($profile); - array_unshift($this->actives, $profile); - } - - public function leave(Twig_Profiler_Profile $profile) - { - $profile->leave(); - array_shift($this->actives); - - if (1 === count($this->actives)) { - $this->actives[0]->leave(); - } - } - - public function getNodeVisitors() - { - return array(new Twig_Profiler_NodeVisitor_Profiler(get_class($this))); - } - - public function getName() - { - return 'profiler'; - } -} - -class_alias('Twig_Extension_Profiler', 'Twig\Extension\ProfilerExtension', false); -class_exists('Twig_Profiler_Profile'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Sandbox.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/Sandbox.php deleted file mode 100644 index 5cb80a717..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Sandbox.php +++ /dev/null @@ -1,103 +0,0 @@ -policy = $policy; - $this->sandboxedGlobally = $sandboxed; - } - - public function getTokenParsers() - { - return array(new Twig_TokenParser_Sandbox()); - } - - public function getNodeVisitors() - { - return array(new Twig_NodeVisitor_Sandbox()); - } - - public function enableSandbox() - { - $this->sandboxed = true; - } - - public function disableSandbox() - { - $this->sandboxed = false; - } - - public function isSandboxed() - { - return $this->sandboxedGlobally || $this->sandboxed; - } - - public function isSandboxedGlobally() - { - return $this->sandboxedGlobally; - } - - public function setSecurityPolicy(Twig_Sandbox_SecurityPolicyInterface $policy) - { - $this->policy = $policy; - } - - public function getSecurityPolicy() - { - return $this->policy; - } - - public function checkSecurity($tags, $filters, $functions) - { - if ($this->isSandboxed()) { - $this->policy->checkSecurity($tags, $filters, $functions); - } - } - - public function checkMethodAllowed($obj, $method) - { - if ($this->isSandboxed()) { - $this->policy->checkMethodAllowed($obj, $method); - } - } - - public function checkPropertyAllowed($obj, $method) - { - if ($this->isSandboxed()) { - $this->policy->checkPropertyAllowed($obj, $method); - } - } - - public function ensureToStringAllowed($obj) - { - if ($this->isSandboxed() && is_object($obj)) { - $this->policy->checkMethodAllowed($obj, '__toString'); - } - - return $obj; - } - - public function getName() - { - return 'sandbox'; - } -} - -class_alias('Twig_Extension_Sandbox', 'Twig\Extension\SandboxExtension', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Staging.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/Staging.php deleted file mode 100644 index d3a0f9c94..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/Staging.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * @internal - */ -class Twig_Extension_Staging extends Twig_Extension -{ - protected $functions = array(); - protected $filters = array(); - protected $visitors = array(); - protected $tokenParsers = array(); - protected $globals = array(); - protected $tests = array(); - - public function addFunction($name, $function) - { - if (isset($this->functions[$name])) { - @trigger_error(sprintf('Overriding function "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED); - } - - $this->functions[$name] = $function; - } - - public function getFunctions() - { - return $this->functions; - } - - public function addFilter($name, $filter) - { - if (isset($this->filters[$name])) { - @trigger_error(sprintf('Overriding filter "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED); - } - - $this->filters[$name] = $filter; - } - - public function getFilters() - { - return $this->filters; - } - - public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) - { - $this->visitors[] = $visitor; - } - - public function getNodeVisitors() - { - return $this->visitors; - } - - public function addTokenParser(Twig_TokenParserInterface $parser) - { - if (isset($this->tokenParsers[$parser->getTag()])) { - @trigger_error(sprintf('Overriding tag "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $parser->getTag()), E_USER_DEPRECATED); - } - - $this->tokenParsers[$parser->getTag()] = $parser; - } - - public function getTokenParsers() - { - return $this->tokenParsers; - } - - public function addGlobal($name, $value) - { - $this->globals[$name] = $value; - } - - public function getGlobals() - { - return $this->globals; - } - - public function addTest($name, $test) - { - if (isset($this->tests[$name])) { - @trigger_error(sprintf('Overriding test "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED); - } - - $this->tests[$name] = $test; - } - - public function getTests() - { - return $this->tests; - } - - public function getName() - { - return 'staging'; - } -} - -class_alias('Twig_Extension_Staging', 'Twig\Extension\StagingExtension', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Extension/StringLoader.php b/lib/silex/vendor/twig/twig/lib/Twig/Extension/StringLoader.php deleted file mode 100644 index 2ce3c9924..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Extension/StringLoader.php +++ /dev/null @@ -1,47 +0,0 @@ - true)), - ); - } - - public function getName() - { - return 'string_loader'; - } -} - -/** - * Loads a template from a string. - * - *
    - * {{ include(template_from_string("Hello {{ name }}")) }}
    - * 
    - * - * @param Twig_Environment $env A Twig_Environment instance - * @param string $template A template as a string or object implementing __toString() - * - * @return Twig_Template - */ -function twig_template_from_string(Twig_Environment $env, $template) -{ - return $env->createTemplate((string) $template); -} - -class_alias('Twig_Extension_StringLoader', 'Twig\Extension\StringLoaderExtension', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/ExtensionInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/ExtensionInterface.php deleted file mode 100644 index 946df500a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/ExtensionInterface.php +++ /dev/null @@ -1,90 +0,0 @@ - - */ -interface Twig_ExtensionInterface -{ - /** - * Initializes the runtime environment. - * - * This is where you can load some file that contains filter functions for instance. - * - * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead - */ - public function initRuntime(Twig_Environment $environment); - - /** - * Returns the token parser instances to add to the existing list. - * - * @return Twig_TokenParserInterface[] - */ - public function getTokenParsers(); - - /** - * Returns the node visitor instances to add to the existing list. - * - * @return Twig_NodeVisitorInterface[] - */ - public function getNodeVisitors(); - - /** - * Returns a list of filters to add to the existing list. - * - * @return Twig_SimpleFilter[] - */ - public function getFilters(); - - /** - * Returns a list of tests to add to the existing list. - * - * @return Twig_SimpleTest[] - */ - public function getTests(); - - /** - * Returns a list of functions to add to the existing list. - * - * @return Twig_SimpleFunction[] - */ - public function getFunctions(); - - /** - * Returns a list of operators to add to the existing list. - * - * @return array First array of unary operators, second array of binary operators - */ - public function getOperators(); - - /** - * Returns a list of global variables to add to the existing list. - * - * @return array An array of global variables - * - * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead - */ - public function getGlobals(); - - /** - * Returns the name of the extension. - * - * @return string The extension name - * - * @deprecated since 1.26 (to be removed in 2.0), not used anymore internally - */ - public function getName(); -} - -class_alias('Twig_ExtensionInterface', 'Twig\Extension\ExtensionInterface', false); -class_exists('Twig_Environment'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php b/lib/silex/vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php deleted file mode 100644 index 2cdaded1d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -class Twig_FactoryRuntimeLoader implements Twig_RuntimeLoaderInterface -{ - private $map; - - /** - * @param array $map An array where keys are class names and values factory callables - */ - public function __construct($map = array()) - { - $this->map = $map; - } - - public function load($class) - { - if (isset($this->map[$class])) { - $runtimeFactory = $this->map[$class]; - - return $runtimeFactory(); - } - } -} - -class_alias('Twig_FactoryRuntimeLoader', 'Twig\RuntimeLoader\FactoryRuntimeLoader', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php b/lib/silex/vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php deleted file mode 100644 index 8f8cd2ee5..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -class Twig_FileExtensionEscapingStrategy -{ - /** - * Guesses the best autoescaping strategy based on the file name. - * - * @param string $name The template name - * - * @return string|false The escaping strategy name to use or false to disable - */ - public static function guess($name) - { - if (in_array(substr($name, -1), array('/', '\\'))) { - return 'html'; // return html for directories - } - - if ('.twig' === substr($name, -5)) { - $name = substr($name, 0, -5); - } - - $extension = pathinfo($name, PATHINFO_EXTENSION); - - switch ($extension) { - case 'js': - return 'js'; - - case 'css': - return 'css'; - - case 'txt': - return false; - - default: - return 'html'; - } - } -} - -class_alias('Twig_FileExtensionEscapingStrategy', 'Twig\FileExtensionEscapingStrategy', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Filter.php b/lib/silex/vendor/twig/twig/lib/Twig/Filter.php deleted file mode 100644 index 893d75d10..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Filter.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface -{ - protected $options; - protected $arguments = array(); - - public function __construct(array $options = array()) - { - $this->options = array_merge(array( - 'needs_environment' => false, - 'needs_context' => false, - 'pre_escape' => null, - 'preserves_safety' => null, - 'callable' => null, - ), $options); - } - - public function setArguments($arguments) - { - $this->arguments = $arguments; - } - - public function getArguments() - { - return $this->arguments; - } - - public function needsEnvironment() - { - return $this->options['needs_environment']; - } - - public function needsContext() - { - return $this->options['needs_context']; - } - - public function getSafe(Twig_Node $filterArgs) - { - if (isset($this->options['is_safe'])) { - return $this->options['is_safe']; - } - - if (isset($this->options['is_safe_callback'])) { - return call_user_func($this->options['is_safe_callback'], $filterArgs); - } - } - - public function getPreservesSafety() - { - return $this->options['preserves_safety']; - } - - public function getPreEscape() - { - return $this->options['pre_escape']; - } - - public function getCallable() - { - return $this->options['callable']; - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Filter/Function.php b/lib/silex/vendor/twig/twig/lib/Twig/Filter/Function.php deleted file mode 100644 index 71b16554e..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Filter/Function.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Filter_Function extends Twig_Filter -{ - protected $function; - - public function __construct($function, array $options = array()) - { - $options['callable'] = $function; - - parent::__construct($options); - - $this->function = $function; - } - - public function compile() - { - return $this->function; - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Filter/Method.php b/lib/silex/vendor/twig/twig/lib/Twig/Filter/Method.php deleted file mode 100644 index 1b75676c5..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Filter/Method.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Filter_Method extends Twig_Filter -{ - protected $extension; - protected $method; - - public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) - { - $options['callable'] = array($extension, $method); - - parent::__construct($options); - - $this->extension = $extension; - $this->method = $method; - } - - public function compile() - { - return sprintf('$this->env->getExtension(\'%s\')->%s', get_class($this->extension), $this->method); - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Filter/Node.php b/lib/silex/vendor/twig/twig/lib/Twig/Filter/Node.php deleted file mode 100644 index 3e6b12eff..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Filter/Node.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Filter_Node extends Twig_Filter -{ - protected $class; - - public function __construct($class, array $options = array()) - { - parent::__construct($options); - - $this->class = $class; - } - - public function getClass() - { - return $this->class; - } - - public function compile() - { - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/FilterCallableInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/FilterCallableInterface.php deleted file mode 100644 index 21b028c4e..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/FilterCallableInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FilterCallableInterface -{ - public function getCallable(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/FilterInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/FilterInterface.php deleted file mode 100644 index 9d7e9ab6a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/FilterInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FilterInterface -{ - /** - * Compiles a filter. - * - * @return string The PHP code for the filter - */ - public function compile(); - - public function needsEnvironment(); - - public function needsContext(); - - public function getSafe(Twig_Node $filterArgs); - - public function getPreservesSafety(); - - public function getPreEscape(); - - public function setArguments($arguments); - - public function getArguments(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Function.php b/lib/silex/vendor/twig/twig/lib/Twig/Function.php deleted file mode 100644 index 9dc16e908..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Function.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface -{ - protected $options; - protected $arguments = array(); - - public function __construct(array $options = array()) - { - $this->options = array_merge(array( - 'needs_environment' => false, - 'needs_context' => false, - 'callable' => null, - ), $options); - } - - public function setArguments($arguments) - { - $this->arguments = $arguments; - } - - public function getArguments() - { - return $this->arguments; - } - - public function needsEnvironment() - { - return $this->options['needs_environment']; - } - - public function needsContext() - { - return $this->options['needs_context']; - } - - public function getSafe(Twig_Node $functionArgs) - { - if (isset($this->options['is_safe'])) { - return $this->options['is_safe']; - } - - if (isset($this->options['is_safe_callback'])) { - return call_user_func($this->options['is_safe_callback'], $functionArgs); - } - - return array(); - } - - public function getCallable() - { - return $this->options['callable']; - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Function/Function.php b/lib/silex/vendor/twig/twig/lib/Twig/Function/Function.php deleted file mode 100644 index 97c0eb77f..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Function/Function.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Function_Function extends Twig_Function -{ - protected $function; - - public function __construct($function, array $options = array()) - { - $options['callable'] = $function; - - parent::__construct($options); - - $this->function = $function; - } - - public function compile() - { - return $this->function; - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Function/Method.php b/lib/silex/vendor/twig/twig/lib/Twig/Function/Method.php deleted file mode 100644 index 4299e1181..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Function/Method.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Function_Method extends Twig_Function -{ - protected $extension; - protected $method; - - public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) - { - $options['callable'] = array($extension, $method); - - parent::__construct($options); - - $this->extension = $extension; - $this->method = $method; - } - - public function compile() - { - return sprintf('$this->env->getExtension(\'%s\')->%s', get_class($this->extension), $this->method); - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Function/Node.php b/lib/silex/vendor/twig/twig/lib/Twig/Function/Node.php deleted file mode 100644 index 0adc5d937..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Function/Node.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Function_Node extends Twig_Function -{ - protected $class; - - public function __construct($class, array $options = array()) - { - parent::__construct($options); - - $this->class = $class; - } - - public function getClass() - { - return $this->class; - } - - public function compile() - { - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php deleted file mode 100644 index d23d69173..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FunctionCallableInterface -{ - public function getCallable(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/FunctionInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/FunctionInterface.php deleted file mode 100644 index 00d4f95c7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/FunctionInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_FunctionInterface -{ - /** - * Compiles a function. - * - * @return string The PHP code for the function - */ - public function compile(); - - public function needsEnvironment(); - - public function needsContext(); - - public function getSafe(Twig_Node $filterArgs); - - public function setArguments($arguments); - - public function getArguments(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Lexer.php b/lib/silex/vendor/twig/twig/lib/Twig/Lexer.php deleted file mode 100644 index 85390b28c..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Lexer.php +++ /dev/null @@ -1,424 +0,0 @@ - - */ -class Twig_Lexer implements Twig_LexerInterface -{ - protected $tokens; - protected $code; - protected $cursor; - protected $lineno; - protected $end; - protected $state; - protected $states; - protected $brackets; - protected $env; - // to be renamed to $name in 2.0 (where it is private) - protected $filename; - protected $options; - protected $regexes; - protected $position; - protected $positions; - protected $currentVarBlockLine; - - private $source; - - const STATE_DATA = 0; - const STATE_BLOCK = 1; - const STATE_VAR = 2; - const STATE_STRING = 3; - const STATE_INTERPOLATION = 4; - - const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'; - const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'; - const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'; - const REGEX_DQ_STRING_DELIM = '/"/A'; - const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As'; - const PUNCTUATION = '()[]{}?:.,|'; - - public function __construct(Twig_Environment $env, array $options = array()) - { - $this->env = $env; - - $this->options = array_merge(array( - 'tag_comment' => array('{#', '#}'), - 'tag_block' => array('{%', '%}'), - 'tag_variable' => array('{{', '}}'), - 'whitespace_trim' => '-', - 'interpolation' => array('#{', '}'), - ), $options); - - $this->regexes = array( - 'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A', - 'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A', - 'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s', - 'operator' => $this->getOperatorRegex(), - 'lex_comment' => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s', - 'lex_block_raw' => '/\s*(raw|verbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As', - 'lex_block_line' => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As', - 'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s', - 'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A', - 'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A', - ); - } - - public function tokenize($code, $name = null) - { - if (!$code instanceof Twig_Source) { - @trigger_error(sprintf('Passing a string as the $code argument of %s() is deprecated since version 1.27 and will be removed in 2.0. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED); - $this->source = new Twig_Source($code, $name); - } else { - $this->source = $code; - } - - if (((int) ini_get('mbstring.func_overload')) & 2) { - @trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED); - } - - if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { - $mbEncoding = mb_internal_encoding(); - mb_internal_encoding('ASCII'); - } else { - $mbEncoding = null; - } - - $this->code = str_replace(array("\r\n", "\r"), "\n", $this->source->getCode()); - $this->filename = $this->source->getName(); - $this->cursor = 0; - $this->lineno = 1; - $this->end = strlen($this->code); - $this->tokens = array(); - $this->state = self::STATE_DATA; - $this->states = array(); - $this->brackets = array(); - $this->position = -1; - - // find all token starts in one go - preg_match_all($this->regexes['lex_tokens_start'], $this->code, $matches, PREG_OFFSET_CAPTURE); - $this->positions = $matches; - - while ($this->cursor < $this->end) { - // dispatch to the lexing functions depending - // on the current state - switch ($this->state) { - case self::STATE_DATA: - $this->lexData(); - break; - - case self::STATE_BLOCK: - $this->lexBlock(); - break; - - case self::STATE_VAR: - $this->lexVar(); - break; - - case self::STATE_STRING: - $this->lexString(); - break; - - case self::STATE_INTERPOLATION: - $this->lexInterpolation(); - break; - } - } - - $this->pushToken(Twig_Token::EOF_TYPE); - - if (!empty($this->brackets)) { - list($expect, $lineno) = array_pop($this->brackets); - throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source); - } - - if ($mbEncoding) { - mb_internal_encoding($mbEncoding); - } - - return new Twig_TokenStream($this->tokens, $this->source); - } - - protected function lexData() - { - // if no matches are left we return the rest of the template as simple text token - if ($this->position == count($this->positions[0]) - 1) { - $this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor)); - $this->cursor = $this->end; - - return; - } - - // Find the first token after the current cursor - $position = $this->positions[0][++$this->position]; - while ($position[1] < $this->cursor) { - if ($this->position == count($this->positions[0]) - 1) { - return; - } - $position = $this->positions[0][++$this->position]; - } - - // push the template text first - $text = $textContent = substr($this->code, $this->cursor, $position[1] - $this->cursor); - if (isset($this->positions[2][$this->position][0])) { - $text = rtrim($text); - } - $this->pushToken(Twig_Token::TEXT_TYPE, $text); - $this->moveCursor($textContent.$position[0]); - - switch ($this->positions[1][$this->position][0]) { - case $this->options['tag_comment'][0]: - $this->lexComment(); - break; - - case $this->options['tag_block'][0]: - // raw data? - if (preg_match($this->regexes['lex_block_raw'], $this->code, $match, null, $this->cursor)) { - $this->moveCursor($match[0]); - $this->lexRawData($match[1]); - // {% line \d+ %} - } elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) { - $this->moveCursor($match[0]); - $this->lineno = (int) $match[1]; - } else { - $this->pushToken(Twig_Token::BLOCK_START_TYPE); - $this->pushState(self::STATE_BLOCK); - $this->currentVarBlockLine = $this->lineno; - } - break; - - case $this->options['tag_variable'][0]: - $this->pushToken(Twig_Token::VAR_START_TYPE); - $this->pushState(self::STATE_VAR); - $this->currentVarBlockLine = $this->lineno; - break; - } - } - - protected function lexBlock() - { - if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) { - $this->pushToken(Twig_Token::BLOCK_END_TYPE); - $this->moveCursor($match[0]); - $this->popState(); - } else { - $this->lexExpression(); - } - } - - protected function lexVar() - { - if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) { - $this->pushToken(Twig_Token::VAR_END_TYPE); - $this->moveCursor($match[0]); - $this->popState(); - } else { - $this->lexExpression(); - } - } - - protected function lexExpression() - { - // whitespace - if (preg_match('/\s+/A', $this->code, $match, null, $this->cursor)) { - $this->moveCursor($match[0]); - - if ($this->cursor >= $this->end) { - throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->source); - } - } - - // operators - if (preg_match($this->regexes['operator'], $this->code, $match, null, $this->cursor)) { - $this->pushToken(Twig_Token::OPERATOR_TYPE, preg_replace('/\s+/', ' ', $match[0])); - $this->moveCursor($match[0]); - } - // names - elseif (preg_match(self::REGEX_NAME, $this->code, $match, null, $this->cursor)) { - $this->pushToken(Twig_Token::NAME_TYPE, $match[0]); - $this->moveCursor($match[0]); - } - // numbers - elseif (preg_match(self::REGEX_NUMBER, $this->code, $match, null, $this->cursor)) { - $number = (float) $match[0]; // floats - if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) { - $number = (int) $match[0]; // integers lower than the maximum - } - $this->pushToken(Twig_Token::NUMBER_TYPE, $number); - $this->moveCursor($match[0]); - } - // punctuation - elseif (false !== strpos(self::PUNCTUATION, $this->code[$this->cursor])) { - // opening bracket - if (false !== strpos('([{', $this->code[$this->cursor])) { - $this->brackets[] = array($this->code[$this->cursor], $this->lineno); - } - // closing bracket - elseif (false !== strpos(')]}', $this->code[$this->cursor])) { - if (empty($this->brackets)) { - throw new Twig_Error_Syntax(sprintf('Unexpected "%s".', $this->code[$this->cursor]), $this->lineno, $this->source); - } - - list($expect, $lineno) = array_pop($this->brackets); - if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) { - throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source); - } - } - - $this->pushToken(Twig_Token::PUNCTUATION_TYPE, $this->code[$this->cursor]); - ++$this->cursor; - } - // strings - elseif (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) { - $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1))); - $this->moveCursor($match[0]); - } - // opening double quoted string - elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) { - $this->brackets[] = array('"', $this->lineno); - $this->pushState(self::STATE_STRING); - $this->moveCursor($match[0]); - } - // unlexable - else { - throw new Twig_Error_Syntax(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->source); - } - } - - protected function lexRawData($tag) - { - if ('raw' === $tag) { - @trigger_error(sprintf('Twig Tag "raw" is deprecated since version 1.21. Use "verbatim" instead in %s at line %d.', $this->filename, $this->lineno), E_USER_DEPRECATED); - } - - if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { - throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block.', $tag), $this->lineno, $this->source); - } - - $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor); - $this->moveCursor($text.$match[0][0]); - - if (false !== strpos($match[1][0], $this->options['whitespace_trim'])) { - $text = rtrim($text); - } - - $this->pushToken(Twig_Token::TEXT_TYPE, $text); - } - - protected function lexComment() - { - if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { - throw new Twig_Error_Syntax('Unclosed comment.', $this->lineno, $this->source); - } - - $this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]); - } - - protected function lexString() - { - if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) { - $this->brackets[] = array($this->options['interpolation'][0], $this->lineno); - $this->pushToken(Twig_Token::INTERPOLATION_START_TYPE); - $this->moveCursor($match[0]); - $this->pushState(self::STATE_INTERPOLATION); - } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) { - $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0])); - $this->moveCursor($match[0]); - } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) { - list($expect, $lineno) = array_pop($this->brackets); - if ($this->code[$this->cursor] != '"') { - throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source); - } - - $this->popState(); - ++$this->cursor; - } - } - - protected function lexInterpolation() - { - $bracket = end($this->brackets); - if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) { - array_pop($this->brackets); - $this->pushToken(Twig_Token::INTERPOLATION_END_TYPE); - $this->moveCursor($match[0]); - $this->popState(); - } else { - $this->lexExpression(); - } - } - - protected function pushToken($type, $value = '') - { - // do not push empty text tokens - if (Twig_Token::TEXT_TYPE === $type && '' === $value) { - return; - } - - $this->tokens[] = new Twig_Token($type, $value, $this->lineno); - } - - protected function moveCursor($text) - { - $this->cursor += strlen($text); - $this->lineno += substr_count($text, "\n"); - } - - protected function getOperatorRegex() - { - $operators = array_merge( - array('='), - array_keys($this->env->getUnaryOperators()), - array_keys($this->env->getBinaryOperators()) - ); - - $operators = array_combine($operators, array_map('strlen', $operators)); - arsort($operators); - - $regex = array(); - foreach ($operators as $operator => $length) { - // an operator that ends with a character must be followed by - // a whitespace or a parenthesis - if (ctype_alpha($operator[$length - 1])) { - $r = preg_quote($operator, '/').'(?=[\s()])'; - } else { - $r = preg_quote($operator, '/'); - } - - // an operator with a space can be any amount of whitespaces - $r = preg_replace('/\s+/', '\s+', $r); - - $regex[] = $r; - } - - return '/'.implode('|', $regex).'/A'; - } - - protected function pushState($state) - { - $this->states[] = $this->state; - $this->state = $state; - } - - protected function popState() - { - if (0 === count($this->states)) { - throw new Exception('Cannot pop state without a previous state.'); - } - - $this->state = array_pop($this->states); - } -} - -class_alias('Twig_Lexer', 'Twig\Lexer', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/LexerInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/LexerInterface.php deleted file mode 100644 index c10bbfec4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/LexerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_LexerInterface -{ - /** - * Tokenizes a source code. - * - * @param string|Twig_Source $code The source code - * @param string $name A unique identifier for the source code - * - * @return Twig_TokenStream - * - * @throws Twig_Error_Syntax When the code is syntactically wrong - */ - public function tokenize($code, $name = null); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Loader/Array.php b/lib/silex/vendor/twig/twig/lib/Twig/Loader/Array.php deleted file mode 100644 index 0aac76900..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Loader/Array.php +++ /dev/null @@ -1,97 +0,0 @@ - - */ -class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface -{ - protected $templates = array(); - - /** - * @param array $templates An array of templates (keys are the names, and values are the source code) - */ - public function __construct(array $templates = array()) - { - $this->templates = $templates; - } - - /** - * Adds or overrides a template. - * - * @param string $name The template name - * @param string $template The template source - */ - public function setTemplate($name, $template) - { - $this->templates[(string) $name] = $template; - } - - public function getSource($name) - { - @trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED); - - $name = (string) $name; - if (!isset($this->templates[$name])) { - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); - } - - return $this->templates[$name]; - } - - public function getSourceContext($name) - { - $name = (string) $name; - if (!isset($this->templates[$name])) { - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); - } - - return new Twig_Source($this->templates[$name], $name); - } - - public function exists($name) - { - return isset($this->templates[(string) $name]); - } - - public function getCacheKey($name) - { - $name = (string) $name; - if (!isset($this->templates[$name])) { - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); - } - - return $name.':'.$this->templates[$name]; - } - - public function isFresh($name, $time) - { - $name = (string) $name; - if (!isset($this->templates[$name])) { - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); - } - - return true; - } -} - -class_alias('Twig_Loader_Array', 'Twig\Loader\ArrayLoader', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Loader/Chain.php b/lib/silex/vendor/twig/twig/lib/Twig/Loader/Chain.php deleted file mode 100644 index 59a337969..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Loader/Chain.php +++ /dev/null @@ -1,151 +0,0 @@ - - */ -class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface -{ - private $hasSourceCache = array(); - protected $loaders = array(); - - /** - * @param Twig_LoaderInterface[] $loaders - */ - public function __construct(array $loaders = array()) - { - foreach ($loaders as $loader) { - $this->addLoader($loader); - } - } - - public function addLoader(Twig_LoaderInterface $loader) - { - $this->loaders[] = $loader; - $this->hasSourceCache = array(); - } - - public function getSource($name) - { - @trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED); - - $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%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : '')); - } - - public function getSourceContext($name) - { - $exceptions = array(); - foreach ($this->loaders as $loader) { - if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { - continue; - } - - try { - if ($loader instanceof Twig_SourceContextLoaderInterface) { - return $loader->getSourceContext($name); - } - - return new Twig_Source($loader->getSource($name), $name); - } catch (Twig_Error_Loader $e) { - $exceptions[] = $e->getMessage(); - } - } - - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : '')); - } - - 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) { - if ($loader->exists($name)) { - return $this->hasSourceCache[$name] = true; - } - - continue; - } - - try { - if ($loader instanceof Twig_SourceContextLoaderInterface) { - $loader->getSourceContext($name); - } else { - $loader->getSource($name); - } - - return $this->hasSourceCache[$name] = true; - } catch (Twig_Error_Loader $e) { - } - } - - return $this->hasSourceCache[$name] = false; - } - - 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%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : '')); - } - - 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%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : '')); - } -} - -class_alias('Twig_Loader_Chain', 'Twig\Loader\ChainLoader', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Loader/Filesystem.php b/lib/silex/vendor/twig/twig/lib/Twig/Loader/Filesystem.php deleted file mode 100644 index 1275044f8..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Loader/Filesystem.php +++ /dev/null @@ -1,290 +0,0 @@ - - */ -class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface -{ - /** Identifier of the main namespace. */ - const MAIN_NAMESPACE = '__main__'; - - protected $paths = array(); - protected $cache = array(); - protected $errorCache = array(); - - private $rootPath; - - /** - * @param string|array $paths A path or an array of paths where to look for templates - * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) - */ - public function __construct($paths = array(), $rootPath = null) - { - $this->rootPath = (null === $rootPath ? getcwd() : $rootPath).DIRECTORY_SEPARATOR; - if (false !== $realPath = realpath($rootPath)) { - $this->rootPath = $realPath.DIRECTORY_SEPARATOR; - } - - if ($paths) { - $this->setPaths($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($namespace = self::MAIN_NAMESPACE) - { - 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 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 $namespace A path namespace - */ - public function setPaths($paths, $namespace = self::MAIN_NAMESPACE) - { - if (!is_array($paths)) { - $paths = array($paths); - } - - $this->paths[$namespace] = array(); - foreach ($paths as $path) { - $this->addPath($path, $namespace); - } - } - - /** - * Adds a path where templates are stored. - * - * @param string $path A path where to look for templates - * @param string $namespace A path namespace - * - * @throws Twig_Error_Loader - */ - public function addPath($path, $namespace = self::MAIN_NAMESPACE) - { - // invalidate the cache - $this->cache = $this->errorCache = array(); - - $checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path; - if (!is_dir($checkPath)) { - throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath)); - } - - $this->paths[$namespace][] = rtrim($path, '/\\'); - } - - /** - * Prepends a path where templates are stored. - * - * @param string $path A path where to look for templates - * @param string $namespace A path namespace - * - * @throws Twig_Error_Loader - */ - public function prependPath($path, $namespace = self::MAIN_NAMESPACE) - { - // invalidate the cache - $this->cache = $this->errorCache = array(); - - $checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path; - if (!is_dir($checkPath)) { - throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath)); - } - - $path = rtrim($path, '/\\'); - - if (!isset($this->paths[$namespace])) { - $this->paths[$namespace][] = $path; - } else { - array_unshift($this->paths[$namespace], $path); - } - } - - public function getSource($name) - { - @trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED); - - return file_get_contents($this->findTemplate($name)); - } - - public function getSourceContext($name) - { - $path = $this->findTemplate($name); - - return new Twig_Source(file_get_contents($path), $name, $path); - } - - public function getCacheKey($name) - { - $path = $this->findTemplate($name); - $len = strlen($this->rootPath); - if (0 === strncmp($this->rootPath, $path, $len)) { - return substr($path, $len); - } - - return $path; - } - - public function exists($name) - { - $name = $this->normalizeName($name); - - if (isset($this->cache[$name])) { - return true; - } - - try { - return false !== $this->findTemplate($name, false); - } catch (Twig_Error_Loader $exception) { - @trigger_error(sprintf('In %s::findTemplate(), you must accept a second argument that when set to "false" returns "false" instead of throwing an exception. Not supporting this argument is deprecated since version 1.27.', get_class($this)), E_USER_DEPRECATED); - - return false; - } - } - - public function isFresh($name, $time) - { - return filemtime($this->findTemplate($name)) <= $time; - } - - protected function findTemplate($name) - { - $throw = func_num_args() > 1 ? func_get_arg(1) : true; - $name = $this->normalizeName($name); - - if (isset($this->cache[$name])) { - return $this->cache[$name]; - } - - if (isset($this->errorCache[$name])) { - if (!$throw) { - return false; - } - - throw new Twig_Error_Loader($this->errorCache[$name]); - } - - $this->validateName($name); - - list($namespace, $shortname) = $this->parseName($name); - - if (!isset($this->paths[$namespace])) { - $this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace); - - if (!$throw) { - return false; - } - - throw new Twig_Error_Loader($this->errorCache[$name]); - } - - foreach ($this->paths[$namespace] as $path) { - if (!$this->isAbsolutePath($path)) { - $path = $this->rootPath.'/'.$path; - } - - if (is_file($path.'/'.$shortname)) { - if (false !== $realpath = realpath($path.'/'.$shortname)) { - return $this->cache[$name] = $realpath; - } - - return $this->cache[$name] = $path.'/'.$shortname; - } - } - - $this->errorCache[$name] = sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace])); - - if (!$throw) { - return false; - } - - throw new Twig_Error_Loader($this->errorCache[$name]); - } - - protected function parseName($name, $default = self::MAIN_NAMESPACE) - { - 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); - $shortname = substr($name, $pos + 1); - - return array($namespace, $shortname); - } - - return array($default, $name); - } - - protected function normalizeName($name) - { - return preg_replace('#/{2,}#', '/', str_replace('\\', '/', (string) $name)); - } - - protected function validateName($name) - { - if (false !== strpos($name, "\0")) { - throw new Twig_Error_Loader('A template name cannot contain NUL bytes.'); - } - - $name = ltrim($name, '/'); - $parts = explode('/', $name); - $level = 0; - foreach ($parts as $part) { - if ('..' === $part) { - --$level; - } elseif ('.' !== $part) { - ++$level; - } - - if ($level < 0) { - throw new Twig_Error_Loader(sprintf('Looks like you try to load a template outside configured directories (%s).', $name)); - } - } - } - - private function isAbsolutePath($file) - { - return strspn($file, '/\\', 0, 1) - || (strlen($file) > 3 && ctype_alpha($file[0]) - && substr($file, 1, 1) === ':' - && strspn($file, '/\\', 2, 1) - ) - || null !== parse_url($file, PHP_URL_SCHEME) - ; - } -} - -class_alias('Twig_Loader_Filesystem', 'Twig\Loader\FilesystemLoader', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Loader/String.php b/lib/silex/vendor/twig/twig/lib/Twig/Loader/String.php deleted file mode 100644 index 950bd35b0..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Loader/String.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ -class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface -{ - public function getSource($name) - { - @trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED); - - return $name; - } - - public function getSourceContext($name) - { - return new Twig_Source($name, $name); - } - - public function exists($name) - { - return true; - } - - public function getCacheKey($name) - { - return $name; - } - - public function isFresh($name, $time) - { - return true; - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/LoaderInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/LoaderInterface.php deleted file mode 100644 index 459a70abb..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/LoaderInterface.php +++ /dev/null @@ -1,57 +0,0 @@ - - */ -interface Twig_LoaderInterface -{ - /** - * 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 - * - * @throws Twig_Error_Loader When $name is not found - * - * @deprecated since 1.27 (to be removed in 2.0), implement Twig_SourceContextLoaderInterface - */ - 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 - * - * @throws Twig_Error_Loader When $name is not found - */ - public function getCacheKey($name); - - /** - * Returns true if the template is still fresh. - * - * @param string $name The template name - * @param int $time Timestamp of the last modification time of the - * cached template - * - * @return bool true if the template is fresh, false otherwise - * - * @throws Twig_Error_Loader When $name is not found - */ - public function isFresh($name, $time); -} - -class_alias('Twig_LoaderInterface', 'Twig\Loader\LoaderInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Markup.php b/lib/silex/vendor/twig/twig/lib/Twig/Markup.php deleted file mode 100644 index 8591d1f93..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Markup.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -class Twig_Markup implements Countable -{ - protected $content; - protected $charset; - - public function __construct($content, $charset) - { - $this->content = (string) $content; - $this->charset = $charset; - } - - public function __toString() - { - return $this->content; - } - - public function count() - { - return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content); - } -} - -class_alias('Twig_Markup', 'Twig\Markup', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node.php b/lib/silex/vendor/twig/twig/lib/Twig/Node.php deleted file mode 100644 index 89ada1449..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node.php +++ /dev/null @@ -1,256 +0,0 @@ - - */ -class Twig_Node implements Twig_NodeInterface -{ - protected $nodes; - protected $attributes; - protected $lineno; - protected $tag; - - private $name; - - /** - * Constructor. - * - * The nodes are automatically made available as properties ($this->node). - * The attributes are automatically made available as array items ($this['name']). - * - * @param array $nodes An array of named nodes - * @param array $attributes An array of attributes (should not be nodes) - * @param int $lineno The line number - * @param string $tag The tag name associated with the Node - */ - public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null) - { - foreach ($nodes as $name => $node) { - if (!$node instanceof Twig_NodeInterface) { - @trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED); - } - } - $this->nodes = $nodes; - $this->attributes = $attributes; - $this->lineno = $lineno; - $this->tag = $tag; - } - - public function __toString() - { - $attributes = array(); - foreach ($this->attributes as $name => $value) { - $attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true))); - } - - $repr = array(get_class($this).'('.implode(', ', $attributes)); - - if (count($this->nodes)) { - foreach ($this->nodes as $name => $node) { - $len = strlen($name) + 4; - $noderepr = array(); - foreach (explode("\n", (string) $node) as $line) { - $noderepr[] = str_repeat(' ', $len).$line; - } - - $repr[] = sprintf(' %s: %s', $name, ltrim(implode("\n", $noderepr))); - } - - $repr[] = ')'; - } else { - $repr[0] .= ')'; - } - - return implode("\n", $repr); - } - - /** - * @deprecated since 1.16.1 (to be removed in 2.0) - */ - public function toXml($asDom = false) - { - @trigger_error(sprintf('%s is deprecated since version 1.16.1 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED); - - $dom = new DOMDocument('1.0', 'UTF-8'); - $dom->formatOutput = true; - $dom->appendChild($xml = $dom->createElement('twig')); - - $xml->appendChild($node = $dom->createElement('node')); - $node->setAttribute('class', get_class($this)); - - foreach ($this->attributes as $name => $value) { - $node->appendChild($attribute = $dom->createElement('attribute')); - $attribute->setAttribute('name', $name); - $attribute->appendChild($dom->createTextNode($value)); - } - - foreach ($this->nodes as $name => $n) { - if (null === $n) { - continue; - } - - $child = $n->toXml(true)->getElementsByTagName('node')->item(0); - $child = $dom->importNode($child, true); - $child->setAttribute('name', $name); - - $node->appendChild($child); - } - - return $asDom ? $dom : $dom->saveXML(); - } - - public function compile(Twig_Compiler $compiler) - { - foreach ($this->nodes as $node) { - $node->compile($compiler); - } - } - - public function getTemplateLine() - { - return $this->lineno; - } - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function getLine() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateLine() instead.', E_USER_DEPRECATED); - - return $this->lineno; - } - - public function getNodeTag() - { - return $this->tag; - } - - /** - * @return bool - */ - public function hasAttribute($name) - { - return array_key_exists($name, $this->attributes); - } - - /** - * @return mixed - */ - public function getAttribute($name) - { - if (!array_key_exists($name, $this->attributes)) { - throw new LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this))); - } - - return $this->attributes[$name]; - } - - /** - * @param string $name - * @param mixed $value - */ - public function setAttribute($name, $value) - { - $this->attributes[$name] = $value; - } - - public function removeAttribute($name) - { - unset($this->attributes[$name]); - } - - /** - * @return bool - */ - public function hasNode($name) - { - return array_key_exists($name, $this->nodes); - } - - /** - * @return Twig_Node - */ - public function getNode($name) - { - if (!array_key_exists($name, $this->nodes)) { - throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this))); - } - - return $this->nodes[$name]; - } - - public function setNode($name, $node = null) - { - if (!$node instanceof Twig_NodeInterface) { - @trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED); - } - - $this->nodes[$name] = $node; - } - - public function removeNode($name) - { - unset($this->nodes[$name]); - } - - public function count() - { - return count($this->nodes); - } - - public function getIterator() - { - return new ArrayIterator($this->nodes); - } - - public function setTemplateName($name) - { - $this->name = $name; - foreach ($this->nodes as $node) { - if (null !== $node) { - $node->setTemplateName($name); - } - } - } - - public function getTemplateName() - { - return $this->name; - } - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function setFilename($name) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use setTemplateName() instead.', E_USER_DEPRECATED); - - $this->setTemplateName($name); - } - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function getFilename() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateName() instead.', E_USER_DEPRECATED); - - return $this->name; - } -} - -class_alias('Twig_Node', 'Twig\Node\Node', false); -class_exists('Twig_Compiler'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/AutoEscape.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/AutoEscape.php deleted file mode 100644 index 17e4e3813..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/AutoEscape.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -class Twig_Node_AutoEscape extends Twig_Node -{ - public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape') - { - parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->subcompile($this->getNode('body')); - } -} - -class_alias('Twig_Node_AutoEscape', 'Twig\Node\AutoEscapeNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Block.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Block.php deleted file mode 100644 index 91752ad27..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Block.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ -class Twig_Node_Block extends Twig_Node -{ - public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null) - { - parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n") - ->indent() - ; - - $compiler - ->subcompile($this->getNode('body')) - ->outdent() - ->write("}\n\n") - ; - } -} - -class_alias('Twig_Node_Block', 'Twig\Node\BlockNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/BlockReference.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/BlockReference.php deleted file mode 100644 index 92a9f398a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/BlockReference.php +++ /dev/null @@ -1,34 +0,0 @@ - - */ -class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface -{ - public function __construct($name, $lineno, $tag = null) - { - parent::__construct(array(), array('name' => $name), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name'))) - ; - } -} - -class_alias('Twig_Node_BlockReference', 'Twig\Node\BlockReferenceNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Body.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Body.php deleted file mode 100644 index 07dfef8b5..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Body.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -class Twig_Node_Body extends Twig_Node -{ -} - -class_alias('Twig_Node_Body', 'Twig\Node\BodyNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php deleted file mode 100644 index 7258acb6a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php +++ /dev/null @@ -1,80 +0,0 @@ - - */ -class Twig_Node_CheckSecurity extends Twig_Node -{ - protected $usedFilters; - protected $usedTags; - protected $usedFunctions; - - public function __construct(array $usedFilters, array $usedTags, array $usedFunctions) - { - $this->usedFilters = $usedFilters; - $this->usedTags = $usedTags; - $this->usedFunctions = $usedFunctions; - - parent::__construct(); - } - - public function compile(Twig_Compiler $compiler) - { - $tags = $filters = $functions = array(); - foreach (array('tags', 'filters', 'functions') as $type) { - foreach ($this->{'used'.ucfirst($type)} as $name => $node) { - if ($node instanceof Twig_Node) { - ${$type}[$name] = $node->getTemplateLine(); - } else { - ${$type}[$node] = null; - } - } - } - - $compiler - ->write('$tags = ')->repr(array_filter($tags))->raw(";\n") - ->write('$filters = ')->repr(array_filter($filters))->raw(";\n") - ->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n") - ->write("try {\n") - ->indent() - ->write("\$this->env->getExtension('Twig_Extension_Sandbox')->checkSecurity(\n") - ->indent() - ->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n") - ->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n") - ->write(!$functions ? "array()\n" : "array('".implode("', '", array_keys($functions))."')\n") - ->outdent() - ->write(");\n") - ->outdent() - ->write("} catch (Twig_Sandbox_SecurityError \$e) {\n") - ->indent() - ->write("\$e->setSourceContext(\$this->getSourceContext());\n\n") - ->write("if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n") - ->indent() - ->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n") - ->outdent() - ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n") - ->indent() - ->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n") - ->outdent() - ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n") - ->indent() - ->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n") - ->outdent() - ->write("}\n\n") - ->write("throw \$e;\n") - ->outdent() - ->write("}\n\n") - ; - } -} - -class_alias('Twig_Node_CheckSecurity', 'Twig\Node\CheckSecurityNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Do.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Do.php deleted file mode 100644 index cdd7e77a4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Do.php +++ /dev/null @@ -1,35 +0,0 @@ - - */ -class Twig_Node_Do extends Twig_Node -{ - public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) - { - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write('') - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ; - } -} - -class_alias('Twig_Node_Do', 'Twig\Node\DoNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Embed.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Embed.php deleted file mode 100644 index 3785d3a9f..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Embed.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -class Twig_Node_Embed extends Twig_Node_Include -{ - // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module) - public function __construct($name, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) - { - parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag); - - $this->setAttribute('name', $name); - // to be removed in 2.0, used name instead - $this->setAttribute('filename', $name); - $this->setAttribute('index', $index); - } - - protected function addGetTemplate(Twig_Compiler $compiler) - { - $compiler - ->write('$this->loadTemplate(') - ->string($this->getAttribute('name')) - ->raw(', ') - ->repr($this->getTemplateName()) - ->raw(', ') - ->repr($this->getTemplateLine()) - ->raw(', ') - ->string($this->getAttribute('index')) - ->raw(')') - ; - } -} - -class_alias('Twig_Node_Embed', 'Twig\Node\EmbedNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression.php deleted file mode 100644 index a99c4e63a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ -abstract class Twig_Node_Expression extends Twig_Node -{ -} - -class_alias('Twig_Node_Expression', 'Twig\Node\Expression\AbstractExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Array.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Array.php deleted file mode 100644 index 0e77bb08b..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Array.php +++ /dev/null @@ -1,83 +0,0 @@ -index = -1; - foreach ($this->getKeyValuePairs() as $pair) { - if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) { - $this->index = $pair['key']->getAttribute('value'); - } - } - } - - public function getKeyValuePairs() - { - $pairs = array(); - - foreach (array_chunk($this->nodes, 2) as $pair) { - $pairs[] = array( - 'key' => $pair[0], - 'value' => $pair[1], - ); - } - - return $pairs; - } - - public function hasElement(Twig_Node_Expression $key) - { - foreach ($this->getKeyValuePairs() as $pair) { - // we compare the string representation of the keys - // to avoid comparing the line numbers which are not relevant here. - if ((string) $key === (string) $pair['key']) { - return true; - } - } - - return false; - } - - public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null) - { - if (null === $key) { - $key = new Twig_Node_Expression_Constant(++$this->index, $value->getTemplateLine()); - } - - array_push($this->nodes, $key, $value); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->raw('array('); - $first = true; - foreach ($this->getKeyValuePairs() as $pair) { - if (!$first) { - $compiler->raw(', '); - } - $first = false; - - $compiler - ->subcompile($pair['key']) - ->raw(' => ') - ->subcompile($pair['value']) - ; - } - $compiler->raw(')'); - } -} - -class_alias('Twig_Node_Expression_Array', 'Twig\Node\Expression\ArrayExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php deleted file mode 100644 index 2e6b4c7ca..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php +++ /dev/null @@ -1,25 +0,0 @@ -raw('$context[') - ->string($this->getAttribute('name')) - ->raw(']') - ; - } -} - -class_alias('Twig_Node_Expression_AssignName', 'Twig\Node\Expression\AssignNameExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary.php deleted file mode 100644 index 2b545d984..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary.php +++ /dev/null @@ -1,37 +0,0 @@ - $left, 'right' => $right), array(), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('left')) - ->raw(' ') - ; - $this->operator($compiler); - $compiler - ->raw(' ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - abstract public function operator(Twig_Compiler $compiler); -} - -class_alias('Twig_Node_Expression_Binary', 'Twig\Node\Expression\Binary\AbstractBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php deleted file mode 100644 index 5a09d8367..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('+'); - } -} - -class_alias('Twig_Node_Expression_Binary_Add', 'Twig\Node\Expression\Binary\AddBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php deleted file mode 100644 index 9ffddce6b..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('&&'); - } -} - -class_alias('Twig_Node_Expression_Binary_And', 'Twig\Node\Expression\Binary\AndBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php deleted file mode 100644 index e46e9ebfa..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('&'); - } -} - -class_alias('Twig_Node_Expression_Binary_BitwiseAnd', 'Twig\Node\Expression\Binary\BitwiseAndBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php deleted file mode 100644 index 5d7f1b7c0..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('|'); - } -} - -class_alias('Twig_Node_Expression_Binary_BitwiseOr', 'Twig\Node\Expression\Binary\BitwiseOrBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php deleted file mode 100644 index 82edf516c..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('^'); - } -} - -class_alias('Twig_Node_Expression_Binary_BitwiseXor', 'Twig\Node\Expression\Binary\BitwiseXorBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php deleted file mode 100644 index 91abca602..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('.'); - } -} - -class_alias('Twig_Node_Expression_Binary_Concat', 'Twig\Node\Expression\Binary\ConcatBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php deleted file mode 100644 index 38ffa30c3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('/'); - } -} - -class_alias('Twig_Node_Expression_Binary_Div', 'Twig\Node\Expression\Binary\DivBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php deleted file mode 100644 index 85c529376..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php +++ /dev/null @@ -1,32 +0,0 @@ -getVarName(); - $right = $compiler->getVarName(); - $compiler - ->raw(sprintf('(is_string($%s = ', $left)) - ->subcompile($this->getNode('left')) - ->raw(sprintf(') && is_string($%s = ', $right)) - ->subcompile($this->getNode('right')) - ->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right)) - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw(''); - } -} - -class_alias('Twig_Node_Expression_Binary_EndsWith', 'Twig\Node\Expression\Binary\EndsWithBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php deleted file mode 100644 index a6a6946b6..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php +++ /dev/null @@ -1,19 +0,0 @@ -raw('=='); - } -} - -class_alias('Twig_Node_Expression_Binary_Equal', 'Twig\Node\Expression\Binary\EqualBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php deleted file mode 100644 index 7393bcb89..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php +++ /dev/null @@ -1,26 +0,0 @@ -raw('(int) floor('); - parent::compile($compiler); - $compiler->raw(')'); - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('/'); - } -} - -class_alias('Twig_Node_Expression_Binary_FloorDiv', 'Twig\Node\Expression\Binary\FloorDivBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php deleted file mode 100644 index 832f97977..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php +++ /dev/null @@ -1,19 +0,0 @@ -raw('>'); - } -} - -class_alias('Twig_Node_Expression_Binary_Greater', 'Twig\Node\Expression\Binary\GreaterBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php deleted file mode 100644 index c5f762457..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php +++ /dev/null @@ -1,19 +0,0 @@ -raw('>='); - } -} - -class_alias('Twig_Node_Expression_Binary_GreaterEqual', 'Twig\Node\Expression\Binary\GreaterEqualBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php deleted file mode 100644 index af112448f..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php +++ /dev/null @@ -1,30 +0,0 @@ -raw('twig_in_filter(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('in'); - } -} - -class_alias('Twig_Node_Expression_Binary_In', 'Twig\Node\Expression\Binary\InBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php deleted file mode 100644 index ab8fc1f9a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php +++ /dev/null @@ -1,19 +0,0 @@ -raw('<'); - } -} - -class_alias('Twig_Node_Expression_Binary_Less', 'Twig\Node\Expression\Binary\LessBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php deleted file mode 100644 index 71a279e9c..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php +++ /dev/null @@ -1,19 +0,0 @@ -raw('<='); - } -} - -class_alias('Twig_Node_Expression_Binary_LessEqual', 'Twig\Node\Expression\Binary\LessEqualBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php deleted file mode 100644 index 5cb855842..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php +++ /dev/null @@ -1,30 +0,0 @@ -raw('preg_match(') - ->subcompile($this->getNode('right')) - ->raw(', ') - ->subcompile($this->getNode('left')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw(''); - } -} - -class_alias('Twig_Node_Expression_Binary_Matches', 'Twig\Node\Expression\Binary\MatchesBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php deleted file mode 100644 index 28109633d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('%'); - } -} - -class_alias('Twig_Node_Expression_Binary_Mod', 'Twig\Node\Expression\Binary\ModBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php deleted file mode 100644 index 790c6a22d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('*'); - } -} - -class_alias('Twig_Node_Expression_Binary_Mul', 'Twig\Node\Expression\Binary\MulBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php deleted file mode 100644 index bb45c9ed5..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php +++ /dev/null @@ -1,19 +0,0 @@ -raw('!='); - } -} - -class_alias('Twig_Node_Expression_Binary_NotEqual', 'Twig\Node\Expression\Binary\NotEqualBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php deleted file mode 100644 index 9dedf92f9..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php +++ /dev/null @@ -1,30 +0,0 @@ -raw('!twig_in_filter(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('not in'); - } -} - -class_alias('Twig_Node_Expression_Binary_NotIn', 'Twig\Node\Expression\Binary\NotInBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php deleted file mode 100644 index dc9eece14..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('||'); - } -} - -class_alias('Twig_Node_Expression_Binary_Or', 'Twig\Node\Expression\Binary\OrBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php deleted file mode 100644 index d24777bd5..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php +++ /dev/null @@ -1,34 +0,0 @@ -= 50600) { - return parent::compile($compiler); - } - - $compiler - ->raw('pow(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('**'); - } -} - -class_alias('Twig_Node_Expression_Binary_Power', 'Twig\Node\Expression\Binary\PowerBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php deleted file mode 100644 index 187f67653..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php +++ /dev/null @@ -1,30 +0,0 @@ -raw('range(') - ->subcompile($this->getNode('left')) - ->raw(', ') - ->subcompile($this->getNode('right')) - ->raw(')') - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('..'); - } -} - -class_alias('Twig_Node_Expression_Binary_Range', 'Twig\Node\Expression\Binary\RangeBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php deleted file mode 100644 index 7e43b8de0..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php +++ /dev/null @@ -1,32 +0,0 @@ -getVarName(); - $right = $compiler->getVarName(); - $compiler - ->raw(sprintf('(is_string($%s = ', $left)) - ->subcompile($this->getNode('left')) - ->raw(sprintf(') && is_string($%s = ', $right)) - ->subcompile($this->getNode('right')) - ->raw(sprintf(') && (\'\' === $%2$s || 0 === strpos($%1$s, $%2$s)))', $left, $right)) - ; - } - - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw(''); - } -} - -class_alias('Twig_Node_Expression_Binary_StartsWith', 'Twig\Node\Expression\Binary\StartsWithBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php deleted file mode 100644 index cff8ed075..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('-'); - } -} - -class_alias('Twig_Node_Expression_Binary_Sub', 'Twig\Node\Expression\Binary\SubBinary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php deleted file mode 100644 index 37a3983d6..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php +++ /dev/null @@ -1,93 +0,0 @@ - - */ -class Twig_Node_Expression_BlockReference extends Twig_Node_Expression -{ - /** - * @param Twig_Node|null $template - */ - public function __construct(Twig_NodeInterface $name, $template = null, $lineno, $tag = null) - { - if (is_bool($template)) { - @trigger_error(sprintf('The %s method "$asString" argument is deprecated since version 1.28 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED); - - $template = null; - } - - $nodes = array('name' => $name); - if (null !== $template) { - $nodes['template'] = $template; - } - - parent::__construct($nodes, array('is_defined_test' => false, 'output' => false), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - if ($this->getAttribute('is_defined_test')) { - $this->compileTemplateCall($compiler, 'hasBlock'); - } else { - if ($this->getAttribute('output')) { - $compiler->addDebugInfo($this); - - $this - ->compileTemplateCall($compiler, 'displayBlock') - ->raw(";\n"); - } else { - $this->compileTemplateCall($compiler, 'renderBlock'); - } - } - } - - private function compileTemplateCall(Twig_Compiler $compiler, $method) - { - if (!$this->hasNode('template')) { - $compiler->write('$this'); - } else { - $compiler - ->write('$this->loadTemplate(') - ->subcompile($this->getNode('template')) - ->raw(', ') - ->repr($this->getTemplateName()) - ->raw(', ') - ->repr($this->getTemplateLine()) - ->raw(')') - ; - } - - $compiler->raw(sprintf('->%s', $method)); - $this->compileBlockArguments($compiler); - - return $compiler; - } - - private function compileBlockArguments(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('name')) - ->raw(', $context'); - - if (!$this->hasNode('template')) { - $compiler->raw(', $blocks'); - } - - return $compiler->raw(')'); - } -} - -class_alias('Twig_Node_Expression_BlockReference', 'Twig\Node\Expression\BlockReferenceExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Call.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Call.php deleted file mode 100644 index d962b6a50..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Call.php +++ /dev/null @@ -1,291 +0,0 @@ -hasAttribute('callable') && $callable = $this->getAttribute('callable')) { - if (is_string($callable) && false === strpos($callable, '::')) { - $compiler->raw($callable); - } else { - list($r, $callable) = $this->reflectCallable($callable); - if ($r instanceof ReflectionMethod && is_string($callable[0])) { - if ($r->isStatic()) { - $compiler->raw(sprintf('%s::%s', $callable[0], $callable[1])); - } else { - $compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1])); - } - } elseif ($r instanceof ReflectionMethod && $callable[0] instanceof Twig_ExtensionInterface) { - $compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', get_class($callable[0]), $callable[1])); - } else { - $type = ucfirst($this->getAttribute('type')); - $compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->getAttribute('name'))); - $closingParenthesis = true; - } - } - } else { - $compiler->raw($this->getAttribute('thing')->compile()); - } - - $this->compileArguments($compiler); - - if ($closingParenthesis) { - $compiler->raw(')'); - } - } - - protected function compileArguments(Twig_Compiler $compiler) - { - $compiler->raw('('); - - $first = true; - - if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) { - $compiler->raw('$this->env'); - $first = false; - } - - if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) { - if (!$first) { - $compiler->raw(', '); - } - $compiler->raw('$context'); - $first = false; - } - - if ($this->hasAttribute('arguments')) { - foreach ($this->getAttribute('arguments') as $argument) { - if (!$first) { - $compiler->raw(', '); - } - $compiler->string($argument); - $first = false; - } - } - - if ($this->hasNode('node')) { - if (!$first) { - $compiler->raw(', '); - } - $compiler->subcompile($this->getNode('node')); - $first = false; - } - - if ($this->hasNode('arguments')) { - $callable = $this->hasAttribute('callable') ? $this->getAttribute('callable') : null; - - $arguments = $this->getArguments($callable, $this->getNode('arguments')); - - foreach ($arguments as $node) { - if (!$first) { - $compiler->raw(', '); - } - $compiler->subcompile($node); - $first = false; - } - } - - $compiler->raw(')'); - } - - protected function getArguments($callable, $arguments) - { - $callType = $this->getAttribute('type'); - $callName = $this->getAttribute('name'); - - $parameters = array(); - $named = false; - foreach ($arguments as $name => $node) { - if (!is_int($name)) { - $named = true; - $name = $this->normalizeName($name); - } elseif ($named) { - throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName)); - } - - $parameters[$name] = $node; - } - - $isVariadic = $this->hasAttribute('is_variadic') && $this->getAttribute('is_variadic'); - if (!$named && !$isVariadic) { - return $parameters; - } - - if (!$callable) { - if ($named) { - $message = sprintf('Named arguments are not supported for %s "%s".', $callType, $callName); - } else { - $message = sprintf('Arbitrary positional arguments are not supported for %s "%s".', $callType, $callName); - } - - throw new LogicException($message); - } - - $callableParameters = $this->getCallableParameters($callable, $isVariadic); - $arguments = array(); - $names = array(); - $missingArguments = array(); - $optionalArguments = array(); - $pos = 0; - foreach ($callableParameters as $callableParameter) { - $names[] = $name = $this->normalizeName($callableParameter->name); - - if (array_key_exists($name, $parameters)) { - if (array_key_exists($pos, $parameters)) { - throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName)); - } - - if (count($missingArguments)) { - throw new Twig_Error_Syntax(sprintf( - 'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".', - $name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments)) - ); - } - - $arguments = array_merge($arguments, $optionalArguments); - $arguments[] = $parameters[$name]; - unset($parameters[$name]); - $optionalArguments = array(); - } elseif (array_key_exists($pos, $parameters)) { - $arguments = array_merge($arguments, $optionalArguments); - $arguments[] = $parameters[$pos]; - unset($parameters[$pos]); - $optionalArguments = array(); - ++$pos; - } elseif ($callableParameter->isDefaultValueAvailable()) { - $optionalArguments[] = new Twig_Node_Expression_Constant($callableParameter->getDefaultValue(), -1); - } elseif ($callableParameter->isOptional()) { - if (empty($parameters)) { - break; - } else { - $missingArguments[] = $name; - } - } else { - throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName)); - } - } - - if ($isVariadic) { - $arbitraryArguments = new Twig_Node_Expression_Array(array(), -1); - foreach ($parameters as $key => $value) { - if (is_int($key)) { - $arbitraryArguments->addElement($value); - } else { - $arbitraryArguments->addElement($value, new Twig_Node_Expression_Constant($key, -1)); - } - unset($parameters[$key]); - } - - if ($arbitraryArguments->count()) { - $arguments = array_merge($arguments, $optionalArguments); - $arguments[] = $arbitraryArguments; - } - } - - if (!empty($parameters)) { - $unknownParameter = null; - foreach ($parameters as $parameter) { - if ($parameter instanceof Twig_Node) { - $unknownParameter = $parameter; - break; - } - } - - throw new Twig_Error_Syntax(sprintf( - 'Unknown argument%s "%s" for %s "%s(%s)".', - count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names) - ), $unknownParameter ? $unknownParameter->getTemplateLine() : -1); - } - - return $arguments; - } - - protected function normalizeName($name) - { - return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name)); - } - - private function getCallableParameters($callable, $isVariadic) - { - list($r) = $this->reflectCallable($callable); - if (null === $r) { - return array(); - } - - $parameters = $r->getParameters(); - if ($this->hasNode('node')) { - array_shift($parameters); - } - if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) { - array_shift($parameters); - } - if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) { - array_shift($parameters); - } - if ($this->hasAttribute('arguments') && null !== $this->getAttribute('arguments')) { - foreach ($this->getAttribute('arguments') as $argument) { - array_shift($parameters); - } - } - if ($isVariadic) { - $argument = end($parameters); - if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && array() === $argument->getDefaultValue()) { - array_pop($parameters); - } else { - $callableName = $r->name; - if ($r instanceof ReflectionMethod) { - $callableName = $r->getDeclaringClass()->name.'::'.$callableName; - } - - throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".', $callableName, $this->getAttribute('type'), $this->getAttribute('name'))); - } - } - - return $parameters; - } - - private function reflectCallable($callable) - { - if (null !== $this->reflector) { - return $this->reflector; - } - - if (is_array($callable)) { - if (!method_exists($callable[0], $callable[1])) { - // __call() - return array(null, array()); - } - $r = new ReflectionMethod($callable[0], $callable[1]); - } elseif (is_object($callable) && !$callable instanceof Closure) { - $r = new ReflectionObject($callable); - $r = $r->getMethod('__invoke'); - $callable = array($callable, '__invoke'); - } elseif (is_string($callable) && false !== $pos = strpos($callable, '::')) { - $class = substr($callable, 0, $pos); - $method = substr($callable, $pos + 2); - if (!method_exists($class, $method)) { - // __staticCall() - return array(null, array()); - } - $r = new ReflectionMethod($callable); - $callable = array($class, $method); - } else { - $r = new ReflectionFunction($callable); - } - - return $this->reflector = array($r, $callable); - } -} - -class_alias('Twig_Node_Expression_Call', 'Twig\Node\Expression\CallExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php deleted file mode 100644 index c339d773c..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php +++ /dev/null @@ -1,33 +0,0 @@ - $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('((') - ->subcompile($this->getNode('expr1')) - ->raw(') ? (') - ->subcompile($this->getNode('expr2')) - ->raw(') : (') - ->subcompile($this->getNode('expr3')) - ->raw('))') - ; - } -} - -class_alias('Twig_Node_Expression_Conditional', 'Twig\Node\Expression\ConditionalExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Constant.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Constant.php deleted file mode 100644 index bf4d031cf..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Constant.php +++ /dev/null @@ -1,25 +0,0 @@ - $value), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->repr($this->getAttribute('value')); - } -} - -class_alias('Twig_Node_Expression_Constant', 'Twig\Node\Expression\ConstantExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php deleted file mode 100644 index 114b5cd97..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * @deprecated since 1.23 and will be removed in 2.0. - */ -class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression -{ - public function __construct($name, $lineno, $tag = null) - { - parent::__construct(array(), array('name' => $name), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name'))); - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php deleted file mode 100644 index 12da1d676..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php +++ /dev/null @@ -1,41 +0,0 @@ - $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $name = $this->getNode('filter')->getAttribute('value'); - $filter = $compiler->getEnvironment()->getFilter($name); - - $this->setAttribute('name', $name); - $this->setAttribute('type', 'filter'); - $this->setAttribute('thing', $filter); - $this->setAttribute('needs_environment', $filter->needsEnvironment()); - $this->setAttribute('needs_context', $filter->needsContext()); - $this->setAttribute('arguments', $filter->getArguments()); - if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) { - $this->setAttribute('callable', $filter->getCallable()); - } - if ($filter instanceof Twig_SimpleFilter) { - $this->setAttribute('is_variadic', $filter->isVariadic()); - } - - $this->compileCallable($compiler); - } -} - -class_alias('Twig_Node_Expression_Filter', 'Twig\Node\Expression\FilterExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php deleted file mode 100644 index d2e19d54e..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php +++ /dev/null @@ -1,45 +0,0 @@ - - * {{ var.foo|default('foo item on var is not defined') }} - * - * - * @author Fabien Potencier - */ -class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter -{ - public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) - { - $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getTemplateLine()), $arguments, $node->getTemplateLine()); - - if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { - $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getTemplateLine()); - $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getTemplateLine()); - - $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getTemplateLine()); - } else { - $node = $default; - } - - parent::__construct($node, $filterName, $arguments, $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->subcompile($this->getNode('node')); - } -} - -class_alias('Twig_Node_Expression_Filter_Default', 'Twig\Node\Expression\Filter\DefaultFilter', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Function.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Function.php deleted file mode 100644 index cdee7c972..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Function.php +++ /dev/null @@ -1,45 +0,0 @@ - $arguments), array('name' => $name, 'is_defined_test' => false), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $name = $this->getAttribute('name'); - $function = $compiler->getEnvironment()->getFunction($name); - - $this->setAttribute('name', $name); - $this->setAttribute('type', 'function'); - $this->setAttribute('thing', $function); - $this->setAttribute('needs_environment', $function->needsEnvironment()); - $this->setAttribute('needs_context', $function->needsContext()); - $this->setAttribute('arguments', $function->getArguments()); - if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) { - $callable = $function->getCallable(); - if ('constant' === $name && $this->getAttribute('is_defined_test')) { - $callable = 'twig_constant_is_defined'; - } - - $this->setAttribute('callable', $callable); - } - if ($function instanceof Twig_SimpleFunction) { - $this->setAttribute('is_variadic', $function->isVariadic()); - } - - $this->compileCallable($compiler); - } -} - -class_alias('Twig_Node_Expression_Function', 'Twig\Node\Expression\FunctionExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php deleted file mode 100644 index b7823accb..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php +++ /dev/null @@ -1,74 +0,0 @@ - $node, 'attribute' => $attribute); - if (null !== $arguments) { - $nodes['arguments'] = $arguments; - } - - parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - if ($this->getAttribute('disable_c_ext')) { - @trigger_error(sprintf('Using the "disable_c_ext" attribute on %s is deprecated since version 1.30 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED); - } - - if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) { - $compiler->raw('twig_template_get_attributes($this, '); - } else { - $compiler->raw('$this->getAttribute('); - } - - if ($this->getAttribute('ignore_strict_check')) { - $this->getNode('node')->setAttribute('ignore_strict_check', true); - } - - $compiler->subcompile($this->getNode('node')); - - $compiler->raw(', ')->subcompile($this->getNode('attribute')); - - // only generate optional arguments when needed (to make generated code more readable) - $needFourth = $this->getAttribute('ignore_strict_check'); - $needThird = $needFourth || $this->getAttribute('is_defined_test'); - $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type'); - $needFirst = $needSecond || $this->hasNode('arguments'); - - if ($needFirst) { - if ($this->hasNode('arguments')) { - $compiler->raw(', ')->subcompile($this->getNode('arguments')); - } else { - $compiler->raw(', array()'); - } - } - - if ($needSecond) { - $compiler->raw(', ')->repr($this->getAttribute('type')); - } - - if ($needThird) { - $compiler->raw(', ')->repr($this->getAttribute('is_defined_test')); - } - - if ($needFourth) { - $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check')); - } - - $compiler->raw(')'); - } -} - -class_alias('Twig_Node_Expression_GetAttr', 'Twig\Node\Expression\GetAttrExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php deleted file mode 100644 index 709016eb2..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php +++ /dev/null @@ -1,43 +0,0 @@ - $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) - { - $compiler - ->subcompile($this->getNode('node')) - ->raw('->') - ->raw($this->getAttribute('method')) - ->raw('(') - ; - $first = true; - foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) { - if (!$first) { - $compiler->raw(', '); - } - $first = false; - - $compiler->subcompile($pair['value']); - } - $compiler->raw(')'); - } -} - -class_alias('Twig_Node_Expression_MethodCall', 'Twig\Node\Expression\MethodCallExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Name.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Name.php deleted file mode 100644 index 9d5a21f87..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Name.php +++ /dev/null @@ -1,102 +0,0 @@ - '$this', - '_context' => '$context', - '_charset' => '$this->env->getCharset()', - ); - - public function __construct($name, $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) - { - $name = $this->getAttribute('name'); - - $compiler->addDebugInfo($this); - - if ($this->getAttribute('is_defined_test')) { - if ($this->isSpecial()) { - $compiler->repr(true); - } else { - $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); - } - } elseif ($this->isSpecial()) { - $compiler->raw($this->specialVars[$name]); - } elseif ($this->getAttribute('always_defined')) { - $compiler - ->raw('$context[') - ->string($name) - ->raw(']') - ; - } else { - if (PHP_VERSION_ID >= 70000) { - // use PHP 7 null coalescing operator - $compiler - ->raw('($context[') - ->string($name) - ->raw('] ?? ') - ; - - if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) { - $compiler->raw('null)'); - } else { - $compiler->raw('$this->getContext($context, ')->string($name)->raw('))'); - } - } elseif (PHP_VERSION_ID >= 50400) { - // PHP 5.4 ternary operator performance was optimized - $compiler - ->raw('(isset($context[') - ->string($name) - ->raw(']) ? $context[') - ->string($name) - ->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, ') - ->string($name) - ; - - if ($this->getAttribute('ignore_strict_check')) { - $compiler->raw(', true'); - } - - $compiler - ->raw(')') - ; - } - } - } - - public function isSpecial() - { - return isset($this->specialVars[$this->getAttribute('name')]); - } - - public function isSimple() - { - return !$this->isSpecial() && !$this->getAttribute('is_defined_test'); - } -} - -class_alias('Twig_Node_Expression_Name', 'Twig\Node\Expression\NameExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php deleted file mode 100644 index eaafa4c91..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php +++ /dev/null @@ -1,48 +0,0 @@ -getTemplateLine()), - new Twig_Node_Expression_Unary_Not(new Twig_Node_Expression_Test_Null($left, 'null', new Twig_Node(), $left->getTemplateLine()), $left->getTemplateLine()), - $left->getTemplateLine() - ); - - parent::__construct($test, $left, $right, $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - /* - * This optimizes only one case. PHP 7 also supports more complex expressions - * that can return null. So, for instance, if log is defined, log("foo") ?? "..." works, - * but log($a["foo"]) ?? "..." does not if $a["foo"] is not defined. More advanced - * cases might be implemented as an optimizer node visitor, but has not been done - * as benefits are probably not worth the added complexity. - */ - if (PHP_VERSION_ID >= 70000 && $this->getNode('expr2') instanceof Twig_Node_Expression_Name) { - $this->getNode('expr2')->setAttribute('always_defined', true); - $compiler - ->raw('((') - ->subcompile($this->getNode('expr2')) - ->raw(') ?? (') - ->subcompile($this->getNode('expr3')) - ->raw('))') - ; - } else { - parent::compile($compiler); - } - } -} - -class_alias('Twig_Node_Expression_NullCoalesce', 'Twig\Node\Expression\NullCoalesceExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php deleted file mode 100644 index 78692db29..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -class Twig_Node_Expression_Parent extends Twig_Node_Expression -{ - public function __construct($name, $lineno, $tag = null) - { - parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - if ($this->getAttribute('output')) { - $compiler - ->addDebugInfo($this) - ->write('$this->displayParentBlock(') - ->string($this->getAttribute('name')) - ->raw(", \$context, \$blocks);\n") - ; - } else { - $compiler - ->raw('$this->renderParentBlock(') - ->string($this->getAttribute('name')) - ->raw(', $context, $blocks)') - ; - } - } -} - -class_alias('Twig_Node_Expression_Parent', 'Twig\Node\Expression\ParentExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/TempName.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/TempName.php deleted file mode 100644 index 0a86e003d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/TempName.php +++ /dev/null @@ -1,28 +0,0 @@ - $name), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('$_') - ->raw($this->getAttribute('name')) - ->raw('_') - ; - } -} - -class_alias('Twig_Node_Expression_TempName', 'Twig\Node\Expression\TempNameExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test.php deleted file mode 100644 index ad102ba60..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test.php +++ /dev/null @@ -1,42 +0,0 @@ - $node); - if (null !== $arguments) { - $nodes['arguments'] = $arguments; - } - - parent::__construct($nodes, array('name' => $name), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $name = $this->getAttribute('name'); - $test = $compiler->getEnvironment()->getTest($name); - - $this->setAttribute('name', $name); - $this->setAttribute('type', 'test'); - $this->setAttribute('thing', $test); - if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) { - $this->setAttribute('callable', $test->getCallable()); - } - if ($test instanceof Twig_SimpleTest) { - $this->setAttribute('is_variadic', $test->isVariadic()); - } - - $this->compileCallable($compiler); - } -} - -class_alias('Twig_Node_Expression_Test', 'Twig\Node\Expression\TestExpression', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php deleted file mode 100644 index a51a4ba13..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php +++ /dev/null @@ -1,48 +0,0 @@ - - * {% if post.status is constant('Post::PUBLISHED') %} - * the status attribute is exactly the same as Post::PUBLISHED - * {% endif %} - * - * - * @author Fabien Potencier - */ -class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test -{ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('node')) - ->raw(' === constant(') - ; - - if ($this->getNode('arguments')->hasNode(1)) { - $compiler - ->raw('get_class(') - ->subcompile($this->getNode('arguments')->getNode(1)) - ->raw(')."::".') - ; - } - - $compiler - ->subcompile($this->getNode('arguments')->getNode(0)) - ->raw('))') - ; - } -} - -class_alias('Twig_Node_Expression_Test_Constant', 'Twig\Node\Expression\Test\ConstantTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php deleted file mode 100644 index 2136c3907..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php +++ /dev/null @@ -1,61 +0,0 @@ - - * {# defined works with variable names and variable attributes #} - * {% if foo is defined %} - * {# ... #} - * {% endif %} - * - * - * @author Fabien Potencier - */ -class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test -{ - public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) - { - if ($node instanceof Twig_Node_Expression_Name) { - $node->setAttribute('is_defined_test', true); - } elseif ($node instanceof Twig_Node_Expression_GetAttr) { - $node->setAttribute('is_defined_test', true); - $this->changeIgnoreStrictCheck($node); - } elseif ($node instanceof Twig_Node_Expression_BlockReference) { - $node->setAttribute('is_defined_test', true); - } elseif ($node instanceof Twig_Node_Expression_Function && 'constant' === $node->getAttribute('name')) { - $node->setAttribute('is_defined_test', true); - } elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array) { - $node = new Twig_Node_Expression_Constant(true, $node->getTemplateLine()); - } else { - throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getTemplateLine()); - } - - parent::__construct($node, $name, $arguments, $lineno); - } - - protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node) - { - $node->setAttribute('ignore_strict_check', true); - - if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) { - $this->changeIgnoreStrictCheck($node->getNode('node')); - } - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->subcompile($this->getNode('node')); - } -} - -class_alias('Twig_Node_Expression_Test_Defined', 'Twig\Node\Expression\Test\DefinedTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php deleted file mode 100644 index a5d71961a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php +++ /dev/null @@ -1,35 +0,0 @@ - - * {% if loop.index is divisible by(3) %} - * - * - * @author Fabien Potencier - */ -class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test -{ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(0 == ') - ->subcompile($this->getNode('node')) - ->raw(' % ') - ->subcompile($this->getNode('arguments')->getNode(0)) - ->raw(')') - ; - } -} - -class_alias('Twig_Node_Expression_Test_Divisibleby', 'Twig\Node\Expression\Test\DivisiblebyTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php deleted file mode 100644 index 7e198bea6..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php +++ /dev/null @@ -1,34 +0,0 @@ - - * {{ var is even }} - * - * - * @author Fabien Potencier - */ -class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test -{ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('node')) - ->raw(' % 2 == 0') - ->raw(')') - ; - } -} - -class_alias('Twig_Node_Expression_Test_Even', 'Twig\Node\Expression\Test\EvenTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php deleted file mode 100644 index 3746e4cbd..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php +++ /dev/null @@ -1,33 +0,0 @@ - - * {{ var is none }} - * - * - * @author Fabien Potencier - */ -class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test -{ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(null === ') - ->subcompile($this->getNode('node')) - ->raw(')') - ; - } -} - -class_alias('Twig_Node_Expression_Test_Null', 'Twig\Node\Expression\Test\NullTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php deleted file mode 100644 index 0c6c099bb..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php +++ /dev/null @@ -1,34 +0,0 @@ - - * {{ var is odd }} - * - * - * @author Fabien Potencier - */ -class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test -{ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('node')) - ->raw(' % 2 == 1') - ->raw(')') - ; - } -} - -class_alias('Twig_Node_Expression_Test_Odd', 'Twig\Node\Expression\Test\OddTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php deleted file mode 100644 index e95ff1f20..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ -class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test -{ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->raw('(') - ->subcompile($this->getNode('node')) - ->raw(' === ') - ->subcompile($this->getNode('arguments')->getNode(0)) - ->raw(')') - ; - } -} - -class_alias('Twig_Node_Expression_Test_Sameas', 'Twig\Node\Expression\Test\SameasTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary.php deleted file mode 100644 index 5804485e3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary.php +++ /dev/null @@ -1,29 +0,0 @@ - $node), array(), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->raw(' '); - $this->operator($compiler); - $compiler->subcompile($this->getNode('node')); - } - - abstract public function operator(Twig_Compiler $compiler); -} - -class_alias('Twig_Node_Expression_Unary', 'Twig\Node\Expression\Unary\AbstractUnary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php deleted file mode 100644 index 039d933d9..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('-'); - } -} - -class_alias('Twig_Node_Expression_Unary_Neg', 'Twig\Node\Expression\Unary\NegUnary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php deleted file mode 100644 index a0860b183..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('!'); - } -} - -class_alias('Twig_Node_Expression_Unary_Not', 'Twig\Node\Expression\Unary\NotUnary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php deleted file mode 100644 index eeff5452f..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php +++ /dev/null @@ -1,20 +0,0 @@ -raw('+'); - } -} - -class_alias('Twig_Node_Expression_Unary_Pos', 'Twig\Node\Expression\Unary\PosUnary', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Flush.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Flush.php deleted file mode 100644 index fcc461ac0..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Flush.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Node_Flush extends Twig_Node -{ - public function __construct($lineno, $tag) - { - parent::__construct(array(), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write("flush();\n") - ; - } -} - -class_alias('Twig_Node_Flush', 'Twig\Node\FlushNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/For.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/For.php deleted file mode 100644 index 914b70c98..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/For.php +++ /dev/null @@ -1,113 +0,0 @@ - - */ -class Twig_Node_For extends Twig_Node -{ - protected $loop; - - public function __construct(Twig_Node_Expression_AssignName $keyTarget, Twig_Node_Expression_AssignName $valueTarget, Twig_Node_Expression $seq, Twig_Node_Expression $ifexpr = null, Twig_NodeInterface $body, Twig_NodeInterface $else = null, $lineno, $tag = null) - { - $body = new Twig_Node(array($body, $this->loop = new Twig_Node_ForLoop($lineno, $tag))); - - if (null !== $ifexpr) { - $body = new Twig_Node_If(new Twig_Node(array($ifexpr, $body)), null, $lineno, $tag); - } - - $nodes = array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body); - if (null !== $else) { - $nodes['else'] = $else; - } - - parent::__construct($nodes, array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write("\$context['_parent'] = \$context;\n") - ->write("\$context['_seq'] = twig_ensure_traversable(") - ->subcompile($this->getNode('seq')) - ->raw(");\n") - ; - - if ($this->hasNode('else')) { - $compiler->write("\$context['_iterated'] = false;\n"); - } - - if ($this->getAttribute('with_loop')) { - $compiler - ->write("\$context['loop'] = array(\n") - ->write(" 'parent' => \$context['_parent'],\n") - ->write(" 'index0' => 0,\n") - ->write(" 'index' => 1,\n") - ->write(" 'first' => true,\n") - ->write(");\n") - ; - - if (!$this->getAttribute('ifexpr')) { - $compiler - ->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n") - ->indent() - ->write("\$length = count(\$context['_seq']);\n") - ->write("\$context['loop']['revindex0'] = \$length - 1;\n") - ->write("\$context['loop']['revindex'] = \$length;\n") - ->write("\$context['loop']['length'] = \$length;\n") - ->write("\$context['loop']['last'] = 1 === \$length;\n") - ->outdent() - ->write("}\n") - ; - } - } - - $this->loop->setAttribute('else', $this->hasNode('else')); - $this->loop->setAttribute('with_loop', $this->getAttribute('with_loop')); - $this->loop->setAttribute('ifexpr', $this->getAttribute('ifexpr')); - - $compiler - ->write("foreach (\$context['_seq'] as ") - ->subcompile($this->getNode('key_target')) - ->raw(' => ') - ->subcompile($this->getNode('value_target')) - ->raw(") {\n") - ->indent() - ->subcompile($this->getNode('body')) - ->outdent() - ->write("}\n") - ; - - if ($this->hasNode('else')) { - $compiler - ->write("if (!\$context['_iterated']) {\n") - ->indent() - ->subcompile($this->getNode('else')) - ->outdent() - ->write("}\n") - ; - } - - $compiler->write("\$_parent = \$context['_parent'];\n"); - - // remove some "private" loop variables (needed for nested loops) - $compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\'], $context[\'loop\']);'."\n"); - - // keep the values set in the inner context for variables defined in the outer context - $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n"); - } -} - -class_alias('Twig_Node_For', 'Twig\Node\ForNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/ForLoop.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/ForLoop.php deleted file mode 100644 index 06477cf1f..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/ForLoop.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ -class Twig_Node_ForLoop extends Twig_Node -{ - public function __construct($lineno, $tag = null) - { - parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - if ($this->getAttribute('else')) { - $compiler->write("\$context['_iterated'] = true;\n"); - } - - if ($this->getAttribute('with_loop')) { - $compiler - ->write("++\$context['loop']['index0'];\n") - ->write("++\$context['loop']['index'];\n") - ->write("\$context['loop']['first'] = false;\n") - ; - - if (!$this->getAttribute('ifexpr')) { - $compiler - ->write("if (isset(\$context['loop']['length'])) {\n") - ->indent() - ->write("--\$context['loop']['revindex0'];\n") - ->write("--\$context['loop']['revindex'];\n") - ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n") - ->outdent() - ->write("}\n") - ; - } - } - } -} - -class_alias('Twig_Node_ForLoop', 'Twig\Node\ForLoopNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/If.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/If.php deleted file mode 100644 index d82edec77..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/If.php +++ /dev/null @@ -1,68 +0,0 @@ - - */ -class Twig_Node_If extends Twig_Node -{ - public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null) - { - $nodes = array('tests' => $tests); - if (null !== $else) { - $nodes['else'] = $else; - } - - parent::__construct($nodes, array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) { - if ($i > 0) { - $compiler - ->outdent() - ->write('} elseif (') - ; - } else { - $compiler - ->write('if (') - ; - } - - $compiler - ->subcompile($this->getNode('tests')->getNode($i)) - ->raw(") {\n") - ->indent() - ->subcompile($this->getNode('tests')->getNode($i + 1)) - ; - } - - if ($this->hasNode('else')) { - $compiler - ->outdent() - ->write("} else {\n") - ->indent() - ->subcompile($this->getNode('else')) - ; - } - - $compiler - ->outdent() - ->write("}\n"); - } -} - -class_alias('Twig_Node_If', 'Twig\Node\IfNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Import.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Import.php deleted file mode 100644 index c77e320b7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Import.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -class Twig_Node_Import extends Twig_Node -{ - public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null) - { - parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write('') - ->subcompile($this->getNode('var')) - ->raw(' = ') - ; - - if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) { - $compiler->raw('$this'); - } else { - $compiler - ->raw('$this->loadTemplate(') - ->subcompile($this->getNode('expr')) - ->raw(', ') - ->repr($this->getTemplateName()) - ->raw(', ') - ->repr($this->getTemplateLine()) - ->raw(')') - ; - } - - $compiler->raw(";\n"); - } -} - -class_alias('Twig_Node_Import', 'Twig\Node\ImportNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Include.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Include.php deleted file mode 100644 index 2a5114cb8..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Include.php +++ /dev/null @@ -1,90 +0,0 @@ - - */ -class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface -{ - public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) - { - $nodes = array('expr' => $expr); - if (null !== $variables) { - $nodes['variables'] = $variables; - } - - parent::__construct($nodes, array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - if ($this->getAttribute('ignore_missing')) { - $compiler - ->write("try {\n") - ->indent() - ; - } - - $this->addGetTemplate($compiler); - - $compiler->raw('->display('); - - $this->addTemplateArguments($compiler); - - $compiler->raw(");\n"); - - if ($this->getAttribute('ignore_missing')) { - $compiler - ->outdent() - ->write("} catch (Twig_Error_Loader \$e) {\n") - ->indent() - ->write("// ignore missing template\n") - ->outdent() - ->write("}\n\n") - ; - } - } - - protected function addGetTemplate(Twig_Compiler $compiler) - { - $compiler - ->write('$this->loadTemplate(') - ->subcompile($this->getNode('expr')) - ->raw(', ') - ->repr($this->getTemplateName()) - ->raw(', ') - ->repr($this->getTemplateLine()) - ->raw(')') - ; - } - - protected function addTemplateArguments(Twig_Compiler $compiler) - { - if (!$this->hasNode('variables')) { - $compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()'); - } elseif (false === $this->getAttribute('only')) { - $compiler - ->raw('array_merge($context, ') - ->subcompile($this->getNode('variables')) - ->raw(')') - ; - } else { - $compiler->subcompile($this->getNode('variables')); - } - } -} - -class_alias('Twig_Node_Include', 'Twig\Node\IncludeNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Macro.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Macro.php deleted file mode 100644 index 3cf549770..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Macro.php +++ /dev/null @@ -1,125 +0,0 @@ - - */ -class Twig_Node_Macro extends Twig_Node -{ - const VARARGS_NAME = 'varargs'; - - public function __construct($name, Twig_NodeInterface $body, Twig_NodeInterface $arguments, $lineno, $tag = null) - { - foreach ($arguments as $argumentName => $argument) { - if (self::VARARGS_NAME === $argumentName) { - throw new Twig_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments.', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getTemplateLine()); - } - } - - parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write(sprintf('public function get%s(', $this->getAttribute('name'))) - ; - - $count = count($this->getNode('arguments')); - $pos = 0; - foreach ($this->getNode('arguments') as $name => $default) { - $compiler - ->raw('$__'.$name.'__ = ') - ->subcompile($default) - ; - - if (++$pos < $count) { - $compiler->raw(', '); - } - } - - if (PHP_VERSION_ID >= 50600) { - if ($count) { - $compiler->raw(', '); - } - - $compiler->raw('...$__varargs__'); - } - - $compiler - ->raw(")\n") - ->write("{\n") - ->indent() - ; - - $compiler - ->write("\$context = \$this->env->mergeGlobals(array(\n") - ->indent() - ; - - foreach ($this->getNode('arguments') as $name => $default) { - $compiler - ->write('') - ->string($name) - ->raw(' => $__'.$name.'__') - ->raw(",\n") - ; - } - - $compiler - ->write('') - ->string(self::VARARGS_NAME) - ->raw(' => ') - ; - - if (PHP_VERSION_ID >= 50600) { - $compiler->raw("\$__varargs__,\n"); - } else { - $compiler - ->raw('func_num_args() > ') - ->repr($count) - ->raw(' ? array_slice(func_get_args(), ') - ->repr($count) - ->raw(") : array(),\n") - ; - } - - $compiler - ->outdent() - ->write("));\n\n") - ->write("\$blocks = array();\n\n") - ->write("ob_start();\n") - ->write("try {\n") - ->indent() - ->subcompile($this->getNode('body')) - ->outdent() - ->write("} catch (Exception \$e) {\n") - ->indent() - ->write("ob_end_clean();\n\n") - ->write("throw \$e;\n") - ->outdent() - ->write("} catch (Throwable \$e) {\n") - ->indent() - ->write("ob_end_clean();\n\n") - ->write("throw \$e;\n") - ->outdent() - ->write("}\n\n") - ->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n") - ->outdent() - ->write("}\n\n") - ; - } -} - -class_alias('Twig_Node_Macro', 'Twig\Node\MacroNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Module.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Module.php deleted file mode 100644 index 5cd8d0502..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Module.php +++ /dev/null @@ -1,461 +0,0 @@ - - */ -class Twig_Node_Module extends Twig_Node -{ - private $source; - - public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $name, $source = '') - { - if (!$name instanceof Twig_Source) { - @trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED); - $this->source = new Twig_Source($source, $name); - } else { - $this->source = $name; - } - - $nodes = array( - 'body' => $body, - 'blocks' => $blocks, - 'macros' => $macros, - 'traits' => $traits, - 'display_start' => new Twig_Node(), - 'display_end' => new Twig_Node(), - 'constructor_start' => new Twig_Node(), - 'constructor_end' => new Twig_Node(), - 'class_end' => new Twig_Node(), - ); - if (null !== $parent) { - $nodes['parent'] = $parent; - } - - // embedded templates are set as attributes so that they are only visited once by the visitors - parent::__construct($nodes, array( - // source to be remove in 2.0 - 'source' => $this->source->getCode(), - // filename to be remove in 2.0 (use getTemplateName() instead) - 'filename' => $this->source->getName(), - 'index' => null, - 'embedded_templates' => $embeddedTemplates, - ), 1); - - // populate the template name of all node children - $this->setTemplateName($this->source->getName()); - } - - public function setIndex($index) - { - $this->setAttribute('index', $index); - } - - public function compile(Twig_Compiler $compiler) - { - $this->compileTemplate($compiler); - - foreach ($this->getAttribute('embedded_templates') as $template) { - $compiler->subcompile($template); - } - } - - protected function compileTemplate(Twig_Compiler $compiler) - { - if (!$this->getAttribute('index')) { - $compiler->write('compileClassHeader($compiler); - - if ( - count($this->getNode('blocks')) - || count($this->getNode('traits')) - || !$this->hasNode('parent') - || $this->getNode('parent') instanceof Twig_Node_Expression_Constant - || count($this->getNode('constructor_start')) - || count($this->getNode('constructor_end')) - ) { - $this->compileConstructor($compiler); - } - - $this->compileGetParent($compiler); - - $this->compileDisplay($compiler); - - $compiler->subcompile($this->getNode('blocks')); - - $this->compileMacros($compiler); - - $this->compileGetTemplateName($compiler); - - $this->compileIsTraitable($compiler); - - $this->compileDebugInfo($compiler); - - $this->compileGetSource($compiler); - - $this->compileGetSourceContext($compiler); - - $this->compileClassFooter($compiler); - } - - protected function compileGetParent(Twig_Compiler $compiler) - { - if (!$this->hasNode('parent')) { - return; - } - $parent = $this->getNode('parent'); - - $compiler - ->write("protected function doGetParent(array \$context)\n", "{\n") - ->indent() - ->addDebugInfo($parent) - ->write('return ') - ; - - if ($parent instanceof Twig_Node_Expression_Constant) { - $compiler->subcompile($parent); - } else { - $compiler - ->raw('$this->loadTemplate(') - ->subcompile($parent) - ->raw(', ') - ->repr($this->source->getName()) - ->raw(', ') - ->repr($parent->getTemplateLine()) - ->raw(')') - ; - } - - $compiler - ->raw(";\n") - ->outdent() - ->write("}\n\n") - ; - } - - protected function compileClassHeader(Twig_Compiler $compiler) - { - $compiler - ->write("\n\n") - // if the template name contains */, add a blank to avoid a PHP parse error - ->write('/* '.str_replace('*/', '* /', $this->source->getName())." */\n") - ->write('class '.$compiler->getEnvironment()->getTemplateClass($this->source->getName(), $this->getAttribute('index'))) - ->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass())) - ->write("{\n") - ->indent() - ; - } - - protected function compileConstructor(Twig_Compiler $compiler) - { - $compiler - ->write("public function __construct(Twig_Environment \$env)\n", "{\n") - ->indent() - ->subcompile($this->getNode('constructor_start')) - ->write("parent::__construct(\$env);\n\n") - ; - - // parent - if (!$this->hasNode('parent')) { - $compiler->write("\$this->parent = false;\n\n"); - } elseif (($parent = $this->getNode('parent')) && $parent instanceof Twig_Node_Expression_Constant) { - $compiler - ->addDebugInfo($parent) - ->write('$this->parent = $this->loadTemplate(') - ->subcompile($parent) - ->raw(', ') - ->repr($this->source->getName()) - ->raw(', ') - ->repr($parent->getTemplateLine()) - ->raw(");\n") - ; - } - - $countTraits = count($this->getNode('traits')); - if ($countTraits) { - // traits - foreach ($this->getNode('traits') as $i => $trait) { - $this->compileLoadTemplate($compiler, $trait->getNode('template'), sprintf('$_trait_%s', $i)); - - $compiler - ->addDebugInfo($trait->getNode('template')) - ->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i)) - ->indent() - ->write("throw new Twig_Error_Runtime('Template \"'.") - ->subcompile($trait->getNode('template')) - ->raw(".'\" cannot be used as a trait.');\n") - ->outdent() - ->write("}\n") - ->write(sprintf("\$_trait_%s_blocks = \$_trait_%s->getBlocks();\n\n", $i, $i)) - ; - - foreach ($trait->getNode('targets') as $key => $value) { - $compiler - ->write(sprintf('if (!isset($_trait_%s_blocks[', $i)) - ->string($key) - ->raw("])) {\n") - ->indent() - ->write("throw new Twig_Error_Runtime(sprintf('Block ") - ->string($key) - ->raw(' is not defined in trait ') - ->subcompile($trait->getNode('template')) - ->raw(".'));\n") - ->outdent() - ->write("}\n\n") - - ->write(sprintf('$_trait_%s_blocks[', $i)) - ->subcompile($value) - ->raw(sprintf('] = $_trait_%s_blocks[', $i)) - ->string($key) - ->raw(sprintf(']; unset($_trait_%s_blocks[', $i)) - ->string($key) - ->raw("]);\n\n") - ; - } - } - - if ($countTraits > 1) { - $compiler - ->write("\$this->traits = array_merge(\n") - ->indent() - ; - - for ($i = 0; $i < $countTraits; ++$i) { - $compiler - ->write(sprintf('$_trait_%s_blocks'.($i == $countTraits - 1 ? '' : ',')."\n", $i)) - ; - } - - $compiler - ->outdent() - ->write(");\n\n") - ; - } else { - $compiler - ->write("\$this->traits = \$_trait_0_blocks;\n\n") - ; - } - - $compiler - ->write("\$this->blocks = array_merge(\n") - ->indent() - ->write("\$this->traits,\n") - ->write("array(\n") - ; - } else { - $compiler - ->write("\$this->blocks = array(\n") - ; - } - - // blocks - $compiler - ->indent() - ; - - foreach ($this->getNode('blocks') as $name => $node) { - $compiler - ->write(sprintf("'%s' => array(\$this, 'block_%s'),\n", $name, $name)) - ; - } - - if ($countTraits) { - $compiler - ->outdent() - ->write(")\n") - ; - } - - $compiler - ->outdent() - ->write(");\n") - ->outdent() - ->subcompile($this->getNode('constructor_end')) - ->write("}\n\n") - ; - } - - protected function compileDisplay(Twig_Compiler $compiler) - { - $compiler - ->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n") - ->indent() - ->subcompile($this->getNode('display_start')) - ->subcompile($this->getNode('body')) - ; - - if ($this->hasNode('parent')) { - $parent = $this->getNode('parent'); - $compiler->addDebugInfo($parent); - if ($parent instanceof Twig_Node_Expression_Constant) { - $compiler->write('$this->parent'); - } else { - $compiler->write('$this->getParent($context)'); - } - $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n"); - } - - $compiler - ->subcompile($this->getNode('display_end')) - ->outdent() - ->write("}\n\n") - ; - } - - protected function compileClassFooter(Twig_Compiler $compiler) - { - $compiler - ->subcompile($this->getNode('class_end')) - ->outdent() - ->write("}\n") - ; - } - - protected function compileMacros(Twig_Compiler $compiler) - { - $compiler->subcompile($this->getNode('macros')); - } - - protected function compileGetTemplateName(Twig_Compiler $compiler) - { - $compiler - ->write("public function getTemplateName()\n", "{\n") - ->indent() - ->write('return ') - ->repr($this->source->getName()) - ->raw(";\n") - ->outdent() - ->write("}\n\n") - ; - } - - protected function compileIsTraitable(Twig_Compiler $compiler) - { - // A template can be used as a trait if: - // * it has no parent - // * it has no macros - // * it has no body - // - // Put another way, a template can be used as a trait if it - // only contains blocks and use statements. - $traitable = !$this->hasNode('parent') && 0 === count($this->getNode('macros')); - if ($traitable) { - if ($this->getNode('body') instanceof Twig_Node_Body) { - $nodes = $this->getNode('body')->getNode(0); - } else { - $nodes = $this->getNode('body'); - } - - if (!count($nodes)) { - $nodes = new Twig_Node(array($nodes)); - } - - foreach ($nodes as $node) { - if (!count($node)) { - continue; - } - - if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { - continue; - } - - if ($node instanceof Twig_Node_BlockReference) { - continue; - } - - $traitable = false; - break; - } - } - - if ($traitable) { - return; - } - - $compiler - ->write("public function isTraitable()\n", "{\n") - ->indent() - ->write(sprintf("return %s;\n", $traitable ? 'true' : 'false')) - ->outdent() - ->write("}\n\n") - ; - } - - protected function compileDebugInfo(Twig_Compiler $compiler) - { - $compiler - ->write("public function getDebugInfo()\n", "{\n") - ->indent() - ->write(sprintf("return %s;\n", str_replace("\n", '', var_export(array_reverse($compiler->getDebugInfo(), true), true)))) - ->outdent() - ->write("}\n\n") - ; - } - - protected function compileGetSource(Twig_Compiler $compiler) - { - $compiler - ->write("/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */\n") - ->write("public function getSource()\n", "{\n") - ->indent() - ->write("@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);\n\n") - ->write('return $this->getSourceContext()->getCode();') - ->raw("\n") - ->outdent() - ->write("}\n\n") - ; - } - - protected function compileGetSourceContext(Twig_Compiler $compiler) - { - $compiler - ->write("public function getSourceContext()\n", "{\n") - ->indent() - ->write('return new Twig_Source(') - ->string($compiler->getEnvironment()->isDebug() ? $this->source->getCode() : '') - ->raw(', ') - ->string($this->source->getName()) - ->raw(', ') - ->string($this->source->getPath()) - ->raw(");\n") - ->outdent() - ->write("}\n") - ; - } - - protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var) - { - if ($node instanceof Twig_Node_Expression_Constant) { - $compiler - ->write(sprintf('%s = $this->loadTemplate(', $var)) - ->subcompile($node) - ->raw(', ') - ->repr($node->getTemplateName()) - ->raw(', ') - ->repr($node->getTemplateLine()) - ->raw(");\n") - ; - } else { - throw new LogicException('Trait templates can only be constant nodes.'); - } - } -} - -class_alias('Twig_Node_Module', 'Twig\Node\ModuleNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Print.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Print.php deleted file mode 100644 index 374db89b7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Print.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface -{ - public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) - { - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write('echo ') - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ; - } -} - -class_alias('Twig_Node_Print', 'Twig\Node\PrintNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Sandbox.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Sandbox.php deleted file mode 100644 index 44b30ab9c..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Sandbox.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -class Twig_Node_Sandbox extends Twig_Node -{ - public function __construct(Twig_NodeInterface $body, $lineno, $tag = null) - { - parent::__construct(array('body' => $body), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write("\$sandbox = \$this->env->getExtension('Twig_Extension_Sandbox');\n") - ->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n") - ->indent() - ->write("\$sandbox->enableSandbox();\n") - ->outdent() - ->write("}\n") - ->subcompile($this->getNode('body')) - ->write("if (!\$alreadySandboxed) {\n") - ->indent() - ->write("\$sandbox->disableSandbox();\n") - ->outdent() - ->write("}\n") - ; - } -} - -class_alias('Twig_Node_Sandbox', 'Twig\Node\SandboxNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php deleted file mode 100644 index a08f21f56..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -class Twig_Node_SandboxedPrint extends Twig_Node_Print -{ - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write('echo $this->env->getExtension(\'Twig_Extension_Sandbox\')->ensureToStringAllowed(') - ->subcompile($this->getNode('expr')) - ->raw(");\n") - ; - } - - /** - * Removes node filters. - * - * This is mostly needed when another visitor adds filters (like the escaper one). - * - * @return Twig_Node - */ - protected function removeNodeFilter(Twig_Node $node) - { - if ($node instanceof Twig_Node_Expression_Filter) { - return $this->removeNodeFilter($node->getNode('node')); - } - - return $node; - } -} - -class_alias('Twig_Node_SandboxedPrint', 'Twig\Node\SandboxedPrintNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Set.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Set.php deleted file mode 100644 index 6c6743eeb..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Set.php +++ /dev/null @@ -1,98 +0,0 @@ - - */ -class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface -{ - public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null) - { - parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag); - - /* - * Optimizes the node when capture is used for a large block of text. - * - * {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig_Markup("foo"); - */ - if ($this->getAttribute('capture')) { - $this->setAttribute('safe', true); - - $values = $this->getNode('values'); - if ($values instanceof Twig_Node_Text) { - $this->setNode('values', new Twig_Node_Expression_Constant($values->getAttribute('data'), $values->getTemplateLine())); - $this->setAttribute('capture', false); - } - } - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - if (count($this->getNode('names')) > 1) { - $compiler->write('list('); - foreach ($this->getNode('names') as $idx => $node) { - if ($idx) { - $compiler->raw(', '); - } - - $compiler->subcompile($node); - } - $compiler->raw(')'); - } else { - if ($this->getAttribute('capture')) { - $compiler - ->write("ob_start();\n") - ->subcompile($this->getNode('values')) - ; - } - - $compiler->subcompile($this->getNode('names'), false); - - if ($this->getAttribute('capture')) { - $compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())"); - } - } - - if (!$this->getAttribute('capture')) { - $compiler->raw(' = '); - - if (count($this->getNode('names')) > 1) { - $compiler->write('array('); - foreach ($this->getNode('values') as $idx => $value) { - if ($idx) { - $compiler->raw(', '); - } - - $compiler->subcompile($value); - } - $compiler->raw(')'); - } else { - if ($this->getAttribute('safe')) { - $compiler - ->raw("('' === \$tmp = ") - ->subcompile($this->getNode('values')) - ->raw(") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())") - ; - } else { - $compiler->subcompile($this->getNode('values')); - } - } - } - - $compiler->raw(";\n"); - } -} - -class_alias('Twig_Node_Set', 'Twig\Node\SetNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/SetTemp.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/SetTemp.php deleted file mode 100644 index 996fdcde7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/SetTemp.php +++ /dev/null @@ -1,40 +0,0 @@ - $name), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $name = $this->getAttribute('name'); - $compiler - ->addDebugInfo($this) - ->write('if (isset($context[') - ->string($name) - ->raw('])) { $_') - ->raw($name) - ->raw('_ = $context[') - ->repr($name) - ->raw(']; } else { $_') - ->raw($name) - ->raw("_ = null; }\n") - ; - } -} - -class_alias('Twig_Node_SetTemp', 'Twig\Node\SetTempNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Spaceless.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Spaceless.php deleted file mode 100644 index 76f90cde5..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Spaceless.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -class Twig_Node_Spaceless extends Twig_Node -{ - public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless') - { - parent::__construct(array('body' => $body), array(), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write("ob_start();\n") - ->subcompile($this->getNode('body')) - ->write("echo trim(preg_replace('/>\s+<', ob_get_clean()));\n") - ; - } -} - -class_alias('Twig_Node_Spaceless', 'Twig\Node\SpacelessNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/Text.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/Text.php deleted file mode 100644 index f4577fee2..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/Text.php +++ /dev/null @@ -1,36 +0,0 @@ - - */ -class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface -{ - public function __construct($data, $lineno) - { - parent::__construct(array(), array('data' => $data), $lineno); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->addDebugInfo($this) - ->write('echo ') - ->string($this->getAttribute('data')) - ->raw(";\n") - ; - } -} - -class_alias('Twig_Node_Text', 'Twig\Node\TextNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Node/With.php b/lib/silex/vendor/twig/twig/lib/Twig/Node/With.php deleted file mode 100644 index 2ab0ea5d7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Node/With.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ -class Twig_Node_With extends Twig_Node -{ - public function __construct(Twig_Node $body, Twig_Node $variables = null, $only = false, $lineno, $tag = null) - { - $nodes = array('body' => $body); - if (null !== $variables) { - $nodes['variables'] = $variables; - } - - parent::__construct($nodes, array('only' => (bool) $only), $lineno, $tag); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - if ($this->hasNode('variables')) { - $varsName = $compiler->getVarName(); - $compiler - ->write(sprintf('$%s = ', $varsName)) - ->subcompile($this->getNode('variables')) - ->raw(";\n") - ->write(sprintf("if (!is_array(\$%s)) {\n", $varsName)) - ->indent() - ->write("throw new Twig_Error_Runtime('Variables passed to the \"with\" tag must be a hash.');\n") - ->outdent() - ->write("}\n") - ; - - if ($this->getAttribute('only')) { - $compiler->write("\$context = array('_parent' => \$context);\n"); - } else { - $compiler->write("\$context['_parent'] = \$context;\n"); - } - - $compiler->write(sprintf("\$context = array_merge(\$context, \$%s);\n", $varsName)); - } else { - $compiler->write("\$context['_parent'] = \$context;\n"); - } - - $compiler - ->subcompile($this->getNode('body')) - ->write("\$context = \$context['_parent'];\n") - ; - } -} - -class_alias('Twig_Node_With', 'Twig\Node\WithNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeCaptureInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeCaptureInterface.php deleted file mode 100644 index 6638834b1..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeCaptureInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -interface Twig_NodeCaptureInterface -{ -} - -class_alias('Twig_NodeCaptureInterface', 'Twig\Node\NodeCaptureInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeInterface.php deleted file mode 100644 index 78e758bd4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_NodeInterface extends Countable, IteratorAggregate -{ - /** - * Compiles the node to PHP. - */ - public function compile(Twig_Compiler $compiler); - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function getLine(); - - public function getNodeTag(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeOutputInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeOutputInterface.php deleted file mode 100644 index 5a8eaa9c3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeOutputInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -interface Twig_NodeOutputInterface -{ -} - -class_alias('Twig_NodeOutputInterface', 'Twig\Node\NodeOutputInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeTraverser.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeTraverser.php deleted file mode 100644 index 787629ce3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeTraverser.php +++ /dev/null @@ -1,84 +0,0 @@ - - */ -class Twig_NodeTraverser -{ - protected $env; - protected $visitors = array(); - - /** - * @param Twig_Environment $env - * @param Twig_NodeVisitorInterface[] $visitors - */ - public function __construct(Twig_Environment $env, array $visitors = array()) - { - $this->env = $env; - foreach ($visitors as $visitor) { - $this->addVisitor($visitor); - } - } - - public function addVisitor(Twig_NodeVisitorInterface $visitor) - { - if (!isset($this->visitors[$visitor->getPriority()])) { - $this->visitors[$visitor->getPriority()] = array(); - } - - $this->visitors[$visitor->getPriority()][] = $visitor; - } - - /** - * Traverses a node and calls the registered visitors. - * - * @return Twig_NodeInterface - */ - public function traverse(Twig_NodeInterface $node) - { - ksort($this->visitors); - foreach ($this->visitors as $visitors) { - foreach ($visitors as $visitor) { - $node = $this->traverseForVisitor($visitor, $node); - } - } - - return $node; - } - - protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null) - { - if (null === $node) { - return; - } - - $node = $visitor->enterNode($node, $this->env); - - foreach ($node as $k => $n) { - if (false !== $n = $this->traverseForVisitor($visitor, $n)) { - $node->setNode($k, $n); - } else { - $node->removeNode($k); - } - } - - return $visitor->leaveNode($node, $this->env); - } -} - -class_alias('Twig_NodeTraverser', 'Twig\NodeTraverser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php deleted file mode 100644 index 1a1ae66f7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php +++ /dev/null @@ -1,154 +0,0 @@ - - */ -class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor -{ - protected $statusStack = array(); - protected $blocks = array(); - protected $safeAnalysis; - protected $traverser; - protected $defaultStrategy = false; - protected $safeVars = array(); - - public function __construct() - { - $this->safeAnalysis = new Twig_NodeVisitor_SafeAnalysis(); - } - - protected function doEnterNode(Twig_Node $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Module) { - if ($env->hasExtension('Twig_Extension_Escaper') && $defaultStrategy = $env->getExtension('Twig_Extension_Escaper')->getDefaultStrategy($node->getTemplateName())) { - $this->defaultStrategy = $defaultStrategy; - } - $this->safeVars = array(); - $this->blocks = 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; - } - - protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Module) { - $this->defaultStrategy = false; - $this->safeVars = array(); - $this->blocks = array(); - } elseif ($node instanceof Twig_Node_Expression_Filter) { - return $this->preEscapeFilterNode($node, $env); - } elseif ($node instanceof Twig_Node_Print) { - return $this->escapePrintNode($node, $env, $this->needEscaping($env)); - } - - if ($node instanceof Twig_Node_AutoEscape || $node instanceof Twig_Node_Block) { - array_pop($this->statusStack); - } elseif ($node instanceof Twig_Node_BlockReference) { - $this->blocks[$node->getAttribute('name')] = $this->needEscaping($env); - } - - return $node; - } - - protected function escapePrintNode(Twig_Node_Print $node, Twig_Environment $env, $type) - { - if (false === $type) { - return $node; - } - - $expression = $node->getNode('expr'); - - if ($this->isSafeFor($type, $expression, $env)) { - return $node; - } - - $class = get_class($node); - - return new $class( - $this->getEscaperFilter($type, $expression), - $node->getTemplateLine() - ); - } - - protected function preEscapeFilterNode(Twig_Node_Expression_Filter $filter, Twig_Environment $env) - { - $name = $filter->getNode('filter')->getAttribute('value'); - - $type = $env->getFilter($name)->getPreEscape(); - if (null === $type) { - return $filter; - } - - $node = $filter->getNode('node'); - if ($this->isSafeFor($type, $node, $env)) { - return $filter; - } - - $filter->setNode('node', $this->getEscaperFilter($type, $node)); - - return $filter; - } - - protected function isSafeFor($type, Twig_NodeInterface $expression, $env) - { - $safe = $this->safeAnalysis->getSafe($expression); - - if (null === $safe) { - 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); - } - - return in_array($type, $safe) || in_array('all', $safe); - } - - protected function needEscaping(Twig_Environment $env) - { - if (count($this->statusStack)) { - return $this->statusStack[count($this->statusStack) - 1]; - } - - return $this->defaultStrategy ? $this->defaultStrategy : false; - } - - protected function getEscaperFilter($type, Twig_NodeInterface $node) - { - $line = $node->getTemplateLine(); - $name = new Twig_Node_Expression_Constant('escape', $line); - $args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line))); - - return new Twig_Node_Expression_Filter($node, $name, $args, $line); - } - - public function getPriority() - { - return 0; - } -} - -class_alias('Twig_NodeVisitor_Escaper', 'Twig\NodeVisitor\EscaperNodeVisitor', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php deleted file mode 100644 index 2fa19f3d7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +++ /dev/null @@ -1,253 +0,0 @@ - - */ -class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor -{ - const OPTIMIZE_ALL = -1; - const OPTIMIZE_NONE = 0; - const OPTIMIZE_FOR = 2; - const OPTIMIZE_RAW_FILTER = 4; - const OPTIMIZE_VAR_ACCESS = 8; - - protected $loops = array(); - protected $loopsTargets = array(); - protected $optimizers; - protected $prependedNodes = array(); - protected $inABody = false; - - /** - * @param int $optimizers The optimizer mode - */ - public function __construct($optimizers = -1) - { - if (!is_int($optimizers) || $optimizers > (self::OPTIMIZE_FOR | self::OPTIMIZE_RAW_FILTER | self::OPTIMIZE_VAR_ACCESS)) { - throw new InvalidArgumentException(sprintf('Optimizer mode "%s" is not valid.', $optimizers)); - } - - $this->optimizers = $optimizers; - } - - protected function doEnterNode(Twig_Node $node, Twig_Environment $env) - { - if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) { - $this->enterOptimizeFor($node, $env); - } - - if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('Twig_Extension_Sandbox')) { - if ($this->inABody) { - if (!$node instanceof Twig_Node_Expression) { - if (get_class($node) !== 'Twig_Node') { - array_unshift($this->prependedNodes, array()); - } - } else { - $node = $this->optimizeVariables($node, $env); - } - } elseif ($node instanceof Twig_Node_Body) { - $this->inABody = true; - } - } - - return $node; - } - - protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) - { - $expression = $node instanceof Twig_Node_Expression; - - if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) { - $this->leaveOptimizeFor($node, $env); - } - - if (self::OPTIMIZE_RAW_FILTER === (self::OPTIMIZE_RAW_FILTER & $this->optimizers)) { - $node = $this->optimizeRawFilter($node, $env); - } - - $node = $this->optimizePrintNode($node, $env); - - if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('Twig_Extension_Sandbox')) { - if ($node instanceof Twig_Node_Body) { - $this->inABody = false; - } elseif ($this->inABody) { - if (!$expression && get_class($node) !== 'Twig_Node' && $prependedNodes = array_shift($this->prependedNodes)) { - $nodes = array(); - foreach (array_unique($prependedNodes) as $name) { - $nodes[] = new Twig_Node_SetTemp($name, $node->getTemplateLine()); - } - - $nodes[] = $node; - $node = new Twig_Node($nodes); - } - } - } - - return $node; - } - - protected function optimizeVariables(Twig_NodeInterface $node, Twig_Environment $env) - { - if ('Twig_Node_Expression_Name' === get_class($node) && $node->isSimple()) { - $this->prependedNodes[0][] = $node->getAttribute('name'); - - return new Twig_Node_Expression_TempName($node->getAttribute('name'), $node->getTemplateLine()); - } - - return $node; - } - - /** - * Optimizes print nodes. - * - * It replaces: - * - * * "echo $this->render(Parent)Block()" with "$this->display(Parent)Block()" - * - * @return Twig_NodeInterface - */ - protected function optimizePrintNode(Twig_NodeInterface $node, Twig_Environment $env) - { - if (!$node instanceof Twig_Node_Print) { - return $node; - } - - $exprNode = $node->getNode('expr'); - if ( - $exprNode instanceof Twig_Node_Expression_BlockReference || - $exprNode instanceof Twig_Node_Expression_Parent - ) { - $exprNode->setAttribute('output', true); - - return $exprNode; - } - - return $node; - } - - /** - * Removes "raw" filters. - * - * @return Twig_NodeInterface - */ - protected function optimizeRawFilter(Twig_NodeInterface $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Expression_Filter && 'raw' == $node->getNode('filter')->getAttribute('value')) { - return $node->getNode('node'); - } - - return $node; - } - - /** - * Optimizes "for" tag by removing the "loop" variable creation whenever possible. - */ - protected function enterOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_For) { - // disable the loop variable by default - $node->setAttribute('with_loop', false); - array_unshift($this->loops, $node); - array_unshift($this->loopsTargets, $node->getNode('value_target')->getAttribute('name')); - array_unshift($this->loopsTargets, $node->getNode('key_target')->getAttribute('name')); - } elseif (!$this->loops) { - // we are outside a loop - return; - } - - // when do we need to add the loop variable back? - - // the loop variable is referenced for the current loop - elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) { - $node->setAttribute('always_defined', true); - $this->addLoopToCurrent(); - } - - // optimize access to loop targets - elseif ($node instanceof Twig_Node_Expression_Name && in_array($node->getAttribute('name'), $this->loopsTargets)) { - $node->setAttribute('always_defined', true); - } - - // block reference - elseif ($node instanceof Twig_Node_BlockReference || $node instanceof Twig_Node_Expression_BlockReference) { - $this->addLoopToCurrent(); - } - - // include without the only attribute - elseif ($node instanceof Twig_Node_Include && !$node->getAttribute('only')) { - $this->addLoopToAll(); - } - - // include function without the with_context=false parameter - elseif ($node instanceof Twig_Node_Expression_Function - && 'include' === $node->getAttribute('name') - && (!$node->getNode('arguments')->hasNode('with_context') - || false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value') - ) - ) { - $this->addLoopToAll(); - } - - // the loop variable is referenced via an attribute - elseif ($node instanceof Twig_Node_Expression_GetAttr - && (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant - || 'parent' === $node->getNode('attribute')->getAttribute('value') - ) - && (true === $this->loops[0]->getAttribute('with_loop') - || ($node->getNode('node') instanceof Twig_Node_Expression_Name - && 'loop' === $node->getNode('node')->getAttribute('name') - ) - ) - ) { - $this->addLoopToAll(); - } - } - - /** - * Optimizes "for" tag by removing the "loop" variable creation whenever possible. - */ - protected function leaveOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_For) { - array_shift($this->loops); - array_shift($this->loopsTargets); - array_shift($this->loopsTargets); - } - } - - protected function addLoopToCurrent() - { - $this->loops[0]->setAttribute('with_loop', true); - } - - protected function addLoopToAll() - { - foreach ($this->loops as $loop) { - $loop->setAttribute('with_loop', true); - } - } - - public function getPriority() - { - return 255; - } -} - -class_alias('Twig_NodeVisitor_Optimizer', 'Twig\NodeVisitor\OptimizerNodeVisitor', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php deleted file mode 100644 index ca31c8fc7..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php +++ /dev/null @@ -1,150 +0,0 @@ -safeVars = $safeVars; - } - - public function getSafe(Twig_NodeInterface $node) - { - $hash = spl_object_hash($node); - if (!isset($this->data[$hash])) { - return; - } - - foreach ($this->data[$hash] as $bucket) { - if ($bucket['key'] !== $node) { - continue; - } - - if (in_array('html_attr', $bucket['value'])) { - $bucket['value'][] = 'html'; - } - - return $bucket['value']; - } - } - - protected function setSafe(Twig_NodeInterface $node, array $safe) - { - $hash = spl_object_hash($node); - if (isset($this->data[$hash])) { - foreach ($this->data[$hash] as &$bucket) { - if ($bucket['key'] === $node) { - $bucket['value'] = $safe; - - return; - } - } - } - $this->data[$hash][] = array( - 'key' => $node, - 'value' => $safe, - ); - } - - protected function doEnterNode(Twig_Node $node, Twig_Environment $env) - { - return $node; - } - - protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Expression_Constant) { - // constants are marked safe for all - $this->setSafe($node, array('all')); - } elseif ($node instanceof Twig_Node_Expression_BlockReference) { - // blocks are safe by definition - $this->setSafe($node, array('all')); - } elseif ($node instanceof Twig_Node_Expression_Parent) { - // parent block is safe by definition - $this->setSafe($node, array('all')); - } elseif ($node instanceof Twig_Node_Expression_Conditional) { - // intersect safeness of both operands - $safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3'))); - $this->setSafe($node, $safe); - } elseif ($node instanceof Twig_Node_Expression_Filter) { - // filter expression is safe when the filter is safe - $name = $node->getNode('filter')->getAttribute('value'); - $args = $node->getNode('arguments'); - if (false !== $filter = $env->getFilter($name)) { - $safe = $filter->getSafe($args); - if (null === $safe) { - $safe = $this->intersectSafe($this->getSafe($node->getNode('node')), $filter->getPreservesSafety()); - } - $this->setSafe($node, $safe); - } else { - $this->setSafe($node, array()); - } - } elseif ($node instanceof Twig_Node_Expression_Function) { - // function expression is safe when the function is safe - $name = $node->getAttribute('name'); - $args = $node->getNode('arguments'); - $function = $env->getFunction($name); - if (false !== $function) { - $this->setSafe($node, $function->getSafe($args)); - } else { - $this->setSafe($node, array()); - } - } elseif ($node instanceof Twig_Node_Expression_MethodCall) { - if ($node->getAttribute('safe')) { - $this->setSafe($node, array('all')); - } 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()); - } - - return $node; - } - - protected function intersectSafe(array $a = null, array $b = null) - { - if (null === $a || null === $b) { - return array(); - } - - if (in_array('all', $a)) { - return $b; - } - - if (in_array('all', $b)) { - return $a; - } - - return array_intersect($a, $b); - } - - public function getPriority() - { - return 0; - } -} - -class_alias('Twig_NodeVisitor_SafeAnalysis', 'Twig\NodeVisitor\SafeAnalysisNodeVisitor', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php deleted file mode 100644 index b631b29d4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php +++ /dev/null @@ -1,77 +0,0 @@ - - */ -class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor -{ - protected $inAModule = false; - protected $tags; - protected $filters; - protected $functions; - - protected function doEnterNode(Twig_Node $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Module) { - $this->inAModule = true; - $this->tags = array(); - $this->filters = array(); - $this->functions = array(); - - return $node; - } elseif ($this->inAModule) { - // look for tags - if ($node->getNodeTag() && !isset($this->tags[$node->getNodeTag()])) { - $this->tags[$node->getNodeTag()] = $node; - } - - // look for filters - if ($node instanceof Twig_Node_Expression_Filter && !isset($this->filters[$node->getNode('filter')->getAttribute('value')])) { - $this->filters[$node->getNode('filter')->getAttribute('value')] = $node; - } - - // look for functions - if ($node instanceof Twig_Node_Expression_Function && !isset($this->functions[$node->getAttribute('name')])) { - $this->functions[$node->getAttribute('name')] = $node; - } - - // wrap print to check __toString() calls - if ($node instanceof Twig_Node_Print) { - return new Twig_Node_SandboxedPrint($node->getNode('expr'), $node->getTemplateLine(), $node->getNodeTag()); - } - } - - return $node; - } - - protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Module) { - $this->inAModule = false; - - $node->setNode('display_start', new Twig_Node(array(new Twig_Node_CheckSecurity($this->filters, $this->tags, $this->functions), $node->getNode('display_start')))); - } - - return $node; - } - - public function getPriority() - { - return 0; - } -} - -class_alias('Twig_NodeVisitor_Sandbox', 'Twig\NodeVisitor\SandboxNodeVisitor', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php deleted file mode 100644 index 1270a3724..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/NodeVisitorInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -interface Twig_NodeVisitorInterface -{ - /** - * Called before child nodes are visited. - * - * @return Twig_NodeInterface The modified node - */ - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env); - - /** - * Called after child nodes are visited. - * - * @return Twig_NodeInterface|false The modified node or false if the node must be removed - */ - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); - - /** - * Returns the priority for this visitor. - * - * Priority should be between -10 and 10 (0 is the default). - * - * @return int The priority level - */ - public function getPriority(); -} - -class_alias('Twig_NodeVisitorInterface', 'Twig\NodeVisitor\NodeVisitorInterface', false); -class_exists('Twig_Environment'); -class_exists('Twig_Node'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Parser.php b/lib/silex/vendor/twig/twig/lib/Twig/Parser.php deleted file mode 100644 index e796f197a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Parser.php +++ /dev/null @@ -1,410 +0,0 @@ - - */ -class Twig_Parser implements Twig_ParserInterface -{ - protected $stack = array(); - protected $stream; - protected $parent; - protected $handlers; - protected $visitors; - protected $expressionParser; - protected $blocks; - protected $blockStack; - protected $macros; - protected $env; - protected $reservedMacroNames; - protected $importedSymbols; - protected $traits; - protected $embeddedTemplates = array(); - - public function __construct(Twig_Environment $env) - { - $this->env = $env; - } - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function getEnvironment() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED); - - return $this->env; - } - - public function getVarName() - { - return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false)); - } - - /** - * @deprecated since 1.27 (to be removed in 2.0). Use $parser->getStream()->getSourceContext()->getPath() instead. - */ - public function getFilename() - { - @trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use $parser->getStream()->getSourceContext()->getPath() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->stream->getSourceContext()->getName(); - } - - public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false) - { - // push all variables into the stack to keep the current state of the parser - // using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336 - // This hack can be removed when min version if PHP 7.0 - $vars = array(); - foreach ($this as $k => $v) { - $vars[$k] = $v; - } - - unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames']); - $this->stack[] = $vars; - - // tag handlers - if (null === $this->handlers) { - $this->handlers = $this->env->getTokenParsers(); - $this->handlers->setParser($this); - } - - // node visitors - if (null === $this->visitors) { - $this->visitors = $this->env->getNodeVisitors(); - } - - if (null === $this->expressionParser) { - $this->expressionParser = new Twig_ExpressionParser($this, $this->env); - } - - $this->stream = $stream; - $this->parent = null; - $this->blocks = array(); - $this->macros = array(); - $this->traits = array(); - $this->blockStack = array(); - $this->importedSymbols = array(array()); - $this->embeddedTemplates = array(); - - try { - $body = $this->subparse($test, $dropNeedle); - - if (null !== $this->parent && null === $body = $this->filterBodyNodes($body)) { - $body = new Twig_Node(); - } - } catch (Twig_Error_Syntax $e) { - if (!$e->getSourceContext()) { - $e->setSourceContext($this->stream->getSourceContext()); - } - - 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, $stream->getSourceContext()); - - $traverser = new Twig_NodeTraverser($this->env, $this->visitors); - - $node = $traverser->traverse($node); - - // restore previous stack so previous parse() call can resume working - foreach (array_pop($this->stack) as $key => $val) { - $this->$key = $val; - } - - return $node; - } - - public function subparse($test, $dropNeedle = false) - { - $lineno = $this->getCurrentToken()->getLine(); - $rv = array(); - while (!$this->stream->isEOF()) { - switch ($this->getCurrentToken()->getType()) { - case Twig_Token::TEXT_TYPE: - $token = $this->stream->next(); - $rv[] = new Twig_Node_Text($token->getValue(), $token->getLine()); - break; - - case Twig_Token::VAR_START_TYPE: - $token = $this->stream->next(); - $expr = $this->expressionParser->parseExpression(); - $this->stream->expect(Twig_Token::VAR_END_TYPE); - $rv[] = new Twig_Node_Print($expr, $token->getLine()); - break; - - case Twig_Token::BLOCK_START_TYPE: - $this->stream->next(); - $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->getSourceContext()); - } - - if (null !== $test && call_user_func($test, $token)) { - if ($dropNeedle) { - $this->stream->next(); - } - - if (1 === count($rv)) { - return $rv[0]; - } - - return new Twig_Node($rv, array(), $lineno); - } - - $subparser = $this->handlers->getTokenParser($token->getValue()); - if (null === $subparser) { - if (null !== $test) { - $e = new Twig_Error_Syntax(sprintf('Unexpected "%s" tag', $token->getValue()), $token->getLine(), $this->stream->getSourceContext()); - - if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) { - $e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno)); - } - } else { - $e = new Twig_Error_Syntax(sprintf('Unknown "%s" tag.', $token->getValue()), $token->getLine(), $this->stream->getSourceContext()); - $e->addSuggestions($token->getValue(), array_keys($this->env->getTags())); - } - - throw $e; - } - - $this->stream->next(); - - $node = $subparser->parse($token); - if (null !== $node) { - $rv[] = $node; - } - break; - - default: - throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', $this->getCurrentToken()->getLine(), $this->stream->getSourceContext()); - } - } - - if (1 === count($rv)) { - return $rv[0]; - } - - return new Twig_Node($rv, array(), $lineno); - } - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function addHandler($name, $class) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED); - - $this->handlers[$name] = $class; - } - - /** - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED); - - $this->visitors[] = $visitor; - } - - public function getBlockStack() - { - return $this->blockStack; - } - - public function peekBlockStack() - { - return $this->blockStack[count($this->blockStack) - 1]; - } - - public function popBlockStack() - { - array_pop($this->blockStack); - } - - public function pushBlockStack($name) - { - $this->blockStack[] = $name; - } - - public function hasBlock($name) - { - return isset($this->blocks[$name]); - } - - public function getBlock($name) - { - return $this->blocks[$name]; - } - - public function setBlock($name, Twig_Node_Block $value) - { - $this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getTemplateLine()); - } - - public function hasMacro($name) - { - return isset($this->macros[$name]); - } - - public function setMacro($name, Twig_Node_Macro $node) - { - if ($this->isReservedMacroName($name)) { - throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword.', $name), $node->getTemplateLine(), $this->stream->getSourceContext()); - } - - $this->macros[$name] = $node; - } - - public function isReservedMacroName($name) - { - if (null === $this->reservedMacroNames) { - $this->reservedMacroNames = array(); - $r = new ReflectionClass($this->env->getBaseTemplateClass()); - foreach ($r->getMethods() as $method) { - $methodName = strtolower($method->getName()); - - if ('get' === substr($methodName, 0, 3) && isset($methodName[3])) { - $this->reservedMacroNames[] = substr($methodName, 3); - } - } - } - - return in_array(strtolower($name), $this->reservedMacroNames); - } - - public function addTrait($trait) - { - $this->traits[] = $trait; - } - - public function hasTraits() - { - return count($this->traits) > 0; - } - - public function embedTemplate(Twig_Node_Module $template) - { - $template->setIndex(mt_rand()); - - $this->embeddedTemplates[] = $template; - } - - public function addImportedSymbol($type, $alias, $name = null, Twig_Node_Expression $node = null) - { - $this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node); - } - - public function getImportedSymbol($type, $alias) - { - foreach ($this->importedSymbols as $functions) { - if (isset($functions[$type][$alias])) { - return $functions[$type][$alias]; - } - } - } - - public function isMainScope() - { - return 1 === count($this->importedSymbols); - } - - public function pushLocalScope() - { - array_unshift($this->importedSymbols, array()); - } - - public function popLocalScope() - { - array_shift($this->importedSymbols); - } - - /** - * @return Twig_ExpressionParser - */ - public function getExpressionParser() - { - return $this->expressionParser; - } - - public function getParent() - { - return $this->parent; - } - - public function setParent($parent) - { - $this->parent = $parent; - } - - /** - * @return Twig_TokenStream - */ - public function getStream() - { - return $this->stream; - } - - /** - * @return Twig_Token - */ - public function getCurrentToken() - { - return $this->stream->getCurrent(); - } - - protected function filterBodyNodes(Twig_NodeInterface $node) - { - // check that the body does not contain non-empty output nodes - if ( - ($node instanceof Twig_Node_Text && !ctype_space($node->getAttribute('data'))) - || - (!$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 start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext()); - } - - throw new Twig_Error_Syntax('A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext()); - } - - // bypass nodes that will "capture" the output - if ($node instanceof Twig_NodeCaptureInterface) { - return $node; - } - - if ($node instanceof Twig_NodeOutputInterface) { - return; - } - - foreach ($node as $k => $n) { - if (null !== $n && null === $this->filterBodyNodes($n)) { - $node->removeNode($k); - } - } - - return $node; - } -} - -class_alias('Twig_Parser', 'Twig\Parser', false); -class_exists('Twig_Node'); -class_exists('Twig_TokenStream'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/ParserInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/ParserInterface.php deleted file mode 100644 index 85c6e67b2..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/ParserInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_ParserInterface -{ - /** - * Converts a token stream to a node tree. - * - * @return Twig_Node_Module - * - * @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong - */ - public function parse(Twig_TokenStream $stream); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Base.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Base.php deleted file mode 100644 index 913afd4f0..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Base.php +++ /dev/null @@ -1,62 +0,0 @@ - - */ -abstract class Twig_Profiler_Dumper_Base -{ - private $root; - - public function dump(Twig_Profiler_Profile $profile) - { - return $this->dumpProfile($profile); - } - - abstract protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix); - - abstract protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix); - - abstract protected function formatTime(Twig_Profiler_Profile $profile, $percent); - - private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false) - { - if ($profile->isRoot()) { - $this->root = $profile->getDuration(); - $start = $profile->getName(); - } else { - if ($profile->isTemplate()) { - $start = $this->formatTemplate($profile, $prefix); - } else { - $start = $this->formatNonTemplate($profile, $prefix); - } - $prefix .= $sibling ? '│ ' : ' '; - } - - $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0; - - if ($profile->getDuration() * 1000 < 1) { - $str = $start."\n"; - } else { - $str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent)); - } - - $nCount = count($profile->getProfiles()); - foreach ($profile as $i => $p) { - $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount); - } - - return $str; - } -} - -class_alias('Twig_Profiler_Dumper_Base', 'Twig\Profiler\Dumper\BaseDumper', false); -class_exists('Twig_Profiler_Profile'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php deleted file mode 100644 index 7a33baf2d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_Dumper_Blackfire -{ - public function dump(Twig_Profiler_Profile $profile) - { - $data = array(); - $this->dumpProfile('main()', $profile, $data); - $this->dumpChildren('main()', $profile, $data); - - $start = sprintf('%f', microtime(true)); - $str = << $values) { - $str .= "{$name}//{$values['ct']} {$values['wt']} {$values['mu']} {$values['pmu']}\n"; - } - - return $str; - } - - private function dumpChildren($parent, Twig_Profiler_Profile $profile, &$data) - { - foreach ($profile as $p) { - if ($p->isTemplate()) { - $name = $p->getTemplate(); - } else { - $name = sprintf('%s::%s(%s)', $p->getTemplate(), $p->getType(), $p->getName()); - } - $this->dumpProfile(sprintf('%s==>%s', $parent, $name), $p, $data); - $this->dumpChildren($name, $p, $data); - } - } - - private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data) - { - if (isset($data[$edge])) { - $data[$edge]['ct'] += 1; - $data[$edge]['wt'] += floor($profile->getDuration() * 1000000); - $data[$edge]['mu'] += $profile->getMemoryUsage(); - $data[$edge]['pmu'] += $profile->getPeakMemoryUsage(); - } else { - $data[$edge] = array( - 'ct' => 1, - 'wt' => floor($profile->getDuration() * 1000000), - 'mu' => $profile->getMemoryUsage(), - 'pmu' => $profile->getPeakMemoryUsage(), - ); - } - } -} - -class_alias('Twig_Profiler_Dumper_Blackfire', 'Twig\Profiler\Dumper\BlackfireDumper', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php deleted file mode 100644 index b57a25517..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Base -{ - private static $colors = array( - 'block' => '#dfd', - 'macro' => '#ddf', - 'template' => '#ffd', - 'big' => '#d44', - ); - - public function dump(Twig_Profiler_Profile $profile) - { - return '
    '.parent::dump($profile).'
    '; - } - - protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s', $prefix, self::$colors['template'], $profile->getTemplate()); - } - - protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName()); - } - - protected function formatTime(Twig_Profiler_Profile $profile, $percent) - { - return sprintf('%.2fms/%.0f%%', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent); - } -} - -class_alias('Twig_Profiler_Dumper_Html', 'Twig\Profiler\Dumper\HtmlDumper', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php deleted file mode 100644 index 69d2c4bf3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_Dumper_Text extends Twig_Profiler_Dumper_Base -{ - protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s', $prefix, $profile->getTemplate()); - } - - protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName()); - } - - protected function formatTime(Twig_Profiler_Profile $profile, $percent) - { - return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent); - } -} - -class_alias('Twig_Profiler_Dumper_Text', 'Twig\Profiler\Dumper\TextDumper', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php deleted file mode 100644 index 69c8f7970..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -class Twig_Profiler_Node_EnterProfile extends Twig_Node -{ - public function __construct($extensionName, $type, $name, $varName) - { - parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName)); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name'))) - ->repr($this->getAttribute('extension_name')) - ->raw(");\n") - ->write(sprintf('$%s->enter($%s = new Twig_Profiler_Profile($this->getTemplateName(), ', $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) - ->repr($this->getAttribute('type')) - ->raw(', ') - ->repr($this->getAttribute('name')) - ->raw("));\n\n") - ; - } -} - -class_alias('Twig_Profiler_Node_EnterProfile', 'Twig\Profiler\Node\EnterProfileNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php deleted file mode 100644 index d1d6a7cc1..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Profiler_Node_LeaveProfile extends Twig_Node -{ - public function __construct($varName) - { - parent::__construct(array(), array('var_name' => $varName)); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->write("\n") - ->write(sprintf("\$%s->leave(\$%s);\n\n", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) - ; - } -} - -class_alias('Twig_Profiler_Node_LeaveProfile', 'Twig\Profiler\Node\LeaveProfileNode', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php deleted file mode 100644 index a395ae7fd..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor -{ - private $extensionName; - - public function __construct($extensionName) - { - $this->extensionName = $extensionName; - } - - protected function doEnterNode(Twig_Node $node, Twig_Environment $env) - { - return $node; - } - - protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Module) { - $varName = $this->getVarName(); - $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start')))); - $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end')))); - } elseif ($node instanceof Twig_Node_Block) { - $varName = $this->getVarName(); - $node->setNode('body', new Twig_Node_Body(array( - new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName), - $node->getNode('body'), - new Twig_Profiler_Node_LeaveProfile($varName), - ))); - } elseif ($node instanceof Twig_Node_Macro) { - $varName = $this->getVarName(); - $node->setNode('body', new Twig_Node_Body(array( - new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName), - $node->getNode('body'), - new Twig_Profiler_Node_LeaveProfile($varName), - ))); - } - - return $node; - } - - private function getVarName() - { - return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false)); - } - - public function getPriority() - { - return 0; - } -} - -class_alias('Twig_Profiler_NodeVisitor_Profiler', 'Twig\Profiler\NodeVisitor\ProfilerNodeVisitor', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Profile.php b/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Profile.php deleted file mode 100644 index 3fdc1a8ae..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Profiler/Profile.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_Profile implements IteratorAggregate, Serializable -{ - const ROOT = 'ROOT'; - const BLOCK = 'block'; - const TEMPLATE = 'template'; - const MACRO = 'macro'; - - private $template; - private $name; - private $type; - private $starts = array(); - private $ends = array(); - private $profiles = array(); - - public function __construct($template = 'main', $type = self::ROOT, $name = 'main') - { - $this->template = $template; - $this->type = $type; - $this->name = 0 === strpos($name, '__internal_') ? 'INTERNAL' : $name; - $this->enter(); - } - - public function getTemplate() - { - return $this->template; - } - - public function getType() - { - return $this->type; - } - - public function getName() - { - return $this->name; - } - - public function isRoot() - { - return self::ROOT === $this->type; - } - - public function isTemplate() - { - return self::TEMPLATE === $this->type; - } - - public function isBlock() - { - return self::BLOCK === $this->type; - } - - public function isMacro() - { - return self::MACRO === $this->type; - } - - public function getProfiles() - { - return $this->profiles; - } - - public function addProfile(Twig_Profiler_Profile $profile) - { - $this->profiles[] = $profile; - } - - /** - * Returns the duration in microseconds. - * - * @return int - */ - public function getDuration() - { - if ($this->isRoot() && $this->profiles) { - // for the root node with children, duration is the sum of all child durations - $duration = 0; - foreach ($this->profiles as $profile) { - $duration += $profile->getDuration(); - } - - return $duration; - } - - return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0; - } - - /** - * Returns the memory usage in bytes. - * - * @return int - */ - public function getMemoryUsage() - { - return isset($this->ends['mu']) && isset($this->starts['mu']) ? $this->ends['mu'] - $this->starts['mu'] : 0; - } - - /** - * Returns the peak memory usage in bytes. - * - * @return int - */ - public function getPeakMemoryUsage() - { - return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0; - } - - /** - * Starts the profiling. - */ - public function enter() - { - $this->starts = array( - 'wt' => microtime(true), - 'mu' => memory_get_usage(), - 'pmu' => memory_get_peak_usage(), - ); - } - - /** - * Stops the profiling. - */ - public function leave() - { - $this->ends = array( - 'wt' => microtime(true), - 'mu' => memory_get_usage(), - 'pmu' => memory_get_peak_usage(), - ); - } - - public function reset() - { - $this->starts = $this->ends = $this->profiles = array(); - $this->enter(); - } - - public function getIterator() - { - return new ArrayIterator($this->profiles); - } - - public function serialize() - { - return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles)); - } - - public function unserialize($data) - { - list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data); - } -} - -class_alias('Twig_Profiler_Profile', 'Twig\Profiler\Profile', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php deleted file mode 100644 index f5eb14e0d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ -interface Twig_RuntimeLoaderInterface -{ - /** - * Creates the runtime implementation of a Twig element (filter/function/test). - * - * @param string $class A runtime class - * - * @return object|null The runtime instance or null if the loader does not know how to create the runtime for this class - */ - public function load($class); -} - -class_alias('Twig_RuntimeLoaderInterface', 'Twig\RuntimeLoader\RuntimeLoaderInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php deleted file mode 100644 index b6707e386..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -class Twig_Sandbox_SecurityError extends Twig_Error -{ -} - -class_alias('Twig_Sandbox_SecurityError', 'Twig\Sandbox\SecurityError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php deleted file mode 100644 index 0ba332762..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError -{ - private $filterName; - - public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null) - { - parent::__construct($message, $lineno, $filename, $previous); - $this->filterName = $functionName; - } - - public function getFilterName() - { - return $this->filterName; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedFilterError', 'Twig\Sandbox\SecurityNotAllowedFilterError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php deleted file mode 100644 index aa3914293..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError -{ - private $functionName; - - public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null) - { - parent::__construct($message, $lineno, $filename, $previous); - $this->functionName = $functionName; - } - - public function getFunctionName() - { - return $this->functionName; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedFunctionError', 'Twig\Sandbox\SecurityNotAllowedFunctionError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php deleted file mode 100644 index 93012fe99..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedMethodError extends Twig_Sandbox_SecurityError -{ - private $className; - private $methodName; - - public function __construct($message, $className, $methodName, $lineno = -1, $filename = null, Exception $previous = null) - { - parent::__construct($message, $lineno, $filename, $previous); - $this->className = $className; - $this->methodName = $methodName; - } - - public function getClassName() - { - return $this->className; - } - - public function getMethodName() - { - return $this->methodName; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedMethodError', 'Twig\Sandbox\SecurityNotAllowedMethodError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php deleted file mode 100644 index f27969c15..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedPropertyError extends Twig_Sandbox_SecurityError -{ - private $className; - private $propertyName; - - public function __construct($message, $className, $propertyName, $lineno = -1, $filename = null, Exception $previous = null) - { - parent::__construct($message, $lineno, $filename, $previous); - $this->className = $className; - $this->propertyName = $propertyName; - } - - public function getClassName() - { - return $this->className; - } - - public function getPropertyName() - { - return $this->propertyName; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedPropertyError', 'Twig\Sandbox\SecurityNotAllowedPropertyError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php deleted file mode 100644 index 4bbd22387..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError -{ - private $tagName; - - public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null) - { - parent::__construct($message, $lineno, $filename, $previous); - $this->tagName = $tagName; - } - - public function getTagName() - { - return $this->tagName; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedTagError', 'Twig\Sandbox\SecurityNotAllowedTagError', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php deleted file mode 100644 index dca0b82b5..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php +++ /dev/null @@ -1,125 +0,0 @@ - - */ -class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface -{ - protected $allowedTags; - protected $allowedFilters; - protected $allowedMethods; - protected $allowedProperties; - protected $allowedFunctions; - - public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array(), array $allowedFunctions = array()) - { - $this->allowedTags = $allowedTags; - $this->allowedFilters = $allowedFilters; - $this->setAllowedMethods($allowedMethods); - $this->allowedProperties = $allowedProperties; - $this->allowedFunctions = $allowedFunctions; - } - - public function setAllowedTags(array $tags) - { - $this->allowedTags = $tags; - } - - public function setAllowedFilters(array $filters) - { - $this->allowedFilters = $filters; - } - - public function setAllowedMethods(array $methods) - { - $this->allowedMethods = array(); - foreach ($methods as $class => $m) { - $this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : array($m)); - } - } - - public function setAllowedProperties(array $properties) - { - $this->allowedProperties = $properties; - } - - public function setAllowedFunctions(array $functions) - { - $this->allowedFunctions = $functions; - } - - public function checkSecurity($tags, $filters, $functions) - { - foreach ($tags as $tag) { - if (!in_array($tag, $this->allowedTags)) { - throw new Twig_Sandbox_SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag); - } - } - - foreach ($filters as $filter) { - if (!in_array($filter, $this->allowedFilters)) { - throw new Twig_Sandbox_SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter); - } - } - - foreach ($functions as $function) { - if (!in_array($function, $this->allowedFunctions)) { - throw new Twig_Sandbox_SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function); - } - } - } - - public function checkMethodAllowed($obj, $method) - { - if ($obj instanceof Twig_TemplateInterface || $obj instanceof Twig_Markup) { - return true; - } - - $allowed = false; - $method = strtolower($method); - foreach ($this->allowedMethods as $class => $methods) { - if ($obj instanceof $class) { - $allowed = in_array($method, $methods); - - break; - } - } - - if (!$allowed) { - $class = get_class($obj); - throw new Twig_Sandbox_SecurityNotAllowedMethodError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method); - } - } - - public function checkPropertyAllowed($obj, $property) - { - $allowed = false; - foreach ($this->allowedProperties as $class => $properties) { - if ($obj instanceof $class) { - $allowed = in_array($property, is_array($properties) ? $properties : array($properties)); - - break; - } - } - - if (!$allowed) { - $class = get_class($obj); - throw new Twig_Sandbox_SecurityNotAllowedPropertyError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property); - } - } -} - -class_alias('Twig_Sandbox_SecurityPolicy', 'Twig\Sandbox\SecurityPolicy', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php deleted file mode 100644 index 88f64447a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -interface Twig_Sandbox_SecurityPolicyInterface -{ - public function checkSecurity($tags, $filters, $functions); - - public function checkMethodAllowed($obj, $method); - - public function checkPropertyAllowed($obj, $method); -} - -class_alias('Twig_Sandbox_SecurityPolicyInterface', 'Twig\Sandbox\SecurityPolicyInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/SimpleFilter.php b/lib/silex/vendor/twig/twig/lib/Twig/SimpleFilter.php deleted file mode 100644 index ee4c0aebf..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/SimpleFilter.php +++ /dev/null @@ -1,121 +0,0 @@ - - */ -class Twig_SimpleFilter -{ - protected $name; - protected $callable; - protected $options; - protected $arguments = array(); - - public function __construct($name, $callable, array $options = array()) - { - $this->name = $name; - $this->callable = $callable; - $this->options = array_merge(array( - 'needs_environment' => false, - 'needs_context' => false, - 'is_variadic' => false, - 'is_safe' => null, - 'is_safe_callback' => null, - 'pre_escape' => null, - 'preserves_safety' => null, - 'node_class' => 'Twig_Node_Expression_Filter', - 'deprecated' => false, - 'alternative' => null, - ), $options); - } - - public function getName() - { - return $this->name; - } - - public function getCallable() - { - return $this->callable; - } - - public function getNodeClass() - { - return $this->options['node_class']; - } - - public function setArguments($arguments) - { - $this->arguments = $arguments; - } - - public function getArguments() - { - return $this->arguments; - } - - public function needsEnvironment() - { - return $this->options['needs_environment']; - } - - public function needsContext() - { - return $this->options['needs_context']; - } - - public function getSafe(Twig_Node $filterArgs) - { - if (null !== $this->options['is_safe']) { - return $this->options['is_safe']; - } - - if (null !== $this->options['is_safe_callback']) { - return call_user_func($this->options['is_safe_callback'], $filterArgs); - } - } - - public function getPreservesSafety() - { - return $this->options['preserves_safety']; - } - - public function getPreEscape() - { - return $this->options['pre_escape']; - } - - public function isVariadic() - { - return $this->options['is_variadic']; - } - - public function isDeprecated() - { - return (bool) $this->options['deprecated']; - } - - public function getDeprecatedVersion() - { - return $this->options['deprecated']; - } - - public function getAlternative() - { - return $this->options['alternative']; - } -} - -class_alias('Twig_SimpleFilter', 'Twig\TwigFilter', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/SimpleFunction.php b/lib/silex/vendor/twig/twig/lib/Twig/SimpleFunction.php deleted file mode 100644 index a6aa7ca74..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/SimpleFunction.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ -class Twig_SimpleFunction -{ - protected $name; - protected $callable; - protected $options; - protected $arguments = array(); - - public function __construct($name, $callable, array $options = array()) - { - $this->name = $name; - $this->callable = $callable; - $this->options = array_merge(array( - 'needs_environment' => false, - 'needs_context' => false, - 'is_variadic' => false, - 'is_safe' => null, - 'is_safe_callback' => null, - 'node_class' => 'Twig_Node_Expression_Function', - 'deprecated' => false, - 'alternative' => null, - ), $options); - } - - public function getName() - { - return $this->name; - } - - public function getCallable() - { - return $this->callable; - } - - public function getNodeClass() - { - return $this->options['node_class']; - } - - public function setArguments($arguments) - { - $this->arguments = $arguments; - } - - public function getArguments() - { - return $this->arguments; - } - - public function needsEnvironment() - { - return $this->options['needs_environment']; - } - - public function needsContext() - { - return $this->options['needs_context']; - } - - public function getSafe(Twig_Node $functionArgs) - { - if (null !== $this->options['is_safe']) { - return $this->options['is_safe']; - } - - if (null !== $this->options['is_safe_callback']) { - return call_user_func($this->options['is_safe_callback'], $functionArgs); - } - - return array(); - } - - public function isVariadic() - { - return $this->options['is_variadic']; - } - - public function isDeprecated() - { - return (bool) $this->options['deprecated']; - } - - public function getDeprecatedVersion() - { - return $this->options['deprecated']; - } - - public function getAlternative() - { - return $this->options['alternative']; - } -} - -class_alias('Twig_SimpleFunction', 'Twig\TwigFunction', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/SimpleTest.php b/lib/silex/vendor/twig/twig/lib/Twig/SimpleTest.php deleted file mode 100644 index fee5778b3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/SimpleTest.php +++ /dev/null @@ -1,73 +0,0 @@ - - */ -class Twig_SimpleTest -{ - protected $name; - protected $callable; - protected $options; - - public function __construct($name, $callable, array $options = array()) - { - $this->name = $name; - $this->callable = $callable; - $this->options = array_merge(array( - 'is_variadic' => false, - 'node_class' => 'Twig_Node_Expression_Test', - 'deprecated' => false, - 'alternative' => null, - ), $options); - } - - public function getName() - { - return $this->name; - } - - public function getCallable() - { - return $this->callable; - } - - public function getNodeClass() - { - return $this->options['node_class']; - } - - public function isVariadic() - { - return $this->options['is_variadic']; - } - - public function isDeprecated() - { - return (bool) $this->options['deprecated']; - } - - public function getDeprecatedVersion() - { - return $this->options['deprecated']; - } - - public function getAlternative() - { - return $this->options['alternative']; - } -} - -class_alias('Twig_SimpleTest', 'Twig\TwigTest', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Source.php b/lib/silex/vendor/twig/twig/lib/Twig/Source.php deleted file mode 100644 index bd8d869f3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Source.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -class Twig_Source -{ - private $code; - private $name; - private $path; - - /** - * @param string $code The template source code - * @param string $name The template logical name - * @param string $path The filesystem path of the template if any - */ - public function __construct($code, $name, $path = '') - { - $this->code = $code; - $this->name = $name; - $this->path = $path; - } - - public function getCode() - { - return $this->code; - } - - public function getName() - { - return $this->name; - } - - public function getPath() - { - return $this->path; - } -} - -class_alias('Twig_Source', 'Twig\Source', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php deleted file mode 100644 index a6e8c4255..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * @deprecated since 1.27 (to be removed in 3.0) - */ -interface Twig_SourceContextLoaderInterface -{ - /** - * Returns the source context for a given template logical name. - * - * @param string $name The template logical name - * - * @return Twig_Source - * - * @throws Twig_Error_Loader When $name is not found - */ - public function getSourceContext($name); -} - -class_alias('Twig_SourceContextLoaderInterface', 'Twig\Loader\SourceContextLoaderInterface', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Template.php b/lib/silex/vendor/twig/twig/lib/Twig/Template.php deleted file mode 100644 index 64563419e..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Template.php +++ /dev/null @@ -1,706 +0,0 @@ -load() - * instead, which returns an instance of Twig_TemplateWrapper. - * - * @author Fabien Potencier - * - * @internal - */ -abstract class Twig_Template implements Twig_TemplateInterface -{ - /** - * @internal - */ - protected static $cache = array(); - - protected $parent; - protected $parents = array(); - protected $env; - protected $blocks = array(); - protected $traits = array(); - - public function __construct(Twig_Environment $env) - { - $this->env = $env; - } - - /** - * @internal this method will be removed in 2.0 and is only used internally to provide an upgrade path from 1.x to 2.0 - */ - public function __toString() - { - return $this->getTemplateName(); - } - - /** - * Returns the template name. - * - * @return string The template name - */ - abstract public function getTemplateName(); - - /** - * Returns debug information about the template. - * - * @return array Debug information - * - * @internal - */ - public function getDebugInfo() - { - return array(); - } - - /** - * Returns the template source code. - * - * @return string The template source code - * - * @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead - */ - public function getSource() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED); - - return ''; - } - - /** - * Returns information about the original template source code. - * - * @return Twig_Source - */ - public function getSourceContext() - { - return new Twig_Source('', $this->getTemplateName()); - } - - /** - * @deprecated since 1.20 (to be removed in 2.0) - */ - public function getEnvironment() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.20 and will be removed in 2.0.', E_USER_DEPRECATED); - - return $this->env; - } - - /** - * Returns the parent template. - * - * This method is for internal use only and should never be called - * directly. - * - * @param array $context - * - * @return Twig_TemplateInterface|false The parent template or false if there is no parent - * - * @internal - */ - public function getParent(array $context) - { - if (null !== $this->parent) { - return $this->parent; - } - - try { - $parent = $this->doGetParent($context); - - if (false === $parent) { - return false; - } - - if ($parent instanceof self) { - return $this->parents[$parent->getTemplateName()] = $parent; - } - - if (!isset($this->parents[$parent])) { - $this->parents[$parent] = $this->loadTemplate($parent); - } - } catch (Twig_Error_Loader $e) { - $e->setSourceContext(null); - $e->guess(); - - throw $e; - } - - return $this->parents[$parent]; - } - - protected function doGetParent(array $context) - { - return false; - } - - public function isTraitable() - { - return true; - } - - /** - * Displays a parent block. - * - * This method is for internal use only and should never be called - * directly. - * - * @param string $name The block name to display from the parent - * @param array $context The context - * @param array $blocks The current set of blocks - * - * @internal - */ - public function displayParentBlock($name, array $context, array $blocks = array()) - { - $name = (string) $name; - - if (isset($this->traits[$name])) { - $this->traits[$name][0]->displayBlock($name, $context, $blocks, false); - } elseif (false !== $parent = $this->getParent($context)) { - $parent->displayBlock($name, $context, $blocks, false); - } else { - throw new Twig_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block.', $name), -1, $this->getSourceContext()); - } - } - - /** - * Displays a block. - * - * This method is for internal use only and should never be called - * directly. - * - * @param string $name The block name to display - * @param array $context The context - * @param array $blocks The current set of blocks - * @param bool $useBlocks Whether to use the current set of blocks - * - * @internal - */ - public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true) - { - $name = (string) $name; - - if ($useBlocks && isset($blocks[$name])) { - $template = $blocks[$name][0]; - $block = $blocks[$name][1]; - } elseif (isset($this->blocks[$name])) { - $template = $this->blocks[$name][0]; - $block = $this->blocks[$name][1]; - } else { - $template = null; - $block = null; - } - - // avoid RCEs when sandbox is enabled - if (null !== $template && !$template instanceof self) { - throw new LogicException('A block must be a method on a Twig_Template instance.'); - } - - if (null !== $template) { - try { - $template->$block($context, $blocks); - } catch (Twig_Error $e) { - if (!$e->getSourceContext()) { - $e->setSourceContext($template->getSourceContext()); - } - - // 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, $template->getSourceContext(), $e); - } - } elseif (false !== $parent = $this->getParent($context)) { - $parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false); - } else { - @trigger_error(sprintf('Silent display of undefined block "%s" in template "%s" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block(\'%s\') is defined" expression to test for block existence.', $name, $this->getTemplateName(), $name), E_USER_DEPRECATED); - } - } - - /** - * Renders a parent block. - * - * This method is for internal use only and should never be called - * directly. - * - * @param string $name The block name to render from the parent - * @param array $context The context - * @param array $blocks The current set of blocks - * - * @return string The rendered block - * - * @internal - */ - public function renderParentBlock($name, array $context, array $blocks = array()) - { - ob_start(); - $this->displayParentBlock($name, $context, $blocks); - - return ob_get_clean(); - } - - /** - * Renders a block. - * - * This method is for internal use only and should never be called - * directly. - * - * @param string $name The block name to render - * @param array $context The context - * @param array $blocks The current set of blocks - * @param bool $useBlocks Whether to use the current set of blocks - * - * @return string The rendered block - * - * @internal - */ - public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true) - { - ob_start(); - $this->displayBlock($name, $context, $blocks, $useBlocks); - - return ob_get_clean(); - } - - /** - * Returns whether a block exists or not in the current context of the template. - * - * This method checks blocks defined in the current template - * or defined in "used" traits or defined in parent templates. - * - * @param string $name The block name - * @param array $context The context - * @param array $blocks The current set of blocks - * - * @return bool true if the block exists, false otherwise - * - * @internal - */ - public function hasBlock($name, array $context = null, array $blocks = array()) - { - if (null === $context) { - @trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED); - - return isset($this->blocks[(string) $name]); - } - - if (isset($blocks[$name])) { - return $blocks[$name][0] instanceof self; - } - - if (isset($this->blocks[$name])) { - return true; - } - - if (false !== $parent = $this->getParent($context)) { - return $parent->hasBlock($name, $context); - } - - return false; - } - - /** - * Returns all block names in the current context of the template. - * - * This method checks blocks defined in the current template - * or defined in "used" traits or defined in parent templates. - * - * @param array $context The context - * @param array $blocks The current set of blocks - * - * @return array An array of block names - * - * @internal - */ - public function getBlockNames(array $context = null, array $blocks = array()) - { - if (null === $context) { - @trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED); - - return array_keys($this->blocks); - } - - $names = array_merge(array_keys($blocks), array_keys($this->blocks)); - - if (false !== $parent = $this->getParent($context)) { - $names = array_merge($names, $parent->getBlockNames($context)); - } - - return array_unique($names); - } - - protected function loadTemplate($template, $templateName = null, $line = null, $index = null) - { - try { - if (is_array($template)) { - return $this->env->resolveTemplate($template); - } - - if ($template instanceof self) { - return $template; - } - - if ($template instanceof Twig_TemplateWrapper) { - return $template; - } - - return $this->env->loadTemplate($template, $index); - } catch (Twig_Error $e) { - if (!$e->getSourceContext()) { - $e->setSourceContext($templateName ? new Twig_Source('', $templateName) : $this->getSourceContext()); - } - - if ($e->getTemplateLine()) { - throw $e; - } - - if (!$line) { - $e->guess(); - } else { - $e->setTemplateLine($line); - } - - throw $e; - } - } - - /** - * Returns all blocks. - * - * This method is for internal use only and should never be called - * directly. - * - * @return array An array of blocks - * - * @internal - */ - public function getBlocks() - { - return $this->blocks; - } - - public function display(array $context, array $blocks = array()) - { - $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); - } - - public function render(array $context) - { - $level = ob_get_level(); - ob_start(); - try { - $this->display($context); - } catch (Exception $e) { - while (ob_get_level() > $level) { - ob_end_clean(); - } - - throw $e; - } catch (Throwable $e) { - while (ob_get_level() > $level) { - ob_end_clean(); - } - - throw $e; - } - - return ob_get_clean(); - } - - protected function displayWithErrorHandling(array $context, array $blocks = array()) - { - try { - $this->doDisplay($context, $blocks); - } catch (Twig_Error $e) { - if (!$e->getSourceContext()) { - $e->setSourceContext($this->getSourceContext()); - } - - // 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, $this->getSourceContext(), $e); - } - } - - /** - * Auto-generated method to display the template with the given 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 - */ - abstract protected function doDisplay(array $context, array $blocks = array()); - - /** - * Returns a variable from the context. - * - * This method is for internal use only and should never be called - * directly. - * - * 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. - * - * @param array $context The context - * @param string $item The variable to return from the context - * @param bool $ignoreStrictCheck Whether to ignore the strict variable check or not - * - * @return mixed The content of the context variable - * - * @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode - * - * @internal - */ - final protected function getContext($context, $item, $ignoreStrictCheck = false) - { - if (!array_key_exists($item, $context)) { - if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { - return; - } - - throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist.', $item), -1, $this->getSourceContext()); - } - - return $context[$item]; - } - - /** - * Returns the attribute value for a given array/object. - * - * @param mixed $object The object or array from where to get the item - * @param mixed $item The item to get from the array or object - * @param array $arguments An array of arguments to pass if the item is an object method - * @param string $type The type of attribute (@see Twig_Template constants) - * @param bool $isDefinedTest Whether this is only a defined check - * @param bool $ignoreStrictCheck Whether to ignore the strict attribute check or not - * - * @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true - * - * @throws Twig_Error_Runtime if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false - * - * @internal - */ - protected function getAttribute($object, $item, array $arguments = array(), $type = self::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false) - { - // array - if (self::METHOD_CALL !== $type) { - $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item; - - if ((is_array($object) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object))) - || ($object instanceof ArrayAccess && isset($object[$arrayItem])) - ) { - if ($isDefinedTest) { - return true; - } - - return $object[$arrayItem]; - } - - if (self::ARRAY_CALL === $type || !is_object($object)) { - if ($isDefinedTest) { - return false; - } - - if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { - return; - } - - if ($object instanceof ArrayAccess) { - $message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem, get_class($object)); - } elseif (is_object($object)) { - $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item, get_class($object)); - } elseif (is_array($object)) { - if (empty($object)) { - $message = sprintf('Key "%s" does not exist as the array is empty.', $arrayItem); - } else { - $message = sprintf('Key "%s" for array with keys "%s" does not exist.', $arrayItem, implode(', ', array_keys($object))); - } - } elseif (self::ARRAY_CALL === $type) { - if (null === $object) { - $message = sprintf('Impossible to access a key ("%s") on a null variable.', $item); - } else { - $message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s").', $item, gettype($object), $object); - } - } elseif (null === $object) { - $message = sprintf('Impossible to access an attribute ("%s") on a null variable.', $item); - } else { - $message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item, gettype($object), $object); - } - - throw new Twig_Error_Runtime($message, -1, $this->getSourceContext()); - } - } - - if (!is_object($object)) { - if ($isDefinedTest) { - return false; - } - - if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { - return; - } - - if (null === $object) { - $message = sprintf('Impossible to invoke a method ("%s") on a null variable.', $item); - } else { - $message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, gettype($object), $object); - } - - throw new Twig_Error_Runtime($message, -1, $this->getSourceContext()); - } - - // object property - if (self::METHOD_CALL !== $type && !$object instanceof self) { // Twig_Template does not have public properties, and we don't want to allow access to internal ones - if (isset($object->$item) || array_key_exists((string) $item, $object)) { - if ($isDefinedTest) { - return true; - } - - if ($this->env->hasExtension('Twig_Extension_Sandbox')) { - $this->env->getExtension('Twig_Extension_Sandbox')->checkPropertyAllowed($object, $item); - } - - return $object->$item; - } - } - - $class = get_class($object); - - // object method - if (!isset(self::$cache[$class])) { - // get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates - if ($object instanceof self) { - $ref = new ReflectionClass($class); - $methods = array(); - - foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) { - // Accessing the environment from templates is forbidden to prevent untrusted changes to the environment - if ('getenvironment' !== strtolower($refMethod->name)) { - $methods[] = $refMethod->name; - } - } - } else { - $methods = get_class_methods($object); - } - // sort values to have consistent behavior, so that "get" methods win precedence over "is" methods - sort($methods); - - $cache = array(); - - foreach ($methods as $method) { - $cache[$method] = $method; - $cache[$lcName = strtolower($method)] = $method; - - if ('g' === $lcName[0] && 0 === strpos($lcName, 'get')) { - $name = substr($method, 3); - $lcName = substr($lcName, 3); - } elseif ('i' === $lcName[0] && 0 === strpos($lcName, 'is')) { - $name = substr($method, 2); - $lcName = substr($lcName, 2); - } else { - continue; - } - - // skip get() and is() methods (in which case, $name is empty) - if ($name) { - if (!isset($cache[$name])) { - $cache[$name] = $method; - } - if (!isset($cache[$lcName])) { - $cache[$lcName] = $method; - } - } - } - self::$cache[$class] = $cache; - } - - $call = false; - if (isset(self::$cache[$class][$item])) { - $method = self::$cache[$class][$item]; - } elseif (isset(self::$cache[$class][$lcItem = strtolower($item)])) { - $method = self::$cache[$class][$lcItem]; - } elseif (isset(self::$cache[$class]['__call'])) { - $method = $item; - $call = true; - } else { - if ($isDefinedTest) { - return false; - } - - if ($ignoreStrictCheck || !$this->env->isStrictVariables()) { - return; - } - - throw new Twig_Error_Runtime(sprintf('Neither the property "%1$s" nor one of the methods "%1$s()", "get%1$s()"/"is%1$s()" or "__call()" exist and have public access in class "%2$s".', $item, $class), -1, $this->getSourceContext()); - } - - if ($isDefinedTest) { - return true; - } - - if ($this->env->hasExtension('Twig_Extension_Sandbox')) { - $this->env->getExtension('Twig_Extension_Sandbox')->checkMethodAllowed($object, $method); - } - - // Some objects throw exceptions when they have __call, and the method we try - // to call is not supported. If ignoreStrictCheck is true, we should return null. - try { - if (!$arguments) { - $ret = $object->$method(); - } else { - $ret = call_user_func_array(array($object, $method), $arguments); - } - } catch (BadMethodCallException $e) { - if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) { - return; - } - throw $e; - } - - // @deprecated in 1.28 - if ($object instanceof Twig_TemplateInterface) { - $self = $object->getTemplateName() === $this->getTemplateName(); - $message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName()); - if ('renderBlock' === $method || 'displayBlock' === $method) { - $message .= sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template'); - } elseif ('hasBlock' === $method) { - $message .= sprintf(' Use "block("%s"%s) is defined" instead).', $arguments[0], $self ? '' : ', template'); - } elseif ('render' === $method || 'display' === $method) { - $message .= sprintf(' Use include("%s") instead).', $object->getTemplateName()); - } - @trigger_error($message, E_USER_DEPRECATED); - - return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset()); - } - - return $ret; - } -} - -class_alias('Twig_Template', 'Twig\Template', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TemplateInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/TemplateInterface.php deleted file mode 100644 index 457ef7d7b..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TemplateInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 3.0) - */ -interface Twig_TemplateInterface -{ - const ANY_CALL = 'any'; - const ARRAY_CALL = 'array'; - const METHOD_CALL = 'method'; - - /** - * Renders the template with the given context and returns it as string. - * - * @param array $context An array of parameters to pass to the template - * - * @return string The rendered template - */ - public function render(array $context); - - /** - * Displays the template with the given 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 - */ - public function display(array $context, array $blocks = array()); - - /** - * Returns the bound environment for this template. - * - * @return Twig_Environment - */ - public function getEnvironment(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TemplateWrapper.php b/lib/silex/vendor/twig/twig/lib/Twig/TemplateWrapper.php deleted file mode 100644 index 497f6e980..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TemplateWrapper.php +++ /dev/null @@ -1,133 +0,0 @@ - - */ -final class Twig_TemplateWrapper -{ - private $env; - private $template; - - /** - * This method is for internal use only and should never be called - * directly (use Twig_Environment::load() instead). - * - * @internal - */ - public function __construct(Twig_Environment $env, Twig_Template $template) - { - $this->env = $env; - $this->template = $template; - } - - /** - * Renders the template. - * - * @param array $context An array of parameters to pass to the template - * - * @return string The rendered template - */ - public function render($context = array()) - { - return $this->template->render($context); - } - - /** - * Displays the template. - * - * @param array $context An array of parameters to pass to the template - */ - public function display($context = array()) - { - $this->template->display($context); - } - - /** - * Checks if a block is defined. - * - * @param string $name The block name - * @param array $context An array of parameters to pass to the template - * - * @return bool - */ - public function hasBlock($name, $context = array()) - { - return $this->template->hasBlock($name, $context); - } - - /** - * Returns defined block names in the template. - * - * @param array $context An array of parameters to pass to the template - * - * @return string[] An array of defined template block names - */ - public function getBlockNames($context = array()) - { - return $this->template->getBlockNames($context); - } - - /** - * Renders a template block. - * - * @param string $name The block name to render - * @param array $context An array of parameters to pass to the template - * - * @return string The rendered block - */ - public function renderBlock($name, $context = array()) - { - $context = $this->env->mergeGlobals($context); - $level = ob_get_level(); - ob_start(); - try { - $this->template->displayBlock($name, $context); - } catch (Exception $e) { - while (ob_get_level() > $level) { - ob_end_clean(); - } - - throw $e; - } catch (Throwable $e) { - while (ob_get_level() > $level) { - ob_end_clean(); - } - - throw $e; - } - - return ob_get_clean(); - } - - /** - * Displays a template block. - * - * @param string $name The block name to render - * @param array $context An array of parameters to pass to the template - */ - public function displayBlock($name, $context = array()) - { - $this->template->displayBlock($name, $this->env->mergeGlobals($context)); - } - - /** - * @return Twig_Source - */ - public function getSourceContext() - { - return $this->template->getSourceContext(); - } -} - -class_alias('Twig_TemplateWrapper', 'Twig\TemplateWrapper', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Test.php b/lib/silex/vendor/twig/twig/lib/Twig/Test.php deleted file mode 100644 index b450ec625..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Test.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface -{ - protected $options; - protected $arguments = array(); - - public function __construct(array $options = array()) - { - $this->options = array_merge(array( - 'callable' => null, - ), $options); - } - - public function getCallable() - { - return $this->options['callable']; - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Test/Function.php b/lib/silex/vendor/twig/twig/lib/Twig/Test/Function.php deleted file mode 100644 index 9e83c3f84..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Test/Function.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Test_Function extends Twig_Test -{ - protected $function; - - public function __construct($function, array $options = array()) - { - $options['callable'] = $function; - - parent::__construct($options); - - $this->function = $function; - } - - public function compile() - { - return $this->function; - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php b/lib/silex/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php deleted file mode 100644 index 016951aa6..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @author Karma Dordrak - */ -abstract class Twig_Test_IntegrationTestCase extends TestCase -{ - /** - * @return string - */ - abstract protected function getFixturesDir(); - - /** - * @return Twig_RuntimeLoaderInterface[] - */ - protected function getRuntimeLoaders() - { - return array(); - } - - /** - * @return Twig_ExtensionInterface[] - */ - protected function getExtensions() - { - return array(); - } - - /** - * @return Twig_SimpleFilter[] - */ - protected function getTwigFilters() - { - return array(); - } - - /** - * @return Twig_SimpleFunction[] - */ - protected function getTwigFunctions() - { - return array(); - } - - /** - * @return Twig_SimpleTest[] - */ - protected function getTwigTests() - { - return array(); - } - - /** - * @dataProvider getTests - */ - public function testIntegration($file, $message, $condition, $templates, $exception, $outputs) - { - $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs); - } - - /** - * @dataProvider getLegacyTests - * @group legacy - */ - public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs) - { - $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs); - } - - public function getTests($name, $legacyTests = false) - { - $fixturesDir = realpath($this->getFixturesDir()); - $tests = array(); - - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - if (!preg_match('/\.test$/', $file)) { - continue; - } - - if ($legacyTests xor false !== strpos($file->getRealpath(), '.legacy.test')) { - 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 = self::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 = self::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); - } - - if ($legacyTests && empty($tests)) { - // add a dummy test to avoid a PHPUnit message - return array(array('not', '-', '', array(), '', array())); - } - - return $tests; - } - - public function getLegacyTests() - { - return $this->getTests('testLegacyIntegration', true); - } - - protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs) - { - if (!$outputs) { - $this->markTestSkipped('no legacy tests to run'); - } - - if ($condition) { - eval('$ret = '.$condition.';'); - if (!$ret) { - $this->markTestSkipped($condition); - } - } - - $loader = new Twig_Loader_Array($templates); - - foreach ($outputs as $i => $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->getRuntimeLoaders() as $runtimeLoader) { - $twig->addRuntimeLoader($runtimeLoader); - } - - foreach ($this->getExtensions() as $extension) { - $twig->addExtension($extension); - } - - foreach ($this->getTwigFilters() as $filter) { - $twig->addFilter($filter); - } - - foreach ($this->getTwigTests() as $test) { - $twig->addTest($test); - } - - foreach ($this->getTwigFunctions() as $function) { - $twig->addFunction($function); - } - - // avoid using the same PHP class name for different cases - // only for PHP 5.2+ - if (PHP_VERSION_ID >= 50300) { - $p = new ReflectionProperty($twig, 'templateClassPrefix'); - $p->setAccessible(true); - $p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_'); - } - - try { - $template = $twig->loadTemplate('index.twig'); - } catch (Exception $e) { - if (false !== $exception) { - $message = $e->getMessage(); - $this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $message))); - $last = substr($message, strlen($message) - 1); - $this->assertTrue('.' === $last || '?' === $last, $message, 'Exception message must end with a dot or a question mark.'); - - return; - } - - 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->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage()))); - - return; - } - - $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); - $constraintClass = class_exists('PHPUnit\Framework\Constraint\Exception') ? 'PHPUnit\Framework\Constraint\Exception' : 'PHPUnit_Framework_Constraint_Exception'; - $this->assertThat(null, new $constraintClass($class)); - } - - $expected = trim($match[3], "\n "); - - if ($expected !== $output) { - printf("Compiled templates that failed on case %d:\n", $i + 1); - - foreach (array_keys($templates) as $name) { - echo "Template: $name\n"; - $loader = $twig->getLoader(); - if (!$loader instanceof Twig_SourceContextLoaderInterface) { - $source = new Twig_Source($loader->getSource($name), $name); - } else { - $source = $loader->getSourceContext($name); - } - echo $twig->compile($twig->parse($twig->tokenize($source))); - } - } - $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; - } -} - -class_alias('Twig_Test_IntegrationTestCase', 'Twig\Test\IntegrationTestCase', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Test/Method.php b/lib/silex/vendor/twig/twig/lib/Twig/Test/Method.php deleted file mode 100644 index feccd5db3..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Test/Method.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Test_Method extends Twig_Test -{ - protected $extension; - protected $method; - - public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) - { - $options['callable'] = array($extension, $method); - - parent::__construct($options); - - $this->extension = $extension; - $this->method = $method; - } - - public function compile() - { - return sprintf('$this->env->getExtension(\'%s\')->%s', get_class($this->extension), $this->method); - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Test/Node.php b/lib/silex/vendor/twig/twig/lib/Twig/Test/Node.php deleted file mode 100644 index 6098a5275..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Test/Node.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_Test_Node extends Twig_Test -{ - protected $class; - - public function __construct($class, array $options = array()) - { - parent::__construct($options); - - $this->class = $class; - } - - public function getClass() - { - return $this->class; - } - - public function compile() - { - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php b/lib/silex/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php deleted file mode 100644 index 479426757..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +++ /dev/null @@ -1,75 +0,0 @@ -assertNodeCompilation($source, $node, $environment, $isPattern); - } - - public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null, $isPattern = false) - { - $compiler = $this->getCompiler($environment); - $compiler->compile($node); - - if ($isPattern) { - $this->assertStringMatchesFormat($source, trim($compiler->getSource())); - } else { - $this->assertEquals($source, trim($compiler->getSource())); - } - } - - protected function getCompiler(Twig_Environment $environment = null) - { - return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment); - } - - protected function getEnvironment() - { - return new Twig_Environment(new Twig_Loader_Array(array())); - } - - protected function getVariableGetter($name, $line = false) - { - $line = $line > 0 ? "// line {$line}\n" : ''; - - if (PHP_VERSION_ID >= 70000) { - return sprintf('%s($context["%s"] ?? null)', $line, $name, $name); - } - - if (PHP_VERSION_ID >= 50400) { - return sprintf('%s(isset($context["%s"]) ? $context["%s"] : null)', $line, $name, $name); - } - - return sprintf('%s$this->getContext($context, "%s")', $line, $name); - } - - protected function getAttributeGetter() - { - if (function_exists('twig_template_get_attributes')) { - return 'twig_template_get_attributes($this, '; - } - - return '$this->getAttribute('; - } -} - -class_alias('Twig_Test_NodeTestCase', 'Twig\Test\NodeTestCase', false); -class_exists('Twig_Environment'); -class_exists('Twig_Node'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TestCallableInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/TestCallableInterface.php deleted file mode 100644 index 51ecb9a28..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TestCallableInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_TestCallableInterface -{ - public function getCallable(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TestInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/TestInterface.php deleted file mode 100644 index 91664075a..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TestInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_TestInterface -{ - /** - * Compiles a test. - * - * @return string The PHP code for the test - */ - public function compile(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Token.php b/lib/silex/vendor/twig/twig/lib/Twig/Token.php deleted file mode 100644 index c7850eccc..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Token.php +++ /dev/null @@ -1,207 +0,0 @@ - - * - * @final - */ -class Twig_Token -{ - protected $value; - protected $type; - protected $lineno; - - const EOF_TYPE = -1; - const TEXT_TYPE = 0; - const BLOCK_START_TYPE = 1; - const VAR_START_TYPE = 2; - const BLOCK_END_TYPE = 3; - const VAR_END_TYPE = 4; - const NAME_TYPE = 5; - const NUMBER_TYPE = 6; - const STRING_TYPE = 7; - const OPERATOR_TYPE = 8; - const PUNCTUATION_TYPE = 9; - const INTERPOLATION_START_TYPE = 10; - const INTERPOLATION_END_TYPE = 11; - - /** - * @param int $type The type of the token - * @param string $value The token value - * @param int $lineno The line position in the source - */ - public function __construct($type, $value, $lineno) - { - $this->type = $type; - $this->value = $value; - $this->lineno = $lineno; - } - - public function __toString() - { - return sprintf('%s(%s)', self::typeToString($this->type, true), $this->value); - } - - /** - * Tests the current token for a type and/or a value. - * - * Parameters may be: - * * just type - * * type and value (or array of possible values) - * * just value (or array of possible values) (NAME_TYPE is used as type) - * - * @param array|int $type The type to test - * @param array|string|null $values The token value - * - * @return bool - */ - public function test($type, $values = null) - { - if (null === $values && !is_int($type)) { - $values = $type; - $type = self::NAME_TYPE; - } - - return ($this->type === $type) && ( - null === $values || - (is_array($values) && in_array($this->value, $values)) || - $this->value == $values - ); - } - - /** - * @return int - */ - public function getLine() - { - return $this->lineno; - } - - /** - * @return int - */ - public function getType() - { - return $this->type; - } - - /** - * @return string - */ - public function getValue() - { - return $this->value; - } - - /** - * Returns the constant representation (internal) of a given type. - * - * @param int $type The type as an integer - * @param bool $short Whether to return a short representation or not - * - * @return string The string representation - */ - public static function typeToString($type, $short = false) - { - switch ($type) { - case self::EOF_TYPE: - $name = 'EOF_TYPE'; - break; - case self::TEXT_TYPE: - $name = 'TEXT_TYPE'; - break; - case self::BLOCK_START_TYPE: - $name = 'BLOCK_START_TYPE'; - break; - case self::VAR_START_TYPE: - $name = 'VAR_START_TYPE'; - break; - case self::BLOCK_END_TYPE: - $name = 'BLOCK_END_TYPE'; - break; - case self::VAR_END_TYPE: - $name = 'VAR_END_TYPE'; - break; - case self::NAME_TYPE: - $name = 'NAME_TYPE'; - break; - case self::NUMBER_TYPE: - $name = 'NUMBER_TYPE'; - break; - case self::STRING_TYPE: - $name = 'STRING_TYPE'; - break; - case self::OPERATOR_TYPE: - $name = 'OPERATOR_TYPE'; - break; - case self::PUNCTUATION_TYPE: - $name = 'PUNCTUATION_TYPE'; - break; - case self::INTERPOLATION_START_TYPE: - $name = 'INTERPOLATION_START_TYPE'; - break; - case self::INTERPOLATION_END_TYPE: - $name = 'INTERPOLATION_END_TYPE'; - break; - default: - throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); - } - - return $short ? $name : 'Twig_Token::'.$name; - } - - /** - * Returns the English representation of a given type. - * - * @param int $type The type as an integer - * - * @return string The string representation - */ - public static function typeToEnglish($type) - { - switch ($type) { - case self::EOF_TYPE: - return 'end of template'; - case self::TEXT_TYPE: - return 'text'; - case self::BLOCK_START_TYPE: - return 'begin of statement block'; - case self::VAR_START_TYPE: - return 'begin of print statement'; - case self::BLOCK_END_TYPE: - return 'end of statement block'; - case self::VAR_END_TYPE: - return 'end of print statement'; - case self::NAME_TYPE: - return 'name'; - case self::NUMBER_TYPE: - return 'number'; - case self::STRING_TYPE: - return 'string'; - case self::OPERATOR_TYPE: - return 'operator'; - case self::PUNCTUATION_TYPE: - return 'punctuation'; - case self::INTERPOLATION_START_TYPE: - return 'begin of string interpolation'; - case self::INTERPOLATION_END_TYPE: - return 'end of string interpolation'; - default: - throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); - } - } -} - -class_alias('Twig_Token', 'Twig\Token', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser.php deleted file mode 100644 index 1b4de14da..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -abstract class Twig_TokenParser implements Twig_TokenParserInterface -{ - /** - * @var Twig_Parser - */ - protected $parser; - - /** - * Sets the parser associated with this token parser. - */ - public function setParser(Twig_Parser $parser) - { - $this->parser = $parser; - } -} - -class_alias('Twig_TokenParser', 'Twig\TokenParser\AbstractTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php deleted file mode 100644 index a20dedd18..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +++ /dev/null @@ -1,83 +0,0 @@ - - * {% autoescape true %} - * Everything will be automatically escaped in this block - * {% endautoescape %} - * - * {% autoescape false %} - * Everything will be outputed as is in this block - * {% endautoescape %} - * - * {% autoescape true js %} - * Everything will be automatically escaped in this block - * using the js escaping strategy - * {% endautoescape %} - * - * - * @final - */ -class Twig_TokenParser_AutoEscape extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $stream = $this->parser->getStream(); - - 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 bool.', $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - $value = $expr->getAttribute('value'); - - $compat = true === $value || false === $value; - - if (true === $value) { - $value = 'html'; - } - - if ($compat && $stream->test(Twig_Token::NAME_TYPE)) { - @trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated since version 1.21.', E_USER_DEPRECATED); - - if (false === $value) { - throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - - $value = $stream->next()->getValue(); - } - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag()); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('endautoescape'); - } - - public function getTag() - { - return 'autoescape'; - } -} - -class_alias('Twig_TokenParser_AutoEscape', 'Twig\TokenParser\AutoEscapeTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Block.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Block.php deleted file mode 100644 index f30f86b58..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Block.php +++ /dev/null @@ -1,73 +0,0 @@ - - * {% block head %} - * - * {% block title %}{% endblock %} - My Webpage - * {% endblock %} - * - * - * @final - */ -class Twig_TokenParser_Block extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $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 '%s' has already been defined line %d.", $name, $this->parser->getBlock($name)->getTemplateLine()), $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno)); - $this->parser->pushLocalScope(); - $this->parser->pushBlockStack($name); - - if ($stream->nextIf(Twig_Token::BLOCK_END_TYPE)) { - $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { - $value = $token->getValue(); - - if ($value != $name) { - throw new Twig_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - } - } else { - $body = new Twig_Node(array( - new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno), - )); - } - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - $block->setNode('body', $body); - $this->parser->popBlockStack(); - $this->parser->popLocalScope(); - - return new Twig_Node_BlockReference($name, $lineno, $this->getTag()); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('endblock'); - } - - public function getTag() - { - return 'block'; - } -} - -class_alias('Twig_TokenParser_Block', 'Twig\TokenParser\BlockTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Do.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Do.php deleted file mode 100644 index 8ce088089..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Do.php +++ /dev/null @@ -1,34 +0,0 @@ -parser->getExpressionParser()->parseExpression(); - - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_Do($expr, $token->getLine(), $this->getTag()); - } - - public function getTag() - { - return 'do'; - } -} - -class_alias('Twig_TokenParser_Do', 'Twig\TokenParser\DoTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Embed.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Embed.php deleted file mode 100644 index 44644cc6b..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Embed.php +++ /dev/null @@ -1,67 +0,0 @@ -parser->getStream(); - - $parent = $this->parser->getExpressionParser()->parseExpression(); - - list($variables, $only, $ignoreMissing) = $this->parseArguments(); - - $parentToken = $fakeParentToken = new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine()); - if ($parent instanceof Twig_Node_Expression_Constant) { - $parentToken = new Twig_Token(Twig_Token::STRING_TYPE, $parent->getAttribute('value'), $token->getLine()); - } elseif ($parent instanceof Twig_Node_Expression_Name) { - $parentToken = new Twig_Token(Twig_Token::NAME_TYPE, $parent->getAttribute('name'), $token->getLine()); - } - - // inject a fake parent to make the parent() function work - $stream->injectTokens(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()), - new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()), - $parentToken, - new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()), - )); - - $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true); - - // override the parent with the correct one - if ($fakeParentToken === $parentToken) { - $module->setNode('parent', $parent); - } - - $this->parser->embedTemplate($module); - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_Embed($module->getTemplateName(), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('endembed'); - } - - public function getTag() - { - return 'embed'; - } -} - -class_alias('Twig_TokenParser_Embed', 'Twig\TokenParser\EmbedTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Extends.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Extends.php deleted file mode 100644 index 31168ccec..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Extends.php +++ /dev/null @@ -1,46 +0,0 @@ - - * {% extends "base.html" %} - * - * - * @final - */ -class Twig_TokenParser_Extends extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $stream = $this->parser->getStream(); - - if (!$this->parser->isMainScope()) { - throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext()); - } - - if (null !== $this->parser->getParent()) { - throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext()); - } - $this->parser->setParent($this->parser->getExpressionParser()->parseExpression()); - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - } - - public function getTag() - { - return 'extends'; - } -} - -class_alias('Twig_TokenParser_Extends', 'Twig\TokenParser\ExtendsTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Filter.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Filter.php deleted file mode 100644 index 760178293..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Filter.php +++ /dev/null @@ -1,53 +0,0 @@ - - * {% filter upper %} - * This text becomes uppercase - * {% endfilter %} - * - * - * @final - */ -class Twig_TokenParser_Filter extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $name = $this->parser->getVarName(); - $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), null, $token->getLine(), $this->getTag()); - - $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag()); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - $block = new Twig_Node_Block($name, $body, $token->getLine()); - $this->parser->setBlock($name, $block); - - return new Twig_Node_Print($filter, $token->getLine(), $this->getTag()); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('endfilter'); - } - - public function getTag() - { - return 'filter'; - } -} - -class_alias('Twig_TokenParser_Filter', 'Twig\TokenParser\FilterTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Flush.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Flush.php deleted file mode 100644 index 51832c77e..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Flush.php +++ /dev/null @@ -1,34 +0,0 @@ -parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_Flush($token->getLine(), $this->getTag()); - } - - public function getTag() - { - return 'flush'; - } -} - -class_alias('Twig_TokenParser_Flush', 'Twig\TokenParser\FlushTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/For.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/For.php deleted file mode 100644 index 63bf41d66..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/For.php +++ /dev/null @@ -1,127 +0,0 @@ - - *
      - * {% for user in users %} - *
    • {{ user.username|e }}
    • - * {% endfor %} - *
    - * - * - * @final - */ -class Twig_TokenParser_For extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $stream = $this->parser->getStream(); - $targets = $this->parser->getExpressionParser()->parseAssignmentExpression(); - $stream->expect(Twig_Token::OPERATOR_TYPE, 'in'); - $seq = $this->parser->getExpressionParser()->parseExpression(); - - $ifexpr = null; - if ($stream->nextIf(Twig_Token::NAME_TYPE, 'if')) { - $ifexpr = $this->parser->getExpressionParser()->parseExpression(); - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideForFork')); - if ($stream->next()->getValue() == 'else') { - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $else = $this->parser->subparse(array($this, 'decideForEnd'), true); - } else { - $else = null; - } - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - if (count($targets) > 1) { - $keyTarget = $targets->getNode(0); - $keyTarget = new Twig_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getTemplateLine()); - $valueTarget = $targets->getNode(1); - $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine()); - } else { - $keyTarget = new Twig_Node_Expression_AssignName('_key', $lineno); - $valueTarget = $targets->getNode(0); - $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine()); - } - - if ($ifexpr) { - $this->checkLoopUsageCondition($stream, $ifexpr); - $this->checkLoopUsageBody($stream, $body); - } - - return new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, $lineno, $this->getTag()); - } - - public function decideForFork(Twig_Token $token) - { - return $token->test(array('else', 'endfor')); - } - - public function decideForEnd(Twig_Token $token) - { - return $token->test('endfor'); - } - - // the loop variable cannot be used in the condition - protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node) - { - if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) { - throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition.', $node->getTemplateLine(), $stream->getSourceContext()); - } - - foreach ($node as $n) { - if (!$n) { - continue; - } - - $this->checkLoopUsageCondition($stream, $n); - } - } - - // check usage of non-defined loop-items - // it does not catch all problems (for instance when a for is included into another or when the variable is used in an include) - protected function checkLoopUsageBody(Twig_TokenStream $stream, Twig_NodeInterface $node) - { - if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) { - $attribute = $node->getNode('attribute'); - if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) { - throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition.', $attribute->getAttribute('value')), $node->getTemplateLine(), $stream->getSourceContext()); - } - } - - // should check for parent.loop.XXX usage - if ($node instanceof Twig_Node_For) { - return; - } - - foreach ($node as $n) { - if (!$n) { - continue; - } - - $this->checkLoopUsageBody($stream, $n); - } - } - - public function getTag() - { - return 'for'; - } -} - -class_alias('Twig_TokenParser_For', 'Twig\TokenParser\ForTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/From.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/From.php deleted file mode 100644 index f3053da4b..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/From.php +++ /dev/null @@ -1,66 +0,0 @@ - - * {% from 'forms.html' import forms %} - * - * - * @final - */ -class Twig_TokenParser_From extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $macro = $this->parser->getExpressionParser()->parseExpression(); - $stream = $this->parser->getStream(); - $stream->expect('import'); - - $targets = array(); - do { - $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - - $alias = $name; - if ($stream->nextIf('as')) { - $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - } - - $targets[$name] = $alias; - - if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { - break; - } - } while (true); - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - $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) { - if ($this->parser->isReservedMacroName($name)) { - throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext()); - } - - $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var')); - } - - return $node; - } - - public function getTag() - { - return 'from'; - } -} - -class_alias('Twig_TokenParser_From', 'Twig\TokenParser\FromTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/If.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/If.php deleted file mode 100644 index f081df3ab..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/If.php +++ /dev/null @@ -1,86 +0,0 @@ - - * {% if users %} - *
      - * {% for user in users %} - *
    • {{ user.username|e }}
    • - * {% endfor %} - *
    - * {% endif %} - * - * - * @final - */ -class Twig_TokenParser_If extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $expr = $this->parser->getExpressionParser()->parseExpression(); - $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 ($stream->next()->getValue()) { - case 'else': - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $else = $this->parser->subparse(array($this, 'decideIfEnd')); - break; - - case 'elseif': - $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideIfFork')); - $tests[] = $expr; - $tests[] = $body; - break; - - case 'endif': - $end = true; - 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), $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); - } - - public function decideIfFork(Twig_Token $token) - { - return $token->test(array('elseif', 'else', 'endif')); - } - - public function decideIfEnd(Twig_Token $token) - { - return $token->test(array('endif')); - } - - public function getTag() - { - return 'if'; - } -} - -class_alias('Twig_TokenParser_If', 'Twig\TokenParser\IfTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Import.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Import.php deleted file mode 100644 index 47802f502..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Import.php +++ /dev/null @@ -1,41 +0,0 @@ - - * {% import 'forms.html' as forms %} - * - * - * @final - */ -class Twig_TokenParser_Import extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $macro = $this->parser->getExpressionParser()->parseExpression(); - $this->parser->getStream()->expect('as'); - $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()); - } - - public function getTag() - { - return 'import'; - } -} - -class_alias('Twig_TokenParser_Import', 'Twig\TokenParser\ImportTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Include.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Include.php deleted file mode 100644 index 309f11db4..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Include.php +++ /dev/null @@ -1,65 +0,0 @@ - - * {% include 'header.html' %} - * Body - * {% include 'footer.html' %} - * - */ -class Twig_TokenParser_Include extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); - - list($variables, $only, $ignoreMissing) = $this->parseArguments(); - - return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); - } - - protected function parseArguments() - { - $stream = $this->parser->getStream(); - - $ignoreMissing = false; - if ($stream->nextIf(Twig_Token::NAME_TYPE, 'ignore')) { - $stream->expect(Twig_Token::NAME_TYPE, 'missing'); - - $ignoreMissing = true; - } - - $variables = null; - if ($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) { - $variables = $this->parser->getExpressionParser()->parseExpression(); - } - - $only = false; - if ($stream->nextIf(Twig_Token::NAME_TYPE, 'only')) { - $only = true; - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return array($variables, $only, $ignoreMissing); - } - - public function getTag() - { - return 'include'; - } -} - -class_alias('Twig_TokenParser_Include', 'Twig\TokenParser\IncludeTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Macro.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Macro.php deleted file mode 100644 index 4287934ba..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Macro.php +++ /dev/null @@ -1,60 +0,0 @@ - - * {% macro input(name, value, type, size) %} - * - * {% endmacro %} - * - * - * @final - */ -class Twig_TokenParser_Macro extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $stream = $this->parser->getStream(); - $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - - $arguments = $this->parser->getExpressionParser()->parseArguments(true, true); - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $this->parser->pushLocalScope(); - $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { - $value = $token->getValue(); - - if ($value != $name) { - throw new Twig_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - } - $this->parser->popLocalScope(); - $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())); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('endmacro'); - } - - public function getTag() - { - return 'macro'; - } -} - -class_alias('Twig_TokenParser_Macro', 'Twig\TokenParser\MacroTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php deleted file mode 100644 index b8f581cbc..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php +++ /dev/null @@ -1,61 +0,0 @@ - - * {% sandbox %} - * {% include 'user.html' %} - * {% endsandbox %} - * - * - * @see http://www.twig-project.org/doc/api.html#sandbox-extension for details - * - * @final - */ -class Twig_TokenParser_Sandbox extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $stream->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->getTemplateLine(), $stream->getSourceContext()); - } - } - } - - return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag()); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('endsandbox'); - } - - public function getTag() - { - return 'sandbox'; - } -} - -class_alias('Twig_TokenParser_Sandbox', 'Twig\TokenParser\SandboxTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Set.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Set.php deleted file mode 100644 index 48c6b3aeb..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Set.php +++ /dev/null @@ -1,75 +0,0 @@ - - * {% set foo = 'foo' %} - * - * {% set foo = [1, 2] %} - * - * {% set foo = {'foo': 'bar'} %} - * - * {% set foo = 'foo' ~ 'bar' %} - * - * {% set foo, bar = 'foo', 'bar' %} - * - * {% set foo %}Some content{% endset %} - * - * - * @final - */ -class Twig_TokenParser_Set extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $stream = $this->parser->getStream(); - $names = $this->parser->getExpressionParser()->parseAssignmentExpression(); - - $capture = false; - if ($stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) { - $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); - - $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 assignments.', $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - } else { - $capture = true; - - if (count($names) > 1) { - throw new Twig_Error_Syntax('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - } - - return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag()); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('endset'); - } - - public function getTag() - { - return 'set'; - } -} - -class_alias('Twig_TokenParser_Set', 'Twig\TokenParser\SetTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php deleted file mode 100644 index cecf27c67..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php +++ /dev/null @@ -1,51 +0,0 @@ - - * {% spaceless %} - *
    - * foo - *
    - * {% endspaceless %} - * - * {# output will be
    foo
    #} - * - * - * @final - */ -class Twig_TokenParser_Spaceless extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true); - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_Spaceless($body, $lineno, $this->getTag()); - } - - public function decideSpacelessEnd(Twig_Token $token) - { - return $token->test('endspaceless'); - } - - public function getTag() - { - return 'spaceless'; - } -} - -class_alias('Twig_TokenParser_Spaceless', 'Twig\TokenParser\SpacelessTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Use.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Use.php deleted file mode 100644 index f15a91ea0..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/Use.php +++ /dev/null @@ -1,70 +0,0 @@ - - * {% extends "base.html" %} - * - * {% use "blocks.html" %} - * - * {% block title %}{% endblock %} - * {% block content %}{% endblock %} - * - * - * @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details. - * - * @final - */ -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.', $stream->getCurrent()->getLine(), $stream->getSourceContext()); - } - - $targets = array(); - if ($stream->nextIf('with')) { - do { - $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - - $alias = $name; - if ($stream->nextIf('as')) { - $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - } - - $targets[$name] = new Twig_Node_Expression_Constant($alias, -1); - - if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { - break; - } - } while (true); - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets)))); - - return new Twig_Node(); - } - - public function getTag() - { - return 'use'; - } -} - -class_alias('Twig_TokenParser_Use', 'Twig\TokenParser\UseTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/With.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/With.php deleted file mode 100644 index 7a692597c..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParser/With.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * @final - */ -class Twig_TokenParser_With extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $stream = $this->parser->getStream(); - - $variables = null; - $only = false; - if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) { - $variables = $this->parser->getExpressionParser()->parseExpression(); - $only = $stream->nextIf(Twig_Token::NAME_TYPE, 'only'); - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - $body = $this->parser->subparse(array($this, 'decideWithEnd'), true); - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_With($body, $variables, $only, $token->getLine(), $this->getTag()); - } - - public function decideWithEnd(Twig_Token $token) - { - return $token->test('endwith'); - } - - public function getTag() - { - return 'with'; - } -} - -class_alias('Twig_TokenParser_With', 'Twig\TokenParser\WithTokenParser', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParserBroker.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParserBroker.php deleted file mode 100644 index a64013508..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParserBroker.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface -{ - protected $parser; - protected $parsers = array(); - protected $brokers = array(); - - /** - * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances - * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances - * @param bool $triggerDeprecationError - */ - public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED); - } - - foreach ($parsers as $parser) { - if (!$parser instanceof 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 LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.'); - } - $this->brokers[] = $broker; - } - } - - public function addTokenParser(Twig_TokenParserInterface $parser) - { - $this->parsers[$parser->getTag()] = $parser; - } - - public function removeTokenParser(Twig_TokenParserInterface $parser) - { - $name = $parser->getTag(); - if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) { - unset($this->parsers[$name]); - } - } - - public function addTokenParserBroker(Twig_TokenParserBroker $broker) - { - $this->brokers[] = $broker; - } - - public function removeTokenParserBroker(Twig_TokenParserBroker $broker) - { - if (false !== $pos = array_search($broker, $this->brokers)) { - unset($this->brokers[$pos]); - } - } - - /** - * Gets a suitable TokenParser for a tag. - * - * First looks in parsers, then in brokers. - * - * @param string $tag A tag name - * - * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found - */ - public function getTokenParser($tag) - { - if (isset($this->parsers[$tag])) { - return $this->parsers[$tag]; - } - $broker = end($this->brokers); - while (false !== $broker) { - $parser = $broker->getTokenParser($tag); - if (null !== $parser) { - return $parser; - } - $broker = prev($this->brokers); - } - } - - public function getParsers() - { - return $this->parsers; - } - - public function getParser() - { - return $this->parser; - } - - public function setParser(Twig_ParserInterface $parser) - { - $this->parser = $parser; - foreach ($this->parsers as $tokenParser) { - $tokenParser->setParser($parser); - } - foreach ($this->brokers as $broker) { - $broker->setParser($parser); - } - } -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php deleted file mode 100644 index 6c93f5ea1..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * @deprecated since 1.12 (to be removed in 2.0) - */ -interface Twig_TokenParserBrokerInterface -{ - /** - * Gets a TokenParser suitable for a tag. - * - * @param string $tag A tag name - * - * @return Twig_TokenParserInterface|null A Twig_TokenParserInterface or null if no suitable TokenParser was found - */ - public function getTokenParser($tag); - - /** - * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of. - */ - public function setParser(Twig_ParserInterface $parser); - - /** - * Gets the Twig_ParserInterface. - * - * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null - */ - public function getParser(); -} diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenParserInterface.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenParserInterface.php deleted file mode 100644 index 14acc8084..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenParserInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - */ -interface Twig_TokenParserInterface -{ - /** - * Sets the parser associated with this token parser. - */ - public function setParser(Twig_Parser $parser); - - /** - * Parses a token and returns a node. - * - * @return Twig_NodeInterface - * - * @throws Twig_Error_Syntax - */ - public function parse(Twig_Token $token); - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag(); -} - -class_alias('Twig_TokenParserInterface', 'Twig\TokenParser\TokenParserInterface', false); -class_exists('Twig_Parser'); -class_exists('Twig_Token'); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/TokenStream.php b/lib/silex/vendor/twig/twig/lib/Twig/TokenStream.php deleted file mode 100644 index e1bd7ca1e..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/TokenStream.php +++ /dev/null @@ -1,196 +0,0 @@ - - */ -class Twig_TokenStream -{ - protected $tokens; - protected $current = 0; - protected $filename; - - private $source; - - /** - * @param array $tokens An array of tokens - * @param string|null $name The name of the template which tokens are associated with - * @param string|null $source The source code associated with the tokens - */ - public function __construct(array $tokens, $name = null, $source = null) - { - if (!$name instanceof Twig_Source) { - if (null !== $name || null !== $source) { - @trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED); - } - $this->source = new Twig_Source($source, $name); - } else { - $this->source = $name; - } - - $this->tokens = $tokens; - - // deprecated, not used anymore, to be removed in 2.0 - $this->filename = $this->source->getName(); - } - - public function __toString() - { - return implode("\n", $this->tokens); - } - - public function injectTokens(array $tokens) - { - $this->tokens = array_merge(array_slice($this->tokens, 0, $this->current), $tokens, array_slice($this->tokens, $this->current)); - } - - /** - * Sets the pointer to the next token and returns the old one. - * - * @return Twig_Token - */ - public function next() - { - if (!isset($this->tokens[++$this->current])) { - throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current - 1]->getLine(), $this->source); - } - - return $this->tokens[$this->current - 1]; - } - - /** - * Tests a token, sets the pointer to the next one and returns it or throws a syntax error. - * - * @return Twig_Token|null The next token if the condition is true, null otherwise - */ - public function nextIf($primary, $secondary = null) - { - if ($this->tokens[$this->current]->test($primary, $secondary)) { - return $this->next(); - } - } - - /** - * Tests a token and returns it or throws a syntax error. - * - * @return Twig_Token - */ - public function expect($type, $value = null, $message = null) - { - $token = $this->tokens[$this->current]; - if (!$token->test($type, $value)) { - $line = $token->getLine(); - throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).', - $message ? $message.'. ' : '', - Twig_Token::typeToEnglish($token->getType()), $token->getValue(), - Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''), - $line, - $this->source - ); - } - $this->next(); - - return $token; - } - - /** - * Looks at the next token. - * - * @param int $number - * - * @return Twig_Token - */ - public function look($number = 1) - { - if (!isset($this->tokens[$this->current + $number])) { - throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current + $number - 1]->getLine(), $this->source); - } - - return $this->tokens[$this->current + $number]; - } - - /** - * Tests the current token. - * - * @return bool - */ - public function test($primary, $secondary = null) - { - return $this->tokens[$this->current]->test($primary, $secondary); - } - - /** - * Checks if end of stream was reached. - * - * @return bool - */ - public function isEOF() - { - return $this->tokens[$this->current]->getType() === Twig_Token::EOF_TYPE; - } - - /** - * @return Twig_Token - */ - public function getCurrent() - { - return $this->tokens[$this->current]; - } - - /** - * Gets the name associated with this stream (null if not defined). - * - * @return string|null - * - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function getFilename() - { - @trigger_error(sprintf('The %s() method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->source->getName(); - } - - /** - * Gets the source code associated with this stream. - * - * @return string - * - * @internal Don't use this as it might be empty depending on the environment configuration - * - * @deprecated since 1.27 (to be removed in 2.0) - */ - public function getSource() - { - @trigger_error(sprintf('The %s() method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->source->getCode(); - } - - /** - * Gets the source associated with this stream. - * - * @return Twig_Source - * - * @internal - */ - public function getSourceContext() - { - return $this->source; - } -} - -class_alias('Twig_TokenStream', 'Twig\TokenStream', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php b/lib/silex/vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php deleted file mode 100644 index c7bf53be2..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * @final - */ -class Twig_Util_DeprecationCollector -{ - private $twig; - private $deprecations; - - public function __construct(Twig_Environment $twig) - { - $this->twig = $twig; - } - - /** - * Returns deprecations for templates contained in a directory. - * - * @param string $dir A directory where templates are stored - * @param string $ext Limit the loaded templates by extension - * - * @return array An array of deprecations - */ - public function collectDir($dir, $ext = '.twig') - { - $iterator = new RegexIterator( - new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY - ), '{'.preg_quote($ext).'$}' - ); - - return $this->collect(new Twig_Util_TemplateDirIterator($iterator)); - } - - /** - * Returns deprecations for passed templates. - * - * @param Traversable $iterator An iterator of templates (where keys are template names and values the contents of the template) - * - * @return array An array of deprecations - */ - public function collect(Traversable $iterator) - { - $this->deprecations = array(); - - set_error_handler(array($this, 'errorHandler')); - - foreach ($iterator as $name => $contents) { - try { - $this->twig->parse($this->twig->tokenize(new Twig_Source($contents, $name))); - } catch (Twig_Error_Syntax $e) { - // ignore templates containing syntax errors - } - } - - restore_error_handler(); - - $deprecations = $this->deprecations; - $this->deprecations = array(); - - return $deprecations; - } - - /** - * @internal - */ - public function errorHandler($type, $msg) - { - if (E_USER_DEPRECATED === $type) { - $this->deprecations[] = $msg; - } - } -} - -class_alias('Twig_Util_DeprecationCollector', 'Twig\Util\DeprecationCollector', false); diff --git a/lib/silex/vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php b/lib/silex/vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php deleted file mode 100644 index c8682335d..000000000 --- a/lib/silex/vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php +++ /dev/null @@ -1,28 +0,0 @@ - - */ -class Twig_Util_TemplateDirIterator extends IteratorIterator -{ - public function current() - { - return file_get_contents(parent::current()); - } - - public function key() - { - return (string) parent::key(); - } -} - -class_alias('Twig_Util_TemplateDirIterator', 'Twig\Util\TemplateDirIterator', false); diff --git a/lib/silex/vendor/twig/twig/phpunit.xml.dist b/lib/silex/vendor/twig/twig/phpunit.xml.dist deleted file mode 100644 index ce7732785..000000000 --- a/lib/silex/vendor/twig/twig/phpunit.xml.dist +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - ./test/Twig/ - - - - - - - - - - - - - - ./lib/Twig/ - - - diff --git a/lib/silex/vendor/twig/twig/src/Cache/CacheInterface.php b/lib/silex/vendor/twig/twig/src/Cache/CacheInterface.php deleted file mode 100644 index 2e35e3ba0..000000000 --- a/lib/silex/vendor/twig/twig/src/Cache/CacheInterface.php +++ /dev/null @@ -1,11 +0,0 @@ - - */ -interface RuntimeExtensionInterface -{ -} diff --git a/lib/silex/vendor/twig/twig/src/Extension/SandboxExtension.php b/lib/silex/vendor/twig/twig/src/Extension/SandboxExtension.php deleted file mode 100644 index 0c244ffc6..000000000 --- a/lib/silex/vendor/twig/twig/src/Extension/SandboxExtension.php +++ /dev/null @@ -1,11 +0,0 @@ -assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig'); - - $autoloader = new Twig_Autoloader(); - $this->assertNull($autoloader->autoload('Foo'), '->autoload() returns false if it is not able to load a class'); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php deleted file mode 100644 index e9e600c1f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php +++ /dev/null @@ -1,193 +0,0 @@ -classname = '__Twig_Tests_Cache_FilesystemTest_Template_'.$nonce; - $this->directory = sys_get_temp_dir().'/twig-test'; - $this->cache = new Twig_Cache_Filesystem($this->directory); - } - - protected function tearDown() - { - if (file_exists($this->directory)) { - Twig_Tests_FilesystemHelper::removeDir($this->directory); - } - } - - public function testLoad() - { - $key = $this->directory.'/cache/cachefile.php'; - - $dir = dirname($key); - @mkdir($dir, 0777, true); - $this->assertTrue(is_dir($dir)); - $this->assertFalse(class_exists($this->classname, false)); - - $content = $this->generateSource(); - file_put_contents($key, $content); - - $this->cache->load($key); - - $this->assertTrue(class_exists($this->classname, false)); - } - - public function testLoadMissing() - { - $key = $this->directory.'/cache/cachefile.php'; - - $this->assertFalse(class_exists($this->classname, false)); - - $this->cache->load($key); - - $this->assertFalse(class_exists($this->classname, false)); - } - - public function testWrite() - { - $key = $this->directory.'/cache/cachefile.php'; - $content = $this->generateSource(); - - $this->assertFileNotExists($key); - $this->assertFileNotExists($this->directory); - - $this->cache->write($key, $content); - - $this->assertFileExists($this->directory); - $this->assertFileExists($key); - $this->assertSame(file_get_contents($key), $content); - } - - /** - * @expectedException RuntimeException - * @expectedExceptionMessage Unable to create the cache directory - */ - public function testWriteFailMkdir() - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('Read-only directories not possible on Windows.'); - } - - $key = $this->directory.'/cache/cachefile.php'; - $content = $this->generateSource(); - - $this->assertFileNotExists($key); - - // Create read-only root directory. - @mkdir($this->directory, 0555, true); - $this->assertTrue(is_dir($this->directory)); - - $this->cache->write($key, $content); - } - - /** - * @expectedException RuntimeException - * @expectedExceptionMessage Unable to write in the cache directory - */ - public function testWriteFailDirWritable() - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('Read-only directories not possible on Windows.'); - } - - $key = $this->directory.'/cache/cachefile.php'; - $content = $this->generateSource(); - - $this->assertFileNotExists($key); - - // Create root directory. - @mkdir($this->directory, 0777, true); - // Create read-only subdirectory. - @mkdir($this->directory.'/cache', 0555); - $this->assertTrue(is_dir($this->directory.'/cache')); - - $this->cache->write($key, $content); - } - - /** - * @expectedException RuntimeException - * @expectedExceptionMessage Failed to write cache file - */ - public function testWriteFailWriteFile() - { - $key = $this->directory.'/cache/cachefile.php'; - $content = $this->generateSource(); - - $this->assertFileNotExists($key); - - // Create a directory in the place of the cache file. - @mkdir($key, 0777, true); - $this->assertTrue(is_dir($key)); - - $this->cache->write($key, $content); - } - - public function testGetTimestamp() - { - $key = $this->directory.'/cache/cachefile.php'; - - $dir = dirname($key); - @mkdir($dir, 0777, true); - $this->assertTrue(is_dir($dir)); - - // Create the file with a specific modification time. - touch($key, 1234567890); - - $this->assertSame(1234567890, $this->cache->getTimestamp($key)); - } - - public function testGetTimestampMissingFile() - { - $key = $this->directory.'/cache/cachefile.php'; - $this->assertSame(0, $this->cache->getTimestamp($key)); - } - - /** - * Test file cache is tolerant towards trailing (back)slashes on the configured cache directory. - * - * @dataProvider provideDirectories - */ - public function testGenerateKey($expected, $input) - { - $cache = new Twig_Cache_Filesystem($input); - $this->assertRegExp($expected, $cache->generateKey('_test_', get_class($this))); - } - - public function provideDirectories() - { - $pattern = '#a/b/[a-zA-Z0-9]+/[a-zA-Z0-9]+.php$#'; - - return array( - array($pattern, 'a/b'), - array($pattern, 'a/b/'), - array($pattern, 'a/b\\'), - array($pattern, 'a/b\\/'), - array($pattern, 'a/b\\//'), - array('#/'.substr($pattern, 1), '/a/b'), - ); - } - - private function generateSource() - { - return strtr(' $this->classname, - )); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/CompilerTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/CompilerTest.php deleted file mode 100644 index 4d4b8df9e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/CompilerTest.php +++ /dev/null @@ -1,33 +0,0 @@ -getMockBuilder('Twig_LoaderInterface')->getMock())); - - $locale = setlocale(LC_NUMERIC, 0); - if (false === $locale) { - $this->markTestSkipped('Your platform does not support locales.'); - } - - $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'); - if (false === setlocale(LC_NUMERIC, $required_locales)) { - $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $required_locales)); - } - - $this->assertEquals('1.2', $compiler->repr(1.2)->getSource()); - $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0))); - - setlocale(LC_NUMERIC, $locale); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/ContainerRuntimeLoaderTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/ContainerRuntimeLoaderTest.php deleted file mode 100644 index c111f9284..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/ContainerRuntimeLoaderTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getMockBuilder('Psr\Container\ContainerInterface')->getMock(); - $container->expects($this->once())->method('has')->with('stdClass')->willReturn(true); - $container->expects($this->once())->method('get')->with('stdClass')->willReturn(new stdClass()); - - $loader = new Twig_ContainerRuntimeLoader($container); - - $this->assertInstanceOf('stdClass', $loader->load('stdClass')); - } - - /** - * @requires PHP 5.3 - */ - public function testLoadUnknownRuntimeReturnsNull() - { - $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); - $container->expects($this->once())->method('has')->with('Foo'); - $container->expects($this->never())->method('get'); - - $loader = new Twig_ContainerRuntimeLoader($container); - $this->assertNull($loader->load('Foo')); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/CustomExtensionTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/CustomExtensionTest.php deleted file mode 100644 index f9d44fda5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/CustomExtensionTest.php +++ /dev/null @@ -1,93 +0,0 @@ -expectException('InvalidArgumentException'); - $this->expectExceptionMessage($expectedExceptionMessage); - } else { - $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); - } - - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $env->addExtension($extension); - $env->getUnaryOperators(); - } - - public function provideInvalidExtensions() - { - return array( - array(new InvalidOperatorExtension(new stdClass()), '"InvalidOperatorExtension::getOperators()" must return an array with operators, got "stdClass".'), - array(new InvalidOperatorExtension(array(1, 2, 3)), '"InvalidOperatorExtension::getOperators()" must return an array of 2 elements, got 3.'), - ); - } -} - -class InvalidOperatorExtension implements Twig_ExtensionInterface -{ - private $operators; - - public function __construct($operators) - { - $this->operators = $operators; - } - - public function initRuntime(Twig_Environment $environment) - { - } - - public function getTokenParsers() - { - return array(); - } - - public function getNodeVisitors() - { - return array(); - } - - public function getFilters() - { - return array(); - } - - public function getTests() - { - return array(); - } - - public function getFunctions() - { - return array(); - } - - public function getGlobals() - { - return array(); - } - - public function getOperators() - { - return $this->operators; - } - - public function getName() - { - return __CLASS__; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php deleted file mode 100644 index ca9f2cf8a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +++ /dev/null @@ -1,686 +0,0 @@ -tokenize('{{ foo }}', 'foo'); - $this->assertEquals('{{ foo }}', $stream->getSource()); - $this->assertEquals('foo', $stream->getFilename()); - } - - /** - * @group legacy - */ - public function testLegacyCompileSourceSignature() - { - $loader = new Twig_Loader_Array(array('foo' => '{{ foo }}')); - $env = new Twig_Environment($loader); - $this->assertContains('getTemplateName', $env->compileSource('{{ foo }}', 'foo')); - } - - /** - * @expectedException LogicException - * @expectedExceptionMessage You must set a loader first. - * @group legacy - */ - public function testRenderNoLoader() - { - $env = new Twig_Environment(); - $env->render('test'); - } - - public function testAutoescapeOption() - { - $loader = new Twig_Loader_Array(array( - 'html' => '{{ foo }} {{ foo }}', - 'js' => '{{ bar }} {{ bar }}', - )); - - $twig = new Twig_Environment($loader, array( - 'debug' => true, - 'cache' => false, - 'autoescape' => array($this, 'escapingStrategyCallback'), - )); - - $this->assertEquals('foo<br/ > foo<br/ >', $twig->render('html', array('foo' => 'foo
    '))); - $this->assertEquals('foo\x3Cbr\x2F\x20\x3E foo\x3Cbr\x2F\x20\x3E', $twig->render('js', array('bar' => 'foo
    '))); - } - - public function escapingStrategyCallback($name) - { - return $name; - } - - public function testGlobals() - { - // to be removed in 2.0 - $loader = $this->getMockBuilder('Twig_EnvironmentTestLoaderInterface')->getMock(); - //$loader = $this->getMockBuilder(array('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface'))->getMock(); - $loader->expects($this->any())->method('getSourceContext')->will($this->returnValue(new Twig_Source('', ''))); - - // globals can be added after calling getGlobals - - $twig = new Twig_Environment($loader); - $twig->addGlobal('foo', 'foo'); - $twig->getGlobals(); - $twig->addGlobal('foo', 'bar'); - $globals = $twig->getGlobals(); - $this->assertEquals('bar', $globals['foo']); - - // globals can be modified after a template has been loaded - $twig = new Twig_Environment($loader); - $twig->addGlobal('foo', 'foo'); - $twig->getGlobals(); - $twig->loadTemplate('index'); - $twig->addGlobal('foo', 'bar'); - $globals = $twig->getGlobals(); - $this->assertEquals('bar', $globals['foo']); - - // globals can be modified after extensions init - $twig = new Twig_Environment($loader); - $twig->addGlobal('foo', 'foo'); - $twig->getGlobals(); - $twig->getFunctions(); - $twig->addGlobal('foo', 'bar'); - $globals = $twig->getGlobals(); - $this->assertEquals('bar', $globals['foo']); - - // globals can be modified after extensions and a template has been loaded - $arrayLoader = new Twig_Loader_Array(array('index' => '{{foo}}')); - $twig = new Twig_Environment($arrayLoader); - $twig->addGlobal('foo', 'foo'); - $twig->getGlobals(); - $twig->getFunctions(); - $twig->loadTemplate('index'); - $twig->addGlobal('foo', 'bar'); - $globals = $twig->getGlobals(); - $this->assertEquals('bar', $globals['foo']); - - $twig = new Twig_Environment($arrayLoader); - $twig->getGlobals(); - $twig->addGlobal('foo', 'bar'); - $template = $twig->loadTemplate('index'); - $this->assertEquals('bar', $template->render(array())); - - /* to be uncomment in Twig 2.0 - // globals cannot be added after a template has been loaded - $twig = new Twig_Environment($loader); - $twig->addGlobal('foo', 'foo'); - $twig->getGlobals(); - $twig->loadTemplate('index'); - try { - $twig->addGlobal('bar', 'bar'); - $this->fail(); - } catch (LogicException $e) { - $this->assertFalse(array_key_exists('bar', $twig->getGlobals())); - } - - // globals cannot be added after extensions init - $twig = new Twig_Environment($loader); - $twig->addGlobal('foo', 'foo'); - $twig->getGlobals(); - $twig->getFunctions(); - try { - $twig->addGlobal('bar', 'bar'); - $this->fail(); - } catch (LogicException $e) { - $this->assertFalse(array_key_exists('bar', $twig->getGlobals())); - } - - // globals cannot be added after extensions and a template has been loaded - $twig = new Twig_Environment($loader); - $twig->addGlobal('foo', 'foo'); - $twig->getGlobals(); - $twig->getFunctions(); - $twig->loadTemplate('index'); - try { - $twig->addGlobal('bar', 'bar'); - $this->fail(); - } catch (LogicException $e) { - $this->assertFalse(array_key_exists('bar', $twig->getGlobals())); - } - - // test adding globals after a template has been loaded without call to getGlobals - $twig = new Twig_Environment($loader); - $twig->loadTemplate('index'); - try { - $twig->addGlobal('bar', 'bar'); - $this->fail(); - } catch (LogicException $e) { - $this->assertFalse(array_key_exists('bar', $twig->getGlobals())); - } - */ - } - - public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate() - { - $cache = new Twig_Cache_Filesystem($dir = sys_get_temp_dir().'/twig'); - $options = array('cache' => $cache, 'auto_reload' => false, 'debug' => false); - - // force compilation - $twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{ foo }}')), $options); - - $key = $cache->generateKey('index', $twig->getTemplateClass('index')); - $cache->write($key, $twig->compileSource(new Twig_Source('{{ foo }}', 'index'))); - - // check that extensions won't be initialized when rendering a template that is already in the cache - $twig = $this - ->getMockBuilder('Twig_Environment') - ->setConstructorArgs(array($loader, $options)) - ->setMethods(array('initExtensions')) - ->getMock() - ; - - $twig->expects($this->never())->method('initExtensions'); - - // render template - $output = $twig->render('index', array('foo' => 'bar')); - $this->assertEquals('bar', $output); - - Twig_Tests_FilesystemHelper::removeDir($dir); - } - - public function testAutoReloadCacheMiss() - { - $templateName = __FUNCTION__; - $templateContent = __FUNCTION__; - - $cache = $this->getMockBuilder('Twig_CacheInterface')->getMock(); - $loader = $this->getMockLoader($templateName, $templateContent); - $twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false)); - - // Cache miss: getTimestamp returns 0 and as a result the load() is - // skipped. - $cache->expects($this->once()) - ->method('generateKey') - ->will($this->returnValue('key')); - $cache->expects($this->once()) - ->method('getTimestamp') - ->will($this->returnValue(0)); - $loader->expects($this->never()) - ->method('isFresh'); - $cache->expects($this->once()) - ->method('write'); - $cache->expects($this->once()) - ->method('load'); - - $twig->loadTemplate($templateName); - } - - public function testAutoReloadCacheHit() - { - $templateName = __FUNCTION__; - $templateContent = __FUNCTION__; - - $cache = $this->getMockBuilder('Twig_CacheInterface')->getMock(); - $loader = $this->getMockLoader($templateName, $templateContent); - $twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false)); - - $now = time(); - - // Cache hit: getTimestamp returns something > extension timestamps and - // the loader returns true for isFresh(). - $cache->expects($this->once()) - ->method('generateKey') - ->will($this->returnValue('key')); - $cache->expects($this->once()) - ->method('getTimestamp') - ->will($this->returnValue($now)); - $loader->expects($this->once()) - ->method('isFresh') - ->will($this->returnValue(true)); - $cache->expects($this->atLeastOnce()) - ->method('load'); - - $twig->loadTemplate($templateName); - } - - public function testAutoReloadOutdatedCacheHit() - { - $templateName = __FUNCTION__; - $templateContent = __FUNCTION__; - - $cache = $this->getMockBuilder('Twig_CacheInterface')->getMock(); - $loader = $this->getMockLoader($templateName, $templateContent); - $twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false)); - - $now = time(); - - $cache->expects($this->once()) - ->method('generateKey') - ->will($this->returnValue('key')); - $cache->expects($this->once()) - ->method('getTimestamp') - ->will($this->returnValue($now)); - $loader->expects($this->once()) - ->method('isFresh') - ->will($this->returnValue(false)); - $cache->expects($this->once()) - ->method('write'); - $cache->expects($this->once()) - ->method('load'); - - $twig->loadTemplate($templateName); - } - - /** - * @group legacy - */ - public function testHasGetExtensionWithDynamicName() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - - $ext1 = new Twig_Tests_EnvironmentTest_Extension_DynamicWithDeprecatedName('ext1'); - $ext2 = new Twig_Tests_EnvironmentTest_Extension_DynamicWithDeprecatedName('ext2'); - $twig->addExtension($ext1); - $twig->addExtension($ext2); - - $this->assertTrue($twig->hasExtension('ext1')); - $this->assertTrue($twig->hasExtension('ext2')); - - $this->assertTrue($twig->hasExtension('Twig_Tests_EnvironmentTest_Extension_DynamicWithDeprecatedName')); - - $this->assertSame($ext1, $twig->getExtension('ext1')); - $this->assertSame($ext2, $twig->getExtension('ext2')); - } - - public function testHasGetExtensionByClassName() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addExtension($ext = new Twig_Tests_EnvironmentTest_Extension()); - $this->assertTrue($twig->hasExtension('Twig_Tests_EnvironmentTest_Extension')); - $this->assertTrue($twig->hasExtension('\Twig_Tests_EnvironmentTest_Extension')); - - $this->assertSame($ext, $twig->getExtension('Twig_Tests_EnvironmentTest_Extension')); - $this->assertSame($ext, $twig->getExtension('\Twig_Tests_EnvironmentTest_Extension')); - - $this->assertTrue($twig->hasExtension('Twig\Tests\EnvironmentTest\Extension')); - $this->assertSame($ext, $twig->getExtension('Twig\Tests\EnvironmentTest\Extension')); - } - - public function testAddExtension() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension()); - - $this->assertArrayHasKey('test', $twig->getTags()); - $this->assertArrayHasKey('foo_filter', $twig->getFilters()); - $this->assertArrayHasKey('foo_function', $twig->getFunctions()); - $this->assertArrayHasKey('foo_test', $twig->getTests()); - $this->assertArrayHasKey('foo_unary', $twig->getUnaryOperators()); - $this->assertArrayHasKey('foo_binary', $twig->getBinaryOperators()); - $this->assertArrayHasKey('foo_global', $twig->getGlobals()); - $visitors = $twig->getNodeVisitors(); - $found = false; - foreach ($visitors as $visitor) { - if ($visitor instanceof Twig_Tests_EnvironmentTest_NodeVisitor) { - $found = true; - } - } - $this->assertTrue($found); - } - - /** - * @requires PHP 5.3 - */ - public function testAddExtensionWithDeprecatedGetGlobals() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithGlobals()); - - $this->deprecations = array(); - set_error_handler(array($this, 'handleError')); - - $this->assertArrayHasKey('foo_global', $twig->getGlobals()); - - $this->assertCount(1, $this->deprecations); - $this->assertContains('Defining the getGlobals() method in the "Twig_Tests_EnvironmentTest_Extension_WithGlobals" extension ', $this->deprecations[0]); - - restore_error_handler(); - } - - /** - * @group legacy - */ - public function testRemoveExtension() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName()); - $twig->removeExtension('environment_test'); - - $this->assertArrayNotHasKey('test', $twig->getTags()); - $this->assertArrayNotHasKey('foo_filter', $twig->getFilters()); - $this->assertArrayNotHasKey('foo_function', $twig->getFunctions()); - $this->assertArrayNotHasKey('foo_test', $twig->getTests()); - $this->assertArrayNotHasKey('foo_unary', $twig->getUnaryOperators()); - $this->assertArrayNotHasKey('foo_binary', $twig->getBinaryOperators()); - $this->assertArrayNotHasKey('foo_global', $twig->getGlobals()); - $this->assertCount(2, $twig->getNodeVisitors()); - } - - public function testAddMockExtension() - { - // should be replaced by the following in 2.0 (this current code is just to avoid a dep notice) - // $extension = $this->getMockBuilder('Twig_Extension')->getMock(); - $extension = eval(<< 'hey')); - - $twig = new Twig_Environment($loader); - $twig->addExtension($extension); - - $this->assertInstanceOf('Twig_ExtensionInterface', $twig->getExtension(get_class($extension))); - $this->assertTrue($twig->isTemplateFresh('page', time())); - } - - public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime()); - $twig->initRuntime(); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any deprecations - $this->addToAssertionCount(1); - } - - /** - * @requires PHP 5.3 - */ - public function testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime()); - - $this->deprecations = array(); - set_error_handler(array($this, 'handleError')); - - $twig->initRuntime(); - - $this->assertCount(1, $this->deprecations); - $this->assertContains('Defining the initRuntime() method in the "Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime" extension is deprecated since version 1.23.', $this->deprecations[0]); - - restore_error_handler(); - } - - public function handleError($type, $msg) - { - if (E_USER_DEPRECATED === $type) { - $this->deprecations[] = $msg; - } - } - - /** - * @requires PHP 5.3 - */ - public function testOverrideExtension() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime()); - - $this->deprecations = array(); - set_error_handler(array($this, 'handleError')); - - $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName()); - $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName()); - - $this->assertCount(1, $this->deprecations); - $this->assertContains('The possibility to register the same extension twice', $this->deprecations[0]); - - restore_error_handler(); - } - - public function testAddRuntimeLoader() - { - $runtimeLoader = $this->getMockBuilder('Twig_RuntimeLoaderInterface')->getMock(); - $runtimeLoader->expects($this->any())->method('load')->will($this->returnValue(new Twig_Tests_EnvironmentTest_Runtime())); - - $loader = new Twig_Loader_Array(array( - 'func_array' => '{{ from_runtime_array("foo") }}', - 'func_array_default' => '{{ from_runtime_array() }}', - 'func_array_named_args' => '{{ from_runtime_array(name="foo") }}', - 'func_string' => '{{ from_runtime_string("foo") }}', - 'func_string_default' => '{{ from_runtime_string() }}', - 'func_string_named_args' => '{{ from_runtime_string(name="foo") }}', - )); - - $twig = new Twig_Environment($loader); - $twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithoutRuntime()); - $twig->addRuntimeLoader($runtimeLoader); - - $this->assertEquals('foo', $twig->render('func_array')); - $this->assertEquals('bar', $twig->render('func_array_default')); - $this->assertEquals('foo', $twig->render('func_array_named_args')); - $this->assertEquals('foo', $twig->render('func_string')); - $this->assertEquals('bar', $twig->render('func_string_default')); - $this->assertEquals('foo', $twig->render('func_string_named_args')); - } - - /** - * @expectedException Twig_Error_Runtime - * @expectedExceptionMessage Circular reference detected for Twig template "base.html.twig", path: base.html.twig -> base.html.twig in "base.html.twig" at line 1 - */ - public function testFailLoadTemplateOnCircularReference() - { - $twig = new Twig_Environment(new Twig_Loader_Array(array( - 'base.html.twig' => '{% extends "base.html.twig" %}', - ))); - - $twig->loadTemplate('base.html.twig'); - } - - /** - * @expectedException Twig_Error_Runtime - * @expectedExceptionMessage Circular reference detected for Twig template "base1.html.twig", path: base1.html.twig -> base2.html.twig -> base1.html.twig in "base1.html.twig" at line 1 - */ - public function testFailLoadTemplateOnComplexCircularReference() - { - $twig = new Twig_Environment(new Twig_Loader_Array(array( - 'base1.html.twig' => '{% extends "base2.html.twig" %}', - 'base2.html.twig' => '{% extends "base1.html.twig" %}', - ))); - - $twig->loadTemplate('base1.html.twig'); - } - - protected function getMockLoader($templateName, $templateContent) - { - // to be removed in 2.0 - $loader = $this->getMockBuilder('Twig_EnvironmentTestLoaderInterface')->getMock(); - //$loader = $this->getMockBuilder(array('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface'))->getMock(); - $loader->expects($this->any()) - ->method('getSourceContext') - ->with($templateName) - ->will($this->returnValue(new Twig_Source($templateContent, $templateName))); - $loader->expects($this->any()) - ->method('getCacheKey') - ->with($templateName) - ->will($this->returnValue($templateName)); - - return $loader; - } -} - -class Twig_Tests_EnvironmentTest_Extension_WithGlobals extends Twig_Extension -{ - public function getGlobals() - { - return array( - 'foo_global' => 'foo_global', - ); - } -} - -class Twig_Tests_EnvironmentTest_Extension extends Twig_Extension implements Twig_Extension_GlobalsInterface -{ - public function getTokenParsers() - { - return array( - new Twig_Tests_EnvironmentTest_TokenParser(), - ); - } - - public function getNodeVisitors() - { - return array( - new Twig_Tests_EnvironmentTest_NodeVisitor(), - ); - } - - public function getFilters() - { - return array( - new Twig_SimpleFilter('foo_filter', 'foo_filter'), - ); - } - - public function getTests() - { - return array( - new Twig_SimpleTest('foo_test', 'foo_test'), - ); - } - - public function getFunctions() - { - return array( - new Twig_SimpleFunction('foo_function', 'foo_function'), - ); - } - - public function getOperators() - { - return array( - array('foo_unary' => array()), - array('foo_binary' => array()), - ); - } - - public function getGlobals() - { - return array( - 'foo_global' => 'foo_global', - ); - } -} -class_alias('Twig_Tests_EnvironmentTest_Extension', 'Twig\Tests\EnvironmentTest\Extension', false); - -class Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName extends Twig_Extension -{ - public function getName() - { - return 'environment_test'; - } -} - -class Twig_Tests_EnvironmentTest_Extension_DynamicWithDeprecatedName extends Twig_Extension -{ - private $name; - - public function __construct($name) - { - $this->name = $name; - } - - public function getName() - { - return $this->name; - } -} - -class Twig_Tests_EnvironmentTest_TokenParser extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - } - - public function getTag() - { - return 'test'; - } -} - -class Twig_Tests_EnvironmentTest_NodeVisitor implements Twig_NodeVisitorInterface -{ - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) - { - return $node; - } - - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) - { - return $node; - } - - public function getPriority() - { - return 0; - } -} - -class Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime extends Twig_Extension -{ - public function initRuntime(Twig_Environment $env) - { - } -} - -class Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime extends Twig_Extension implements Twig_Extension_InitRuntimeInterface -{ - public function initRuntime(Twig_Environment $env) - { - } -} - -class Twig_Tests_EnvironmentTest_ExtensionWithoutRuntime extends Twig_Extension -{ - public function getFunctions() - { - return array( - new Twig_SimpleFunction('from_runtime_array', array('Twig_Tests_EnvironmentTest_Runtime', 'fromRuntime')), - new Twig_SimpleFunction('from_runtime_string', 'Twig_Tests_EnvironmentTest_Runtime::fromRuntime'), - ); - } - - public function getName() - { - return 'from_runtime'; - } -} - -class Twig_Tests_EnvironmentTest_Runtime -{ - public function fromRuntime($name = 'bar') - { - return $name; - } -} - -// to be removed in 2.0 -interface Twig_EnvironmentTestLoaderInterface extends Twig_LoaderInterface, Twig_SourceContextLoaderInterface -{ -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/ErrorTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/ErrorTest.php deleted file mode 100644 index 3ec572ab2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/ErrorTest.php +++ /dev/null @@ -1,211 +0,0 @@ -setSourceContext(new Twig_Source('', new SplFileInfo(__FILE__))); - - $this->assertContains('test'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR.'ErrorTest.php', $error->getMessage()); - } - - public function testErrorWithArrayFilename() - { - $error = new Twig_Error('foo'); - $error->setSourceContext(new Twig_Source('', array('foo' => 'bar'))); - - $this->assertEquals('foo in {"foo":"bar"}', $error->getMessage()); - } - - public function testTwigExceptionGuessWithMissingVarAndArrayLoader() - { - $loader = new Twig_Loader_Array(array( - 'base.html' => '{% block content %}{% endblock %}', - 'index.html' => << 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->getSourceContext()->getName()); - } - } - - public function testTwigExceptionGuessWithExceptionAndArrayLoader() - { - $loader = new Twig_Loader_Array(array( - 'base.html' => '{% block content %}{% endblock %}', - 'index.html' => << true, 'debug' => true, 'cache' => false)); - - $template = $twig->loadTemplate('index.html'); - 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->getSourceContext()->getName()); - } - } - - public function testTwigExceptionGuessWithMissingVarAndFilesystemLoader() - { - $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.', $e->getMessage()); - $this->assertEquals(3, $e->getTemplateLine()); - $this->assertEquals('index.html', $e->getSourceContext()->getName()); - $this->assertEquals(3, $e->getLine()); - $this->assertEquals(strtr(dirname(__FILE__).'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile()); - } - } - - public function testTwigExceptionGuessWithExceptionAndFilesystemLoader() - { - $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('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...").', $e->getMessage()); - $this->assertEquals(3, $e->getTemplateLine()); - $this->assertEquals('index.html', $e->getSourceContext()->getName()); - $this->assertEquals(3, $e->getLine()); - $this->assertEquals(strtr(dirname(__FILE__).'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile()); - } - } - - /** - * @dataProvider getErroredTemplates - */ - public function testTwigExceptionAddsFileAndLine($templates, $name, $line) - { - $loader = new Twig_Loader_Array($templates); - $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(sprintf('Variable "foo" does not exist in "%s" at line %d.', $name, $line), $e->getMessage()); - $this->assertEquals($line, $e->getTemplateLine()); - $this->assertEquals($name, $e->getSourceContext()->getName()); - } - - try { - $template->render(array('foo' => new Twig_Tests_ErrorTest_Foo())); - - $this->fail(); - } catch (Twig_Error_Runtime $e) { - $this->assertEquals(sprintf('An exception has been thrown during the rendering of a template ("Runtime error...") in "%s" at line %d.', $name, $line), $e->getMessage()); - $this->assertEquals($line, $e->getTemplateLine()); - $this->assertEquals($name, $e->getSourceContext()->getName()); - } - } - - public function getErroredTemplates() - { - return array( - // error occurs in a template - array( - array( - 'index' => "\n\n{{ foo.bar }}\n\n\n{{ 'foo' }}", - ), - 'index', 3, - ), - - // error occurs in an included template - array( - array( - 'index' => "{% include 'partial' %}", - 'partial' => '{{ foo.bar }}', - ), - 'partial', 1, - ), - - // error occurs in a parent block when called via parent() - array( - array( - 'index' => "{% extends 'base' %} - {% block content %} - {{ parent() }} - {% endblock %}", - 'base' => '{% block content %}{{ foo.bar }}{% endblock %}', - ), - 'base', 1, - ), - - // error occurs in a block from the child - array( - array( - 'index' => "{% extends 'base' %} - {% block content %} - {{ foo.bar }} - {% endblock %} - {% block foo %} - {{ foo.bar }} - {% endblock %}", - 'base' => '{% block content %}{% endblock %}', - ), - 'index', 3, - ), - ); - } -} - -class Twig_Tests_ErrorTest_Foo -{ - public function bar() - { - throw new Exception('Runtime error...'); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php deleted file mode 100644 index 3a173f035..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php +++ /dev/null @@ -1,377 +0,0 @@ -getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source($template, 'index'))); - } - - public function getFailingTestsForAssignment() - { - return array( - array('{% set false = "foo" %}'), - array('{% set FALSE = "foo" %}'), - array('{% set true = "foo" %}'), - array('{% set TRUE = "foo" %}'), - array('{% set none = "foo" %}'), - array('{% set NONE = "foo" %}'), - array('{% set null = "foo" %}'), - array('{% set NULL = "foo" %}'), - array('{% set 3 = "foo" %}'), - array('{% set 1 + 2 = "foo" %}'), - array('{% set "bar" = "foo" %}'), - array('{% set %}{% endset %}'), - ); - } - - /** - * @dataProvider getTestsForArray - */ - public function testArrayExpression($template, $expected) - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $stream = $env->tokenize(new Twig_Source($template, '')); - $parser = new Twig_Parser($env); - - $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)->getNode('expr')); - } - - /** - * @expectedException Twig_Error_Syntax - * @dataProvider getFailingTestsForArray - */ - public function testArraySyntaxError($template) - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source($template, 'index'))); - } - - public function getFailingTestsForArray() - { - return array( - array('{{ [1, "a": "b"] }}'), - array('{{ {"a": "b", 2} }}'), - ); - } - - public function getTestsForArray() - { - return array( - // simple array - array('{{ [1, 2] }}', new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant(0, 1), - new Twig_Node_Expression_Constant(1, 1), - - new Twig_Node_Expression_Constant(1, 1), - new Twig_Node_Expression_Constant(2, 1), - ), 1), - ), - - // array with trailing , - array('{{ [1, 2, ] }}', new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant(0, 1), - new Twig_Node_Expression_Constant(1, 1), - - new Twig_Node_Expression_Constant(1, 1), - new Twig_Node_Expression_Constant(2, 1), - ), 1), - ), - - // simple hash - array('{{ {"a": "b", "b": "c"} }}', new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant('a', 1), - new Twig_Node_Expression_Constant('b', 1), - - new Twig_Node_Expression_Constant('b', 1), - new Twig_Node_Expression_Constant('c', 1), - ), 1), - ), - - // hash with trailing , - array('{{ {"a": "b", "b": "c", } }}', new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant('a', 1), - new Twig_Node_Expression_Constant('b', 1), - - new Twig_Node_Expression_Constant('b', 1), - new Twig_Node_Expression_Constant('c', 1), - ), 1), - ), - - // hash in an array - array('{{ [1, {"a": "b", "b": "c"}] }}', new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant(0, 1), - new Twig_Node_Expression_Constant(1, 1), - - new Twig_Node_Expression_Constant(1, 1), - new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant('a', 1), - new Twig_Node_Expression_Constant('b', 1), - - new Twig_Node_Expression_Constant('b', 1), - new Twig_Node_Expression_Constant('c', 1), - ), 1), - ), 1), - ), - - // array in a hash - array('{{ {"a": [1, 2], "b": "c"} }}', new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant('a', 1), - new Twig_Node_Expression_Array(array( - new Twig_Node_Expression_Constant(0, 1), - new Twig_Node_Expression_Constant(1, 1), - - new Twig_Node_Expression_Constant(1, 1), - new Twig_Node_Expression_Constant(2, 1), - ), 1), - new Twig_Node_Expression_Constant('b', 1), - new Twig_Node_Expression_Constant('c', 1), - ), 1), - ), - ); - } - - /** - * @expectedException Twig_Error_Syntax - */ - public function testStringExpressionDoesNotConcatenateTwoConsecutiveStrings() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); - $stream = $env->tokenize(new Twig_Source('{{ "a" "b" }}', 'index')); - $parser = new Twig_Parser($env); - - $parser->parse($stream); - } - - /** - * @dataProvider getTestsForString - */ - public function testStringExpression($template, $expected) - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); - $stream = $env->tokenize(new Twig_Source($template, '')); - $parser = new Twig_Parser($env); - - $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)->getNode('expr')); - } - - public function getTestsForString() - { - return array( - array( - '{{ "foo" }}', new Twig_Node_Expression_Constant('foo', 1), - ), - array( - '{{ "foo #{bar}" }}', new Twig_Node_Expression_Binary_Concat( - new Twig_Node_Expression_Constant('foo ', 1), - new Twig_Node_Expression_Name('bar', 1), - 1 - ), - ), - array( - '{{ "foo #{bar} baz" }}', new Twig_Node_Expression_Binary_Concat( - new Twig_Node_Expression_Binary_Concat( - new Twig_Node_Expression_Constant('foo ', 1), - new Twig_Node_Expression_Name('bar', 1), - 1 - ), - new Twig_Node_Expression_Constant(' baz', 1), - 1 - ), - ), - - array( - '{{ "foo #{"foo #{bar} baz"} baz" }}', new Twig_Node_Expression_Binary_Concat( - new Twig_Node_Expression_Binary_Concat( - new Twig_Node_Expression_Constant('foo ', 1), - new Twig_Node_Expression_Binary_Concat( - new Twig_Node_Expression_Binary_Concat( - new Twig_Node_Expression_Constant('foo ', 1), - new Twig_Node_Expression_Name('bar', 1), - 1 - ), - new Twig_Node_Expression_Constant(' baz', 1), - 1 - ), - 1 - ), - new Twig_Node_Expression_Constant(' baz', 1), - 1 - ), - ), - ); - } - - /** - * @expectedException Twig_Error_Syntax - */ - public function testAttributeCallDoesNotSupportNamedArguments() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{{ foo.bar(name="Foo") }}', 'index'))); - } - - /** - * @expectedException Twig_Error_Syntax - */ - public function testMacroCallDoesNotSupportNamedArguments() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{% from _self import foo %}{% macro foo() %}{% endmacro %}{{ foo(name="Foo") }}', 'index'))); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1. - */ - public function testMacroDefinitionDoesNotSupportNonNameVariableName() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{% macro foo("a") %}{% endmacro %}', 'index'))); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage A default value for an argument must be a constant (a boolean, a string, a number, or an array) in "index" at line 1 - * @dataProvider getMacroDefinitionDoesNotSupportNonConstantDefaultValues - */ - public function testMacroDefinitionDoesNotSupportNonConstantDefaultValues($template) - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source($template, 'index'))); - } - - public function getMacroDefinitionDoesNotSupportNonConstantDefaultValues() - { - return array( - array('{% macro foo(name = "a #{foo} a") %}{% endmacro %}'), - array('{% macro foo(name = [["b", "a #{foo} a"]]) %}{% endmacro %}'), - ); - } - - /** - * @dataProvider getMacroDefinitionSupportsConstantDefaultValues - */ - public function testMacroDefinitionSupportsConstantDefaultValues($template) - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source($template, 'index'))); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function getMacroDefinitionSupportsConstantDefaultValues() - { - return array( - array('{% macro foo(name = "aa") %}{% endmacro %}'), - array('{% macro foo(name = 12) %}{% endmacro %}'), - array('{% macro foo(name = true) %}{% endmacro %}'), - array('{% macro foo(name = ["a"]) %}{% endmacro %}'), - array('{% macro foo(name = [["a"]]) %}{% endmacro %}'), - array('{% macro foo(name = {a: "a"}) %}{% endmacro %}'), - array('{% macro foo(name = {a: {b: "a"}}) %}{% endmacro %}'), - ); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "cycl" function. Did you mean "cycle" in "index" at line 1? - */ - public function testUnknownFunction() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{{ cycl() }}', 'index'))); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "foobar" function in "index" at line 1. - */ - public function testUnknownFunctionWithoutSuggestions() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{{ foobar() }}', 'index'))); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "lowe" filter. Did you mean "lower" in "index" at line 1? - */ - public function testUnknownFilter() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{{ 1|lowe }}', 'index'))); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "foobar" filter in "index" at line 1. - */ - public function testUnknownFilterWithoutSuggestions() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{{ 1|foobar }}', 'index'))); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "nul" test. Did you mean "null" in "index" at line 1 - */ - public function testUnknownTest() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - $stream = $env->tokenize(new Twig_Source('{{ 1 is nul }}', 'index')); - $parser->parse($stream); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "foobar" test in "index" at line 1. - */ - public function testUnknownTestWithoutSuggestions() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $parser = new Twig_Parser($env); - - $parser->parse($env->tokenize(new Twig_Source('{{ 1 is foobar }}', 'index'))); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php deleted file mode 100644 index ca69b4af6..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php +++ /dev/null @@ -1,355 +0,0 @@ -getMockBuilder('Twig_LoaderInterface')->getMock()); - - for ($i = 0; $i < 100; ++$i) { - $this->assertTrue(in_array(twig_random($env, $value), $expectedInArray, true)); // assertContains() would not consider the type - } - } - - public function getRandomFunctionTestData() - { - return array( - array(// array - array('apple', 'orange', 'citrus'), - array('apple', 'orange', 'citrus'), - ), - array(// Traversable - new ArrayObject(array('apple', 'orange', 'citrus')), - array('apple', 'orange', 'citrus'), - ), - array(// unicode string - 'Ä€é', - array('Ä', '€', 'é'), - ), - array(// numeric but string - '123', - array('1', '2', '3'), - ), - array(// integer - 5, - range(0, 5, 1), - ), - array(// float - 5.9, - range(0, 5, 1), - ), - array(// negative - -2, - array(0, -1, -2), - ), - ); - } - - public function testRandomFunctionWithoutParameter() - { - $max = mt_getrandmax(); - - for ($i = 0; $i < 100; ++$i) { - $val = twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $this->assertTrue(is_int($val) && $val >= 0 && $val <= $max); - } - } - - public function testRandomFunctionReturnsAsIs() - { - $this->assertSame('', twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), '')); - $this->assertSame('', twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('charset' => null)), '')); - - $instance = new stdClass(); - $this->assertSame($instance, twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), $instance)); - } - - /** - * @expectedException Twig_Error_Runtime - */ - public function testRandomFunctionOfEmptyArrayThrowsException() - { - twig_random(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), array()); - } - - public function testRandomFunctionOnNonUTF8String() - { - if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) { - $this->markTestSkipped('needs iconv or mbstring'); - } - - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->setCharset('ISO-8859-1'); - - $text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8'); - for ($i = 0; $i < 30; ++$i) { - $rand = twig_random($twig, $text); - $this->assertTrue(in_array(twig_convert_encoding($rand, 'UTF-8', 'ISO-8859-1'), array('Ä', 'é'), true)); - } - } - - public function testReverseFilterOnNonUTF8String() - { - if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) { - $this->markTestSkipped('needs iconv or mbstring'); - } - - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->setCharset('ISO-8859-1'); - - $input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8'); - $output = twig_convert_encoding(twig_reverse_filter($twig, $input), 'UTF-8', 'ISO-8859-1'); - - $this->assertEquals($output, 'éÄ'); - } - - /** - * @dataProvider provideCustomEscaperCases - */ - public function testCustomEscaper($expected, $string, $strategy) - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->getExtension('Twig_Extension_Core')->setEscaper('foo', 'foo_escaper_for_test'); - - $this->assertSame($expected, twig_escape_filter($twig, $string, $strategy)); - } - - public function provideCustomEscaperCases() - { - return array( - array('fooUTF-8', 'foo', 'foo'), - array('UTF-8', null, 'foo'), - array('42UTF-8', 42, 'foo'), - ); - } - - /** - * @expectedException Twig_Error_Runtime - */ - public function testUnknownCustomEscaper() - { - twig_escape_filter(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), 'foo', 'bar'); - } - - /** - * @dataProvider provideTwigFirstCases - */ - public function testTwigFirst($expected, $input) - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $this->assertSame($expected, twig_first($twig, $input)); - } - - public function provideTwigFirstCases() - { - $i = array(1 => 'a', 2 => 'b', 3 => 'c'); - - return array( - array('a', 'abc'), - array(1, array(1, 2, 3)), - array('', null), - array('', ''), - array('a', new CoreTestIterator($i, array_keys($i), true, 3)), - ); - } - - /** - * @dataProvider provideTwigLastCases - */ - public function testTwigLast($expected, $input) - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $this->assertSame($expected, twig_last($twig, $input)); - } - - public function provideTwigLastCases() - { - $i = array(1 => 'a', 2 => 'b', 3 => 'c'); - - return array( - array('c', 'abc'), - array(3, array(1, 2, 3)), - array('', null), - array('', ''), - array('c', new CoreTestIterator($i, array_keys($i), true)), - ); - } - - /** - * @dataProvider provideArrayKeyCases - */ - public function testArrayKeysFilter(array $expected, $input) - { - $this->assertSame($expected, twig_get_array_keys_filter($input)); - } - - public function provideArrayKeyCases() - { - $array = array('a' => 'a1', 'b' => 'b1', 'c' => 'c1'); - $keys = array_keys($array); - - return array( - array($keys, $array), - array($keys, new CoreTestIterator($array, $keys)), - array($keys, new CoreTestIteratorAggregate($array, $keys)), - array($keys, new CoreTestIteratorAggregateAggregate($array, $keys)), - array(array(), null), - array(array('a'), new SimpleXMLElement('')), - ); - } - - /** - * @dataProvider provideInFilterCases - */ - public function testInFilter($expected, $value, $compare) - { - $this->assertSame($expected, twig_in_filter($value, $compare)); - } - - public function provideInFilterCases() - { - $array = array(1, 2, 'a' => 3, 5, 6, 7); - $keys = array_keys($array); - - return array( - array(true, 1, $array), - array(true, '3', $array), - array(true, '3', 'abc3def'), - array(true, 1, new CoreTestIterator($array, $keys, true, 1)), - array(true, '3', new CoreTestIterator($array, $keys, true, 3)), - array(true, '3', new CoreTestIteratorAggregateAggregate($array, $keys, true, 3)), - array(false, 4, $array), - array(false, 4, new CoreTestIterator($array, $keys, true)), - array(false, 4, new CoreTestIteratorAggregateAggregate($array, $keys, true)), - array(false, 1, 1), - array(true, 'b', new SimpleXMLElement('b')), - ); - } - - /** - * @dataProvider provideSliceFilterCases - */ - public function testSliceFilter($expected, $input, $start, $length = null, $preserveKeys = false) - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $this->assertSame($expected, twig_slice($twig, $input, $start, $length, $preserveKeys)); - } - - public function provideSliceFilterCases() - { - $i = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4); - $keys = array_keys($i); - - return array( - array(array('a' => 1), $i, 0, 1, true), - array(array('a' => 1), $i, 0, 1, false), - array(array('b' => 2, 'c' => 3), $i, 1, 2), - array(array(1), array(1, 2, 3, 4), 0, 1), - array(array(2, 3), array(1, 2, 3, 4), 1, 2), - array(array(2, 3), new CoreTestIterator($i, $keys, true), 1, 2), - array(array('c' => 3, 'd' => 4), new CoreTestIteratorAggregate($i, $keys, true), 2, null, true), - array($i, new CoreTestIterator($i, $keys, true), 0, count($keys) + 10, true), - array(array(), new CoreTestIterator($i, $keys, true), count($keys) + 10), - array('de', 'abcdef', 3, 2), - array(array(), new SimpleXMLElement('12'), 3), - array(array(), new ArrayIterator(array(1, 2)), 3), - ); - } -} - -function foo_escaper_for_test(Twig_Environment $env, $string, $charset) -{ - return $string.$charset; -} - -final class CoreTestIteratorAggregate implements IteratorAggregate -{ - private $iterator; - - public function __construct(array $array, array $keys, $allowAccess = false, $maxPosition = false) - { - $this->iterator = new CoreTestIterator($array, $keys, $allowAccess, $maxPosition); - } - - public function getIterator() - { - return $this->iterator; - } -} - -final class CoreTestIteratorAggregateAggregate implements IteratorAggregate -{ - private $iterator; - - public function __construct(array $array, array $keys, $allowValueAccess = false, $maxPosition = false) - { - $this->iterator = new CoreTestIteratorAggregate($array, $keys, $allowValueAccess, $maxPosition); - } - - public function getIterator() - { - return $this->iterator; - } -} - -final class CoreTestIterator implements Iterator -{ - private $position; - private $array; - private $arrayKeys; - private $allowValueAccess; - private $maxPosition; - - public function __construct(array $values, array $keys, $allowValueAccess = false, $maxPosition = false) - { - $this->array = $values; - $this->arrayKeys = $keys; - $this->position = 0; - $this->allowValueAccess = $allowValueAccess; - $this->maxPosition = false === $maxPosition ? count($values) + 1 : $maxPosition; - } - - public function rewind() - { - $this->position = 0; - } - - public function current() - { - if ($this->allowValueAccess) { - return $this->array[$this->key()]; - } - - throw new LogicException('Code should only use the keys, not the values provided by iterator.'); - } - - public function key() - { - return $this->arrayKeys[$this->position]; - } - - public function next() - { - ++$this->position; - if ($this->position === $this->maxPosition) { - throw new LogicException(sprintf('Code should not iterate beyond %d.', $this->maxPosition)); - } - } - - public function valid() - { - return isset($this->arrayKeys[$this->position]); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php deleted file mode 100644 index 9d90e0ea7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php +++ /dev/null @@ -1,304 +0,0 @@ - 'Fabien', - 'obj' => new FooObject(), - 'arr' => array('obj' => new FooObject()), - ); - - self::$templates = array( - '1_basic1' => '{{ obj.foo }}', - '1_basic2' => '{{ name|upper }}', - '1_basic3' => '{% if name %}foo{% endif %}', - '1_basic4' => '{{ obj.bar }}', - '1_basic5' => '{{ obj }}', - '1_basic6' => '{{ arr.obj }}', - '1_basic7' => '{{ cycle(["foo","bar"], 1) }}', - '1_basic8' => '{{ obj.getfoobar }}{{ obj.getFooBar }}', - '1_basic9' => '{{ obj.foobar }}{{ obj.fooBar }}', - '1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}', - '1_layout' => '{% block content %}{% endblock %}', - '1_child' => "{% extends \"1_layout\" %}\n{% block content %}\n{{ \"a\"|json_encode }}\n{% endblock %}", - '1_include' => '{{ include("1_basic1", sandboxed=true) }}', - ); - } - - /** - * @expectedException Twig_Sandbox_SecurityError - * @expectedExceptionMessage Filter "json_encode" is not allowed in "1_child" at line 3. - */ - public function testSandboxWithInheritance() - { - $twig = $this->getEnvironment(true, array(), self::$templates, array('block')); - $twig->loadTemplate('1_child')->render(array()); - } - - public function testSandboxGloballySet() - { - $twig = $this->getEnvironment(false, array(), self::$templates); - $this->assertEquals('FOO', $twig->loadTemplate('1_basic')->render(self::$params), 'Sandbox does nothing if it is disabled globally'); - } - - public function testSandboxUnallowedMethodAccessor() - { - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('1_basic1')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception if an unallowed method is called'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedMethodError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedMethodError'); - $this->assertEquals('FooObject', $e->getClassName(), 'Exception should be raised on the "FooObject" class'); - $this->assertEquals('foo', $e->getMethodName(), 'Exception should be raised on the "foo" method'); - } - } - - public function testSandboxUnallowedFilter() - { - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('1_basic2')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception if an unallowed filter is called'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedFilterError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedFilterError'); - $this->assertEquals('upper', $e->getFilterName(), 'Exception should be raised on the "upper" filter'); - } - } - - public function testSandboxUnallowedTag() - { - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('1_basic3')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception if an unallowed tag is used in the template'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedTagError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedTagError'); - $this->assertEquals('if', $e->getTagName(), 'Exception should be raised on the "if" tag'); - } - } - - public function testSandboxUnallowedProperty() - { - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('1_basic4')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception if an unallowed property is called in the template'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedPropertyError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedPropertyError'); - $this->assertEquals('FooObject', $e->getClassName(), 'Exception should be raised on the "FooObject" class'); - $this->assertEquals('bar', $e->getPropertyName(), 'Exception should be raised on the "bar" property'); - } - } - - public function testSandboxUnallowedToString() - { - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('1_basic5')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception if an unallowed method (__toString()) is called in the template'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedMethodError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedMethodError'); - $this->assertEquals('FooObject', $e->getClassName(), 'Exception should be raised on the "FooObject" class'); - $this->assertEquals('__tostring', $e->getMethodName(), 'Exception should be raised on the "__toString" method'); - } - } - - public function testSandboxUnallowedToStringArray() - { - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('1_basic6')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception if an unallowed method (__toString()) is called in the template'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedMethodError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedMethodError'); - $this->assertEquals('FooObject', $e->getClassName(), 'Exception should be raised on the "FooObject" class'); - $this->assertEquals('__tostring', $e->getMethodName(), 'Exception should be raised on the "__toString" method'); - } - } - - public function testSandboxUnallowedFunction() - { - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('1_basic7')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception if an unallowed function is called in the template'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedFunctionError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedFunctionError'); - $this->assertEquals('cycle', $e->getFunctionName(), 'Exception should be raised on the "cycle" function'); - } - } - - public function testSandboxAllowMethodFoo() - { - $twig = $this->getEnvironment(true, array(), self::$templates, array(), array(), array('FooObject' => 'foo')); - FooObject::reset(); - $this->assertEquals('foo', $twig->loadTemplate('1_basic1')->render(self::$params), 'Sandbox allow some methods'); - $this->assertEquals(1, FooObject::$called['foo'], 'Sandbox only calls method once'); - } - - public function testSandboxAllowMethodToString() - { - $twig = $this->getEnvironment(true, array(), self::$templates, array(), array(), array('FooObject' => '__toString')); - FooObject::reset(); - $this->assertEquals('foo', $twig->loadTemplate('1_basic5')->render(self::$params), 'Sandbox allow some methods'); - $this->assertEquals(1, FooObject::$called['__toString'], 'Sandbox only calls method once'); - } - - public function testSandboxAllowMethodToStringDisabled() - { - $twig = $this->getEnvironment(false, array(), self::$templates); - FooObject::reset(); - $this->assertEquals('foo', $twig->loadTemplate('1_basic5')->render(self::$params), 'Sandbox allows __toString when sandbox disabled'); - $this->assertEquals(1, FooObject::$called['__toString'], 'Sandbox only calls method once'); - } - - public function testSandboxAllowFilter() - { - $twig = $this->getEnvironment(true, array(), self::$templates, array(), array('upper')); - $this->assertEquals('FABIEN', $twig->loadTemplate('1_basic2')->render(self::$params), 'Sandbox allow some filters'); - } - - public function testSandboxAllowTag() - { - $twig = $this->getEnvironment(true, array(), self::$templates, array('if')); - $this->assertEquals('foo', $twig->loadTemplate('1_basic3')->render(self::$params), 'Sandbox allow some tags'); - } - - public function testSandboxAllowProperty() - { - $twig = $this->getEnvironment(true, array(), self::$templates, array(), array(), array(), array('FooObject' => 'bar')); - $this->assertEquals('bar', $twig->loadTemplate('1_basic4')->render(self::$params), 'Sandbox allow some properties'); - } - - public function testSandboxAllowFunction() - { - $twig = $this->getEnvironment(true, array(), self::$templates, array(), array(), array(), array(), array('cycle')); - $this->assertEquals('bar', $twig->loadTemplate('1_basic7')->render(self::$params), 'Sandbox allow some functions'); - } - - public function testSandboxAllowFunctionsCaseInsensitive() - { - foreach (array('getfoobar', 'getFoobar', 'getFooBar') as $name) { - $twig = $this->getEnvironment(true, array(), self::$templates, array(), array(), array('FooObject' => $name)); - FooObject::reset(); - $this->assertEquals('foobarfoobar', $twig->loadTemplate('1_basic8')->render(self::$params), 'Sandbox allow methods in a case-insensitive way'); - $this->assertEquals(2, FooObject::$called['getFooBar'], 'Sandbox only calls method once'); - - $this->assertEquals('foobarfoobar', $twig->loadTemplate('1_basic9')->render(self::$params), 'Sandbox allow methods via shortcut names (ie. without get/set)'); - } - } - - public function testSandboxLocallySetForAnInclude() - { - self::$templates = array( - '2_basic' => '{{ obj.foo }}{% include "2_included" %}{{ obj.foo }}', - '2_included' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}', - ); - - $twig = $this->getEnvironment(false, array(), self::$templates); - $this->assertEquals('fooFOOfoo', $twig->loadTemplate('2_basic')->render(self::$params), 'Sandbox does nothing if disabled globally and sandboxed not used for the include'); - - self::$templates = array( - '3_basic' => '{{ obj.foo }}{% sandbox %}{% include "3_included" %}{% endsandbox %}{{ obj.foo }}', - '3_included' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}', - ); - - $twig = $this->getEnvironment(true, array(), self::$templates); - try { - $twig->loadTemplate('3_basic')->render(self::$params); - $this->fail('Sandbox throws a SecurityError exception when the included file is sandboxed'); - } catch (Twig_Sandbox_SecurityError $e) { - $this->assertInstanceOf('Twig_Sandbox_SecurityNotAllowedTagError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedTagError'); - $this->assertEquals('sandbox', $e->getTagName()); - } - } - - public function testMacrosInASandbox() - { - $twig = $this->getEnvironment(true, array('autoescape' => 'html'), array('index' => <<{{ text }}

    {% endmacro %} - -{{- macros.test('username') }} -EOF - ), array('macro', 'import'), array('escape')); - - $this->assertEquals('

    username

    ', $twig->loadTemplate('index')->render(array())); - } - - public function testSandboxDisabledAfterIncludeFunctionError() - { - $twig = $this->getEnvironment(false, array(), self::$templates); - - $e = null; - try { - $twig->loadTemplate('1_include')->render(self::$params); - } catch (Throwable $e) { - } catch (Exception $e) { - } - if ($e === null) { - $this->fail('An exception should be thrown for this test to be valid.'); - } - - $this->assertFalse($twig->getExtension('Twig_Extension_Sandbox')->isSandboxed(), 'Sandboxed include() function call should not leave Sandbox enabled when an error occurs.'); - } - - protected function getEnvironment($sandboxed, $options, $templates, $tags = array(), $filters = array(), $methods = array(), $properties = array(), $functions = array()) - { - $loader = new Twig_Loader_Array($templates); - $twig = new Twig_Environment($loader, array_merge(array('debug' => true, 'cache' => false, 'autoescape' => false), $options)); - $policy = new Twig_Sandbox_SecurityPolicy($tags, $filters, $methods, $properties, $functions); - $twig->addExtension(new Twig_Extension_Sandbox($policy, $sandboxed)); - - return $twig; - } -} - -class FooObject -{ - public static $called = array('__toString' => 0, 'foo' => 0, 'getFooBar' => 0); - - public $bar = 'bar'; - - public static function reset() - { - self::$called = array('__toString' => 0, 'foo' => 0, 'getFooBar' => 0); - } - - public function __toString() - { - ++self::$called['__toString']; - - return 'foo'; - } - - public function foo() - { - ++self::$called['foo']; - - return 'foo'; - } - - public function getFooBar() - { - ++self::$called['getFooBar']; - - return 'foobar'; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/FactoryRuntimeLoaderTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/FactoryRuntimeLoaderTest.php deleted file mode 100644 index f97d30694..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/FactoryRuntimeLoaderTest.php +++ /dev/null @@ -1,32 +0,0 @@ - 'getRuntime')); - - $this->assertInstanceOf('stdClass', $loader->load('stdClass')); - } - - public function testLoadReturnsNullForUnmappedRuntime() - { - $loader = new Twig_FactoryRuntimeLoader(); - - $this->assertNull($loader->load('stdClass')); - } -} - -function getRuntime() -{ - return new stdClass(); -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php deleted file mode 100644 index e8a23eade..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php +++ /dev/null @@ -1,63 +0,0 @@ -tmpDir = sys_get_temp_dir().'/TwigTests'; - if (!file_exists($this->tmpDir)) { - @mkdir($this->tmpDir, 0777, true); - } - - if (!is_writable($this->tmpDir)) { - $this->markTestSkipped(sprintf('Unable to run the tests as "%s" is not writable.', $this->tmpDir)); - } - - $this->env = new Twig_Environment(new Twig_Loader_Array(array('index' => 'index', 'index2' => 'index2')), array('cache' => $this->tmpDir)); - } - - protected function tearDown() - { - Twig_Tests_FilesystemHelper::removeDir($this->tmpDir); - } - - /** - * @group legacy - */ - public function testWritingCacheFiles() - { - $name = 'index'; - $this->env->loadTemplate($name); - $cacheFileName = $this->env->getCacheFilename($name); - - $this->assertFileExists($cacheFileName, 'Cache file does not exist.'); - } - - /** - * @group legacy - */ - public function testClearingCacheFiles() - { - $name = 'index2'; - $this->env->loadTemplate($name); - $cacheFileName = $this->env->getCacheFilename($name); - - $this->assertFileExists($cacheFileName, 'Cache file does not exist.'); - $this->env->clearCacheFiles(); - $this->assertFileNotExists($cacheFileName, 'Cache file was not cleared.'); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php deleted file mode 100644 index a983a47c8..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php +++ /dev/null @@ -1,51 +0,0 @@ -assertSame($strategy, Twig_FileExtensionEscapingStrategy::guess($filename)); - } - - public function getGuessData() - { - return array( - // default - array('html', 'foo.html'), - array('html', 'foo.html.twig'), - array('html', 'foo'), - array('html', 'foo.bar.twig'), - array('html', 'foo.txt/foo'), - array('html', 'foo.txt/foo.js/'), - - // css - array('css', 'foo.css'), - array('css', 'foo.css.twig'), - array('css', 'foo.twig.css'), - array('css', 'foo.js.css'), - array('css', 'foo.js.css.twig'), - - // js - array('js', 'foo.js'), - array('js', 'foo.js.twig'), - array('js', 'foo.txt/foo.js'), - array('js', 'foo.txt.twig/foo.js'), - - // txt - array(false, 'foo.txt'), - array(false, 'foo.txt.twig'), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/FilesystemHelper.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/FilesystemHelper.php deleted file mode 100644 index 0e315e8f7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/FilesystemHelper.php +++ /dev/null @@ -1,30 +0,0 @@ - $fileInfo) { - if ($iterator->isDot()) { - continue; - } - - if ($fileInfo->isDir()) { - rmdir($filename); - } else { - unlink($filename); - } - } - rmdir($dir); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/block.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/block.test deleted file mode 100644 index 1290973a5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/block.test +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -blocks and autoescape ---TEMPLATE-- -{{ include('unrelated.txt.twig') -}} -{{ include('template.html.twig') -}} ---TEMPLATE(unrelated.txt.twig)-- -{% block content %}{% endblock %} ---TEMPLATE(template.html.twig)-- -{% extends 'parent.html.twig' %} -{% block content %} -{{ br -}} -{% endblock %} ---TEMPLATE(parent.html.twig)-- -{% set _content = block('content')|raw %} -{{ _content|raw }} ---DATA-- -return array('br' => '
    ') ---CONFIG-- -return array('autoescape' => 'name') ---EXPECT-- -<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/filename.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/filename.test deleted file mode 100644 index b091ad34d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/filename.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"filename" autoescape strategy ---TEMPLATE-- -{{ br -}} -{{ include('index.html.twig') -}} -{{ include('index.txt.twig') -}} ---TEMPLATE(index.html.twig)-- -{{ br -}} ---TEMPLATE(index.txt.twig)-- -{{ br -}} ---DATA-- -return array('br' => '
    ') ---CONFIG-- -return array('autoescape' => 'filename') ---EXPECT-- -<br /> -<br /> -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/name.test deleted file mode 100644 index 04299bed3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/name.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"name" autoescape strategy ---TEMPLATE-- -{{ br -}} -{{ include('index.js.twig') -}} -{{ include('index.html.twig') -}} -{{ include('index.txt.twig') -}} ---TEMPLATE(index.js.twig)-- -{{ br -}} ---TEMPLATE(index.html.twig)-- -{{ br -}} ---TEMPLATE(index.txt.twig)-- -{{ br -}} ---DATA-- -return array('br' => '
    ') ---CONFIG-- -return array('autoescape' => 'name') ---EXPECT-- -<br /> -\x3Cbr\x20\x2F\x3E -<br /> -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html deleted file mode 100644 index cb0dbe444..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/base.html +++ /dev/null @@ -1 +0,0 @@ -{% block content %}{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html deleted file mode 100644 index df57c822f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/errors/index.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends 'base.html' %} -{% block content %} - {{ foo.bar }} -{% endblock %} -{% block foo %} - {{ foo.bar }} -{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/child_contents_outside_blocks.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/child_contents_outside_blocks.test deleted file mode 100644 index a3f0b50ff..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/child_contents_outside_blocks.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Exception for child templates defining contents outside blocks defined by parent ---TEMPLATE-- -{% extends 'base.twig' %} - -Content outside a block. - -{% block sidebar %} - Content inside a block. -{% endblock %} ---TEMPLATE(base.twig)-- -{% block sidebar %} -{% endblock %} ---EXCEPTION-- -Twig_Error_Syntax: A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag in "index.twig" at line 3? diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test deleted file mode 100644 index 7ff2eedb7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Exception for multiline array with undefined variable ---TEMPLATE-- -{% set foo = { - foo: 'foo', - bar: 'bar', - - - foobar: foobar, - - - - foo2: foo2, -} %} ---DATA-- -return array('foobar' => 'foobar') ---EXCEPTION-- -Twig_Error_Runtime: Variable "foo2" does not exist in "index.twig" at line 11. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test deleted file mode 100644 index c425069bf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Exception for multiline array with undefined variable ---TEMPLATE-- -{% set foo = { - foo: 'foo', - bar: 'bar', - - - foobar: foobar, - - - - foo2: foo2, -} %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Runtime: Variable "foobar" does not exist in "index.twig" at line 7. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test deleted file mode 100644 index 2f94a5ee9..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Exception for multile function with undefined variable ---TEMPLATE-- -{{ include('foo', - with_context=with_context -) }} ---TEMPLATE(foo)-- -Foo ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Runtime: Variable "with_context" does not exist in "index.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test deleted file mode 100644 index 64761fcf1..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test +++ /dev/null @@ -1,9 +0,0 @@ ---TEST-- -Exception for multiline function with unknown argument ---TEMPLATE-- -{{ include('foo', - with_context=True, - invalid=False -) }} ---EXCEPTION-- -Twig_Error_Syntax: Unknown argument "invalid" for function "include(template, variables, with_context, ignore_missing, sandboxed)" in "index.twig" at line 4. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test deleted file mode 100644 index 7b3b1daf9..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Exception for multiline tag with undefined variable ---TEMPLATE-- -{% include 'foo' - with vars -%} ---TEMPLATE(foo)-- -Foo ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Runtime: Variable "vars" does not exist in "index.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/syntax_error_in_reused_template.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/syntax_error_in_reused_template.test deleted file mode 100644 index 9ca418b22..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/syntax_error_in_reused_template.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Exception for syntax error in reused template ---TEMPLATE-- -{% use 'foo.twig' %} ---TEMPLATE(foo.twig)-- -{% block bar %} - {% do node.data = 5 %} -{% endblock %} ---EXCEPTION-- -Twig_Error_Syntax: Unexpected token "operator" of value "=" ("end of statement block" expected) in "foo.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/unclosed_tag.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/unclosed_tag.test deleted file mode 100644 index 2c35ad564..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/unclosed_tag.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Exception for an unclosed tag ---TEMPLATE-- -{% block foo %} - {% if foo %} - - - - - {% for i in fo %} - - - - {% endfor %} - - - -{% endblock %} ---EXCEPTION-- -Twig_Error_Syntax: Unexpected "endblock" tag (expecting closing tag for the "if" tag defined near line 4) in "index.twig" at line 16. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_parent.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_parent.test deleted file mode 100644 index c8e7a0973..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_parent.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Exception for an undefined parent ---TEMPLATE-- -{% extends 'foo.html' %} - -{% set foo = "foo" %} ---EXCEPTION-- -Twig_Error_Loader: Template "foo.html" is not defined in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_template_in_child_template.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_template_in_child_template.test deleted file mode 100644 index 1992510b2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_template_in_child_template.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Exception for an undefined template in a child template ---TEMPLATE-- -{% extends 'base.twig' %} - -{% block sidebar %} - {{ include('include.twig') }} -{% endblock %} ---TEMPLATE(base.twig)-- -{% block sidebar %} -{% endblock %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Loader: Template "include.twig" is not defined in "index.twig" at line 5. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_trait.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_trait.test deleted file mode 100644 index 6679fbe13..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_trait.test +++ /dev/null @@ -1,9 +0,0 @@ ---TEST-- -Exception for an undefined trait ---TEMPLATE-- -{% use 'foo' with foobar as bar %} ---TEMPLATE(foo)-- -{% block bar %} -{% endblock %} ---EXCEPTION-- -Twig_Error_Runtime: Block "foobar" is not defined in trait "foo" in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/_self.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/_self.test deleted file mode 100644 index 32fed8fd0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/_self.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -_self returns the template name ---TEMPLATE-- -{{ _self }} ---DATA-- -return array() ---EXPECT-- -index.twig diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array.test deleted file mode 100644 index c69b1192f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array.test +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -Twig supports array notation ---TEMPLATE-- -{# empty array #} -{{ []|join(',') }} - -{{ [1, 2]|join(',') }} -{{ ['foo', "bar"]|join(',') }} -{{ {0: 1, 'foo': 'bar'}|join(',') }} -{{ {0: 1, 'foo': 'bar'}|keys|join(',') }} - -{{ {0: 1, foo: 'bar'}|join(',') }} -{{ {0: 1, foo: 'bar'}|keys|join(',') }} - -{# nested arrays #} -{% set a = [1, 2, [1, 2], {'foo': {'foo': 'bar'}}] %} -{{ a[2]|join(',') }} -{{ a[3]["foo"]|join(',') }} - -{# works even if [] is used inside the array #} -{{ [foo[bar]]|join(',') }} - -{# elements can be any expression #} -{{ ['foo'|upper, bar|upper, bar == foo]|join(',') }} - -{# arrays can have a trailing , like in PHP #} -{{ - [ - 1, - 2, - ]|join(',') -}} - -{# keys can be any expression #} -{% set a = 1 %} -{% set b = "foo" %} -{% set ary = { (a): 'a', (b): 'b', 'c': 'c', (a ~ b): 'd' } %} -{{ ary|keys|join(',') }} -{{ ary|join(',') }} ---DATA-- -return array('bar' => 'bar', 'foo' => array('bar' => 'bar')) ---EXPECT-- -1,2 -foo,bar -1,bar -0,foo - -1,bar -0,foo - -1,2 -bar - -bar - -FOO,BAR, - -1,2 - -1,foo,c,1foo -a,b,c,d diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array_call.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array_call.test deleted file mode 100644 index f3df328fe..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/array_call.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Twig supports method calls ---TEMPLATE-- -{{ items.foo }} -{{ items['foo'] }} -{{ items[foo] }} -{{ items[items[foo]] }} ---DATA-- -return array('foo' => 'bar', 'items' => array('foo' => 'bar', 'bar' => 'foo')) ---EXPECT-- -bar -bar -foo -bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/binary.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/binary.test deleted file mode 100644 index f5e68456d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/binary.test +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Twig supports binary operations (+, -, *, /, ~, %, and, or) ---TEMPLATE-- -{{ 1 + 1 }} -{{ 2 - 1 }} -{{ 2 * 2 }} -{{ 2 / 2 }} -{{ 3 % 2 }} -{{ 1 and 1 }} -{{ 1 and 0 }} -{{ 0 and 1 }} -{{ 0 and 0 }} -{{ 1 or 1 }} -{{ 1 or 0 }} -{{ 0 or 1 }} -{{ 0 or 0 }} -{{ 0 or 1 and 0 }} -{{ 1 or 0 and 1 }} -{{ "foo" ~ "bar" }} -{{ foo ~ "bar" }} -{{ "foo" ~ bar }} -{{ foo ~ bar }} -{{ 20 // 7 }} ---DATA-- -return array('foo' => 'bar', 'bar' => 'foo') ---EXPECT-- -2 -1 -4 -1 -1 -1 - - - -1 -1 -1 - - -1 -foobar -barbar -foofoo -barfoo -2 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test deleted file mode 100644 index 74fe6cabb..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Twig supports bitwise operations ---TEMPLATE-- -{{ 1 b-and 5 }} -{{ 1 b-or 5 }} -{{ 1 b-xor 5 }} -{{ (1 and 0 b-or 0) is same as(1 and (0 b-or 0)) ? 'ok' : 'ko' }} ---DATA-- -return array() ---EXPECT-- -1 -5 -4 -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/comparison.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/comparison.test deleted file mode 100644 index 726b85075..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/comparison.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Twig supports comparison operators (==, !=, <, >, >=, <=) ---TEMPLATE-- -{{ 1 > 2 }}/{{ 1 > 1 }}/{{ 1 >= 2 }}/{{ 1 >= 1 }} -{{ 1 < 2 }}/{{ 1 < 1 }}/{{ 1 <= 2 }}/{{ 1 <= 1 }} -{{ 1 == 1 }}/{{ 1 == 2 }} -{{ 1 != 1 }}/{{ 1 != 2 }} ---DATA-- -return array() ---EXPECT-- -///1 -1//1/1 -1/ -/1 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/divisibleby.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/divisibleby.test deleted file mode 100644 index 238dd2790..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/divisibleby.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Twig supports the "divisible by" operator ---TEMPLATE-- -{{ 8 is divisible by(2) ? 'OK' }} -{{ 8 is not divisible by(3) ? 'OK' }} -{{ 8 is divisible by (2) ? 'OK' }} -{{ 8 is not - divisible - by - (3) ? 'OK' }} ---DATA-- -return array() ---EXPECT-- -OK -OK -OK -OK diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/dotdot.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/dotdot.test deleted file mode 100644 index 9cd0676ce..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/dotdot.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Twig supports the .. operator ---TEMPLATE-- -{% for i in 0..10 %}{{ i }} {% endfor %} - -{% for letter in 'a'..'z' %}{{ letter }} {% endfor %} - -{% for letter in 'a'|upper..'z'|upper %}{{ letter }} {% endfor %} - -{% for i in foo[0]..foo[1] %}{{ i }} {% endfor %} - -{% for i in 0 + 1 .. 10 - 1 %}{{ i }} {% endfor %} ---DATA-- -return array('foo' => array(1, 10)) ---EXPECT-- -0 1 2 3 4 5 6 7 8 9 10 -a b c d e f g h i j k l m n o p q r s t u v w x y z -A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -1 2 3 4 5 6 7 8 9 10 -1 2 3 4 5 6 7 8 9 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ends_with.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ends_with.test deleted file mode 100644 index 9ad5e5e8e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ends_with.test +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Twig supports the "ends with" operator ---TEMPLATE-- -{{ 'foo' ends with 'o' ? 'OK' : 'KO' }} -{{ not ('foo' ends with 'f') ? 'OK' : 'KO' }} -{{ not ('foo' ends with 'foowaytoolong') ? 'OK' : 'KO' }} -{{ 'foo' ends with '' ? 'OK' : 'KO' }} -{{ '1' ends with true ? 'OK' : 'KO' }} -{{ 1 ends with true ? 'OK' : 'KO' }} -{{ 0 ends with false ? 'OK' : 'KO' }} -{{ '' ends with false ? 'OK' : 'KO' }} -{{ false ends with false ? 'OK' : 'KO' }} -{{ false ends with '' ? 'OK' : 'KO' }} ---DATA-- -return array() ---EXPECT-- -OK -OK -OK -OK -KO -KO -KO -KO -KO -KO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/grouping.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/grouping.test deleted file mode 100644 index 79f8e0b0d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/grouping.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Twig supports grouping of expressions ---TEMPLATE-- -{{ (2 + 2) / 2 }} ---DATA-- -return array() ---EXPECT-- -2 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/literals.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/literals.test deleted file mode 100644 index 7ae3bae95..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/literals.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Twig supports literals ---TEMPLATE-- -1 {{ true }} -2 {{ TRUE }} -3 {{ false }} -4 {{ FALSE }} -5 {{ none }} -6 {{ NONE }} -7 {{ null }} -8 {{ NULL }} ---DATA-- -return array() ---EXPECT-- -1 1 -2 1 -3 -4 -5 -6 -7 -8 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/magic_call.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/magic_call.test deleted file mode 100644 index 1a27a2d6f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/magic_call.test +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Twig supports __call() for attributes ---TEMPLATE-- -{{ foo.foo }} -{{ foo.bar }} ---DATA-- -class TestClassForMagicCallAttributes -{ - public function getBar() - { - return 'bar_from_getbar'; - } - - public function __call($method, $arguments) - { - if ('foo' === $method) { - return 'foo_from_call'; - } - - return false; - } -} - -return array('foo' => new TestClassForMagicCallAttributes()) ---EXPECT-- -foo_from_call -bar_from_getbar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/matches.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/matches.test deleted file mode 100644 index b6c771657..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/matches.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Twig supports the "matches" operator ---TEMPLATE-- -{{ 'foo' matches '/o/' ? 'OK' : 'KO' }} -{{ 'foo' matches '/^fo/' ? 'OK' : 'KO' }} -{{ 'foo' matches '/O/i' ? 'OK' : 'KO' }} ---DATA-- -return array() ---EXPECT-- -OK -OK -OK diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test deleted file mode 100644 index 5f801e635..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/method_call.test +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Twig supports method calls ---TEMPLATE-- -{{ items.foo.foo }} -{{ items.foo.getFoo() }} -{{ items.foo.bar }} -{{ items.foo['bar'] }} -{{ items.foo.bar('a', 43) }} -{{ items.foo.bar(foo) }} -{{ items.foo.self.foo() }} -{{ items.foo.is }} -{{ items.foo.in }} -{{ items.foo.not }} ---DATA-- -return array('foo' => 'bar', 'items' => array('foo' => new TwigTestFoo(), 'bar' => 'foo')) ---CONFIG-- -return array('strict_variables' => false) ---EXPECT-- -foo -foo -bar - -bar_a-43 -bar_bar -foo -is -in -not diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/negative_numbers.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/negative_numbers.test deleted file mode 100644 index 1853b1b06..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/negative_numbers.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Twig manages negative numbers correctly ---TEMPLATE-- -{{ -1 }} -{{ - 1 }} -{{ 5 - 1 }} -{{ 5-1 }} -{{ 5 + -1 }} -{{ 5 + - 1 }} ---DATA-- -return array() ---EXPECT-- --1 --1 -4 -4 -4 -4 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/operators_as_variables.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/operators_as_variables.test deleted file mode 100644 index fe29d08bb..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/operators_as_variables.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -Twig allows to use named operators as variable names ---TEMPLATE-- -{% for match in matches %} - {{- match }} -{% endfor %} -{{ in }} -{{ is }} ---DATA-- -return array('matches' => array(1, 2, 3), 'in' => 'in', 'is' => 'is') ---EXPECT-- -1 -2 -3 -in -is diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test deleted file mode 100644 index 542c35046..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/postfix.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Twig parses postfix expressions ---TEMPLATE-- -{% import _self as macros %} - -{% macro foo() %}foo{% endmacro %} - -{{ 'a' }} -{{ 'a'|upper }} -{{ ('a')|upper }} -{{ -1|upper }} -{{ macros.foo() }} -{{ (macros).foo() }} ---DATA-- -return array(); ---EXPECT-- -a -A -A --1 -foo -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/power.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/power.test deleted file mode 100644 index eacc98f86..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/power.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Twig parses power expressions ---TEMPLATE-- -{{ 2**3 }} -{{ (-2)**3 }} -{{ (-2)**(-3) }} -{{ a ** a }} -{{ a ** b }} -{{ b ** a }} -{{ b ** b }} ---DATA-- -return array('a' => 4, 'b' => -2); ---EXPECT-- -8 --8 --0.125 -256 -0.0625 -16 -0.25 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/sameas.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/sameas.test deleted file mode 100644 index 601201deb..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/sameas.test +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Twig supports the "same as" operator ---TEMPLATE-- -{{ 1 is same as(1) ? 'OK' }} -{{ 1 is not same as(true) ? 'OK' }} -{{ 1 is same as(1) ? 'OK' }} -{{ 1 is not same as(true) ? 'OK' }} -{{ 1 is same as (1) ? 'OK' }} -{{ 1 is not - same - as - (true) ? 'OK' }} ---DATA-- -return array() ---EXPECT-- -OK -OK -OK -OK -OK -OK diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/starts_with.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/starts_with.test deleted file mode 100644 index 75d331e90..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/starts_with.test +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Twig supports the "starts with" operator ---TEMPLATE-- -{{ 'foo' starts with 'f' ? 'OK' : 'KO' }} -{{ not ('foo' starts with 'oo') ? 'OK' : 'KO' }} -{{ not ('foo' starts with 'foowaytoolong') ? 'OK' : 'KO' }} -{{ 'foo' starts with 'f' ? 'OK' : 'KO' }} -{{ 'foo' starts -with 'f' ? 'OK' : 'KO' }} -{{ 'foo' starts with '' ? 'OK' : 'KO' }} -{{ '1' starts with true ? 'OK' : 'KO' }} -{{ '' starts with false ? 'OK' : 'KO' }} -{{ 'a' starts with false ? 'OK' : 'KO' }} -{{ false starts with '' ? 'OK' : 'KO' }} ---DATA-- -return array() ---EXPECT-- -OK -OK -OK -OK -OK -OK -KO -KO -KO -KO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/strings.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/strings.test deleted file mode 100644 index a9116613e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/strings.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Twig supports string interpolation ---TEMPLATE-- -{{ "foo #{"foo #{bar} baz"} baz" }} -{{ "foo #{bar}#{bar} baz" }} ---DATA-- -return array('bar' => 'BAR'); ---EXPECT-- -foo foo BAR baz baz -foo BARBAR baz diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator.test deleted file mode 100644 index 0e6fa96e2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Twig supports the ternary operator ---TEMPLATE-- -{{ 1 ? 'YES' : 'NO' }} -{{ 0 ? 'YES' : 'NO' }} -{{ 0 ? 'YES' : (1 ? 'YES1' : 'NO1') }} -{{ 0 ? 'YES' : (0 ? 'YES1' : 'NO1') }} -{{ 1 == 1 ? 'foo
    ':'' }} -{{ foo ~ (bar ? ('-' ~ bar) : '') }} ---DATA-- -return array('foo' => 'foo', 'bar' => 'bar') ---EXPECT-- -YES -NO -YES1 -NO1 -foo
    -foo-bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_noelse.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_noelse.test deleted file mode 100644 index fdc660fc5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_noelse.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Twig supports the ternary operator ---TEMPLATE-- -{{ 1 ? 'YES' }} -{{ 0 ? 'YES' }} ---DATA-- -return array() ---EXPECT-- -YES - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_nothen.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_nothen.test deleted file mode 100644 index 9057e8370..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ternary_operator_nothen.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Twig supports the ternary operator ---TEMPLATE-- -{{ 'YES' ?: 'NO' }} -{{ 0 ?: 'NO' }} ---DATA-- -return array() ---EXPECT-- -YES -NO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/two_word_operators_as_variables.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/two_word_operators_as_variables.test deleted file mode 100644 index 0eaabb446..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/two_word_operators_as_variables.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Twig does not allow to use two-word named operators as variable names ---TEMPLATE-- -{{ starts with }} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: Unexpected token "operator" of value "starts with" in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary.test deleted file mode 100644 index b79219a2a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Twig supports unary operators (not, -, +) ---TEMPLATE-- -{{ not 1 }}/{{ not 0 }} -{{ +1 + 1 }}/{{ -1 - 1 }} -{{ not (false or true) }} ---DATA-- -return array() ---EXPECT-- -/1 -2/-2 - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_macro_arguments.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_macro_arguments.test deleted file mode 100644 index ad84a9c26..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_macro_arguments.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Twig manages negative numbers as default parameters ---TEMPLATE-- -{% import _self as macros %} -{{ macros.negative_number1() }} -{{ macros.negative_number2() }} -{{ macros.negative_number3() }} -{{ macros.positive_number1() }} -{{ macros.positive_number2() }} -{% macro negative_number1(nb=-1) %}{{ nb }}{% endmacro %} -{% macro negative_number2(nb = --1) %}{{ nb }}{% endmacro %} -{% macro negative_number3(nb = - 1) %}{{ nb }}{% endmacro %} -{% macro positive_number1(nb = +1) %}{{ nb }}{% endmacro %} -{% macro positive_number2(nb = ++1) %}{{ nb }}{% endmacro %} ---DATA-- -return array() ---EXPECT-- --1 -1 --1 -1 -1 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_precedence.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_precedence.test deleted file mode 100644 index cc6eef8d2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_precedence.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Twig unary operators precedence ---TEMPLATE-- -{{ -1 - 1 }} -{{ -1 - -1 }} -{{ -1 * -1 }} -{{ 4 / -1 * 5 }} ---DATA-- -return array() ---EXPECT-- --2 -0 -1 --20 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/abs.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/abs.test deleted file mode 100644 index 27e93fd63..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/abs.test +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -"abs" filter ---TEMPLATE-- -{{ (-5.5)|abs }} -{{ (-5)|abs }} -{{ (-0)|abs }} -{{ 0|abs }} -{{ 5|abs }} -{{ 5.5|abs }} -{{ number1|abs }} -{{ number2|abs }} -{{ number3|abs }} -{{ number4|abs }} -{{ number5|abs }} -{{ number6|abs }} ---DATA-- -return array('number1' => -5.5, 'number2' => -5, 'number3' => -0, 'number4' => 0, 'number5' => 5, 'number6' => 5.5) ---EXPECT-- -5.5 -5 -0 -0 -5 -5.5 -5.5 -5 -0 -0 -5 -5.5 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch.test deleted file mode 100644 index cb6de7f97..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch.test +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -"batch" filter ---TEMPLATE-- -{% for row in items|batch(3) %} -
    - {% for column in row %} -
    {{ column }}
    - {% endfor %} -
    -{% endfor %} ---DATA-- -return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')) ---EXPECT-- -
    -
    a
    -
    b
    -
    c
    -
    -
    -
    d
    -
    e
    -
    f
    -
    -
    -
    g
    -
    h
    -
    i
    -
    -
    -
    j
    -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_float.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_float.test deleted file mode 100644 index e2ec4beb2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_float.test +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -"batch" filter ---TEMPLATE-- -{% for row in items|batch(3.1) %} -
    - {% for column in row %} -
    {{ column }}
    - {% endfor %} -
    -{% endfor %} ---DATA-- -return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')) ---EXPECT-- -
    -
    a
    -
    b
    -
    c
    -
    d
    -
    -
    -
    e
    -
    f
    -
    g
    -
    h
    -
    -
    -
    i
    -
    j
    -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_empty_fill.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_empty_fill.test deleted file mode 100644 index af996f246..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_empty_fill.test +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -"batch" filter ---TEMPLATE-- - -{% for row in items|batch(3, '') %} - - {% for column in row %} - - {% endfor %} - -{% endfor %} -
    {{ column }}
    ---DATA-- -return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')) ---EXPECT-- - - - - - - - - - - - - - - - - - - - - - -
    abc
    def
    ghi
    j
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_exact_elements.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_exact_elements.test deleted file mode 100644 index 72483f4b5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_exact_elements.test +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -"batch" filter ---TEMPLATE-- -{% for row in items|batch(3, 'fill') %} -
    - {% for column in row %} -
    {{ column }}
    - {% endfor %} -
    -{% endfor %} ---DATA-- -return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l')) ---EXPECT-- -
    -
    a
    -
    b
    -
    c
    -
    -
    -
    d
    -
    e
    -
    f
    -
    -
    -
    g
    -
    h
    -
    i
    -
    -
    -
    j
    -
    k
    -
    l
    -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_fill.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_fill.test deleted file mode 100644 index 746295f1b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_fill.test +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -"batch" filter ---TEMPLATE-- - -{% for row in items|batch(3, 'fill') %} - - {% for column in row %} - - {% endfor %} - -{% endfor %} -
    {{ column }}
    ---DATA-- -return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')) ---EXPECT-- - - - - - - - - - - - - - - - - - - - - - -
    abc
    def
    ghi
    jfillfill
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_keys.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_keys.test deleted file mode 100644 index 6015380e2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_keys.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"batch" filter preserves array keys ---TEMPLATE-- -{{ {'foo': 'bar', 'key': 'value'}|batch(4)|first|keys|join(',') }} -{{ {'foo': 'bar', 'key': 'value'}|batch(4, 'fill')|first|keys|join(',') }} ---DATA-- -return array() ---EXPECT-- -foo,key -foo,key,0,1 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_zero_elements.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_zero_elements.test deleted file mode 100644 index b9c058d6b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_zero_elements.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"batch" filter with zero elements ---TEMPLATE-- -{{ []|batch(3)|length }} -{{ []|batch(3, 'fill')|length }} ---DATA-- -return array() ---EXPECT-- -0 -0 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/convert_encoding.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/convert_encoding.test deleted file mode 100644 index 380b04bb8..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/convert_encoding.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"convert_encoding" filter ---CONDITION-- -function_exists('iconv') || function_exists('mb_convert_encoding') ---TEMPLATE-- -{{ "愛していますか?"|convert_encoding('ISO-2022-JP', 'UTF-8')|convert_encoding('UTF-8', 'ISO-2022-JP') }} ---DATA-- -return array() ---EXPECT-- -愛していますか? diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test deleted file mode 100644 index d17e5e2f0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test +++ /dev/null @@ -1,90 +0,0 @@ ---TEST-- -"date" filter ---TEMPLATE-- -{{ date1|date }} -{{ date1|date('d/m/Y') }} -{{ date1|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }} -{{ date1|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }} -{{ date1|date('d/m/Y H:i:s P', 'America/Chicago') }} -{{ date1|date('e') }} -{{ date1|date('d/m/Y H:i:s') }} - -{{ date2|date }} -{{ date2|date('d/m/Y') }} -{{ date2|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }} -{{ date2|date('d/m/Y H:i:s', timezone1) }} -{{ date2|date('d/m/Y H:i:s') }} - -{{ date3|date }} -{{ date3|date('d/m/Y') }} - -{{ date4|date }} -{{ date4|date('d/m/Y') }} - -{{ date5|date }} -{{ 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', false) }} - -{{ date7|date }} -{{ date7|date(timezone='Europe/Paris') }} -{{ date7|date(timezone='Asia/Hong_Kong') }} -{{ date7|date(timezone=false) }} -{{ date7|date(timezone='Indian/Mauritius') }} - -{{ '2010-01-28 15:00:00'|date(timezone="Europe/Paris") }} -{{ '2010-01-28 15:00:00'|date(timezone="Asia/Hong_Kong") }} ---DATA-- -date_default_timezone_set('Europe/Paris'); -return array( - 'date1' => mktime(13, 45, 0, 10, 4, 2010), - 'date2' => new DateTime('2010-10-04 13:45'), - 'date3' => '2010-10-04 13:45', - 'date4' => 1286199900, // DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT - 'date5' => -189291360, // DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new DateTimeZone('UTC'))->getTimestamp(), - 'date6' => new DateTime('2010-10-04 13:45', new DateTimeZone('America/New_York')), - 'date7' => '2010-01-28T15:00:00+04:00', - 'timezone1' => new DateTimeZone('America/New_York'), -) ---EXPECT-- -October 4, 2010 13:45 -04/10/2010 -04/10/2010 19:45:00 -04/10/2010 19:45:00 +08:00 -04/10/2010 06:45:00 -05:00 -Europe/Paris -04/10/2010 13:45:00 - -October 4, 2010 13:45 -04/10/2010 -04/10/2010 19:45:00 -04/10/2010 07:45:00 -04/10/2010 13:45:00 - -October 4, 2010 13:45 -04/10/2010 - -October 4, 2010 15:45 -04/10/2010 - -January 2, 1964 04:04 -02/01/1964 - -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 - -January 28, 2010 12:00 -January 28, 2010 12:00 -January 28, 2010 19:00 -January 28, 2010 15:00 -January 28, 2010 15:00 - -January 28, 2010 15:00 -January 28, 2010 22:00 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format.test deleted file mode 100644 index 6ad504cdf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"date" filter ---TEMPLATE-- -{{ date1|date }} -{{ date1|date('d/m/Y') }} ---DATA-- -date_default_timezone_set('UTC'); -$twig->getExtension('Twig_Extension_Core')->setDateFormat('Y-m-d', '%d days %h hours'); -return array( - 'date1' => mktime(13, 45, 0, 10, 4, 2010), -) ---EXPECT-- -2010-10-04 -04/10/2010 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format_interval.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format_interval.test deleted file mode 100644 index be4a642e7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_default_format_interval.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"date" filter (interval support as of PHP 5.3) ---CONDITION-- -version_compare(phpversion(), '5.3.0', '>=') ---TEMPLATE-- -{{ date2|date }} -{{ date2|date('%d days') }} ---DATA-- -date_default_timezone_set('UTC'); -$twig->getExtension('Twig_Extension_Core')->setDateFormat('Y-m-d', '%d days %h hours'); -return array( - 'date2' => new DateInterval('P2D'), -) ---EXPECT-- -2 days 0 hours -2 days diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_immutable.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_immutable.test deleted file mode 100644 index 4e1832562..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_immutable.test +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -"date" filter ---CONDITION-- -version_compare(phpversion(), '5.5.0', '>=') ---TEMPLATE-- -{{ date1|date }} -{{ date1|date('d/m/Y') }} -{{ date1|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }} -{{ date1|date('d/m/Y H:i:s', timezone1) }} -{{ date1|date('d/m/Y H:i:s') }} -{{ date1|date_modify('+1 hour')|date('d/m/Y H:i:s') }} - -{{ date2|date('d/m/Y H:i:s P', 'Europe/Paris') }} -{{ date2|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }} -{{ date2|date('d/m/Y H:i:s P', false) }} -{{ date2|date('e', 'Europe/Paris') }} -{{ date2|date('e', false) }} ---DATA-- -date_default_timezone_set('Europe/Paris'); -return array( - 'date1' => new DateTimeImmutable('2010-10-04 13:45'), - 'date2' => new DateTimeImmutable('2010-10-04 13:45', new DateTimeZone('America/New_York')), - 'timezone1' => new DateTimeZone('America/New_York'), -) ---EXPECT-- -October 4, 2010 13:45 -04/10/2010 -04/10/2010 19:45:00 -04/10/2010 07:45:00 -04/10/2010 13:45:00 -04/10/2010 14:45:00 - -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 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test deleted file mode 100644 index 0c8c6f1a2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_interval.test +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -"date" filter (interval support as of PHP 5.3) ---CONDITION-- -version_compare(phpversion(), '5.3.0', '>=') ---TEMPLATE-- -{{ date1|date }} -{{ date1|date('%d days %h hours') }} -{{ date1|date('%d days %h hours', timezone1) }} ---DATA-- -date_default_timezone_set('UTC'); -return array( - '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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test deleted file mode 100644 index 53d3a69cd..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_modify.test +++ /dev/null @@ -1,14 +0,0 @@ ---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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_namedargs.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_namedargs.test deleted file mode 100644 index 4ecde8a18..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_namedargs.test +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -"date" filter ---TEMPLATE-- -{{ date|date(format='d/m/Y H:i:s P', timezone='America/Chicago') }} -{{ date|date(timezone='America/Chicago', format='d/m/Y H:i:s P') }} -{{ date|date('d/m/Y H:i:s P', timezone='America/Chicago') }} ---DATA-- -date_default_timezone_set('UTC'); -return array('date' => mktime(13, 45, 0, 10, 4, 2010)) ---EXPECT-- -04/10/2010 08:45:00 -05:00 -04/10/2010 08:45:00 -05:00 -04/10/2010 08:45:00 -05:00 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test deleted file mode 100644 index b8d1d66f5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test +++ /dev/null @@ -1,150 +0,0 @@ ---TEST-- -"default" filter ---TEMPLATE-- -Variable: -{{ definedVar |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ nullVar |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }} -Array access: -{{ nested.definedVar |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ nested['definedVar'] |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ nested.zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ nested.emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ nested.nullVar |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ nested.undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ nested['undefinedVar'] |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ undefinedVar.foo |default('default') is same as('default') ? 'ok' : 'ko' }} -Plain values: -{{ 'defined' |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ 0 |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ '' |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ null |default('default') is same as('default') ? 'ok' : 'ko' }} -Precedence: -{{ 'o' ~ nullVar |default('k') }} -{{ 'o' ~ nested.nullVar |default('k') }} -Object methods: -{{ object.foo |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ object.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ object.getFoo() |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ object.getFoo('a') |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ object.undefinedMethod() |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ object.undefinedMethod('a') |default('default') is same as('default') ? 'ok' : 'ko' }} -Deep nested: -{{ nested.undefinedVar.foo.bar |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ nested.definedArray.0 |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ nested['definedArray'][0] |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ object.self.foo |default('default') is same as('default') ? 'ko' : 'ok' }} -{{ object.self.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }} -{{ object.undefinedMethod.self |default('default') is same as('default') ? 'ok' : 'ko' }} ---DATA-- -return array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'emptyVar' => '', - 'nullVar' => null, - 'nested' => array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'emptyVar' => '', - 'nullVar' => null, - 'definedArray' => array(0), - ), - 'object' => new TwigTestFoo(), -) ---CONFIG-- -return array('strict_variables' => false) ---EXPECT-- -Variable: -ok -ok -ok -ok -ok -Array access: -ok -ok -ok -ok -ok -ok -ok -ok -Plain values: -ok -ok -ok -ok -Precedence: -ok -ok -Object methods: -ok -ok -ok -ok -ok -ok -Deep nested: -ok -ok -ok -ok -ok -ok ---DATA-- -return array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'emptyVar' => '', - 'nullVar' => null, - 'nested' => array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'emptyVar' => '', - 'nullVar' => null, - 'definedArray' => array(0), - ), - 'object' => new TwigTestFoo(), -) ---CONFIG-- -return array('strict_variables' => true) ---EXPECT-- -Variable: -ok -ok -ok -ok -ok -Array access: -ok -ok -ok -ok -ok -ok -ok -ok -Plain values: -ok -ok -ok -ok -Precedence: -ok -ok -Object methods: -ok -ok -ok -ok -ok -ok -Deep nested: -ok -ok -ok -ok -ok -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/dynamic_filter.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/dynamic_filter.test deleted file mode 100644 index 93c5913f2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/dynamic_filter.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -dynamic filter ---TEMPLATE-- -{{ 'bar'|foo_path }} -{{ 'bar'|a_foo_b_bar }} ---DATA-- -return array() ---EXPECT-- -foo/bar -a/b/bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape.test deleted file mode 100644 index a606c1065..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"escape" filter ---TEMPLATE-- -{{ "foo
    "|e }} ---DATA-- -return array() ---EXPECT-- -foo <br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_html_attr.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_html_attr.test deleted file mode 100644 index 009a24532..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_html_attr.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"escape" filter does not escape with the html strategy when using the html_attr strategy ---TEMPLATE-- -{{ '
    '|escape('html_attr') }} ---DATA-- -return array() ---EXPECT-- -<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_javascript.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_javascript.test deleted file mode 100644 index 647147a43..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_javascript.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"escape" filter ---TEMPLATE-- -{{ "é ♜ 𝌆"|e('js') }} ---DATA-- -return array() ---EXPECT-- -\u00E9\x20\u265C\x20\uD834\uDF06 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_non_supported_charset.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_non_supported_charset.test deleted file mode 100644 index bba26a0df..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/escape_non_supported_charset.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"escape" filter ---TEMPLATE-- -{{ "愛していますか?
    "|e }} ---DATA-- -return array() ---EXPECT-- -愛していますか? <br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/first.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/first.test deleted file mode 100644 index aa54645c3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/first.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"first" filter ---TEMPLATE-- -{{ [1, 2, 3, 4]|first }} -{{ {a: 1, b: 2, c: 3, d: 4}|first }} -{{ '1234'|first }} -{{ arr|first }} -{{ 'Ä€é'|first }} -{{ ''|first }} ---DATA-- -return array('arr' => new ArrayObject(array(1, 2, 3, 4))) ---EXPECT-- -1 -1 -1 -1 -Ä diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test deleted file mode 100644 index 85a9b7172..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/force_escape.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"escape" filter ---TEMPLATE-- -{% set foo %} - foo
    -{% endset %} - -{{ foo|e('html') -}} -{{ foo|e('js') }} -{% autoescape true %} - {{ foo }} -{% endautoescape %} ---DATA-- -return array() ---EXPECT-- - foo<br /> -\x20\x20\x20\x20foo\x3Cbr\x20\x2F\x3E\x0A - foo
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/format.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/format.test deleted file mode 100644 index 97221ff80..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/format.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"format" filter ---TEMPLATE-- -{{ string|format(foo, 3) }} ---DATA-- -return array('string' => '%s/%d', 'foo' => 'bar') ---EXPECT-- -bar/3 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test deleted file mode 100644 index b342c174c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/join.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"join" filter ---TEMPLATE-- -{{ ["foo", "bar"]|join(', ') }} -{{ foo|join(', ') }} -{{ bar|join(', ') }} ---DATA-- -return array('foo' => new TwigTestFoo(), 'bar' => new ArrayObject(array(3, 4))) ---EXPECT-- -foo, bar -1, 2 -3, 4 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/json_encode.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/json_encode.test deleted file mode 100644 index 1738d40cd..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/json_encode.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"json_encode" filter ---TEMPLATE-- -{{ "foo"|json_encode|raw }} -{{ foo|json_encode|raw }} -{{ [foo, "foo"]|json_encode|raw }} ---DATA-- -return array('foo' => new Twig_Markup('foo', 'UTF-8')) ---EXPECT-- -"foo" -"foo" -["foo","foo"] diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/last.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/last.test deleted file mode 100644 index 1b8031ee8..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/last.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"last" filter ---TEMPLATE-- -{{ [1, 2, 3, 4]|last }} -{{ {a: 1, b: 2, c: 3, d: 4}|last }} -{{ '1234'|last }} -{{ arr|last }} -{{ 'Ä€é'|last }} -{{ ''|last }} ---DATA-- -return array('arr' => new ArrayObject(array(1, 2, 3, 4))) ---EXPECT-- -4 -4 -4 -4 -é diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length.test deleted file mode 100644 index a7f1e5031..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length.test +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -"length" filter ---TEMPLATE-- -{{ array|length }} -{{ string|length }} -{{ number|length }} -{{ to_string_able|length }} -{{ countable|length }} -{{ null|length }} -{{ magic|length }} -{{ non_countable|length }} ---DATA-- -return array( - 'array' => array(1, 4), - 'string' => 'foo', - 'number' => 1000, - 'to_string_able' => new ToStringStub('foobar'), - 'countable' => new CountableStub(42), /* also asserts we do *not* call __toString() */ - 'null' => null, - 'magic' => new MagicCallStub(), /* used to assert we do *not* call __call */ - 'non_countable' => new \StdClass(), -); ---EXPECT-- -2 -3 -4 -6 -42 -0 -1 -1 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length_utf8.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length_utf8.test deleted file mode 100644 index 5d5e24361..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/length_utf8.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"length" filter ---CONDITION-- -function_exists('mb_get_info') ---TEMPLATE-- -{{ string|length }} -{{ markup|length }} ---DATA-- -return array('string' => 'été', 'markup' => new Twig_Markup('foo', 'UTF-8')) ---EXPECT-- -3 -3 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test deleted file mode 100644 index 81371a41b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"merge" filter ---TEMPLATE-- -{{ items|merge({'bar': 'foo'})|join }} -{{ items|merge({'bar': 'foo'})|keys|join }} -{{ {'bar': 'foo'}|merge(items)|join }} -{{ {'bar': 'foo'}|merge(items)|keys|join }} -{{ numerics|merge([4, 5, 6])|join }} -{{ traversable.a|merge(traversable.b)|join }} ---DATA-- -return array('items' => array('foo' => 'bar'), 'numerics' => array(1, 2, 3), 'traversable' => array('a' => new ArrayObject(array(0 => 1, 1 => 2, 2 => 3)), 'b' => new ArrayObject(array('a' => 'b')))) ---EXPECT-- -barfoo -foobar -foobar -barfoo -123456 -123b diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/nl2br.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/nl2br.test deleted file mode 100644 index 6545a9bb0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/nl2br.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"nl2br" filter ---TEMPLATE-- -{{ "I like Twig.\nYou will like it too.\n\nEverybody like it!"|nl2br }} -{{ text|nl2br }} ---DATA-- -return array('text' => "If you have some HTML\nit will be escaped.") ---EXPECT-- -I like Twig.
    -You will like it too.
    -
    -Everybody like it! -If you have some <strong>HTML</strong>
    -it will be escaped. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format.test deleted file mode 100644 index 639a8659f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"number_format" filter ---TEMPLATE-- -{{ 20|number_format }} -{{ 20.25|number_format }} -{{ 20.25|number_format(2) }} -{{ 20.25|number_format(2, ',') }} -{{ 1020.25|number_format(2, ',') }} -{{ 1020.25|number_format(2, ',', '.') }} ---DATA-- -return array(); ---EXPECT-- -20 -20 -20.25 -20,25 -1,020,25 -1.020,25 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format_default.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format_default.test deleted file mode 100644 index 65c1cdb48..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/number_format_default.test +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -"number_format" filter with defaults. ---TEMPLATE-- -{{ 20|number_format }} -{{ 20.25|number_format }} -{{ 20.25|number_format(1) }} -{{ 20.25|number_format(2, ',') }} -{{ 1020.25|number_format }} -{{ 1020.25|number_format(2, ',') }} -{{ 1020.25|number_format(2, ',', '.') }} ---DATA-- -$twig->getExtension('Twig_Extension_Core')->setNumberFormat(2, '!', '='); -return array(); ---EXPECT-- -20!00 -20!25 -20!3 -20,25 -1=020!25 -1=020,25 -1.020,25 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace.test deleted file mode 100644 index 06be7e270..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"replace" filter ---TEMPLATE-- -{{ "I liké %this% and %that%."|replace({'%this%': "foo", '%that%': "bar"}) }} -{{ 'I like single replace operation only %that%'|replace({'%that%' : '%that%1'}) }} -{{ 'I like %this% and %that%.'|replace(traversable) }} ---DATA-- -return array('traversable' => new ArrayObject(array('%this%' => 'foo', '%that%' => 'bar'))) ---EXPECT-- -I liké foo and bar. -I like single replace operation only %that%1 -I like foo and bar. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace_invalid_arg.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace_invalid_arg.test deleted file mode 100644 index 2143a8690..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace_invalid_arg.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Exception for invalid argument type in replace call ---TEMPLATE-- -{{ 'test %foo%'|replace(stdClass) }} ---DATA-- -return array('stdClass' => new stdClass()) ---EXCEPTION-- -Twig_Error_Runtime: The "replace" filter expects an array or "Traversable" as replace values, got "stdClass" in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/reverse.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/reverse.test deleted file mode 100644 index 7948ac45f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/reverse.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"reverse" filter ---TEMPLATE-- -{{ [1, 2, 3, 4]|reverse|join('') }} -{{ '1234évènement'|reverse }} -{{ arr|reverse|join('') }} -{{ {'a': 'c', 'b': 'a'}|reverse()|join(',') }} -{{ {'a': 'c', 'b': 'a'}|reverse(preserveKeys=true)|join(glue=',') }} -{{ {'a': 'c', 'b': 'a'}|reverse(preserve_keys=true)|join(glue=',') }} ---DATA-- -return array('arr' => new ArrayObject(array(1, 2, 3, 4))) ---EXPECT-- -4321 -tnemenèvé4321 -4321 -a,c -a,c -a,c diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/round.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/round.test deleted file mode 100644 index 57806b619..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/round.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"round" filter ---TEMPLATE-- -{{ 2.7|round }} -{{ 2.1|round }} -{{ 2.1234|round(3, 'floor') }} -{{ 2.1|round(0, 'ceil') }} - -{{ 21.3|round(-1)}} -{{ 21.3|round(-1, 'ceil')}} -{{ 21.3|round(-1, 'floor')}} ---DATA-- -return array() ---EXPECT-- -3 -2 -2.123 -3 - -20 -30 -20 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test deleted file mode 100644 index b49b89fe5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -"slice" filter ---TEMPLATE-- -{{ [1, 2, 3, 4][1:2]|join('') }} -{{ {a: 1, b: 2, c: 3, d: 4}[1:2]|join('') }} -{{ [1, 2, 3, 4][start:length]|join('') }} -{{ [1, 2, 3, 4]|slice(1, 2)|join('') }} -{{ [1, 2, 3, 4]|slice(1, 2)|keys|join('') }} -{{ [1, 2, 3, 4]|slice(1, 2, true)|keys|join('') }} -{{ {a: 1, b: 2, c: 3, d: 4}|slice(1, 2)|join('') }} -{{ {a: 1, b: 2, c: 3, d: 4}|slice(1, 2)|keys|join('') }} -{{ '1234'|slice(1, 2) }} -{{ '1234'[1:2] }} -{{ arr|slice(1, 2)|join('') }} -{{ arr[1:2]|join('') }} -{{ arr[4:1]|join('') }} -{{ arr[3:2]|join('') }} - -{{ [1, 2, 3, 4]|slice(1)|join('') }} -{{ [1, 2, 3, 4][1:]|join('') }} -{{ '1234'|slice(1) }} -{{ '1234'[1:] }} -{{ '1234'[:1] }} - -{{ arr|slice(3)|join('') }} -{{ arr[2:]|join('') }} -{{ xml|slice(1)|join('')}} ---DATA-- -return array('start' => 1, 'length' => 2, 'arr' => new ArrayObject(array(1, 2, 3, 4)), 'xml' => new SimpleXMLElement('12')) ---EXPECT-- -23 -23 -23 -23 -01 -12 -23 -bc -23 -23 -23 -23 - -4 - -234 -234 -234 -234 -1 - -4 -34 -2 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/sort.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/sort.test deleted file mode 100644 index c67c18ea9..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/sort.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"sort" filter ---TEMPLATE-- -{{ array1|sort|join }} -{{ array2|sort|join }} -{{ traversable|sort|join }} ---DATA-- -return array('array1' => array(4, 1), 'array2' => array('foo', 'bar'), 'traversable' => new ArrayObject(array(0 => 3, 1 => 2, 2 => 1))) ---EXPECT-- -14 -barfoo -123 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/special_chars.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/special_chars.test deleted file mode 100644 index dbaf7dc97..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/special_chars.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"§" custom filter ---TEMPLATE-- -{{ 'foo'|§ }} ---DATA-- -return array() ---EXPECT-- -§foo§ diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test deleted file mode 100644 index a093ed79b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -"split" filter ---TEMPLATE-- -{{ "one,two,three,four,five"|split(',')|join('-') }} -{{ foo|split(',')|join('-') }} -{{ foo|split(',', 3)|join('-') }} -{{ baz|split('')|join('-') }} -{{ baz|split('', 1)|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 -1-2-3-4-5 -12-34-5 -one-two-three \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split_utf8.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split_utf8.test deleted file mode 100644 index 305e162fe..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split_utf8.test +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -"split" filter ---CONDITION-- -function_exists('mb_get_info') ---TEMPLATE-- -{{ "é"|split('', 10)|join('-') }} -{{ foo|split(',')|join('-') }} -{{ foo|split(',', 1)|join('-') }} -{{ foo|split(',', 2)|join('-') }} -{{ foo|split(',', 3)|join('-') }} -{{ baz|split('')|join('-') }} -{{ baz|split('', 1)|join('-') }} -{{ baz|split('', 2)|join('-') }} ---DATA-- -return array('foo' => 'Ä,é,Äほ', 'baz' => 'éÄßごa',) ---EXPECT-- -é -Ä-é-Äほ -Ä,é,Äほ -Ä-é,Äほ -Ä-é-Äほ -é-Ä-ß-ご-a -é-Ä-ß-ご-a -éÄ-ßご-a \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/static_calls.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/static_calls.test deleted file mode 100644 index 4e17b7726..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/static_calls.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Filters as static method calls ---TEMPLATE-- -{{ 'foo'|static_call_string }} -{{ 'foo'|static_call_array }} ---DATA-- -return array('foo' => 'foo') ---EXPECT-- -*foo* -*foo* diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/trim.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/trim.test deleted file mode 100644 index b1ef7b473..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/trim.test +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -"trim" filter ---TEMPLATE-- -{{ " I like Twig. "|trim }} -{{ text|trim }} -{{ " foo/"|trim("/") }} -{{ "xxxI like Twig.xxx"|trim(character_mask="x", side="left") }} -{{ "xxxI like Twig.xxx"|trim(side="right", character_mask="x") }} -{{ "xxxI like Twig.xxx"|trim("x", "right") }} -{{ "/ foo/"|trim("/", "left") }} -{{ "/ foo/"|trim(character_mask="/", side="left") }} -{{ " do nothing. "|trim("", "right") }} ---DATA-- -return array('text' => " If you have some HTML it will be escaped. ") ---EXPECT-- -I like Twig. -If you have some <strong>HTML</strong> it will be escaped. - foo -I like Twig.xxx -xxxI like Twig. -xxxI like Twig. - foo/ - foo/ - do nothing. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test deleted file mode 100644 index 8726159db..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"url_encode" filter ---CONDITION-- -defined('PHP_QUERY_RFC3986') ---TEMPLATE-- -{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }} -{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }} -{{ {}|url_encode|default("default") }} -{{ 'spéßi%le%c0d@dspa ce'|url_encode }} ---DATA-- -return array() ---EXPECT-- -foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce= -foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce= -default -sp%C3%A9%C3%9Fi%25le%25c0d%40dspa%20ce diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode_deprecated.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode_deprecated.test deleted file mode 100644 index 35e50390d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode_deprecated.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"url_encode" filter for PHP < 5.4 ---CONDITION-- -defined('PHP_QUERY_RFC3986') ---TEMPLATE-- -{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }} -{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }} -{{ {}|url_encode|default("default") }} -{{ 'spéßi%le%c0d@dspa ce'|url_encode }} ---DATA-- -return array() ---EXPECT-- -foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce= -foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce= -default -sp%C3%A9%C3%9Fi%25le%25c0d%40dspa%20ce diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test deleted file mode 100644 index 71b2038aa..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"attribute" function ---TEMPLATE-- -{{ attribute(obj, method) }} -{{ attribute(array, item) }} -{{ attribute(obj, "bar", ["a", "b"]) }} -{{ attribute(obj, "bar", arguments) }} -{{ attribute(obj, method) is defined ? 'ok' : 'ko' }} -{{ attribute(obj, nonmethod) is defined ? 'ok' : 'ko' }} ---DATA-- -return array('obj' => new TwigTestFoo(), 'method' => 'foo', 'array' => array('foo' => 'bar'), 'item' => 'foo', 'nonmethod' => 'xxx', 'arguments' => array('a', 'b')) ---EXPECT-- -foo -bar -bar_a-b -bar_a-b -ok -ko diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block.test deleted file mode 100644 index 8e54059ae..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"block" function ---TEMPLATE-- -{% extends 'base.twig' %} -{% block bar %}BAR{% endblock %} ---TEMPLATE(base.twig)-- -{% block foo %}{{ block('bar') }}{% endblock %} -{% block bar %}BAR_BASE{% endblock %} ---DATA-- -return array() ---EXPECT-- -BARBAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_with_template.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_with_template.test deleted file mode 100644 index 8305eb67f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_with_template.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"block" function with a template argument ---TEMPLATE-- -{{ block('foo', 'included.twig') }} -{{ block('foo', included_loaded) }} -{{ block('foo', included_loaded_internal) }} -{% set output = block('foo', 'included.twig') %} -{{ output }} -{% block foo %}NOT FOO{% endblock %} ---TEMPLATE(included.twig)-- -{% block foo %}FOO{% endblock %} ---DATA-- -return array( - 'included_loaded' => $twig->load('included.twig'), - 'included_loaded_internal' => $twig->loadTemplate('included.twig'), -) ---EXPECT-- -FOO -FOO -FOO -FOO -NOT FOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_without_name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_without_name.test deleted file mode 100644 index 665cc87e5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block_without_name.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"block" function without arguments ---TEMPLATE-- -{% extends 'base.twig' %} -{% block bar %}BAR{% endblock %} ---TEMPLATE(base.twig)-- -{% block foo %}{{ block() }}{% endblock %} -{% block bar %}BAR_BASE{% endblock %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: The "block" function takes one argument (the block name) in "base.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/constant.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/constant.test deleted file mode 100644 index 63128791f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/constant.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"constant" function ---TEMPLATE-- -{{ constant('DATE_W3C') == expect ? 'true' : 'false' }} -{{ constant('ARRAY_AS_PROPS', object) }} ---DATA-- -return array('expect' => DATE_W3C, 'object' => new ArrayObject(array('hi'))); ---EXPECT-- -true -2 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/cycle.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/cycle.test deleted file mode 100644 index 522a63b85..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/cycle.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"cycle" function ---TEMPLATE-- -{% for i in 0..6 %} -{{ cycle(array1, i) }}-{{ cycle(array2, i) }} -{% endfor %} ---DATA-- -return array('array1' => array('odd', 'even'), 'array2' => array('apple', 'orange', 'citrus')) ---EXPECT-- -odd-apple -even-orange -odd-citrus -even-apple -odd-orange -even-citrus -odd-apple diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date.test deleted file mode 100644 index c9f464468..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date.test +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -"date" function ---TEMPLATE-- -{{ date().format('r') == date('now').format('r') ? 'OK' : 'KO' }} -{{ date(date1) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} -{{ date(date2) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} -{{ date(date3) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} -{{ date(date4) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} -{{ date(date5) == date('1964-01-02 03:04') ? 'OK' : 'KO' }} -{{ date() > date('-1day') ? 'OK' : 'KO' }} ---DATA-- -date_default_timezone_set('UTC'); -return array( - 'date1' => mktime(13, 45, 0, 10, 4, 2010), - 'date2' => new DateTime('2010-10-04 13:45'), - 'date3' => '2010-10-04 13:45', - 'date4' => 1286199900, // DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT - 'date5' => -189291360, // DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new DateTimeZone('UTC'))->getTimestamp(), -) ---EXPECT-- -OK -OK -OK -OK -OK -OK -OK diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date_namedargs.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date_namedargs.test deleted file mode 100644 index b9dd9e383..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date_namedargs.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"date" function ---TEMPLATE-- -{{ date(date, "America/New_York")|date('d/m/Y H:i:s P', false) }} -{{ date(timezone="America/New_York", date=date)|date('d/m/Y H:i:s P', false) }} ---DATA-- -date_default_timezone_set('UTC'); -return array('date' => mktime(13, 45, 0, 10, 4, 2010)) ---EXPECT-- -04/10/2010 09:45:00 -04:00 -04/10/2010 09:45:00 -04:00 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test deleted file mode 100644 index f4072375a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"dump" function ---CONDITION-- -!extension_loaded('xdebug') ---TEMPLATE-- -{{ dump('foo') }} -{{ dump('foo', 'bar') }} ---DATA-- -return array('foo' => 'foo', 'bar' => 'bar') ---CONFIG-- -return array('debug' => true, 'autoescape' => false); ---EXPECT-- -string(3) "foo" - -string(3) "foo" -string(3) "bar" diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump_array.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump_array.test deleted file mode 100644 index 889b7a922..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump_array.test +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -"dump" function, xdebug is not loaded or xdebug <2.2-dev is loaded ---CONDITION-- -!extension_loaded('xdebug') || (($r = new ReflectionExtension('xdebug')) && version_compare($r->getVersion(), '2.2-dev', '<')) ---TEMPLATE-- -{{ dump() }} ---DATA-- -return array('foo' => 'foo', 'bar' => 'bar') ---CONFIG-- -return array('debug' => true, 'autoescape' => false); ---EXPECT-- -array(3) { - ["foo"]=> - string(3) "foo" - ["bar"]=> - string(3) "bar" - ["global"]=> - string(6) "global" -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dynamic_function.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dynamic_function.test deleted file mode 100644 index 913fbc995..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dynamic_function.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -dynamic function ---TEMPLATE-- -{{ foo_path('bar') }} -{{ a_foo_b_bar('bar') }} ---DATA-- -return array() ---EXPECT-- -foo/bar -a/b/bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/assignment.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/assignment.test deleted file mode 100644 index b7653b4ef..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/assignment.test +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -"include" function ---TEMPLATE-- -{% set tmp = include("foo.twig") %} - -FOO{{ tmp }}BAR ---TEMPLATE(foo.twig)-- -FOOBAR ---DATA-- -return array() ---EXPECT-- -FOO -FOOBARBAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/autoescaping.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/autoescaping.test deleted file mode 100644 index 56f8f3b5a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/autoescaping.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"include" function is safe for auto-escaping ---TEMPLATE-- -{{ include("foo.twig") }} ---TEMPLATE(foo.twig)-- -

    Test

    ---DATA-- -return array() ---EXPECT-- -

    Test

    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/basic.test deleted file mode 100644 index a434182a2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/basic.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"include" function ---TEMPLATE-- -FOO -{{ include("foo.twig") }} - -BAR ---TEMPLATE(foo.twig)-- -FOOBAR ---DATA-- -return array() ---EXPECT-- -FOO - -FOOBAR - -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/expression.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/expression.test deleted file mode 100644 index aba30ce3f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/expression.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"include" function allows expressions for the template to include ---TEMPLATE-- -FOO -{{ include(foo) }} - -BAR ---TEMPLATE(foo.twig)-- -FOOBAR ---DATA-- -return array('foo' => 'foo.twig') ---EXPECT-- -FOO - -FOOBAR - -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/ignore_missing.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/ignore_missing.test deleted file mode 100644 index 43a2ccc2c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/ignore_missing.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"include" function ---TEMPLATE-- -{{ include(["foo.twig", "bar.twig"], ignore_missing = true) }} -{{ include("foo.twig", ignore_missing = true) }} -{{ include("foo.twig", ignore_missing = true, variables = {}) }} -{{ include("foo.twig", ignore_missing = true, variables = {}, with_context = true) }} ---DATA-- -return array() ---EXPECT-- diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing.test deleted file mode 100644 index 4d2f6cf13..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"include" function ---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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing_nested.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing_nested.test deleted file mode 100644 index 78fddc7a6..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing_nested.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" function ---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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test deleted file mode 100644 index 7b9ccaca8..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -"include" tag sandboxed ---TEMPLATE-- -{{ include("foo.twig", sandboxed = true) }} ---TEMPLATE(foo.twig)-- - - -{{ foo|e }} -{{ foo|e }} ---DATA-- -return array() ---EXCEPTION-- -Twig_Sandbox_SecurityNotAllowedFilterError: Filter "e" is not allowed in "foo.twig" at line 4. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling.test deleted file mode 100644 index 8ffc49225..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" tag sandboxed ---TEMPLATE-- -{{ include("foo.twig", sandboxed = true) }} -{{ include("bar.twig") }} ---TEMPLATE(foo.twig)-- -foo ---TEMPLATE(bar.twig)-- -{{ foo|e }} ---DATA-- -return array('foo' => 'bar
    ') ---EXPECT-- -foo - - -bar<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test deleted file mode 100644 index 8bf6e102d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -"include" tag sandboxed ---TEMPLATE-- -{{ include("unknown.twig", sandboxed = true, ignore_missing = true) }} -{{ include("bar.twig") }} ---TEMPLATE(bar.twig)-- -{{ foo|e }} ---DATA-- -return array('foo' => 'bar
    ') ---EXPECT-- - - -bar<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/template_instance.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/template_instance.test deleted file mode 100644 index 18d405a02..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/template_instance.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"include" function accepts Twig_Template instance ---TEMPLATE-- -{{ include(foo) }} FOO ---TEMPLATE(foo.twig)-- -BAR ---DATA-- -return array('foo' => $twig->loadTemplate('foo.twig')) ---EXPECT-- -BAR FOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/templates_as_array.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/templates_as_array.test deleted file mode 100644 index 1a8100687..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/templates_as_array.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"include" function ---TEMPLATE-- -{{ include(["foo.twig", "bar.twig"]) }} -{{- include(["bar.twig", "foo.twig"]) }} ---TEMPLATE(foo.twig)-- -foo ---DATA-- -return array() ---EXPECT-- -foo -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_context.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_context.test deleted file mode 100644 index 35611fbb9..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_context.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" function accept variables and with_context ---TEMPLATE-- -{{ include("foo.twig") }} -{{- include("foo.twig", with_context = false) }} -{{- include("foo.twig", {'foo1': 'bar'}) }} -{{- include("foo.twig", {'foo1': 'bar'}, with_context = false) }} ---TEMPLATE(foo.twig)-- -{% for k, v in _context %}{{ k }},{% endfor %} ---DATA-- -return array('foo' => 'bar') ---EXPECT-- -foo,global,_parent, -global,_parent, -foo,global,foo1,_parent, -foo1,global,_parent, diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_variables.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_variables.test deleted file mode 100644 index b2ace940e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_variables.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"include" function accept variables ---TEMPLATE-- -{{ include("foo.twig", {'foo': 'bar'}) }} -{{- include("foo.twig", vars) }} ---TEMPLATE(foo.twig)-- -{{ foo }} ---DATA-- -return array('vars' => array('foo' => 'bar')) ---EXPECT-- -bar -bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call.test deleted file mode 100644 index 933544312..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -__call calls ---TEMPLATE-- -{{ 'foo'|magic_call }} ---DATA-- -return array() ---EXPECT-- -magic_foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call53.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call53.test deleted file mode 100644 index a0f55e116..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/magic_call53.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -__staticCall calls ---CONDITION-- -version_compare(phpversion(), '5.3.0', '>=') ---TEMPLATE-- -{{ 'foo'|magic_call_string }} -{{ 'foo'|magic_call_array }} ---DATA-- -return array() ---EXPECT-- -static_magic_foo -static_magic_foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/max.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/max.test deleted file mode 100644 index e6c94af63..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/max.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"max" function ---TEMPLATE-- -{{ max([2, 1, 3, 5, 4]) }} -{{ max(2, 1, 3, 5, 4) }} -{{ max({2:"two", 1:"one", 3:"three", 5:"five", 4:"for"}) }} ---DATA-- -return array() ---EXPECT-- -5 -5 -two diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/min.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/min.test deleted file mode 100644 index 660471c00..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/min.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"min" function ---TEMPLATE-- -{{ min(2, 1, 3, 5, 4) }} -{{ min([2, 1, 3, 5, 4]) }} -{{ min({2:"two", 1:"one", 3:"three", 5:"five", 4:"for"}) }} ---DATA-- -return array() ---EXPECT-- -1 -1 -five diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/range.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/range.test deleted file mode 100644 index e0377c8d4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/range.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"range" function ---TEMPLATE-- -{{ range(low=0+1, high=10+0, step=2)|join(',') }} ---DATA-- -return array() ---EXPECT-- -1,3,5,7,9 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test deleted file mode 100644 index bf0556d24..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -"block" function recursively called in a parent template ---TEMPLATE-- -{% extends "ordered_menu.twig" %} -{% block label %}"{{ parent() }}"{% endblock %} -{% block list %}{% set class = 'b' %}{{ parent() }}{% endblock %} ---TEMPLATE(ordered_menu.twig)-- -{% extends "menu.twig" %} -{% block list %}{% set class = class|default('a') %}
      {{ block('children') }}
    {% endblock %} ---TEMPLATE(menu.twig)-- -{% extends "base.twig" %} -{% block list %}
      {{ block('children') }}
    {% endblock %} -{% block children %}{% set currentItem = item %}{% for item in currentItem %}{{ block('item') }}{% endfor %}{% set item = currentItem %}{% endblock %} -{% block item %}
  • {% if item is not iterable %}{{ block('label') }}{% else %}{{ block('list') }}{% endif %}
  • {% endblock %} -{% block label %}{{ item }}{% endblock %} ---TEMPLATE(base.twig)-- -{{ block('list') }} ---DATA-- -return array('item' => array('1', '2', array('3.1', array('3.2.1', '3.2.2'), '3.4'))) ---EXPECT-- -
    1. "1"
    2. "2"
      1. "3.1"
        1. "3.2.1"
        2. "3.2.2"
      2. "3.4"
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/source.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/source.test deleted file mode 100644 index 0e094c3b2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/source.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"source" function ---TEMPLATE-- -FOO -{{ source("foo.twig") }} - -BAR ---TEMPLATE(foo.twig)-- -{{ foo }}
    ---DATA-- -return array() ---EXPECT-- -FOO - -{{ foo }}
    - -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/special_chars.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/special_chars.test deleted file mode 100644 index 30c3df516..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/special_chars.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"§" custom function ---TEMPLATE-- -{{ §('foo') }} ---DATA-- -return array() ---EXPECT-- -§foo§ diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/static_calls.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/static_calls.test deleted file mode 100644 index 57e5be392..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/static_calls.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Functions as static method calls ---TEMPLATE-- -{{ static_call_string('foo') }} -{{ static_call_array('foo') }} ---DATA-- -return array('foo' => 'foo') ---EXPECT-- -*foo* -*foo* diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test deleted file mode 100644 index 3d3b95874..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -"template_from_string" function ---TEMPLATE-- -{% include template_from_string(template) %} - -{% include template_from_string("Hello {{ name }}") %} -{% include template_from_string('{% extends "parent.twig" %}{% block content %}Hello {{ name }}{% endblock %}') %} ---TEMPLATE(parent.twig)-- -{% block content %}{% endblock %} ---DATA-- -return array('name' => 'Fabien', 'template' => "Hello {{ name }}") ---EXPECT-- -Hello Fabien -Hello Fabien -Hello Fabien diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/default_values.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/default_values.test deleted file mode 100644 index 4ccff7b67..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/default_values.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -macro ---TEMPLATE-- -{% from _self import test %} - -{% macro test(a, b = 'bar') -%} -{{ a }}{{ b }} -{%- endmacro %} - -{{ test('foo') }} -{{ test('bar', 'foo') }} ---DATA-- -return array(); ---EXPECT-- -foobar -barfoo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test deleted file mode 100644 index cd2542810..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/nested_calls.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -macro ---TEMPLATE-- -{% import _self as macros %} - -{% macro foo(data) %} - {{ data }} -{% endmacro %} - -{% macro bar() %} -
    -{% endmacro %} - -{{ macros.foo(macros.bar()) }} ---DATA-- -return array(); ---EXPECT-- -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test deleted file mode 100644 index cbfb921b2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/reserved_variables.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -macro ---TEMPLATE-- -{% from _self import test %} - -{% macro test(this) -%} - {{ this }} -{%- endmacro %} - -{{ test(this) }} ---DATA-- -return array('this' => 'foo'); ---EXPECT-- -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/simple.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/simple.test deleted file mode 100644 index 6a366cdf1..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/simple.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -macro ---TEMPLATE-- -{% import _self as test %} -{% from _self import test %} - -{% macro test(a, b) -%} - {{ a|default('a') }}
    - {{- b|default('b') }}
    -{%- endmacro %} - -{{ test.test() }} -{{ test() }} -{{ test.test(1, "c") }} -{{ test(1, "c") }} ---DATA-- -return array(); ---EXPECT-- -a
    b
    -a
    b
    -1
    c
    -1
    c
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs.test deleted file mode 100644 index 412c90fae..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs.test +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -macro with arbitrary arguments ---TEMPLATE-- -{% from _self import test1, test2 %} - -{% macro test1(var) %} - {{- var }}: {{ varargs|join(", ") }} -{% endmacro %} - -{% macro test2() %} - {{- varargs|join(", ") }} -{% endmacro %} - -{{ test1("foo", "bar", "foobar") }} -{{ test2("foo", "bar", "foobar") }} ---DATA-- -return array(); ---EXPECT-- -foo: bar, foobar - -foo, bar, foobar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test deleted file mode 100644 index 800c262e7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test +++ /dev/null @@ -1,7 +0,0 @@ ---TEST-- -macro with varargs argument ---TEMPLATE-- -{% macro test(varargs) %} -{% endmacro %} ---EXCEPTION-- -Twig_Error_Syntax: The argument "varargs" in macro "test" cannot be defined because the variable "varargs" is reserved for arbitrary arguments in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/with_filters.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/with_filters.test deleted file mode 100644 index 685626f2a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/with_filters.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -macro with a filter ---TEMPLATE-- -{% import _self as test %} - -{% macro test() %} - {% filter escape %}foo
    {% endfilter %} -{% endmacro %} - -{{ test.test() }} ---DATA-- -return array(); ---EXPECT-- -foo<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/combined_debug_info.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/combined_debug_info.test deleted file mode 100644 index ff977ad62..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/combined_debug_info.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Exception with bad line number ---TEMPLATE-- -{% block content %} - {{ foo }} - {{ include("foo") }} -{% endblock %} -index ---TEMPLATE(foo)-- -foo -{{ foo.bar }} ---DATA-- -return array('foo' => 'foo'); ---EXCEPTION-- -Twig_Error_Runtime: Impossible to access an attribute ("bar") on a string variable ("foo") in "foo" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/empty_token.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/empty_token.test deleted file mode 100644 index 65f6cd2b8..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/empty_token.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Twig outputs 0 nodes correctly ---TEMPLATE-- -{{ foo }}0{{ foo }} ---DATA-- -return array('foo' => 'foo') ---EXPECT-- -foo0foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/issue_1143.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/issue_1143.test deleted file mode 100644 index ff7c8bb70..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/issue_1143.test +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -error in twig extension ---TEMPLATE-- -{{ object.region is not null ? object.regionChoices[object.region] }} ---DATA-- -class House -{ - const REGION_S = 1; - const REGION_P = 2; - - public static $regionChoices = array(self::REGION_S => 'house.region.s', self::REGION_P => 'house.region.p'); - - public function getRegionChoices() - { - return self::$regionChoices; - } -} - -$object = new House(); -$object->region = 1; -return array('object' => $object) ---EXPECT-- -house.region.s diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/multi_word_tests.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/multi_word_tests.test deleted file mode 100644 index 269a30571..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/multi_word_tests.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Twig allows multi-word tests without a custom node class ---TEMPLATE-- -{{ 'foo' is multi word ? 'yes' : 'no' }} -{{ 'foo bar' is multi word ? 'yes' : 'no' }} ---DATA-- -return array() ---EXPECT-- -no -yes diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/simple_xml_element.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/simple_xml_element.test deleted file mode 100644 index 60c3c51d7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/simple_xml_element.test +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -Twig is able to deal with SimpleXMLElement instances as variables ---CONDITION-- -version_compare(phpversion(), '5.3.0', '>=') ---TEMPLATE-- -Hello '{{ images.image.0.group }}'! -{{ images.image.0.group.attributes.myattr }} -{{ images.children().image.count() }} -{% for image in images %} - - {{ image.group }} -{% endfor %} ---DATA-- -return array('images' => new SimpleXMLElement('foobar')) ---EXPECT-- -Hello 'foo'! -example -2 - - foo - - bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/strings_like_numbers.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/strings_like_numbers.test deleted file mode 100644 index e18e11079..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/regression/strings_like_numbers.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Twig does not confuse strings with integers in getAttribute() ---TEMPLATE-- -{{ hash['2e2'] }} ---DATA-- -return array('hash' => array('2e2' => 'works')) ---EXPECT-- -works diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/basic.test deleted file mode 100644 index 2f6a3e1a0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/basic.test +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping on its children ---TEMPLATE-- -{% autoescape %} -{{ var }}
    -{% endautoescape %} -{% autoescape 'html' %} -{{ var }}
    -{% endautoescape %} -{% autoescape false %} -{{ var }}
    -{% endautoescape %} -{% autoescape true %} -{{ var }}
    -{% endautoescape %} -{% autoescape false %} -{{ var }}
    -{% endautoescape %} ---DATA-- -return array('var' => '
    ') ---EXPECT-- -<br />
    -<br />
    -

    -<br />
    -

    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test deleted file mode 100644 index 05ab83ce3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/blocks.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping on embedded blocks ---TEMPLATE-- -{% autoescape 'html' %} - {% block foo %} - {{ var }} - {% endblock %} -{% endautoescape %} ---DATA-- -return array('var' => '
    ') ---EXPECT-- -<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test deleted file mode 100644 index 9c0972462..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/double_escaping.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"autoescape" tag does not double-escape ---TEMPLATE-- -{% autoescape 'html' %} -{{ var|escape }} -{% endautoescape %} ---DATA-- -return array('var' => '
    ') ---EXPECT-- -<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test deleted file mode 100644 index ce7ea789e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/functions.test +++ /dev/null @@ -1,83 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping after calling functions ---TEMPLATE-- - -autoescape false -{% autoescape false %} - -safe_br -{{ safe_br() }} - -unsafe_br -{{ unsafe_br() }} - -{% endautoescape %} - -autoescape 'html' -{% autoescape 'html' %} - -safe_br -{{ safe_br() }} - -unsafe_br -{{ unsafe_br() }} - -unsafe_br()|raw -{{ (unsafe_br())|raw }} - -safe_br()|escape -{{ (safe_br())|escape }} - -safe_br()|raw -{{ (safe_br())|raw }} - -unsafe_br()|escape -{{ (unsafe_br())|escape }} - -{% endautoescape %} - -autoescape js -{% autoescape 'js' %} - -safe_br -{{ safe_br() }} - -{% endautoescape %} ---DATA-- -return array() ---EXPECT-- - -autoescape false - -safe_br -
    - -unsafe_br -
    - - -autoescape 'html' - -safe_br -
    - -unsafe_br -<br /> - -unsafe_br()|raw -
    - -safe_br()|escape -<br /> - -safe_br()|raw -
    - -unsafe_br()|escape -<br /> - - -autoescape js - -safe_br -\x3Cbr\x20\x2F\x3E diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/literal.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/literal.test deleted file mode 100644 index e389d4dd5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/literal.test +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -"autoescape" tag does not apply escaping on literals ---TEMPLATE-- -{% autoescape 'html' %} - -1. Simple literal -{{ "
    " }} - -2. Conditional expression with only literals -{{ true ? "
    " : "
    " }} - -3. Conditional expression with a variable -{{ true ? "
    " : someVar }} - -4. Nested conditionals with only literals -{{ true ? (true ? "
    " : "
    ") : "\n" }} - -5. Nested conditionals with a variable -{{ true ? (true ? "
    " : someVar) : "\n" }} - -6. Nested conditionals with a variable marked safe -{{ true ? (true ? "
    " : someVar|raw) : "\n" }} - -{% endautoescape %} ---DATA-- -return array() ---EXPECT-- - -1. Simple literal -
    - -2. Conditional expression with only literals -
    - -3. Conditional expression with a variable -<br /> - -4. Nested conditionals with only literals -
    - -5. Nested conditionals with a variable -<br /> - -6. Nested conditionals with a variable marked safe -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/nested.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/nested.test deleted file mode 100644 index 798e6feaf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/nested.test +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -"autoescape" tags can be nested at will ---TEMPLATE-- -{{ var }} -{% autoescape 'html' %} - {{ var }} - {% autoescape false %} - {{ var }} - {% autoescape 'html' %} - {{ var }} - {% endautoescape %} - {{ var }} - {% endautoescape %} - {{ var }} -{% endautoescape %} -{{ var }} ---DATA-- -return array('var' => '
    ') ---EXPECT-- -<br /> - <br /> -
    - <br /> -
    - <br /> -<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/objects.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/objects.test deleted file mode 100644 index e896aa41c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/objects.test +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping to object method calls ---TEMPLATE-- -{% autoescape 'html' %} -{{ user.name }} -{{ user.name|lower }} -{{ user }} -{% endautoescape %} ---DATA-- -class UserForAutoEscapeTest -{ - public function getName() - { - return 'Fabien
    '; - } - - public function __toString() - { - return 'Fabien
    '; - } -} -return array('user' => new UserForAutoEscapeTest()) ---EXPECT-- -Fabien<br /> -fabien<br /> -Fabien<br /> diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/raw.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/raw.test deleted file mode 100644 index 9f1cedd3a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/raw.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"autoescape" tag does not escape when raw is used as a filter ---TEMPLATE-- -{% autoescape 'html' %} -{{ var|raw }} -{% endautoescape %} ---DATA-- -return array('var' => '
    ') ---EXPECT-- -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test deleted file mode 100644 index bbf1356e7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"autoescape" tag accepts an escaping strategy ---TEMPLATE-- -{% autoescape true js %}{{ var }}{% endautoescape %} - -{% autoescape true html %}{{ var }}{% endautoescape %} ---DATA-- -return array('var' => '
    "') ---EXPECT-- -\x3Cbr\x20\x2F\x3E\x22 -<br />" diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test deleted file mode 100644 index e496f6081..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"autoescape" tag accepts an escaping strategy ---TEMPLATE-- -{% autoescape 'js' %}{{ var }}{% endautoescape %} - -{% autoescape 'html' %}{{ var }}{% endautoescape %} ---DATA-- -return array('var' => '
    "') ---EXPECT-- -\x3Cbr\x20\x2F\x3E\x22 -<br />" diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test deleted file mode 100644 index 4f415201d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/type.test +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -escape types ---TEMPLATE-- - -1. autoescape 'html' |escape('js') - -{% autoescape 'html' %} - -{% endautoescape %} - -2. autoescape 'html' |escape('js') - -{% autoescape 'html' %} - -{% endautoescape %} - -3. autoescape 'js' |escape('js') - -{% autoescape 'js' %} - -{% endautoescape %} - -4. no escape - -{% autoescape false %} - -{% endautoescape %} - -5. |escape('js')|escape('html') - -{% autoescape false %} - -{% endautoescape %} - -6. autoescape 'html' |escape('js')|escape('html') - -{% autoescape 'html' %} - -{% endautoescape %} - ---DATA-- -return array('msg' => "<>\n'\"") ---EXPECT-- - -1. autoescape 'html' |escape('js') - - - -2. autoescape 'html' |escape('js') - - - -3. autoescape 'js' |escape('js') - - - -4. no escape - - - -5. |escape('js')|escape('html') - - - -6. autoescape 'html' |escape('js')|escape('html') - - - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test deleted file mode 100644 index 7821a9aaf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters.test +++ /dev/null @@ -1,131 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping after calling filters ---TEMPLATE-- -{% autoescape 'html' %} - -(escape_and_nl2br is an escaper filter) - -1. Don't escape escaper filter output -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is not escaped ) -{{ var|escape_and_nl2br }} - -2. Don't escape escaper filter output -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is not escaped, |raw is redundant ) -{{ var|escape_and_nl2br|raw }} - -3. Explicit escape -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is explicitly escaped by |escape ) -{{ var|escape_and_nl2br|escape }} - -4. Escape non-escaper filter output -( var is upper-cased by |upper, - the output is auto-escaped ) -{{ var|upper }} - -5. Escape if last filter is not an escaper -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is upper-cased by |upper, - the output is auto-escaped as |upper is not an escaper ) -{{ var|escape_and_nl2br|upper }} - -6. Don't escape escaper filter output -( var is upper cased by upper, - the output is escaped by |escape_and_nl2br, line-breaks are added, - the output is not escaped as |escape_and_nl2br is an escaper ) -{{ var|upper|escape_and_nl2br }} - -7. Escape if last filter is not an escaper -( the output of |format is "" ~ var ~ "", - the output is auto-escaped ) -{{ "%s"|format(var) }} - -8. Escape if last filter is not an escaper -( the output of |format is "" ~ var ~ "", - |raw is redundant, - the output is auto-escaped ) -{{ "%s"|raw|format(var) }} - -9. Don't escape escaper filter output -( the output of |format is "" ~ var ~ "", - the output is not escaped due to |raw filter at the end ) -{{ "%s"|format(var)|raw }} - -10. Don't escape escaper filter output -( the output of |format is "" ~ var ~ "", - the output is not escaped due to |raw filter at the end, - the |raw filter on var is redundant ) -{{ "%s"|format(var|raw)|raw }} - -{% endautoescape %} ---DATA-- -return array('var' => "\nTwig") ---EXPECT-- - -(escape_and_nl2br is an escaper filter) - -1. Don't escape escaper filter output -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is not escaped ) -<Fabien>
    -Twig - -2. Don't escape escaper filter output -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is not escaped, |raw is redundant ) -<Fabien>
    -Twig - -3. Explicit escape -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is explicitly escaped by |escape ) -&lt;Fabien&gt;<br /> -Twig - -4. Escape non-escaper filter output -( var is upper-cased by |upper, - the output is auto-escaped ) -<FABIEN> -TWIG - -5. Escape if last filter is not an escaper -( var is escaped by |escape_and_nl2br, line-breaks are added, - the output is upper-cased by |upper, - the output is auto-escaped as |upper is not an escaper ) -&LT;FABIEN&GT;<BR /> -TWIG - -6. Don't escape escaper filter output -( var is upper cased by upper, - the output is escaped by |escape_and_nl2br, line-breaks are added, - the output is not escaped as |escape_and_nl2br is an escaper ) -<FABIEN>
    -TWIG - -7. Escape if last filter is not an escaper -( the output of |format is "" ~ var ~ "", - the output is auto-escaped ) -<b><Fabien> -Twig</b> - -8. Escape if last filter is not an escaper -( the output of |format is "" ~ var ~ "", - |raw is redundant, - the output is auto-escaped ) -<b><Fabien> -Twig</b> - -9. Don't escape escaper filter output -( the output of |format is "" ~ var ~ "", - the output is not escaped due to |raw filter at the end ) - -Twig - -10. Don't escape escaper filter output -( the output of |format is "" ~ var ~ "", - the output is not escaped due to |raw filter at the end, - the |raw filter on var is redundant ) - -Twig diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test deleted file mode 100644 index f58a1e09c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_filters_arguments.test +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -"autoescape" tag do not applies escaping on filter arguments ---TEMPLATE-- -{% autoescape 'html' %} -{{ var|nl2br("
    ") }} -{{ var|nl2br("
    "|escape) }} -{{ var|nl2br(sep) }} -{{ var|nl2br(sep|raw) }} -{{ var|nl2br(sep|escape) }} -{% endautoescape %} ---DATA-- -return array('var' => "\nTwig", 'sep' => '
    ') ---EXPECT-- -<Fabien>
    -Twig -<Fabien><br /> -Twig -<Fabien>
    -Twig -<Fabien>
    -Twig -<Fabien><br /> -Twig diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test deleted file mode 100644 index 134c77ea8..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_pre_escape_filters.test +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -"autoescape" tag applies escaping after calling filters, and before calling pre_escape filters ---TEMPLATE-- -{% autoescape 'html' %} - -(nl2br is pre_escaped for "html" and declared safe for "html") - -1. Pre-escape and don't post-escape -( var|escape|nl2br ) -{{ var|nl2br }} - -2. Don't double-pre-escape -( var|escape|nl2br ) -{{ var|escape|nl2br }} - -3. Don't escape safe values -( var|raw|nl2br ) -{{ var|raw|nl2br }} - -4. Don't escape safe values -( var|escape|nl2br|nl2br ) -{{ var|nl2br|nl2br }} - -5. Re-escape values that are escaped for an other contexts -( var|escape_something|escape|nl2br ) -{{ var|escape_something|nl2br }} - -6. Still escape when using filters not declared safe -( var|escape|nl2br|upper|escape ) -{{ var|nl2br|upper }} - -{% endautoescape %} ---DATA-- -return array('var' => "\nTwig") ---EXPECT-- - -(nl2br is pre_escaped for "html" and declared safe for "html") - -1. Pre-escape and don't post-escape -( var|escape|nl2br ) -<Fabien>
    -Twig - -2. Don't double-pre-escape -( var|escape|nl2br ) -<Fabien>
    -Twig - -3. Don't escape safe values -( var|raw|nl2br ) -
    -Twig - -4. Don't escape safe values -( var|escape|nl2br|nl2br ) -<Fabien>

    -Twig - -5. Re-escape values that are escaped for an other contexts -( var|escape_something|escape|nl2br ) -<FABIEN>
    -TWIG - -6. Still escape when using filters not declared safe -( var|escape|nl2br|upper|escape ) -&LT;FABIEN&GT;<BR /> -TWIG - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_preserves_safety_filters.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_preserves_safety_filters.test deleted file mode 100644 index 32d3943b5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/with_preserves_safety_filters.test +++ /dev/null @@ -1,50 +0,0 @@ ---TEST-- -"autoescape" tag handles filters preserving the safety ---TEMPLATE-- -{% autoescape 'html' %} - -(preserves_safety is preserving safety for "html") - -1. Unsafe values are still unsafe -( var|preserves_safety|escape ) -{{ var|preserves_safety }} - -2. Safe values are still safe -( var|escape|preserves_safety ) -{{ var|escape|preserves_safety }} - -3. Re-escape values that are escaped for an other contexts -( var|escape_something|preserves_safety|escape ) -{{ var|escape_something|preserves_safety }} - -4. Still escape when using filters not declared safe -( var|escape|preserves_safety|replace({'FABIEN': 'FABPOT'})|escape ) -{{ var|escape|preserves_safety|replace({'FABIEN': 'FABPOT'}) }} - -{% endautoescape %} ---DATA-- -return array('var' => "\nTwig") ---EXPECT-- - -(preserves_safety is preserving safety for "html") - -1. Unsafe values are still unsafe -( var|preserves_safety|escape ) -<FABIEN> -TWIG - -2. Safe values are still safe -( var|escape|preserves_safety ) -<FABIEN> -TWIG - -3. Re-escape values that are escaped for an other contexts -( var|escape_something|preserves_safety|escape ) -<FABIEN> -TWIG - -4. Still escape when using filters not declared safe -( var|escape|preserves_safety|replace({'FABIEN': 'FABPOT'})|escape ) -&LT;FABPOT&GT; -TWIG - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/basic.test deleted file mode 100644 index 360dcf030..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/basic.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"block" tag ---TEMPLATE-- -{% block title1 %}FOO{% endblock %} -{% block title2 foo|lower %} ---TEMPLATE(foo.twig)-- -{% block content %}{% endblock %} ---DATA-- -return array('foo' => 'bar') ---EXPECT-- -FOObar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/block_unique_name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/block_unique_name.test deleted file mode 100644 index bc89ec820..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/block_unique_name.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"block" tag ---TEMPLATE-- -{% block content %} - {% block content %} - {% endblock %} -{% endblock %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: The block 'content' has already been defined line 2 in "index.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/special_chars.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/special_chars.test deleted file mode 100644 index be17fedf3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/special_chars.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"§" special chars in a block name ---TEMPLATE-- -{% block § %} -§ -{% endblock § %} ---DATA-- -return array() ---EXPECT-- -§ diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/basic.test deleted file mode 100644 index f44296ea0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/basic.test +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -"embed" tag ---TEMPLATE-- -FOO -{% embed "foo.twig" %} - {% block c1 %} - {{ parent() }} - block1extended - {% endblock %} -{% endembed %} - -BAR ---TEMPLATE(foo.twig)-- -A -{% block c1 %} - block1 -{% endblock %} -B -{% block c2 %} - block2 -{% endblock %} -C ---DATA-- -return array() ---EXPECT-- -FOO - -A - block1 - - block1extended - B - block2 -C -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/complex_dynamic_parent.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/complex_dynamic_parent.test deleted file mode 100644 index de5ea7eea..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/complex_dynamic_parent.test +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -"embed" tag ---TEMPLATE-- -FOO -{% embed foo ~ ".twig" %} - {% block c1 %} - {{ parent() }} - block1extended - {% endblock %} -{% endembed %} - -BAR ---TEMPLATE(foo.twig)-- -A -{% block c1 %} - block1 -{% endblock %} -B -{% block c2 %} - block2 -{% endblock %} -C ---DATA-- -return array('foo' => 'foo') ---EXPECT-- -FOO - -A - block1 - - block1extended - B - block2 -C -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/dynamic_parent.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/dynamic_parent.test deleted file mode 100644 index 2a125e6b5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/dynamic_parent.test +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -"embed" tag ---TEMPLATE-- -FOO -{% embed foo %} - {% block c1 %} - {{ parent() }} - block1extended - {% endblock %} -{% endembed %} - -BAR ---TEMPLATE(foo.twig)-- -A -{% block c1 %} - block1 -{% endblock %} -B -{% block c2 %} - block2 -{% endblock %} -C ---DATA-- -return array('foo' => 'foo.twig') ---EXPECT-- -FOO - -A - block1 - - block1extended - B - block2 -C -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/error_line.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/error_line.test deleted file mode 100644 index 431473707..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/error_line.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"embed" tag ---TEMPLATE(index.twig)-- -FOO -{% embed "foo.twig" %} - {% block c1 %} - {{ nothing }} - {% endblock %} -{% endembed %} -BAR ---TEMPLATE(foo.twig)-- -{% block c1 %}{% endblock %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Runtime: Variable "nothing" does not exist in "index.twig" at line 5. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/multiple.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/multiple.test deleted file mode 100644 index da161e6d4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/multiple.test +++ /dev/null @@ -1,50 +0,0 @@ ---TEST-- -"embed" tag ---TEMPLATE-- -FOO -{% embed "foo.twig" %} - {% block c1 %} - {{ parent() }} - block1extended - {% endblock %} -{% endembed %} - -{% embed "foo.twig" %} - {% block c1 %} - {{ parent() }} - block1extended - {% endblock %} -{% endembed %} - -BAR ---TEMPLATE(foo.twig)-- -A -{% block c1 %} - block1 -{% endblock %} -B -{% block c2 %} - block2 -{% endblock %} -C ---DATA-- -return array() ---EXPECT-- -FOO - -A - block1 - - block1extended - B - block2 -C - -A - block1 - - block1extended - B - block2 -C -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test deleted file mode 100644 index 81563dcef..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/nested.test +++ /dev/null @@ -1,42 +0,0 @@ ---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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/with_extends.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/with_extends.test deleted file mode 100644 index 2c1dd584c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/embed/with_extends.test +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -"embed" tag ---TEMPLATE-- -{% extends "base.twig" %} - -{% block c1 %} - {{ parent() }} - blockc1baseextended -{% endblock %} - -{% block c2 %} - {{ parent() }} - - {% embed "foo.twig" %} - {% block c1 %} - {{ parent() }} - block1extended - {% endblock %} - {% endembed %} - {{ parent() }} -{% endblock %} ---TEMPLATE(base.twig)-- -A -{% block c1 %} - blockc1base -{% endblock %} -{% block c2 %} - blockc2base -{% endblock %} -B ---TEMPLATE(foo.twig)-- -A -{% block c1 %} - block1 -{% endblock %} -B -{% block c2 %} - block2 -{% endblock %} -C ---DATA-- -return array() ---EXPECT-- -A - blockc1base - - blockc1baseextended - blockc2base - - - -A - block1 - - block1extended - B - block2 -C blockc2base - -B \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/basic.test deleted file mode 100644 index 82094f2f0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/basic.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"filter" tag applies a filter on its children ---TEMPLATE-- -{% filter upper %} -Some text with a {{ var }} -{% endfilter %} ---DATA-- -return array('var' => 'var') ---EXPECT-- -SOME TEXT WITH A VAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/json_encode.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/json_encode.test deleted file mode 100644 index 3e7148bf4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/json_encode.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"filter" tag applies a filter on its children ---TEMPLATE-- -{% filter json_encode|raw %}test{% endfilter %} ---DATA-- -return array() ---EXPECT-- -"test" diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/multiple.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/multiple.test deleted file mode 100644 index 75512ef96..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/multiple.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"filter" tags accept multiple chained filters ---TEMPLATE-- -{% filter lower|title %} - {{ var }} -{% endfilter %} ---DATA-- -return array('var' => 'VAR') ---EXPECT-- - Var diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/nested.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/nested.test deleted file mode 100644 index 7e4e4eb33..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/nested.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"filter" tags can be nested at will ---TEMPLATE-- -{% filter lower|title %} - {{ var }} - {% filter upper %} - {{ var }} - {% endfilter %} - {{ var }} -{% endfilter %} ---DATA-- -return array('var' => 'var') ---EXPECT-- - Var - Var - Var diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test deleted file mode 100644 index 22745eadf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_for_tag.test +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -"filter" tag applies the filter on "for" tags ---TEMPLATE-- -{% filter upper %} -{% for item in items %} -{{ item }} -{% endfor %} -{% endfilter %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- -A -B diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test deleted file mode 100644 index afd95b296..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/filter/with_if_tag.test +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -"filter" tag applies the filter on "if" tags ---TEMPLATE-- -{% filter upper %} -{% if items %} -{{ items|join(', ') }} -{% endif %} - -{% if items.3 is defined %} -FOO -{% else %} -{{ items.1 }} -{% endif %} - -{% if items.3 is defined %} -FOO -{% elseif items.1 %} -{{ items.0 }} -{% endif %} - -{% endfilter %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- -A, B - -B - -A diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/condition.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/condition.test deleted file mode 100644 index 380531f78..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/condition.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"for" tag takes a condition ---TEMPLATE-- -{% for i in 1..5 if i is odd -%} - {{ loop.index }}.{{ i }}{{ foo.bar }} -{% endfor %} ---DATA-- -return array('foo' => array('bar' => 'X')) ---CONFIG-- -return array('strict_variables' => false) ---EXPECT-- -1.1X -2.3X -3.5X diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/context.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/context.test deleted file mode 100644 index ddc69307b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/context.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"for" tag keeps the context safe ---TEMPLATE-- -{% for item in items %} - {% for item in items %} - * {{ item }} - {% endfor %} - * {{ item }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * a - * b - * a - * a - * b - * b diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/else.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/else.test deleted file mode 100644 index 20ccc880c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/else.test +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -"for" tag can use an "else" clause ---TEMPLATE-- -{% for item in items %} - * {{ item }} -{% else %} - no item -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * a - * b ---DATA-- -return array('items' => array()) ---EXPECT-- - no item ---DATA-- -return array() ---CONFIG-- -return array('strict_variables' => false) ---EXPECT-- - no item diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/inner_variables.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/inner_variables.test deleted file mode 100644 index 49fb9ca6f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/inner_variables.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"for" tag does not reset inner variables ---TEMPLATE-- -{% for i in 1..2 %} - {% for j in 0..2 %} - {{k}}{% set k = k+1 %} {{ loop.parent.loop.index }} - {% endfor %} -{% endfor %} ---DATA-- -return array('k' => 0) ---EXPECT-- - 0 1 - 1 1 - 2 1 - 3 2 - 4 2 - 5 2 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys.test deleted file mode 100644 index 4e22cb473..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"for" tag can iterate over keys ---TEMPLATE-- -{% for key in items|keys %} - * {{ key }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * 0 - * 1 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys_and_values.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys_and_values.test deleted file mode 100644 index 4c211689d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/keys_and_values.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"for" tag can iterate over keys and values ---TEMPLATE-- -{% for key, item in items %} - * {{ key }}/{{ item }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * 0/a - * 1/b diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context.test deleted file mode 100644 index 93bc76a1f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context.test +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -"for" tag adds a loop variable to the context ---TEMPLATE-- -{% for item in items %} - * {{ loop.index }}/{{ loop.index0 }} - * {{ loop.revindex }}/{{ loop.revindex0 }} - * {{ loop.first }}/{{ loop.last }}/{{ loop.length }} - -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * 1/0 - * 2/1 - * 1//2 - - * 2/1 - * 1/0 - * /1/2 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context_local.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context_local.test deleted file mode 100644 index 58af2c326..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_context_local.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"for" tag adds a loop variable to the context locally ---TEMPLATE-- -{% for item in items %} -{% endfor %} -{% if loop is not defined %}WORKS{% endif %} ---DATA-- -return array('items' => array()) ---EXPECT-- -WORKS diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined.test deleted file mode 100644 index 6a2af63b6..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"for" tag ---TEMPLATE-- -{% for i, item in items if i > 0 %} - {{ loop.last }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXCEPTION-- -Twig_Error_Syntax: The "loop.last" variable is not defined when looping with a condition in "index.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined_cond.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined_cond.test deleted file mode 100644 index 1e819ca0a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined_cond.test +++ /dev/null @@ -1,9 +0,0 @@ ---TEST-- -"for" tag ---TEMPLATE-- -{% for i, item in items if loop.last > 0 %} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXCEPTION-- -Twig_Error_Syntax: The "loop" variable cannot be used in a looping condition in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/nested_else.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/nested_else.test deleted file mode 100644 index f8b9f6bc1..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/nested_else.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"for" tag can use an "else" clause ---TEMPLATE-- -{% for item in items %} - {% for item in items1 %} - * {{ item }} - {% else %} - no {{ item }} - {% endfor %} -{% else %} - no item1 -{% endfor %} ---DATA-- -return array('items' => array('a', 'b'), 'items1' => array()) ---EXPECT-- -no a - no b diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test deleted file mode 100644 index 503443792..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects.test +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -"for" tag iterates over iterable objects ---TEMPLATE-- -{% for item in items %} - * {{ item }} - * {{ loop.index }}/{{ loop.index0 }} - * {{ loop.first }} - -{% endfor %} - -{% for key, value in items %} - * {{ key }}/{{ value }} -{% endfor %} - -{% for key in items|keys %} - * {{ key }} -{% endfor %} ---DATA-- -class ItemsIterator implements Iterator -{ - protected $values = array('foo' => 'bar', 'bar' => 'foo'); - public function current() { return current($this->values); } - public function key() { return key($this->values); } - public function next() { return next($this->values); } - public function rewind() { return reset($this->values); } - public function valid() { return false !== current($this->values); } -} -return array('items' => new ItemsIterator()) ---EXPECT-- - * bar - * 1/0 - * 1 - - * foo - * 2/1 - * - - - * foo/bar - * bar/foo - - * foo - * bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects_countable.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects_countable.test deleted file mode 100644 index 4a1ff6119..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/objects_countable.test +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -"for" tag iterates over iterable and countable objects ---TEMPLATE-- -{% for item in items %} - * {{ item }} - * {{ loop.index }}/{{ loop.index0 }} - * {{ loop.revindex }}/{{ loop.revindex0 }} - * {{ loop.first }}/{{ loop.last }}/{{ loop.length }} - -{% endfor %} - -{% for key, value in items %} - * {{ key }}/{{ value }} -{% endfor %} - -{% for key in items|keys %} - * {{ key }} -{% endfor %} ---DATA-- -class ItemsIteratorCountable implements Iterator, Countable -{ - protected $values = array('foo' => 'bar', 'bar' => 'foo'); - public function current() { return current($this->values); } - public function key() { return key($this->values); } - public function next() { return next($this->values); } - public function rewind() { return reset($this->values); } - public function valid() { return false !== current($this->values); } - public function count() { return count($this->values); } -} -return array('items' => new ItemsIteratorCountable()) ---EXPECT-- - * bar - * 1/0 - * 2/1 - * 1//2 - - * foo - * 2/1 - * 1/0 - * /1/2 - - - * foo/bar - * bar/foo - - * foo - * bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/recursive.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/recursive.test deleted file mode 100644 index 17b2e2223..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/recursive.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"for" tags can be nested ---TEMPLATE-- -{% for key, item in items %} -* {{ key }} ({{ loop.length }}): -{% for value in item %} - * {{ value }} ({{ loop.length }}) -{% endfor %} -{% endfor %} ---DATA-- -return array('items' => array('a' => array('a1', 'a2', 'a3'), 'b' => array('b1'))) ---EXPECT-- -* a (2): - * a1 (3) - * a2 (3) - * a3 (3) -* b (2): - * b1 (1) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/values.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/values.test deleted file mode 100644 index 82f2ae8a4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/values.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"for" tag iterates over item values ---TEMPLATE-- -{% for item in items %} - * {{ item }} -{% endfor %} ---DATA-- -return array('items' => array('a', 'b')) ---EXPECT-- - * a - * b diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/from.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/from.test deleted file mode 100644 index 5f5da0ec1..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/from.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -global variables ---TEMPLATE-- -{% include "included.twig" %} -{% from "included.twig" import foobar %} -{{ foobar() }} ---TEMPLATE(included.twig)-- -{% macro foobar() %} -called foobar -{% endmacro %} ---DATA-- -return array(); ---EXPECT-- -called foobar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/basic.test deleted file mode 100644 index c1c3d2768..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/basic.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"if" creates a condition ---TEMPLATE-- -{% if a is defined %} - {{ a }} -{% elseif b is defined %} - {{ b }} -{% else %} - NOTHING -{% endif %} ---DATA-- -return array('a' => 'a') ---EXPECT-- - a ---DATA-- -return array('b' => 'b') ---EXPECT-- - b ---DATA-- -return array() ---EXPECT-- - NOTHING diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/expression.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/expression.test deleted file mode 100644 index edfb73df4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/if/expression.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"if" takes an expression as a test ---TEMPLATE-- -{% if a < 2 %} - A1 -{% elseif a > 10 %} - A2 -{% else %} - A3 -{% endif %} ---DATA-- -return array('a' => 1) ---EXPECT-- - A1 ---DATA-- -return array('a' => 12) ---EXPECT-- - A2 ---DATA-- -return array('a' => 7) ---EXPECT-- - A3 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/basic.test deleted file mode 100644 index 8fe1a6c13..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/basic.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" tag ---TEMPLATE-- -FOO -{% include "foo.twig" %} - -BAR ---TEMPLATE(foo.twig)-- -FOOBAR ---DATA-- -return array() ---EXPECT-- -FOO - -FOOBAR -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/expression.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/expression.test deleted file mode 100644 index eaeeb112e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/expression.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" tag allows expressions for the template to include ---TEMPLATE-- -FOO -{% include foo %} - -BAR ---TEMPLATE(foo.twig)-- -FOOBAR ---DATA-- -return array('foo' => 'foo.twig') ---EXPECT-- -FOO - -FOOBAR -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/ignore_missing.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/ignore_missing.test deleted file mode 100644 index 24aed06de..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/ignore_missing.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"include" tag ---TEMPLATE-- -{% include ["foo.twig", "bar.twig"] ignore missing %} -{% include "foo.twig" ignore missing %} -{% include "foo.twig" ignore missing with {} %} -{% include "foo.twig" ignore missing with {} only %} ---DATA-- -return array() ---EXPECT-- diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test deleted file mode 100644 index f25e87155..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing.test +++ /dev/null @@ -1,8 +0,0 @@ ---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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test deleted file mode 100644 index 86c186444..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/missing_nested.test +++ /dev/null @@ -1,16 +0,0 @@ ---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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/only.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/only.test deleted file mode 100644 index 77760a09e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/only.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"include" tag accept variables and only ---TEMPLATE-- -{% include "foo.twig" %} -{% include "foo.twig" only %} -{% include "foo.twig" with {'foo1': 'bar'} %} -{% include "foo.twig" with {'foo1': 'bar'} only %} ---TEMPLATE(foo.twig)-- -{% for k, v in _context %}{{ k }},{% endfor %} ---DATA-- -return array('foo' => 'bar') ---EXPECT-- -foo,global,_parent, -global,_parent, -foo,global,foo1,_parent, -foo1,global,_parent, diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/template_instance.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/template_instance.test deleted file mode 100644 index 6ba064a38..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/template_instance.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"include" tag accepts Twig_Template instance ---TEMPLATE-- -{% include foo %} FOO ---TEMPLATE(foo.twig)-- -BAR ---DATA-- -return array('foo' => $twig->loadTemplate('foo.twig')) ---EXPECT-- -BAR FOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/templates_as_array.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/templates_as_array.test deleted file mode 100644 index ab670ee06..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/templates_as_array.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"include" tag ---TEMPLATE-- -{% include ["foo.twig", "bar.twig"] %} -{% include ["bar.twig", "foo.twig"] %} ---TEMPLATE(foo.twig)-- -foo ---DATA-- -return array() ---EXPECT-- -foo -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/with_variables.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/with_variables.test deleted file mode 100644 index 41384ac7c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/include/with_variables.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"include" tag accept variables ---TEMPLATE-- -{% include "foo.twig" with {'foo': 'bar'} %} -{% include "foo.twig" with vars %} ---TEMPLATE(foo.twig)-- -{{ foo }} ---DATA-- -return array('vars' => array('foo' => 'bar')) ---EXPECT-- -bar -bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/basic.test deleted file mode 100644 index 0778a4b49..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/basic.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "foo.twig" %} - -{% block content %} -FOO -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}{% endblock %} ---DATA-- -return array() ---EXPECT-- -FOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr.test deleted file mode 100644 index 9a81499ab..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr.test +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -block_expr ---TEMPLATE-- -{% extends "base.twig" %} - -{% block element -%} - Element: - {{- parent() -}} -{% endblock %} ---TEMPLATE(base.twig)-- -{% spaceless %} -{% block element -%} -
    - {%- if item.children is defined %} - {%- for item in item.children %} - {{- block('element') -}} - {% endfor %} - {%- endif -%} -
    -{%- endblock %} -{% endspaceless %} ---DATA-- -return array( - 'item' => array( - 'children' => array( - null, - null, - ) - ) -) ---EXPECT-- -Element:
    Element:
    Element:
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr2.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr2.test deleted file mode 100644 index 3e868c0da..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr2.test +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -block_expr2 ---TEMPLATE-- -{% extends "base2.twig" %} - -{% block element -%} - Element: - {{- parent() -}} -{% endblock %} ---TEMPLATE(base2.twig)-- -{% extends "base.twig" %} ---TEMPLATE(base.twig)-- -{% spaceless %} -{% block element -%} -
    - {%- if item.children is defined %} - {%- for item in item.children %} - {{- block('element') -}} - {% endfor %} - {%- endif -%} -
    -{%- endblock %} -{% endspaceless %} ---DATA-- -return array( - 'item' => array( - 'children' => array( - null, - null, - ) - ) -) ---EXPECT-- -Element:
    Element:
    Element:
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/conditional.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/conditional.test deleted file mode 100644 index 8576e773a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/conditional.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends standalone ? foo : 'bar.twig' %} - -{% block content %}{{ parent() }}FOO{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}FOO{% endblock %} ---TEMPLATE(bar.twig)-- -{% block content %}BAR{% endblock %} ---DATA-- -return array('foo' => 'foo.twig', 'standalone' => true) ---EXPECT-- -FOOFOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test deleted file mode 100644 index ee06ddce3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/dynamic.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends foo %} - -{% block content %} -FOO -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}{% endblock %} ---DATA-- -return array('foo' => 'foo.twig') ---EXPECT-- -FOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/empty.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/empty.test deleted file mode 100644 index 784f35718..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/empty.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "foo.twig" %} ---TEMPLATE(foo.twig)-- -{% block content %}FOO{% endblock %} ---DATA-- -return array() ---EXPECT-- -FOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array.test deleted file mode 100644 index a1cb1ce8a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends ["foo.twig", "bar.twig"] %} ---TEMPLATE(bar.twig)-- -{% block content %} -foo -{% endblock %} ---DATA-- -return array() ---EXPECT-- -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test deleted file mode 100644 index acc74f6a1..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends ["", "bar.twig"] %} ---TEMPLATE(bar.twig)-- -{% block content %} -foo -{% endblock %} ---DATA-- -return array() ---EXPECT-- -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test deleted file mode 100644 index cfa648d41..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends [null, "bar.twig"] %} ---TEMPLATE(bar.twig)-- -{% block content %} -foo -{% endblock %} ---DATA-- -return array() ---EXPECT-- -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple.test deleted file mode 100644 index dfc2b6c49..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "layout.twig" %}{% block content %}{{ parent() }}index {% endblock %} ---TEMPLATE(layout.twig)-- -{% extends "base.twig" %}{% block content %}{{ parent() }}layout {% endblock %} ---TEMPLATE(base.twig)-- -{% block content %}base {% endblock %} ---DATA-- -return array() ---EXPECT-- -base layout index diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple_dynamic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple_dynamic.test deleted file mode 100644 index 1d3e639ca..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple_dynamic.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% set foo = 1 %} -{{ include('parent.twig') }} -{{ include('parent.twig') }} -{% set foo = 2 %} -{{ include('parent.twig') }} ---TEMPLATE(parent.twig)-- -{% extends foo~'_parent.twig' %}{% block content %}{{ parent() }} parent{% endblock %} ---TEMPLATE(1_parent.twig)-- -{% block content %}1{% endblock %} ---TEMPLATE(2_parent.twig)-- -{% block content %}2{% endblock %} ---DATA-- -return array() ---EXPECT-- -1 parent - -1 parent - -2 parent diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks.test deleted file mode 100644 index faca92591..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"block" tag ---TEMPLATE-- -{% extends "foo.twig" %} - -{% block content %} - {% block subcontent %} - {% block subsubcontent %} - SUBSUBCONTENT - {% endblock %} - {% endblock %} -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %} - {% block subcontent %} - SUBCONTENT - {% endblock %} -{% endblock %} ---DATA-- -return array() ---EXPECT-- -SUBSUBCONTENT diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks_parent_only.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks_parent_only.test deleted file mode 100644 index 0ad11d0c0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_blocks_parent_only.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -"block" tag ---TEMPLATE-- -{% block content %} - CONTENT - {%- block subcontent -%} - SUBCONTENT - {%- endblock -%} - ENDCONTENT -{% endblock %} ---TEMPLATE(foo.twig)-- ---DATA-- -return array() ---EXPECT-- -CONTENTSUBCONTENTENDCONTENT diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test deleted file mode 100644 index 71e3cdfd4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/nested_inheritance.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "layout.twig" %} -{% block inside %}INSIDE{% endblock inside %} ---TEMPLATE(layout.twig)-- -{% extends "base.twig" %} -{% block body %} - {% block inside '' %} -{% endblock body %} ---TEMPLATE(base.twig)-- -{% block body '' %} ---DATA-- -return array() ---EXPECT-- -INSIDE diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent.test deleted file mode 100644 index 4f975db80..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "foo.twig" %} - -{% block content %}{{ parent() }}FOO{{ parent() }}{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}BAR{% endblock %} ---DATA-- -return array() ---EXPECT-- -BARFOOBAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_change.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_change.test deleted file mode 100644 index a8bc90cef..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_change.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends foo ? 'foo.twig' : 'bar.twig' %} ---TEMPLATE(foo.twig)-- -FOO ---TEMPLATE(bar.twig)-- -BAR ---DATA-- -return array('foo' => true) ---EXPECT-- -FOO ---DATA-- -return array('foo' => false) ---EXPECT-- -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_in_a_block.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_in_a_block.test deleted file mode 100644 index cca6dbc9b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_in_a_block.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% block content %} - {% extends "foo.twig" %} -{% endblock %} ---EXCEPTION-- -Twig_Error_Syntax: Cannot extend from a block in "index.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_isolation.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_isolation.test deleted file mode 100644 index 628167135..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_isolation.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "base.twig" %} -{% block content %}{% include "included.twig" %}{% endblock %} - -{% block footer %}Footer{% endblock %} ---TEMPLATE(included.twig)-- -{% extends "base.twig" %} -{% block content %}Included Content{% endblock %} ---TEMPLATE(base.twig)-- -{% block content %}Default Content{% endblock %} - -{% block footer %}Default Footer{% endblock %} ---DATA-- -return array() ---EXPECT-- -Included Content -Default Footer -Footer diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test deleted file mode 100644 index 71e7c2080..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_nested.test +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -"extends" tag ---TEMPLATE-- -{% extends "foo.twig" %} - -{% block content %} - {% block inside %} - INSIDE OVERRIDDEN - {% endblock %} - - BEFORE - {{ parent() }} - AFTER -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %} - BAR -{% endblock %} ---DATA-- -return array() ---EXPECT-- - -INSIDE OVERRIDDEN - - BEFORE - BAR - - AFTER diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends.test deleted file mode 100644 index e29b1ac4b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"parent" tag ---TEMPLATE-- -{% block content %} - {{ parent() }} -{% endblock %} ---EXCEPTION-- -Twig_Error_Syntax: Calling "parent" on a template that does not extend nor "use" another template is forbidden in "index.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends_but_traits.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends_but_traits.test deleted file mode 100644 index 63c730550..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends_but_traits.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"parent" tag ---TEMPLATE-- -{% use 'foo.twig' %} - -{% block content %} - {{ parent() }} -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}BAR{% endblock %} ---DATA-- -return array() ---EXPECT-- -BAR diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test deleted file mode 100644 index d1876a52d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/template_instance.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"extends" tag accepts Twig_Template instance ---TEMPLATE-- -{% extends foo %} - -{% block content %} -{{ parent() }}FOO -{% endblock %} ---TEMPLATE(foo.twig)-- -{% block content %}BAR{% endblock %} ---DATA-- -return array('foo' => $twig->loadTemplate('foo.twig')) ---EXPECT-- -BARFOO diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/use.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/use.test deleted file mode 100644 index 8f9ece7ce..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/use.test +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -"parent" function ---TEMPLATE-- -{% extends "parent.twig" %} - -{% use "use1.twig" %} -{% use "use2.twig" %} - -{% block content_parent %} - {{ parent() }} -{% endblock %} - -{% block content_use1 %} - {{ parent() }} -{% endblock %} - -{% block content_use2 %} - {{ parent() }} -{% endblock %} - -{% block content %} - {{ block('content_use1_only') }} - {{ block('content_use2_only') }} -{% endblock %} ---TEMPLATE(parent.twig)-- -{% block content_parent 'content_parent' %} -{% block content_use1 'content_parent' %} -{% block content_use2 'content_parent' %} -{% block content '' %} ---TEMPLATE(use1.twig)-- -{% block content_use1 'content_use1' %} -{% block content_use2 'content_use1' %} -{% block content_use1_only 'content_use1_only' %} ---TEMPLATE(use2.twig)-- -{% block content_use2 'content_use2' %} -{% block content_use2_only 'content_use2_only' %} ---DATA-- -return array() ---EXPECT-- - content_parent - content_use1 - content_use2 - content_use1_only - content_use2_only diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test deleted file mode 100644 index eef0c10d5..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/basic.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{% import _self as macros %} - -{{ macros.input('username') }} -{{ macros.input('password', null, 'password', 1) }} - -{% macro input(name, value, type, size) %} - -{% endmacro %} ---DATA-- -return array() ---EXPECT-- - - - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test deleted file mode 100644 index ae6203bb6..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -"macro" tag supports name for endmacro ---TEMPLATE-- -{% import _self as macros %} - -{{ macros.foo() }} -{{ macros.bar() }} - -{% macro foo() %}foo{% endmacro %} -{% macro bar() %}bar{% endmacro bar %} ---DATA-- -return array() ---EXPECT-- -foo -bar - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/external.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/external.test deleted file mode 100644 index 5cd3dae66..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/external.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{% import 'forms.twig' as forms %} - -{{ forms.input('username') }} -{{ forms.input('password', null, 'password', 1) }} ---TEMPLATE(forms.twig)-- -{% macro input(name, value, type, size) %} - -{% endmacro %} ---DATA-- -return array() ---EXPECT-- - - - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from.test deleted file mode 100644 index 205f59182..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{% from 'forms.twig' import foo %} -{% from 'forms.twig' import foo as foobar, bar %} - -{{ foo('foo') }} -{{ foobar('foo') }} -{{ bar('foo') }} ---TEMPLATE(forms.twig)-- -{% macro foo(name) %}foo{{ name }}{% endmacro %} -{% macro bar(name) %}bar{{ name }}{% endmacro %} ---DATA-- -return array() ---EXPECT-- -foofoo -foofoo -barfoo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test deleted file mode 100644 index 2de9765ff..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test +++ /dev/null @@ -1,9 +0,0 @@ ---TEST-- -"from" tag with reserved name ---TEMPLATE-- -{% from 'forms.twig' import templateName %} ---TEMPLATE(forms.twig)-- ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: "templateName" cannot be an imported macro as it is a reserved keyword in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/global.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/global.test deleted file mode 100644 index 6b371768e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/global.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{% from 'forms.twig' import foo %} - -{{ foo('foo') }} -{{ foo() }} ---TEMPLATE(forms.twig)-- -{% macro foo(name) %}{{ name|default('foo') }}{{ global }}{% endmacro %} ---DATA-- -return array() ---EXPECT-- -fooglobal -fooglobal diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test deleted file mode 100644 index 7bd93c62d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -"from" tag with reserved name ---TEMPLATE-- -{% import 'forms.twig' as macros %} - -{{ macros.parent() }} ---TEMPLATE(forms.twig)-- ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: "parent" cannot be called as macro as it is a reserved keyword in "index.twig" at line 4. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test deleted file mode 100644 index f7c102f02..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"macro" tag with reserved name ---TEMPLATE-- -{% macro parent(arg1, arg2) %} - parent -{% endmacro %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: "parent" cannot be used as a macro name as it is a reserved keyword in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/self_import.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/self_import.test deleted file mode 100644 index 17756cb6c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/self_import.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"macro" tag ---TEMPLATE-- -{% import _self as forms %} - -{{ forms.input('username') }} -{{ forms.input('password', null, 'password', 1) }} - -{% macro input(name, value, type, size) %} - -{% endmacro %} ---DATA-- -return array() ---EXPECT-- - - - diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test deleted file mode 100644 index 372177073..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"§" as a macro name ---TEMPLATE-- -{% import _self as macros %} - -{{ macros.§('foo') }} - -{% macro §(foo) %} - §{{ foo }}§ -{% endmacro %} ---DATA-- -return array() ---EXPECT-- -§foo§ diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/super_globals.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/super_globals.test deleted file mode 100644 index 567946281..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/super_globals.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Super globals as macro arguments ---TEMPLATE-- -{% import _self as macros %} - -{{ macros.foo('foo') }} - -{% macro foo(GET) %} - {{ GET }} -{% endmacro %} ---DATA-- -return array() ---EXPECT-- -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.legacy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.legacy.test deleted file mode 100644 index 0445e8530..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.legacy.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"raw" tag ---TEMPLATE-- -{% raw %} -{{ foo }} -{% endraw %} ---DATA-- -return array() ---EXPECT-- -{{ foo }} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test deleted file mode 100644 index 99deefc32..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"raw" tag ---TEMPLATE-- -{% raw %} -{{ foo }} -{% endverbatim %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: Unexpected end of file: Unclosed "raw" block in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.legacy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.legacy.test deleted file mode 100644 index 352bb1876..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.legacy.test +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -"raw" tag ---TEMPLATE-- -1*** - -{%- raw %} - {{ 'bla' }} -{% endraw %} - -1*** -2*** - -{%- raw -%} - {{ 'bla' }} -{% endraw %} - -2*** -3*** - -{%- raw -%} - {{ 'bla' }} -{% endraw -%} - -3*** -4*** - -{%- raw -%} - {{ 'bla' }} -{%- endraw %} - -4*** -5*** - -{%- raw -%} - {{ 'bla' }} -{%- endraw -%} - -5*** ---DATA-- -return array() ---EXPECT-- -1*** - {{ 'bla' }} - - -1*** -2***{{ 'bla' }} - - -2*** -3***{{ 'bla' }} -3*** -4***{{ 'bla' }} - -4*** -5***{{ 'bla' }}5*** diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid1.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid1.test deleted file mode 100644 index dfddc1513..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid1.test +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -sandbox tag ---TEMPLATE-- -{%- sandbox %} - {%- include "foo.twig" %} - a -{%- endsandbox %} ---TEMPLATE(foo.twig)-- -foo ---EXCEPTION-- -Twig_Error_Syntax: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 4. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid2.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid2.test deleted file mode 100644 index a33a13ee6..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid2.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -sandbox tag ---TEMPLATE-- -{%- sandbox %} - {%- include "foo.twig" %} - - {% if 1 %} - {%- include "foo.twig" %} - {% endif %} -{%- endsandbox %} ---TEMPLATE(foo.twig)-- -foo ---EXCEPTION-- -Twig_Error_Syntax: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 5. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/simple.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/simple.test deleted file mode 100644 index de20f3dba..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/simple.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -sandbox tag ---TEMPLATE-- -{%- sandbox %} - {%- include "foo.twig" %} -{%- endsandbox %} - -{%- sandbox %} - {%- include "foo.twig" %} - {%- include "foo.twig" %} -{%- endsandbox %} - -{%- sandbox %}{% include "foo.twig" %}{% endsandbox %} ---TEMPLATE(foo.twig)-- -foo ---DATA-- -return array() ---EXPECT-- -foo -foo -foo -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/basic.test deleted file mode 100644 index a5a9f830e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/basic.test +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -"set" tag ---TEMPLATE-- -{% set foo = 'foo' %} -{% set bar = 'foo
    ' %} - -{{ foo }} -{{ bar }} - -{% set foo, bar = 'foo', 'bar' %} - -{{ foo }}{{ bar }} ---DATA-- -return array() ---EXPECT-- -foo -foo<br /> - - -foobar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture-empty.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture-empty.test deleted file mode 100644 index ec657f005..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture-empty.test +++ /dev/null @@ -1,9 +0,0 @@ ---TEST-- -"set" tag block empty capture ---TEMPLATE-- -{% set foo %}{% endset %} - -{% if foo %}FAIL{% endif %} ---DATA-- -return array() ---EXPECT-- diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture.test deleted file mode 100644 index f156a1a7f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/capture.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"set" tag block capture ---TEMPLATE-- -{% set foo %}f
    o
    o{% endset %} - -{{ foo }} ---DATA-- -return array() ---EXPECT-- -f
    o
    o diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/expression.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/expression.test deleted file mode 100644 index 8ff434a01..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/set/expression.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"set" tag ---TEMPLATE-- -{% set foo, bar = 'foo' ~ 'bar', 'bar' ~ 'foo' %} - -{{ foo }} -{{ bar }} ---DATA-- -return array() ---EXPECT-- -foobar -barfoo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/spaceless/simple.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/spaceless/simple.test deleted file mode 100644 index dd06dec25..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/spaceless/simple.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"spaceless" tag removes whites between HTML tags ---TEMPLATE-- -{% spaceless %} - -
    foo
    - -{% endspaceless %} ---DATA-- -return array() ---EXPECT-- -
    foo
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/special_chars.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/special_chars.test deleted file mode 100644 index 789b4ba80..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/special_chars.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -"§" custom tag ---TEMPLATE-- -{% § %} ---DATA-- -return array() ---EXPECT-- -§ diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/trim_block.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/trim_block.test deleted file mode 100644 index 1d2273f88..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/trim_block.test +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -Whitespace trimming on tags. ---TEMPLATE-- -{{ 5 * '{#-'|length }} -{{ '{{-'|length * 5 + '{%-'|length }} - -Trim on control tag: -{% for i in range(1, 9) -%} - {{ i }} -{%- endfor %} - - -Trim on output tag: -{% for i in range(1, 9) %} - {{- i -}} -{% endfor %} - - -Trim comments: - -{#- Invisible -#} - -After the comment. - -Trim leading space: -{% if leading %} - - {{- leading }} -{% endif %} - -{%- if leading %} - {{- leading }} - -{%- endif %} - - -Trim trailing space: -{% if trailing -%} - {{ trailing -}} - -{% endif -%} - -Combined: - -{%- if both -%} -
      -
    • {{- both -}}
    • -
    - -{%- endif -%} - -end ---DATA-- -return array('leading' => 'leading space', 'trailing' => 'trailing space', 'both' => 'both') ---EXPECT-- -15 -18 - -Trim on control tag: -123456789 - -Trim on output tag: -123456789 - -Trim comments:After the comment. - -Trim leading space: -leading space -leading space - -Trim trailing space: -trailing spaceCombined:
      -
    • both
    • -
    end diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/aliases.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/aliases.test deleted file mode 100644 index f887006f6..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/aliases.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "blocks.twig" with content as foo %} - -{{ block('foo') }} ---TEMPLATE(blocks.twig)-- -{% block content 'foo' %} ---DATA-- -return array() ---EXPECT-- -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/basic.test deleted file mode 100644 index 7364d76de..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/basic.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "blocks.twig" %} - -{{ block('content') }} ---TEMPLATE(blocks.twig)-- -{% block content 'foo' %} ---DATA-- -return array() ---EXPECT-- -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep.test deleted file mode 100644 index b551a1e60..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep.test +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "foo.twig" %} - -{{ block('content') }} -{{ block('foo') }} -{{ block('bar') }} ---TEMPLATE(foo.twig)-- -{% use "bar.twig" %} - -{% block content 'foo' %} -{% block foo 'foo' %} ---TEMPLATE(bar.twig)-- -{% block content 'bar' %} -{% block bar 'bar' %} ---DATA-- -return array() ---EXPECT-- -foo -foo -bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep_empty.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep_empty.test deleted file mode 100644 index 05cca682e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/deep_empty.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "foo.twig" %} ---TEMPLATE(foo.twig)-- -{% use "bar.twig" %} ---TEMPLATE(bar.twig)-- ---DATA-- -return array() ---EXPECT-- diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test deleted file mode 100644 index 0d0d470ee..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "parent.twig" %} - -{{ block('container') }} ---TEMPLATE(parent.twig)-- -{% use "ancestor.twig" %} - -{% block sub_container %} -
    overridden sub_container
    -{% endblock %} ---TEMPLATE(ancestor.twig)-- -{% block container %} -
    {{ block('sub_container') }}
    -{% endblock %} - -{% block sub_container %} -
    sub_container
    -{% endblock %} ---DATA-- -return array() ---EXPECT-- -
    overridden sub_container
    -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test deleted file mode 100644 index df95599ce..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "ancestor.twig" %} -{% use "parent.twig" %} - -{{ block('container') }} ---TEMPLATE(parent.twig)-- -{% block sub_container %} -
    overridden sub_container
    -{% endblock %} ---TEMPLATE(ancestor.twig)-- -{% block container %} -
    {{ block('sub_container') }}
    -{% endblock %} - -{% block sub_container %} -
    sub_container
    -{% endblock %} ---DATA-- -return array() ---EXPECT-- -
    overridden sub_container
    -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple.test deleted file mode 100644 index 198be0c5c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple.test +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "foo.twig" %} -{% use "bar.twig" %} - -{{ block('content') }} -{{ block('foo') }} -{{ block('bar') }} ---TEMPLATE(foo.twig)-- -{% block content 'foo' %} -{% block foo 'foo' %} ---TEMPLATE(bar.twig)-- -{% block content 'bar' %} -{% block bar 'bar' %} ---DATA-- -return array() ---EXPECT-- -bar -foo -bar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple_aliases.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple_aliases.test deleted file mode 100644 index 8de871a8a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/multiple_aliases.test +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use "foo.twig" with content as foo_content %} -{% use "bar.twig" %} - -{{ block('content') }} -{{ block('foo') }} -{{ block('bar') }} -{{ block('foo_content') }} ---TEMPLATE(foo.twig)-- -{% block content 'foo' %} -{% block foo 'foo' %} ---TEMPLATE(bar.twig)-- -{% block content 'bar' %} -{% block bar 'bar' %} ---DATA-- -return array() ---EXPECT-- -bar -foo -bar -foo diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block.test deleted file mode 100644 index 59db23d95..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block.test +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use 'file2.html.twig' with foobar as base_base_foobar %} -{% block foobar %} - {{- block('base_base_foobar') -}} - Content of block (second override) -{% endblock foobar %} ---TEMPLATE(file2.html.twig)-- -{% use 'file1.html.twig' with foobar as base_foobar %} -{% block foobar %} - {{- block('base_foobar') -}} - Content of block (first override) -{% endblock foobar %} ---TEMPLATE(file1.html.twig)-- -{% block foobar -%} - Content of block -{% endblock foobar %} ---DATA-- -return array() ---EXPECT-- -Content of block -Content of block (first override) -Content of block (second override) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block2.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block2.test deleted file mode 100644 index d3f302df0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block2.test +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use 'file2.html.twig'%} -{% block foobar %} - {{- parent() -}} - Content of block (second override) -{% endblock foobar %} ---TEMPLATE(file2.html.twig)-- -{% use 'file1.html.twig' %} -{% block foobar %} - {{- parent() -}} - Content of block (first override) -{% endblock foobar %} ---TEMPLATE(file1.html.twig)-- -{% block foobar -%} - Content of block -{% endblock foobar %} ---DATA-- -return array() ---EXPECT-- -Content of block -Content of block (first override) -Content of block (second override) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block3.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block3.test deleted file mode 100644 index 95b55a469..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block3.test +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -"use" tag ---TEMPLATE-- -{% use 'file2.html.twig' %} -{% use 'file1.html.twig' with foo %} -{% block foo %} - {{- parent() -}} - Content of foo (second override) -{% endblock foo %} -{% block bar %} - {{- parent() -}} - Content of bar (second override) -{% endblock bar %} ---TEMPLATE(file2.html.twig)-- -{% use 'file1.html.twig' %} -{% block foo %} - {{- parent() -}} - Content of foo (first override) -{% endblock foo %} -{% block bar %} - {{- parent() -}} - Content of bar (first override) -{% endblock bar %} ---TEMPLATE(file1.html.twig)-- -{% block foo -%} - Content of foo -{% endblock foo %} -{% block bar -%} - Content of bar -{% endblock bar %} ---DATA-- -return array() ---EXPECT-- -Content of foo -Content of foo (first override) -Content of foo (second override) -Content of bar -Content of bar (second override) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/use_with_parent.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/use_with_parent.test deleted file mode 100644 index 3fe2ad83c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/use_with_parent.test +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -"use" tag with a parent block ---TEMPLATE-- -{% extends "parent.twig" %} - -{% use 'blocks.twig' %} - -{% block body %} - {{ parent() -}} - CHILD - {{ block('content') }} -{% endblock %} ---TEMPLATE(parent.twig)-- -{% block body %} - PARENT -{% endblock %} ---TEMPLATE(blocks.twig)-- -{% block content 'BLOCK' %} ---DATA-- -return array() ---EXPECT-- -PARENT -CHILD - BLOCK diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/basic.test deleted file mode 100644 index a95be5572..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/basic.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"verbatim" tag ---TEMPLATE-- -{% verbatim %} -{{ foo }} -{% endverbatim %} ---DATA-- -return array() ---EXPECT-- -{{ foo }} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test deleted file mode 100644 index 28626a816..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"verbatim" tag ---TEMPLATE-- -{% verbatim %} -{{ foo }} -{% endraw %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: Unexpected end of file: Unclosed "verbatim" block in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/whitespace_control.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/whitespace_control.test deleted file mode 100644 index eb6104446..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/whitespace_control.test +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -"verbatim" tag ---TEMPLATE-- -1*** - -{%- verbatim %} - {{ 'bla' }} -{% endverbatim %} - -1*** -2*** - -{%- verbatim -%} - {{ 'bla' }} -{% endverbatim %} - -2*** -3*** - -{%- verbatim -%} - {{ 'bla' }} -{% endverbatim -%} - -3*** -4*** - -{%- verbatim -%} - {{ 'bla' }} -{%- endverbatim %} - -4*** -5*** - -{%- verbatim -%} - {{ 'bla' }} -{%- endverbatim -%} - -5*** ---DATA-- -return array() ---EXPECT-- -1*** - {{ 'bla' }} - - -1*** -2***{{ 'bla' }} - - -2*** -3***{{ 'bla' }} -3*** -4***{{ 'bla' }} - -4*** -5***{{ 'bla' }}5*** diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/basic.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/basic.test deleted file mode 100644 index 264ca5e7e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/basic.test +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -"with" tag ---TEMPLATE-- -{% with %} - {% set bar = 'BAZ' %} - {{ foo }}{{ bar }} -{% endwith %} -{{ foo }}{{ bar }} ---DATA-- -return array('foo' => 'foo', 'bar' => 'bar') ---EXPECT-- -fooBAZ -foobar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/expression.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/expression.test deleted file mode 100644 index 32ed0916c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/expression.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"with" tag with expression ---TEMPLATE-- -{% with {foo: 'foo', bar: 'BAZ'} %} - {{ foo }}{{ bar }} -{% endwith %} ---DATA-- -return array('foo' => 'baz') ---EXPECT-- -fooBAZ diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/nested.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/nested.test deleted file mode 100644 index 98e3aef43..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/nested.test +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -nested "with" tags ---TEMPLATE-- -{% set foo, bar = 'foo', 'bar' %} -{% with {bar: 'BAZ'} %} - {% with {foo: 'FOO'} %} - {{ foo }}{{ bar }} - {% endwith %} -{% endwith %} -{{ foo }}{{ bar }} ---DATA-- -return array() ---EXPECT-- -FOOBAZ - foobar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_no_hash.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_no_hash.test deleted file mode 100644 index 93689f42c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_no_hash.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"with" tag with an expression that is not a hash ---TEMPLATE-- -{% with vars %} - {{ foo }}{{ bar }} -{% endwith %} ---DATA-- -return array('vars' => 'no-hash') ---EXCEPTION-- -Twig_Error_Runtime: Variables passed to the "with" tag must be a hash in "index.twig" at line 2. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_only.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_only.test deleted file mode 100644 index 6247617e3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/with/with_only.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"with" tag with expression and only ---TEMPLATE-- -{% with {foo: 'foo', bar: 'BAZ'} only %} - {{ foo }}{{ bar }}{{ baz }} -{% endwith %} ---DATA-- -return array('foo' => 'baz', 'baz' => 'baz') ---EXCEPTION-- -Twig_Error_Runtime: Variable "baz" does not exist in "index.twig" at line 3. diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/array.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/array.test deleted file mode 100644 index 1429d3753..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/array.test +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -array index test ---TEMPLATE-- -{% for key, value in days %} -{{ key }} -{% endfor %} ---DATA-- -return array('days' => array( - 1 => array('money' => 9), - 2 => array('money' => 21), - 3 => array('money' => 38), - 4 => array('money' => 6), - 18 => array('money' => 6), - 19 => array('money' => 3), - 31 => array('money' => 11), -)); ---EXPECT-- -1 -2 -3 -4 -18 -19 -31 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test deleted file mode 100644 index 60218ac04..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/constant.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"const" test ---TEMPLATE-- -{{ 8 is constant('E_NOTICE') ? 'ok' : 'no' }} -{{ 'bar' is constant('TwigTestFoo::BAR_NAME') ? 'ok' : 'no' }} -{{ value is constant('TwigTestFoo::BAR_NAME') ? 'ok' : 'no' }} -{{ 2 is constant('ARRAY_AS_PROPS', object) ? 'ok' : 'no' }} ---DATA-- -return array('value' => 'bar', 'object' => new ArrayObject(array('hi'))); ---EXPECT-- -ok -ok -ok -ok \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test deleted file mode 100644 index d4e204efa..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined.test +++ /dev/null @@ -1,129 +0,0 @@ ---TEST-- -"defined" test ---TEMPLATE-- -{{ definedVar is defined ? 'ok' : 'ko' }} -{{ definedVar is not defined ? 'ko' : 'ok' }} -{{ undefinedVar is defined ? 'ko' : 'ok' }} -{{ undefinedVar is not defined ? 'ok' : 'ko' }} -{{ zeroVar is defined ? 'ok' : 'ko' }} -{{ nullVar is defined ? 'ok' : 'ko' }} -{{ nested.definedVar is defined ? 'ok' : 'ko' }} -{{ nested['definedVar'] is defined ? 'ok' : 'ko' }} -{{ nested.definedVar is not defined ? 'ko' : 'ok' }} -{{ nested.undefinedVar is defined ? 'ko' : 'ok' }} -{{ nested['undefinedVar'] is defined ? 'ko' : 'ok' }} -{{ nested.undefinedVar is not defined ? 'ok' : 'ko' }} -{{ nested.zeroVar is defined ? 'ok' : 'ko' }} -{{ nested.nullVar is defined ? 'ok' : 'ko' }} -{{ nested.definedArray.0 is defined ? 'ok' : 'ko' }} -{{ nested['definedArray'][0] is defined ? 'ok' : 'ko' }} -{{ object.foo is defined ? 'ok' : 'ko' }} -{{ object.undefinedMethod is defined ? 'ko' : 'ok' }} -{{ object.getFoo() is defined ? 'ok' : 'ko' }} -{{ object.getFoo('a') is defined ? 'ok' : 'ko' }} -{{ object.undefinedMethod() is defined ? 'ko' : 'ok' }} -{{ object.undefinedMethod('a') is defined ? 'ko' : 'ok' }} -{{ object.self.foo is defined ? 'ok' : 'ko' }} -{{ object.self.undefinedMethod is defined ? 'ko' : 'ok' }} -{{ object.undefinedMethod.self is defined ? 'ko' : 'ok' }} -{{ 0 is defined ? 'ok' : 'ko' }} -{{ "foo" is defined ? 'ok' : 'ko' }} -{{ true is defined ? 'ok' : 'ko' }} -{{ false is defined ? 'ok' : 'ko' }} -{{ null is defined ? 'ok' : 'ko' }} -{{ [1, 2] is defined ? 'ok' : 'ko' }} -{{ { foo: "bar" } is defined ? 'ok' : 'ko' }} ---DATA-- -return array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'nullVar' => null, - 'nested' => array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'nullVar' => null, - 'definedArray' => array(0), - ), - 'object' => new TwigTestFoo(), -); ---EXPECT-- -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok ---DATA-- -return array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'nullVar' => null, - 'nested' => array( - 'definedVar' => 'defined', - 'zeroVar' => 0, - 'nullVar' => null, - 'definedArray' => array(0), - ), - 'object' => new TwigTestFoo(), -); ---CONFIG-- -return array('strict_variables' => false) ---EXPECT-- -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_attribute.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_attribute.test deleted file mode 100644 index 4a5b8dcdb..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_attribute.test +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -"defined" support for attribute ---TEMPLATE-- -{{ attribute(nested, "definedVar") is defined ? 'ok' : 'ko' }} -{{ attribute(nested, "undefinedVar") is not defined ? 'ok' : 'ko' }} -{{ attribute(nested, definedVarName) is defined ? 'ok' : 'ko' }} -{{ attribute(nested, undefinedVarName) is not defined ? 'ok' : 'ko' }} ---DATA-- -return array( - 'nested' => array( - 'definedVar' => 'defined', - ), - 'definedVarName' => 'definedVar', - 'undefinedVarName' => 'undefinedVar', -); ---EXPECT-- -ok -ok -ok -ok ---DATA-- -return array( - 'nested' => array( - 'definedVar' => 'defined', - ), - 'definedVarName' => 'definedVar', - 'undefinedVarName' => 'undefinedVar', -); ---CONFIG-- -return array('strict_variables' => false) ---EXPECT-- -ok -ok -ok -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks.test deleted file mode 100644 index 64d7d0431..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks.test +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -"defined" support for blocks ---TEMPLATE-- -{% extends 'parent' %} -{% block icon %}icon{% endblock %} -{% block body %} - {{ parent() }} - {{ block('foo') is defined ? 'ok' : 'ko' }} - {{ block('footer') is defined ? 'ok' : 'ko' }} - {{ block('icon') is defined ? 'ok' : 'ko' }} - {{ block('block1') is defined ? 'ok' : 'ko' }} - {%- embed 'embed' %} - {% block content %}content{% endblock %} - {% endembed %} -{% endblock %} -{% use 'blocks' %} ---TEMPLATE(parent)-- -{% block body %} - {{ block('icon') is defined ? 'ok' : 'ko' -}} -{% endblock %} -{% block footer %}{% endblock %} ---TEMPLATE(embed)-- -{{ block('icon') is defined ? 'ok' : 'ko' }} -{{ block('content') is defined ? 'ok' : 'ko' }} -{{ block('block1') is defined ? 'ok' : 'ko' }} ---TEMPLATE(blocks)-- -{% block block1 %}{%endblock %} ---DATA-- -return array() ---EXPECT-- -ok - ko - ok - ok - ok -ko -ok -ko diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks_with_template.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks_with_template.test deleted file mode 100644 index 2c651657e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_blocks_with_template.test +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -"defined" support for blocks with a template argument ---TEMPLATE-- -{{ block('foo', 'included.twig') is defined ? 'ok' : 'ko' }} -{{ block('foo', included_loaded) is defined ? 'ok' : 'ko' }} -{{ block('foo', included_loaded_internal) is defined ? 'ok' : 'ko' }} ---TEMPLATE(included.twig)-- -{% block foo %}FOO{% endblock %} ---DATA-- -return array( - 'included_loaded' => $twig->load('included.twig'), - 'included_loaded_internal' => $twig->loadTemplate('included.twig'), -) ---EXPECT-- -ok -ok -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_constants.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_constants.test deleted file mode 100644 index 2fa9929d3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/defined_for_constants.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"defined" support for constants ---TEMPLATE-- -{{ constant('DATE_W3C') is defined ? 'ok' : 'ko' }} -{{ constant('ARRAY_AS_PROPS', object) is defined ? 'ok' : 'ko' }} -{{ constant('FOOBAR') is not defined ? 'ok' : 'ko' }} -{{ constant('FOOBAR', object) is not defined ? 'ok' : 'ko' }} ---DATA-- -return array('expect' => DATE_W3C, 'object' => new ArrayObject(array('hi'))); ---EXPECT-- -ok -ok -ok -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test deleted file mode 100644 index 807c0ed4a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -"empty" test ---TEMPLATE-- -{{ string_empty is empty ? 'ok' : 'ko' }} -{{ string_zero is empty ? 'ko' : 'ok' }} -{{ value_null is empty ? 'ok' : 'ko' }} -{{ value_false is empty ? 'ok' : 'ko' }} -{{ value_int_zero is empty ? 'ko' : 'ok' }} -{{ array_empty is empty ? 'ok' : 'ko' }} -{{ array_not_empty is empty ? 'ko' : 'ok' }} -{{ magically_callable is empty ? 'ko' : 'ok' }} -{{ countable_empty is empty ? 'ok' : 'ko' }} -{{ countable_not_empty is empty ? 'ko' : 'ok' }} -{{ tostring_empty is empty ? 'ok' : 'ko' }} -{{ tostring_not_empty is empty ? 'ko' : 'ok' }} -{{ markup_empty is empty ? 'ok' : 'ko' }} -{{ markup_not_empty is empty ? 'ko' : 'ok' }} ---DATA-- -return array( - 'string_empty' => '', 'string_zero' => '0', - 'value_null' => null, 'value_false' => false, 'value_int_zero' => 0, - 'array_empty' => array(), 'array_not_empty' => array(1, 2), - 'magically_callable' => new MagicCallStub(), - 'countable_empty' => new CountableStub(array()), 'countable_not_empty' => new CountableStub(array(1, 2)), - 'tostring_empty' => new ToStringStub(''), 'tostring_not_empty' => new ToStringStub('0' /* edge case of using "0" as the string */), - 'markup_empty' => new Twig_Markup('', 'UTF-8'), 'markup_not_empty' => new Twig_Markup('test', 'UTF-8'), -); ---EXPECT-- -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/even.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/even.test deleted file mode 100644 index 695b4c2f8..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/even.test +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -"even" test ---TEMPLATE-- -{{ 1 is even ? 'ko' : 'ok' }} -{{ 2 is even ? 'ok' : 'ko' }} -{{ 1 is not even ? 'ok' : 'ko' }} -{{ 2 is not even ? 'ko' : 'ok' }} ---DATA-- -return array() ---EXPECT-- -ok -ok -ok -ok diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in.test deleted file mode 100644 index 545f51f81..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in.test +++ /dev/null @@ -1,128 +0,0 @@ ---TEST-- -Twig supports the in operator ---TEMPLATE-- -{% if bar in foo %} -TRUE -{% endif %} -{% if not (bar in foo) %} -{% else %} -TRUE -{% endif %} -{% if bar not in foo %} -{% else %} -TRUE -{% endif %} -{% if 'a' in bar %} -TRUE -{% endif %} -{% if 'c' not in bar %} -TRUE -{% endif %} -{% if '' in bar %} -TRUE -{% endif %} -{% if '' in '' %} -TRUE -{% endif %} -{% if '0' not in '' %} -TRUE -{% endif %} -{% if 'a' not in '0' %} -TRUE -{% endif %} -{% if '0' in '0' %} -TRUE -{% endif %} - -{{ false in [0, 1] ? 'TRUE' : 'FALSE' }} -{{ true in [0, 1] ? 'TRUE' : 'FALSE' }} -{{ '0' in [0, 1] ? 'TRUE' : 'FALSE' }} -{{ '' in [0, 1] ? 'TRUE' : 'FALSE' }} -{{ 0 in ['', 1] ? 'TRUE' : 'FALSE' }} - -{{ '' in 'foo' ? 'TRUE' : 'FALSE' }} -{{ 0 in 'foo' ? 'TRUE' : 'FALSE' }} -{{ false in 'foo' ? 'TRUE' : 'FALSE' }} -{{ false in '100' ? 'TRUE' : 'FALSE' }} -{{ true in '100' ? 'TRUE' : 'FALSE' }} - -{{ [] in [true, false] ? 'TRUE' : 'FALSE' }} -{{ [] in [true, ''] ? 'TRUE' : 'FALSE' }} -{{ [] in [true, []] ? 'TRUE' : 'FALSE' }} - -{{ resource ? 'TRUE' : 'FALSE' }} -{{ resource in 'foo'~resource ? 'TRUE' : 'FALSE' }} -{{ object in 'stdClass' ? 'TRUE' : 'FALSE' }} -{{ [] in 'Array' ? 'TRUE' : 'FALSE' }} -{{ dir_object in 'foo'~dir_object ? 'TRUE' : 'FALSE' }} - -{{ ''~resource in resource ? 'TRUE' : 'FALSE' }} -{{ 'stdClass' in object ? 'TRUE' : 'FALSE' }} -{{ 'Array' in [] ? 'TRUE' : 'FALSE' }} -{{ ''~dir_object in dir_object ? 'TRUE' : 'FALSE' }} - -{{ resource in [''~resource] ? 'TRUE' : 'FALSE' }} -{{ resource in [resource + 1 - 1] ? 'TRUE' : 'FALSE' }} -{{ dir_object in [''~dir_object] ? 'TRUE' : 'FALSE' }} - -{{ 5 in 125 ? 'TRUE' : 'FALSE' }} -{{ 5 in '125' ? 'TRUE' : 'FALSE' }} -{{ '5' in 125 ? 'TRUE' : 'FALSE' }} -{{ '5' in '125' ? 'TRUE' : 'FALSE' }} - -{{ 5.5 in 125.5 ? 'TRUE' : 'FALSE' }} -{{ 5.5 in '125.5' ? 'TRUE' : 'FALSE' }} -{{ '5.5' in 125.5 ? 'TRUE' : 'FALSE' }} ---DATA-- -return array('bar' => 'bar', 'foo' => array('bar' => 'bar'), 'dir_object' => new SplFileInfo(dirname(__FILE__)), 'object' => new stdClass(), 'resource' => opendir(dirname(__FILE__))) ---EXPECT-- -TRUE -TRUE -TRUE -TRUE -TRUE -TRUE -TRUE -TRUE -TRUE -TRUE - -TRUE -TRUE -TRUE -TRUE -TRUE - -TRUE -FALSE -FALSE -FALSE -FALSE - -TRUE -FALSE -TRUE - -TRUE -FALSE -FALSE -FALSE -FALSE - -FALSE -FALSE -FALSE -FALSE - -FALSE -FALSE -FALSE - -FALSE -TRUE -FALSE -TRUE - -FALSE -TRUE -FALSE diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test deleted file mode 100644 index 8e08061bb..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in_with_objects.test +++ /dev/null @@ -1,19 +0,0 @@ ---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/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/iterable.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/iterable.test deleted file mode 100644 index ec5255013..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/iterable.test +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -"iterable" test ---TEMPLATE-- -{{ foo is iterable ? 'ok' : 'ko' }} -{{ traversable is iterable ? 'ok' : 'ko' }} -{{ obj is iterable ? 'ok' : 'ko' }} -{{ val is iterable ? 'ok' : 'ko' }} ---DATA-- -return array( - 'foo' => array(), - 'traversable' => new ArrayIterator(array()), - 'obj' => new stdClass(), - 'val' => 'test', -); ---EXPECT-- -ok -ok -ko -ko \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/null_coalesce.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/null_coalesce.test deleted file mode 100644 index 3d148c893..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/null_coalesce.test +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Twig supports the ?? operator ---TEMPLATE-- -{{ 'OK' ?? 'KO' }} -{{ null ?? 'OK' }} -{{ bar ?? 'KO' }} -{{ baz ?? 'OK' }} -{{ foo.bar ?? 'KO' }} -{{ foo.missing ?? 'OK' }} -{{ foo.bar.baz.missing ?? 'OK' }} -{{ foo['bar'] ?? 'KO' }} -{{ foo['missing'] ?? 'OK' }} -{{ nope ?? nada ?? 'OK' }} -{{ 1 + nope ?? nada ?? 2 }} -{{ 1 + nope ?? 3 + nada ?? 2 }} ---DATA-- -return array('bar' => 'OK', 'foo' => array('bar' => 'OK')) ---EXPECT-- -OK -OK -OK -OK -OK -OK -OK -OK -OK -OK -3 -6 diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/odd.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/odd.test deleted file mode 100644 index 1b8311e3d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/odd.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"odd" test ---TEMPLATE-- -{{ 1 is odd ? 'ok' : 'ko' }} -{{ 2 is odd ? 'ko' : 'ok' }} ---DATA-- -return array() ---EXPECT-- -ok -ok \ No newline at end of file diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php deleted file mode 100644 index 5d20112de..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php +++ /dev/null @@ -1,309 +0,0 @@ -position = 0; - } - - public function current() - { - return $this->array[$this->position]; - } - - public function key() - { - return 'a'; - } - - public function next() - { - ++$this->position; - } - - public function valid() - { - return isset($this->array[$this->position]); - } -} - -class TwigTestTokenParser_§ extends Twig_TokenParser -{ - public function parse(Twig_Token $token) - { - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_Print(new Twig_Node_Expression_Constant('§', -1), -1); - } - - public function getTag() - { - return '§'; - } -} - -class TwigTestExtension extends Twig_Extension -{ - public function getTokenParsers() - { - return array( - new TwigTestTokenParser_§(), - ); - } - - public function getFilters() - { - return array( - new Twig_SimpleFilter('§', array($this, '§Filter')), - new Twig_SimpleFilter('escape_and_nl2br', array($this, 'escape_and_nl2br'), array('needs_environment' => true, 'is_safe' => array('html'))), - new Twig_SimpleFilter('nl2br', array($this, 'nl2br'), array('pre_escape' => 'html', 'is_safe' => array('html'))), - new Twig_SimpleFilter('escape_something', array($this, 'escape_something'), array('is_safe' => array('something'))), - new Twig_SimpleFilter('preserves_safety', array($this, 'preserves_safety'), array('preserves_safety' => array('html'))), - new Twig_SimpleFilter('static_call_string', 'TwigTestExtension::staticCall'), - new Twig_SimpleFilter('static_call_array', array('TwigTestExtension', 'staticCall')), - new Twig_SimpleFilter('magic_call', array($this, 'magicCall')), - new Twig_SimpleFilter('magic_call_string', 'TwigTestExtension::magicStaticCall'), - new Twig_SimpleFilter('magic_call_array', array('TwigTestExtension', 'magicStaticCall')), - new Twig_SimpleFilter('*_path', array($this, 'dynamic_path')), - new Twig_SimpleFilter('*_foo_*_bar', array($this, 'dynamic_foo')), - ); - } - - public function getFunctions() - { - return array( - new Twig_SimpleFunction('§', array($this, '§Function')), - new Twig_SimpleFunction('safe_br', array($this, 'br'), array('is_safe' => array('html'))), - new Twig_SimpleFunction('unsafe_br', array($this, 'br')), - new Twig_SimpleFunction('static_call_string', 'TwigTestExtension::staticCall'), - new Twig_SimpleFunction('static_call_array', array('TwigTestExtension', 'staticCall')), - new Twig_SimpleFunction('*_path', array($this, 'dynamic_path')), - new Twig_SimpleFunction('*_foo_*_bar', array($this, 'dynamic_foo')), - ); - } - - public function getTests() - { - return array( - new Twig_SimpleTest('multi word', array($this, 'is_multi_word')), - ); - } - - public function §Filter($value) - { - return "§{$value}§"; - } - - public function §Function($value) - { - return "§{$value}§"; - } - - /** - * nl2br which also escapes, for testing escaper filters. - */ - public function escape_and_nl2br($env, $value, $sep = '
    ') - { - return $this->nl2br(twig_escape_filter($env, $value, 'html'), $sep); - } - - /** - * nl2br only, for testing filters with pre_escape. - */ - public function nl2br($value, $sep = '
    ') - { - // not secure if $value contains html tags (not only entities) - // don't use - return str_replace("\n", "$sep\n", $value); - } - - public function dynamic_path($element, $item) - { - return $element.'/'.$item; - } - - public function dynamic_foo($foo, $bar, $item) - { - return $foo.'/'.$bar.'/'.$item; - } - - public function escape_something($value) - { - return strtoupper($value); - } - - public function preserves_safety($value) - { - return strtoupper($value); - } - - public static function staticCall($value) - { - return "*$value*"; - } - - public function br() - { - return '
    '; - } - - public function is_multi_word($value) - { - return false !== strpos($value, ' '); - } - - public function __call($method, $arguments) - { - if ('magicCall' !== $method) { - throw new BadMethodCallException('Unexpected call to __call'); - } - - return 'magic_'.$arguments[0]; - } - - public static function __callStatic($method, $arguments) - { - if ('magicStaticCall' !== $method) { - throw new BadMethodCallException('Unexpected call to __callStatic'); - } - - return 'static_magic_'.$arguments[0]; - } -} - -/** - * This class is used in tests for the "length" filter and "empty" test. It asserts that __call is not - * used to convert such objects to strings. - */ -class MagicCallStub -{ - public function __call($name, $args) - { - throw new Exception('__call shall not be called'); - } -} - -class ToStringStub -{ - /** - * @var string - */ - private $string; - - public function __construct($string) - { - $this->string = $string; - } - - public function __toString() - { - return $this->string; - } -} - -/** - * This class is used in tests for the length filter and empty test to show - * that when \Countable is implemented, it is preferred over the __toString() - * method. - */ -class CountableStub implements \Countable -{ - private $count; - - public function __construct($count) - { - $this->count = $count; - } - - public function count() - { - return $this->count; - } - - public function __toString() - { - throw new Exception('__toString shall not be called on \Countables'); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/autoescape/filename.legacy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/autoescape/filename.legacy.test deleted file mode 100644 index b091ad34d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/autoescape/filename.legacy.test +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -"filename" autoescape strategy ---TEMPLATE-- -{{ br -}} -{{ include('index.html.twig') -}} -{{ include('index.txt.twig') -}} ---TEMPLATE(index.html.twig)-- -{{ br -}} ---TEMPLATE(index.txt.twig)-- -{{ br -}} ---DATA-- -return array('br' => '
    ') ---CONFIG-- -return array('autoescape' => 'filename') ---EXPECT-- -<br /> -<br /> -
    diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/functions/undefined_block.legacy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/functions/undefined_block.legacy.test deleted file mode 100644 index 62e24f0f4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/functions/undefined_block.legacy.test +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -"block" function with undefined block ---TEMPLATE-- -{% extends "base.twig" %} -{% block foo %}{{ parent() }}{{ block('unknown') }}{{ block('bar') }}{% endblock %} ---TEMPLATE(base.twig)-- -{% block foo %}Foo{% endblock %} -{% block bar %}Bar{% endblock %} ---DATA-- -return array() ---EXPECT-- -FooBarBar diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test b/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test deleted file mode 100644 index d9c1d5085..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -Old test classes usage ---TEMPLATE-- -{{ 'foo' is multi word ? 'yes' : 'no' }} ---DATA-- -return array() ---EXPECT-- -no diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php deleted file mode 100644 index 2ed758038..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php +++ /dev/null @@ -1,54 +0,0 @@ - new Twig_Test_Method($this, 'is_multi_word'), - ); - } - - public function is_multi_word($value) - { - return false !== strpos($value, ' '); - } - - public function getName() - { - return 'legacy_integration_test'; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/LexerTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/LexerTest.php deleted file mode 100644 index ffe9a235b..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/LexerTest.php +++ /dev/null @@ -1,347 +0,0 @@ -getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize('{{ foo }}', 'foo'); - $this->assertEquals('foo', $stream->getFilename()); - $this->assertEquals('{{ foo }}', $stream->getSource()); - } - - public function testNameLabelForTag() - { - $template = '{% § %}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - - $stream->expect(Twig_Token::BLOCK_START_TYPE); - $this->assertSame('§', $stream->expect(Twig_Token::NAME_TYPE)->getValue()); - } - - public function testNameLabelForFunction() - { - $template = '{{ §() }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - - $stream->expect(Twig_Token::VAR_START_TYPE); - $this->assertSame('§', $stream->expect(Twig_Token::NAME_TYPE)->getValue()); - } - - public function testBracketsNesting() - { - $template = '{{ {"a":{"b":"c"}} }}'; - - $this->assertEquals(2, $this->countToken($template, Twig_Token::PUNCTUATION_TYPE, '{')); - $this->assertEquals(2, $this->countToken($template, Twig_Token::PUNCTUATION_TYPE, '}')); - } - - protected function countToken($template, $type, $value = null) - { - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - - $count = 0; - while (!$stream->isEOF()) { - $token = $stream->next(); - if ($type === $token->getType()) { - if (null === $value || $value === $token->getValue()) { - ++$count; - } - } - } - - return $count; - } - - public function testLineDirective() - { - $template = "foo\n" - ."bar\n" - ."{% line 10 %}\n" - ."{{\n" - ."baz\n" - ."}}\n"; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - - // foo\nbar\n - $this->assertSame(1, $stream->expect(Twig_Token::TEXT_TYPE)->getLine()); - // \n (after {% line %}) - $this->assertSame(10, $stream->expect(Twig_Token::TEXT_TYPE)->getLine()); - // {{ - $this->assertSame(11, $stream->expect(Twig_Token::VAR_START_TYPE)->getLine()); - // baz - $this->assertSame(12, $stream->expect(Twig_Token::NAME_TYPE)->getLine()); - } - - public function testLineDirectiveInline() - { - $template = "foo\n" - ."bar{% line 10 %}{{\n" - ."baz\n" - ."}}\n"; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - - // foo\nbar - $this->assertSame(1, $stream->expect(Twig_Token::TEXT_TYPE)->getLine()); - // {{ - $this->assertSame(10, $stream->expect(Twig_Token::VAR_START_TYPE)->getLine()); - // baz - $this->assertSame(11, $stream->expect(Twig_Token::NAME_TYPE)->getLine()); - } - - public function testLongComments() - { - $template = '{# '.str_repeat('*', 100000).' #}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $lexer->tokenize(new Twig_Source($template, 'index')); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testLongVerbatim() - { - $template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $lexer->tokenize(new Twig_Source($template, 'index')); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testLongVar() - { - $template = '{{ '.str_repeat('x', 100000).' }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $lexer->tokenize(new Twig_Source($template, 'index')); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testLongBlock() - { - $template = '{% '.str_repeat('x', 100000).' %}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $lexer->tokenize(new Twig_Source($template, 'index')); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testBigNumbers() - { - $template = '{{ 922337203685477580700 }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->next(); - $node = $stream->next(); - $this->assertEquals('922337203685477580700', $node->getValue()); - } - - public function testStringWithEscapedDelimiter() - { - $tests = array( - "{{ 'foo \' bar' }}" => 'foo \' bar', - '{{ "foo \" bar" }}' => 'foo " bar', - ); - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - foreach ($tests as $template => $expected) { - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->expect(Twig_Token::VAR_START_TYPE); - $stream->expect(Twig_Token::STRING_TYPE, $expected); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - } - - public function testStringWithInterpolation() - { - $template = 'foo {{ "bar #{ baz + 1 }" }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->expect(Twig_Token::TEXT_TYPE, 'foo '); - $stream->expect(Twig_Token::VAR_START_TYPE); - $stream->expect(Twig_Token::STRING_TYPE, 'bar '); - $stream->expect(Twig_Token::INTERPOLATION_START_TYPE); - $stream->expect(Twig_Token::NAME_TYPE, 'baz'); - $stream->expect(Twig_Token::OPERATOR_TYPE, '+'); - $stream->expect(Twig_Token::NUMBER_TYPE, '1'); - $stream->expect(Twig_Token::INTERPOLATION_END_TYPE); - $stream->expect(Twig_Token::VAR_END_TYPE); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testStringWithEscapedInterpolation() - { - $template = '{{ "bar \#{baz+1}" }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->expect(Twig_Token::VAR_START_TYPE); - $stream->expect(Twig_Token::STRING_TYPE, 'bar #{baz+1}'); - $stream->expect(Twig_Token::VAR_END_TYPE); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testStringWithHash() - { - $template = '{{ "bar # baz" }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->expect(Twig_Token::VAR_START_TYPE); - $stream->expect(Twig_Token::STRING_TYPE, 'bar # baz'); - $stream->expect(Twig_Token::VAR_END_TYPE); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unclosed """ - */ - public function testStringWithUnterminatedInterpolation() - { - $template = '{{ "bar #{x" }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $lexer->tokenize(new Twig_Source($template, 'index')); - } - - public function testStringWithNestedInterpolations() - { - $template = '{{ "bar #{ "foo#{bar}" }" }}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->expect(Twig_Token::VAR_START_TYPE); - $stream->expect(Twig_Token::STRING_TYPE, 'bar '); - $stream->expect(Twig_Token::INTERPOLATION_START_TYPE); - $stream->expect(Twig_Token::STRING_TYPE, 'foo'); - $stream->expect(Twig_Token::INTERPOLATION_START_TYPE); - $stream->expect(Twig_Token::NAME_TYPE, 'bar'); - $stream->expect(Twig_Token::INTERPOLATION_END_TYPE); - $stream->expect(Twig_Token::INTERPOLATION_END_TYPE); - $stream->expect(Twig_Token::VAR_END_TYPE); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testStringWithNestedInterpolationsInBlock() - { - $template = '{% foo "bar #{ "foo#{bar}" }" %}'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->expect(Twig_Token::BLOCK_START_TYPE); - $stream->expect(Twig_Token::NAME_TYPE, 'foo'); - $stream->expect(Twig_Token::STRING_TYPE, 'bar '); - $stream->expect(Twig_Token::INTERPOLATION_START_TYPE); - $stream->expect(Twig_Token::STRING_TYPE, 'foo'); - $stream->expect(Twig_Token::INTERPOLATION_START_TYPE); - $stream->expect(Twig_Token::NAME_TYPE, 'bar'); - $stream->expect(Twig_Token::INTERPOLATION_END_TYPE); - $stream->expect(Twig_Token::INTERPOLATION_END_TYPE); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - public function testOperatorEndingWithALetterAtTheEndOfALine() - { - $template = "{{ 1 and\n0}}"; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $stream = $lexer->tokenize(new Twig_Source($template, 'index')); - $stream->expect(Twig_Token::VAR_START_TYPE); - $stream->expect(Twig_Token::NUMBER_TYPE, 1); - $stream->expect(Twig_Token::OPERATOR_TYPE, 'and'); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unclosed "variable" in "index" at line 3 - */ - public function testUnterminatedVariable() - { - $template = ' - -{{ - -bar - - -'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $lexer->tokenize(new Twig_Source($template, 'index')); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unclosed "block" in "index" at line 3 - */ - public function testUnterminatedBlock() - { - $template = ' - -{% - -bar - - -'; - - $lexer = new Twig_Lexer(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $lexer->tokenize(new Twig_Source($template, 'index')); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ArrayTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ArrayTest.php deleted file mode 100644 index 593063933..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ArrayTest.php +++ /dev/null @@ -1,137 +0,0 @@ - 'bar')); - - $this->assertEquals('bar', $loader->getSource('foo')); - } - - /** - * @group legacy - * @expectedException Twig_Error_Loader - */ - public function testGetSourceWhenTemplateDoesNotExist() - { - $loader = new Twig_Loader_Array(array()); - - $loader->getSource('foo'); - } - - /** - * @expectedException Twig_Error_Loader - */ - public function testGetSourceContextWhenTemplateDoesNotExist() - { - $loader = new Twig_Loader_Array(array()); - - $loader->getSourceContext('foo'); - } - - public function testGetCacheKey() - { - $loader = new Twig_Loader_Array(array('foo' => 'bar')); - - $this->assertEquals('foo:bar', $loader->getCacheKey('foo')); - } - - public function testGetCacheKeyWhenTemplateHasDuplicateContent() - { - $loader = new Twig_Loader_Array(array( - 'foo' => 'bar', - 'baz' => 'bar', - )); - - $this->assertEquals('foo:bar', $loader->getCacheKey('foo')); - $this->assertEquals('baz:bar', $loader->getCacheKey('baz')); - } - - public function testGetCacheKeyIsProtectedFromEdgeCollisions() - { - $loader = new Twig_Loader_Array(array( - 'foo__' => 'bar', - 'foo' => '__bar', - )); - - $this->assertEquals('foo__:bar', $loader->getCacheKey('foo__')); - $this->assertEquals('foo:__bar', $loader->getCacheKey('foo')); - } - - /** - * @expectedException Twig_Error_Loader - */ - public function testGetCacheKeyWhenTemplateDoesNotExist() - { - $loader = new Twig_Loader_Array(array()); - - $loader->getCacheKey('foo'); - } - - public function testSetTemplate() - { - $loader = new Twig_Loader_Array(array()); - $loader->setTemplate('foo', 'bar'); - - $this->assertEquals('bar', $loader->getSourceContext('foo')->getCode()); - } - - public function testIsFresh() - { - $loader = new Twig_Loader_Array(array('foo' => 'bar')); - $this->assertTrue($loader->isFresh('foo', time())); - } - - /** - * @expectedException Twig_Error_Loader - */ - public function testIsFreshWhenTemplateDoesNotExist() - { - $loader = new Twig_Loader_Array(array()); - - $loader->isFresh('foo', time()); - } - - public function testTemplateReference() - { - $name = new Twig_Test_Loader_TemplateReference('foo'); - $loader = new Twig_Loader_Array(array('foo' => 'bar')); - - $loader->getCacheKey($name); - $loader->getSourceContext($name); - $loader->isFresh($name, time()); - $loader->setTemplate($name, 'foo:bar'); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without crashing PHP - $this->addToAssertionCount(1); - } -} - -class Twig_Test_Loader_TemplateReference -{ - private $name; - - public function __construct($name) - { - $this->name = $name; - } - - public function __toString() - { - return $this->name; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ChainTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ChainTest.php deleted file mode 100644 index 8a8a84a5a..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/ChainTest.php +++ /dev/null @@ -1,124 +0,0 @@ - 'bar')), - new Twig_Loader_Array(array('foo' => 'foobar', 'bar' => 'foo')), - )); - - $this->assertEquals('bar', $loader->getSource('foo')); - $this->assertEquals('foo', $loader->getSource('bar')); - } - - public function testGetSourceContext() - { - $path = dirname(__FILE__).'/../Fixtures'; - $loader = new Twig_Loader_Chain(array( - new Twig_Loader_Array(array('foo' => 'bar')), - new Twig_Loader_Array(array('errors/index.html' => 'baz')), - new Twig_Loader_Filesystem(array($path)), - )); - - $this->assertEquals('foo', $loader->getSourceContext('foo')->getName()); - $this->assertSame('', $loader->getSourceContext('foo')->getPath()); - - $this->assertEquals('errors/index.html', $loader->getSourceContext('errors/index.html')->getName()); - $this->assertSame('', $loader->getSourceContext('errors/index.html')->getPath()); - $this->assertEquals('baz', $loader->getSourceContext('errors/index.html')->getCode()); - - $this->assertEquals('errors/base.html', $loader->getSourceContext('errors/base.html')->getName()); - $this->assertEquals(realpath($path.'/errors/base.html'), realpath($loader->getSourceContext('errors/base.html')->getPath())); - $this->assertNotEquals('baz', $loader->getSourceContext('errors/base.html')->getCode()); - } - - /** - * @expectedException Twig_Error_Loader - */ - public function testGetSourceContextWhenTemplateDoesNotExist() - { - $loader = new Twig_Loader_Chain(array()); - - $loader->getSourceContext('foo'); - } - - /** - * @group legacy - * @expectedException Twig_Error_Loader - */ - public function testGetSourceWhenTemplateDoesNotExist() - { - $loader = new Twig_Loader_Chain(array()); - - $loader->getSource('foo'); - } - - public function testGetCacheKey() - { - $loader = new Twig_Loader_Chain(array( - new Twig_Loader_Array(array('foo' => 'bar')), - new Twig_Loader_Array(array('foo' => 'foobar', 'bar' => 'foo')), - )); - - $this->assertEquals('foo:bar', $loader->getCacheKey('foo')); - $this->assertEquals('bar:foo', $loader->getCacheKey('bar')); - } - - /** - * @expectedException Twig_Error_Loader - */ - public function testGetCacheKeyWhenTemplateDoesNotExist() - { - $loader = new Twig_Loader_Chain(array()); - - $loader->getCacheKey('foo'); - } - - public function testAddLoader() - { - $loader = new Twig_Loader_Chain(); - $loader->addLoader(new Twig_Loader_Array(array('foo' => 'bar'))); - - $this->assertEquals('bar', $loader->getSourceContext('foo')->getCode()); - } - - public function testExists() - { - $loader1 = $this->getMockBuilder('Twig_ChainTestLoaderWithExistsInterface')->getMock(); - $loader1->expects($this->once())->method('exists')->will($this->returnValue(false)); - $loader1->expects($this->never())->method('getSourceContext'); - - // can be removed in 2.0 - $loader2 = $this->getMockBuilder('Twig_ChainTestLoaderInterface')->getMock(); - //$loader2 = $this->getMockBuilder(array('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface'))->getMock(); - $loader2->expects($this->once())->method('getSourceContext')->will($this->returnValue(new Twig_Source('content', 'index'))); - - $loader = new Twig_Loader_Chain(); - $loader->addLoader($loader1); - $loader->addLoader($loader2); - - $this->assertTrue($loader->exists('foo')); - } -} - -interface Twig_ChainTestLoaderInterface extends Twig_LoaderInterface, Twig_SourceContextLoaderInterface -{ -} - -interface Twig_ChainTestLoaderWithExistsInterface extends Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface -{ -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php deleted file mode 100644 index bd2acbd75..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php +++ /dev/null @@ -1,226 +0,0 @@ -assertEquals('errors/index.html', $loader->getSourceContext('errors/index.html')->getName()); - $this->assertEquals(realpath($path.'/errors/index.html'), realpath($loader->getSourceContext('errors/index.html')->getPath())); - } - - /** - * @dataProvider getSecurityTests - */ - public function testSecurity($template) - { - $loader = new Twig_Loader_Filesystem(array(dirname(__FILE__).'/../Fixtures')); - - try { - $loader->getCacheKey($template); - $this->fail(); - } catch (Twig_Error_Loader $e) { - $this->assertNotContains('Unable to find template', $e->getMessage()); - } - } - - public function getSecurityTests() - { - return array( - array("AutoloaderTest\0.php"), - array('..\\AutoloaderTest.php'), - array('..\\\\\\AutoloaderTest.php'), - array('../AutoloaderTest.php'), - array('..////AutoloaderTest.php'), - array('./../AutoloaderTest.php'), - array('.\\..\\AutoloaderTest.php'), - array('././././././../AutoloaderTest.php'), - array('.\\./.\\./.\\./../AutoloaderTest.php'), - array('foo/../../AutoloaderTest.php'), - array('foo\\..\\..\\AutoloaderTest.php'), - array('foo/../bar/../../AutoloaderTest.php'), - array('foo/bar/../../../AutoloaderTest.php'), - array('filters/../../AutoloaderTest.php'), - array('filters//..//..//AutoloaderTest.php'), - array('filters\\..\\..\\AutoloaderTest.php'), - array('filters\\\\..\\\\..\\\\AutoloaderTest.php'), - array('filters\\//../\\/\\..\\AutoloaderTest.php'), - array('/../AutoloaderTest.php'), - ); - } - - /** - * @dataProvider getBasePaths - */ - public function testPaths($basePath, $cacheKey, $rootPath) - { - $loader = new Twig_Loader_Filesystem(array($basePath.'/normal', $basePath.'/normal_bis'), $rootPath); - $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/../named_quater', 'named'); - $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/../named_quater', - $basePath.'/named', - $basePath.'/named_bis', - $basePath.'/named_ter', - ), $loader->getPaths('named')); - - // do not use realpath here as it would make the test unuseful - $this->assertEquals($cacheKey, str_replace('\\', '/', $loader->getCacheKey('@named/named_absolute.html'))); - $this->assertEquals("path (final)\n", $loader->getSourceContext('index.html')->getCode()); - $this->assertEquals("path (final)\n", $loader->getSourceContext('@__main__/index.html')->getCode()); - $this->assertEquals("named path (final)\n", $loader->getSourceContext('@named/index.html')->getCode()); - } - - public function getBasePaths() - { - return array( - array( - dirname(__FILE__).'/Fixtures', - 'test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html', - null, - ), - array( - dirname(__FILE__).'/Fixtures/../Fixtures', - 'test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html', - null, - ), - array( - 'test/Twig/Tests/Loader/Fixtures', - 'test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html', - getcwd(), - ), - array( - 'Fixtures', - 'Fixtures/named_quater/named_absolute.html', - getcwd().'/test/Twig/Tests/Loader', - ), - array( - 'Fixtures', - 'Fixtures/named_quater/named_absolute.html', - getcwd().'/test/../test/Twig/Tests/Loader', - ), - ); - } - - public function testEmptyConstructor() - { - $loader = new Twig_Loader_Filesystem(); - $this->assertEquals(array(), $loader->getPaths()); - } - - public function testGetNamespaces() - { - $loader = new Twig_Loader_Filesystem(sys_get_temp_dir()); - $this->assertEquals(array(Twig_Loader_Filesystem::MAIN_NAMESPACE), $loader->getNamespaces()); - - $loader->addPath(sys_get_temp_dir(), 'named'); - $this->assertEquals(array(Twig_Loader_Filesystem::MAIN_NAMESPACE, 'named'), $loader->getNamespaces()); - } - - public function testFindTemplateExceptionNamespace() - { - $basePath = dirname(__FILE__).'/Fixtures'; - - $loader = new Twig_Loader_Filesystem(array($basePath.'/normal')); - $loader->addPath($basePath.'/named', 'named'); - - try { - $loader->getSourceContext('@named/nowhere.html'); - } catch (Exception $e) { - $this->assertInstanceof('Twig_Error_Loader', $e); - $this->assertContains('Unable to find template "@named/nowhere.html"', $e->getMessage()); - } - } - - public function testFindTemplateWithCache() - { - $basePath = dirname(__FILE__).'/Fixtures'; - - $loader = new Twig_Loader_Filesystem(array($basePath.'/normal')); - $loader->addPath($basePath.'/named', 'named'); - - // prime the cache for index.html in the named namespace - $namedSource = $loader->getSourceContext('@named/index.html')->getCode(); - $this->assertEquals("named path\n", $namedSource); - - // get index.html from the main namespace - $this->assertEquals("path\n", $loader->getSourceContext('index.html')->getCode()); - } - - public function testLoadTemplateAndRenderBlockWithCache() - { - $loader = new Twig_Loader_Filesystem(array()); - $loader->addPath(dirname(__FILE__).'/Fixtures/themes/theme2'); - $loader->addPath(dirname(__FILE__).'/Fixtures/themes/theme1'); - $loader->addPath(dirname(__FILE__).'/Fixtures/themes/theme1', 'default_theme'); - - $twig = new Twig_Environment($loader); - - $template = $twig->loadTemplate('blocks.html.twig'); - $this->assertSame('block from theme 1', $template->renderBlock('b1', array())); - - $template = $twig->loadTemplate('blocks.html.twig'); - $this->assertSame('block from theme 2', $template->renderBlock('b2', array())); - } - - public function getArrayInheritanceTests() - { - return array( - 'valid array inheritance' => array('array_inheritance_valid_parent.html.twig'), - 'array inheritance with null first template' => array('array_inheritance_null_parent.html.twig'), - 'array inheritance with empty first template' => array('array_inheritance_empty_parent.html.twig'), - 'array inheritance with non-existent first template' => array('array_inheritance_nonexistent_parent.html.twig'), - ); - } - - /** - * @dataProvider getArrayInheritanceTests - * - * @param $templateName string Template name with array inheritance - */ - public function testArrayInheritance($templateName) - { - $loader = new Twig_Loader_Filesystem(array()); - $loader->addPath(dirname(__FILE__).'/Fixtures/inheritance'); - - $twig = new Twig_Environment($loader); - - $template = $twig->loadTemplate($templateName); - $this->assertSame('VALID Child', $template->renderBlock('body', array())); - } - - /** - * @requires PHP 5.3 - */ - public function testLoadTemplateFromPhar() - { - $loader = new Twig_Loader_Filesystem(array()); - // phar-sample.phar was created with the following script: - // $f = new Phar('phar-test.phar'); - // $f->addFromString('hello.twig', 'hello from phar'); - $loader->addPath('phar://'.dirname(__FILE__).'/Fixtures/phar/phar-sample.phar'); - $this->assertSame('hello from phar', $loader->getSourceContext('hello.twig')->getCode()); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig deleted file mode 100644 index 6977ebf66..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% extends ['','parent.html.twig'] %} - -{% block body %}{{ parent() }} Child{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig deleted file mode 100644 index 5b50a8b21..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% extends ['nonexistent.html.twig','parent.html.twig'] %} - -{% block body %}{{ parent() }} Child{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig deleted file mode 100644 index a16b3aded..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% extends [null,'parent.html.twig'] %} - -{% block body %}{{ parent() }} Child{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig deleted file mode 100644 index 4940dad41..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% extends ['parent.html.twig','spare_parent.html.twig'] %} - -{% block body %}{{ parent() }} Child{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/parent.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/parent.html.twig deleted file mode 100644 index d594c0ed4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/parent.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% block body %}VALID{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/spare_parent.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/spare_parent.html.twig deleted file mode 100644 index 70b7360a2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/spare_parent.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% block body %}SPARE PARENT{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html deleted file mode 100644 index 9e5449c7c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named/index.html +++ /dev/null @@ -1 +0,0 @@ -named path diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html deleted file mode 100644 index d3a272b19..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_bis/index.html +++ /dev/null @@ -1 +0,0 @@ -named path (bis) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html deleted file mode 100644 index 9f05d1507..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_final/index.html +++ /dev/null @@ -1 +0,0 @@ -named path (final) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html deleted file mode 100644 index b1fb5f5d7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html +++ /dev/null @@ -1 +0,0 @@ -named path (quater) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html deleted file mode 100644 index 24fb68ad2..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_ter/index.html +++ /dev/null @@ -1 +0,0 @@ -named path (ter) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html deleted file mode 100644 index e7a8fd4d0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal/index.html +++ /dev/null @@ -1 +0,0 @@ -path diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html deleted file mode 100644 index bfa916049..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_bis/index.html +++ /dev/null @@ -1 +0,0 @@ -path (bis) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html deleted file mode 100644 index 73a089bbd..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_final/index.html +++ /dev/null @@ -1 +0,0 @@ -path (final) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html deleted file mode 100644 index b7ad97d8f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/normal_ter/index.html +++ /dev/null @@ -1 +0,0 @@ -path (ter) diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/phar/phar-sample.phar b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/phar/phar-sample.phar deleted file mode 100644 index 092bbfae3e4c98b308dc98bf7653ead68ae3ee6e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6786 zcmb_hOLN=E5q5IqWh?g_#w@G>Mx-dx&rq@~*-JkvlEqM5ZLJv>0s=!4E4&r}B}(hP zu&2!Q zBabh)K{9u1HGj%1KeC-Pb*?NknLDZ3WLchaC$wigw=YvCNqCxBjRw1SkGX-9Wj0^> zS)N(uK(g;(@4Ff;dObhNdFt{cf9VJO@V}w zadTVhIUOAiN4vF@=ZiGjt$i4sBa?mjz}5||unkU5M`lALde!||Y~|^KBX%S7L!RM;DW<2Eh9F$qo(Np_{kp$|P=Z;JZ%l z$5DIP`o_6%GB@>;oK%Lsr_$prJU?!WwWLdxx5%-|y&_{t%<+X}#s{Cbzg_t5d5&Tf zd&&J3MOczVqCA#|5~={jZxP8VJ@M2LltUpRR3*B2Wbm{EHM^{k$mX$oe(7BB))akg zPJH?5;bJM2ir=M_YC43=(a;h~mJ?MA(gj))6(u25hzg-qvxaM0n{&tGsa1dBxO3im z5l49%2R#7h?{wI4e8D|7;A!YYJj#PB z^Cq?CQ7o@WkI_(CZ^t4}*pV{?wjhf^nA6BG97K+p8HnLlkv7PE@n+b6fvNWO%7Bx4 z#0fzOLQ)|k{dA(1;ov;>G_^vrI4)HlI@%rfVCMmQ8|Un0yofxClDqSm)%U3J?EfKR zdn7?0*k11E0pF)_eIucW#MsuHdz09^k|OiYJ{f2+Ayr55Bzcq7OY&{72x%n*HDtM7 zN*Q4hN|zr^V+vE9tQxA5v585=qYO<8la!8E2T3;ur`H-?CA`N<1FdwJn&*f|vwSX( zbczr&|61mh3fJ+7ByH=H6nIEZelbqR#;PaM72=ZPc5NT^_>^_X-{PJ)H&K5|uqy)f zXY&C6b9>#t>Lj3IH@Ne2API}dtQVmI=2Lw!w5ZrpxBzWz`CBja`W)LGJ*yWt=wxw+mS-@9K5XOZu$ckZ6v4b!? zpIc^sI6N8l7#gTQ?f#|I;*1 zd+a*!C#+~N%+D}>bA};02{0jA6oknNd8@&+au#v!fn^$}LP^Vw!zAVC7#_o$%1JXB zlzK*#JVn)Sc6D;?ajj|H+sU<`bU*2CS;q#CC)eGNI4mx5aSnNy5C+gSaaZnQLf!Q< zJPZAta%D+SAj&pF7I6Ehrwb)wWoLj}^34ZL)c#N$03zt0C4LN#-Fk!FMe9`8wY*E( z1gf|#v{}_wM_Ic|EmT)TS!siYErmisu51*w@0szR$>{jy>FZ3E^~zEw6%4o2Y!kPVY@6E}eU&?ts3%e=FGiu1bQDC@ZjmFrmEB8^ z4(uR27f}&olkGfy{J6>VBT+a|0xR+W)x}!Pmh^Q4a0$JKay;o)Dj%on4yPPX0X_6Ltez1B^mjZ>a#xRo3j8g)V~Wo(A#dxoZD$eP?| z2B{XsN`P%8S|m&YE)}(gd8lS;?JA`oWYb7xzf`GS(fE9BW_@U>e-u z*z)leK?^x)0`7dzIHnq!+NW}*#N@H4a-%b`)P~3i#@aLyQM&Um#zb4s0W3dy^oT5r ze>M3)SS=nkb48a^Zv<&qeZ@keYqMIn84T!~?qCgG5A2gu9P3wa-U8d-GzNq$Fw}*U z%97{Ng=LP82jF@}1y)-3Zq|KbAjcFeFd$E{kS^5&%r-?0HRucS{%A@`4&@~=zTP7x zN~h>tS}7S=brAT!(gh`5)=X}YqP1j|W+MR_H8;!nL_fbm99WYHR01RbPc|@hG?&0G zCF#xsyuXY9I0dd4^tI9k4TS<4;lOwXYCa`|A{1m$02+c616;DuJ*7J;Rv7O9Kk~wY z7oWDaDC02BBXDdmE6u17mCY>}-Gv~{96g5Aa}@c|5~Np$C0vD=qCuE3=`32uxKM=K zDZf>-@hD%Qp%qR!?XyYy%x#}}?K9p!!70eif2a zY}5~RK6da`w1npMH<9?ph>5S@BPWn}l+lC$>cYd9aRR@1r*9Vz52J-!82Nj$#F)uGaeJ3q1ba)V<%e^m|15jfyCh>Q8eK-+j5~*&>u~YU3y&d@s+0 zTH(#@$DUn{H4Fue=;e27SQRK?7Q_?F{0(|OfrP29CNWdh-#9=OWQ7yK^Nby&p@3Id z^w_~73jBzkjz|_A^DSxmtBFRLQr8BEG+n_*YRqa=G@77)9aE^#bg-&a`zwFpz;hU~ zw*C6>Xk@=QIUeB8Eklslv;8M`?%eqW{{Kq-#xMNT@PE#OAl}X|{n=+&{rQLgenr2R zUq3wj2MORuaIk3_hXVQj>yQ8J|L^Zl{`Bz2U;pj!umAb+FF!2*{Y$XDdVc);|E1Ux AZ~y=R diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig deleted file mode 100644 index dd0cbc2e7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme1/blocks.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% block b1 %}block from theme 1{% endblock %} - -{% block b2 %}block from theme 1{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig b/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig deleted file mode 100644 index 07cf9db0d..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/themes/theme2/blocks.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% use '@default_theme/blocks.html.twig' %} - -{% block b2 %}block from theme 2{% endblock %} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php deleted file mode 100644 index 50736dc22..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php +++ /dev/null @@ -1,32 +0,0 @@ - '{{ d1.date }}{{ d2.date }}')), array( - 'debug' => true, - 'cache' => false, - 'autoescape' => false, - )); - - $d1 = new DateTime(); - $d2 = new DateTime(); - $output = $twig->render('index', compact('d1', 'd2')); - - // If it fails, PHP will crash. - $this->assertEquals($output, $d1->date.$d2->date); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php deleted file mode 100644 index 25d16023f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php +++ /dev/null @@ -1,32 +0,0 @@ -assertEquals($body, $node->getNode('body')); - $this->assertTrue($node->getAttribute('value')); - } - - public function getTests() - { - $body = new Twig_Node(array(new Twig_Node_Text('foo', 1))); - $node = new Twig_Node_AutoEscape(true, $body, 1); - - return array( - array($node, "// line 1\necho \"foo\";"), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php deleted file mode 100644 index 84dac9bfa..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php +++ /dev/null @@ -1,31 +0,0 @@ -assertEquals('foo', $node->getAttribute('name')); - } - - public function getTests() - { - return array( - array(new Twig_Node_BlockReference('foo', 1), <<displayBlock('foo', \$context, \$blocks); -EOF - ), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php deleted file mode 100644 index e7246dcc3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php +++ /dev/null @@ -1,39 +0,0 @@ -assertEquals($body, $node->getNode('body')); - $this->assertEquals('foo', $node->getAttribute('name')); - } - - public function getTests() - { - $body = new Twig_Node_Text('foo', 1); - $node = new Twig_Node_Block('foo', $body, 1); - - return array( - array($node, <<assertEquals($expr, $node->getNode('expr')); - } - - public function getTests() - { - $tests = array(); - - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php deleted file mode 100644 index 4f83ab176..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php +++ /dev/null @@ -1,37 +0,0 @@ -assertEquals($foo, $node->getNode(1)); - } - - public function getTests() - { - $elements = array( - new Twig_Node_Expression_Constant('foo', 1), - new Twig_Node_Expression_Constant('bar', 1), - - new Twig_Node_Expression_Constant('bar', 1), - new Twig_Node_Expression_Constant('foo', 1), - ); - $node = new Twig_Node_Expression_Array($elements, 1); - - return array( - array($node, 'array("foo" => "bar", "bar" => "foo")'), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php deleted file mode 100644 index bf365de49..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php +++ /dev/null @@ -1,29 +0,0 @@ -assertEquals('foo', $node->getAttribute('name')); - } - - public function getTests() - { - $node = new Twig_Node_Expression_AssignName('foo', 1); - - return array( - array($node, '$context["foo"]'), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php deleted file mode 100644 index 02310a1b0..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php deleted file mode 100644 index 2df3c8e45..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php deleted file mode 100644 index 759e48289..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php deleted file mode 100644 index 0e54b10a3..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php deleted file mode 100644 index 5813dce6e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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, '(int) floor((1 / 2))'), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php deleted file mode 100644 index 4c663c787..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php deleted file mode 100644 index e92c95e64..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php deleted file mode 100644 index ec37c83eb..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php deleted file mode 100644 index 061cb270f..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals($left, $node->getNode('left')); - $this->assertEquals($right, $node->getNode('right')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php deleted file mode 100644 index 883bb6127..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php +++ /dev/null @@ -1,143 +0,0 @@ - 'function', 'name' => 'date')); - $this->assertEquals(array('U', null), $node->getArguments('date', array('format' => 'U', 'timestamp' => null))); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Positional arguments cannot be used after named arguments for function "date". - */ - public function testGetArgumentsWhenPositionalArgumentsAfterNamedArguments() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date')); - $node->getArguments('date', array('timestamp' => 123456, 'Y-m-d')); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Argument "format" is defined twice for function "date". - */ - public function testGetArgumentsWhenArgumentIsDefinedTwice() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date')); - $node->getArguments('date', array('Y-m-d', 'format' => 'U')); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown argument "unknown" for function "date(format, timestamp)". - */ - public function testGetArgumentsWithWrongNamedArgumentName() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date')); - $node->getArguments('date', array('Y-m-d', 'timestamp' => null, 'unknown' => '')); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown arguments "unknown1", "unknown2" for function "date(format, timestamp)". - */ - public function testGetArgumentsWithWrongNamedArgumentNames() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date')); - $node->getArguments('date', array('Y-m-d', 'timestamp' => null, 'unknown1' => '', 'unknown2' => '')); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Argument "case_sensitivity" could not be assigned for function "substr_compare(main_str, str, offset, length, case_sensitivity)" because it is mapped to an internal PHP function which cannot determine default value for optional argument "length". - */ - public function testResolveArgumentsWithMissingValueForOptionalArgument() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'substr_compare')); - $node->getArguments('substr_compare', array('abcd', 'bc', 'offset' => 1, 'case_sensitivity' => true)); - } - - public function testResolveArgumentsOnlyNecessaryArgumentsForCustomFunction() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_function')); - - $this->assertEquals(array('arg1'), $node->getArguments(array($this, 'customFunction'), array('arg1' => 'arg1'))); - } - - public function testGetArgumentsForStaticMethod() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_static_function')); - $this->assertEquals(array('arg1'), $node->getArguments(__CLASS__.'::customStaticFunction', array('arg1' => 'arg1'))); - } - - /** - * @expectedException LogicException - * @expectedExceptionMessage The last parameter of "Twig_Tests_Node_Expression_CallTest::customFunctionWithArbitraryArguments" for function "foo" must be an array with default value, eg. "array $arg = array()". - */ - public function testResolveArgumentsWithMissingParameterForArbitraryArguments() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true)); - $node->getArguments(array($this, 'customFunctionWithArbitraryArguments'), array()); - } - - public static function customStaticFunction($arg1, $arg2 = 'default', $arg3 = array()) - { - } - - public function customFunction($arg1, $arg2 = 'default', $arg3 = array()) - { - } - - public function customFunctionWithArbitraryArguments() - { - } - - /** - * @expectedException LogicException - * @expectedExceptionMessageRegExp #^The last parameter of "custom_Twig_Tests_Node_Expression_CallTest_function" for function "foo" must be an array with default value, eg\. "array \$arg \= array\(\)"\.$# - */ - public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnFunction() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true)); - $node->getArguments('custom_Twig_Tests_Node_Expression_CallTest_function', array()); - } - - /** - * @expectedException LogicException - * @expectedExceptionMessageRegExp #^The last parameter of "CallableTestClass\:\:__invoke" for function "foo" must be an array with default value, eg\. "array \$arg \= array\(\)"\.$# - */ - public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnObject() - { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true)); - $node->getArguments(new CallableTestClass(), array()); - } -} - -class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call -{ - public function getArguments($callable, $arguments) - { - return parent::getArguments($callable, $arguments); - } -} - -class CallableTestClass -{ - public function __invoke($required) - { - } -} - -function custom_Twig_Tests_Node_Expression_CallTest_function($required) -{ -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php deleted file mode 100644 index a3e8badff..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php +++ /dev/null @@ -1,38 +0,0 @@ -assertEquals($expr1, $node->getNode('expr1')); - $this->assertEquals($expr2, $node->getNode('expr2')); - $this->assertEquals($expr3, $node->getNode('expr3')); - } - - public function getTests() - { - $tests = array(); - - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php deleted file mode 100644 index 2ff931822..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php +++ /dev/null @@ -1,30 +0,0 @@ -assertEquals('foo', $node->getAttribute('value')); - } - - public function getTests() - { - $tests = array(); - - $node = new Twig_Node_Expression_Constant('foo', 1); - $tests[] = array($node, '"foo"'); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php deleted file mode 100644 index 773375c94..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php +++ /dev/null @@ -1,154 +0,0 @@ -assertEquals($expr, $node->getNode('node')); - $this->assertEquals($name, $node->getNode('filter')); - $this->assertEquals($args, $node->getNode('arguments')); - } - - public function getTests() - { - $environment = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $environment->addFilter(new Twig_SimpleFilter('bar', 'bar', array('needs_environment' => true))); - $environment->addFilter(new Twig_SimpleFilter('barbar', 'twig_tests_filter_barbar', array('needs_context' => true, 'is_variadic' => true))); - - $tests = array(); - - $expr = new Twig_Node_Expression_Constant('foo', 1); - $node = $this->createFilter($expr, 'upper'); - $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_number_format_filter($this->env, twig_upper_filter($this->env, "foo"), 2, ".", ",")'); - } else { - $tests[] = array($node, 'twig_number_format_filter($this->env, strtoupper("foo"), 2, ".", ",")'); - } - - // named arguments - $date = new Twig_Node_Expression_Constant(0, 1); - $node = $this->createFilter($date, 'date', array( - 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1), - 'format' => new Twig_Node_Expression_Constant('d/m/Y H:i:s P', 1), - )); - $tests[] = array($node, 'twig_date_format_filter($this->env, 0, "d/m/Y H:i:s P", "America/Chicago")'); - - // skip an optional argument - $date = new Twig_Node_Expression_Constant(0, 1); - $node = $this->createFilter($date, 'date', array( - 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1), - )); - $tests[] = array($node, 'twig_date_format_filter($this->env, 0, null, "America/Chicago")'); - - // underscores vs camelCase for named arguments - $string = new Twig_Node_Expression_Constant('abc', 1); - $node = $this->createFilter($string, 'reverse', array( - 'preserve_keys' => new Twig_Node_Expression_Constant(true, 1), - )); - $tests[] = array($node, 'twig_reverse_filter($this->env, "abc", true)'); - $node = $this->createFilter($string, 'reverse', array( - 'preserveKeys' => new Twig_Node_Expression_Constant(true, 1), - )); - $tests[] = array($node, 'twig_reverse_filter($this->env, "abc", true)'); - - // filter as an anonymous function - if (PHP_VERSION_ID >= 50300) { - $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'anonymous'); - $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))'); - } - - // needs environment - $node = $this->createFilter($string, 'bar'); - $tests[] = array($node, 'bar($this->env, "abc")', $environment); - - $node = $this->createFilter($string, 'bar', array(new Twig_Node_Expression_Constant('bar', 1))); - $tests[] = array($node, 'bar($this->env, "abc", "bar")', $environment); - - // arbitrary named arguments - $node = $this->createFilter($string, 'barbar'); - $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc")', $environment); - - $node = $this->createFilter($string, 'barbar', array('foo' => new Twig_Node_Expression_Constant('bar', 1))); - $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc", null, null, array("foo" => "bar"))', $environment); - - $node = $this->createFilter($string, 'barbar', array('arg2' => new Twig_Node_Expression_Constant('bar', 1))); - $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc", null, "bar")', $environment); - - $node = $this->createFilter($string, 'barbar', array( - new Twig_Node_Expression_Constant('1', 1), - new Twig_Node_Expression_Constant('2', 1), - new Twig_Node_Expression_Constant('3', 1), - 'foo' => new Twig_Node_Expression_Constant('bar', 1), - )); - $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc", "1", "2", array(0 => "3", "foo" => "bar"))', $environment); - - return $tests; - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown argument "foobar" for filter "date(format, timezone)" at line 1. - */ - public function testCompileWithWrongNamedArgumentName() - { - $date = new Twig_Node_Expression_Constant(0, 1); - $node = $this->createFilter($date, 'date', array( - 'foobar' => new Twig_Node_Expression_Constant('America/Chicago', 1), - )); - - $compiler = $this->getCompiler(); - $compiler->compile($node); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Value for argument "from" is required for filter "replace". - */ - public function testCompileWithMissingNamedArgument() - { - $value = new Twig_Node_Expression_Constant(0, 1); - $node = $this->createFilter($value, 'replace', array( - 'to' => new Twig_Node_Expression_Constant('foo', 1), - )); - - $compiler = $this->getCompiler(); - $compiler->compile($node); - } - - protected function createFilter($node, $name, array $arguments = array()) - { - $name = new Twig_Node_Expression_Constant($name, 1); - $arguments = new Twig_Node($arguments); - - return new Twig_Node_Expression_Filter($node, $name, $arguments, 1); - } - - protected function getEnvironment() - { - if (PHP_VERSION_ID >= 50300) { - return include 'PHP53/FilterInclude.php'; - } - - return parent::getEnvironment(); - } -} - -function twig_tests_filter_barbar($context, $string, $arg1 = null, $arg2 = null, array $args = array()) -{ -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php deleted file mode 100644 index 2e82e2f11..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php +++ /dev/null @@ -1,110 +0,0 @@ -assertEquals($name, $node->getAttribute('name')); - $this->assertEquals($args, $node->getNode('arguments')); - } - - public function getTests() - { - $environment = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $environment->addFunction(new Twig_SimpleFunction('foo', 'foo', array())); - $environment->addFunction(new Twig_SimpleFunction('bar', 'bar', array('needs_environment' => true))); - $environment->addFunction(new Twig_SimpleFunction('foofoo', 'foofoo', array('needs_context' => true))); - $environment->addFunction(new Twig_SimpleFunction('foobar', 'foobar', array('needs_environment' => true, 'needs_context' => true))); - $environment->addFunction(new Twig_SimpleFunction('barbar', 'twig_tests_function_barbar', array('is_variadic' => true))); - - $tests = array(); - - $node = $this->createFunction('foo'); - $tests[] = array($node, 'foo()', $environment); - - $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', 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', 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', 1))); - $tests[] = array($node, 'foobar($this->env, $context, "bar")', $environment); - - // named arguments - $node = $this->createFunction('date', array( - 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1), - 'date' => new Twig_Node_Expression_Constant(0, 1), - )); - $tests[] = array($node, 'twig_date_converter($this->env, 0, "America/Chicago")'); - - // arbitrary named arguments - $node = $this->createFunction('barbar'); - $tests[] = array($node, 'twig_tests_function_barbar()', $environment); - - $node = $this->createFunction('barbar', array('foo' => new Twig_Node_Expression_Constant('bar', 1))); - $tests[] = array($node, 'twig_tests_function_barbar(null, null, array("foo" => "bar"))', $environment); - - $node = $this->createFunction('barbar', array('arg2' => new Twig_Node_Expression_Constant('bar', 1))); - $tests[] = array($node, 'twig_tests_function_barbar(null, "bar")', $environment); - - $node = $this->createFunction('barbar', array( - new Twig_Node_Expression_Constant('1', 1), - new Twig_Node_Expression_Constant('2', 1), - new Twig_Node_Expression_Constant('3', 1), - 'foo' => new Twig_Node_Expression_Constant('bar', 1), - )); - $tests[] = array($node, 'twig_tests_function_barbar("1", "2", array(0 => "3", "foo" => "bar"))', $environment); - - // function as an anonymous function - if (PHP_VERSION_ID >= 50300) { - $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); - $tests[] = array($node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), array("foo"))'); - } - - return $tests; - } - - protected function createFunction($name, array $arguments = array()) - { - return new Twig_Node_Expression_Function($name, new Twig_Node($arguments), 1); - } - - protected function getEnvironment() - { - if (PHP_VERSION_ID >= 50300) { - return include 'PHP53/FunctionInclude.php'; - } - - return parent::getEnvironment(); - } -} - -function twig_tests_function_barbar($arg1 = null, $arg2 = null, array $args = array()) -{ -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php deleted file mode 100644 index 2764478c4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php +++ /dev/null @@ -1,50 +0,0 @@ -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_Template::ARRAY_CALL, 1); - - $this->assertEquals($expr, $node->getNode('node')); - $this->assertEquals($attr, $node->getNode('attribute')); - $this->assertEquals($args, $node->getNode('arguments')); - $this->assertEquals(Twig_Template::ARRAY_CALL, $node->getAttribute('type')); - } - - public function getTests() - { - $tests = array(); - - $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_Template::ANY_CALL, 1); - $tests[] = array($node, sprintf('%s%s, "bar", array())', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1))); - - $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::ARRAY_CALL, 1); - $tests[] = array($node, sprintf('%s%s, "bar", array(), "array")', $this->getAttributeGetter(), $this->getVariableGetter('foo', 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_Template::METHOD_CALL, 1); - $tests[] = array($node, sprintf('%s%s, "bar", array(0 => %s, 1 => "bar"), "method")', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1), $this->getVariableGetter('foo'))); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php deleted file mode 100644 index 70721a8bf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php +++ /dev/null @@ -1,43 +0,0 @@ -assertEquals('foo', $node->getAttribute('name')); - } - - public function getTests() - { - $node = new Twig_Node_Expression_Name('foo', 1); - $context = new Twig_Node_Expression_Name('_context', 1); - - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)); - $env1 = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => false)); - - if (PHP_VERSION_ID >= 70000) { - $output = '($context["foo"] ?? $this->getContext($context, "foo"))'; - } elseif (PHP_VERSION_ID >= 50400) { - $output = '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))'; - } else { - $output = '$this->getContext($context, "foo")'; - } - - return array( - array($node, "// line 1\n".$output, $env), - array($node, $this->getVariableGetter('foo', 1), $env1), - array($context, "// line 1\n\$context"), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NullCoalesceTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NullCoalesceTest.php deleted file mode 100644 index a37490baf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/NullCoalesceTest.php +++ /dev/null @@ -1,31 +0,0 @@ -= 70000) { - $tests[] = array($node, "((// line 1\n\$context[\"foo\"]) ?? (2))"); - } elseif (PHP_VERSION_ID >= 50400) { - $tests[] = array($node, "(((// line 1\narray_key_exists(\"foo\", \$context) && !(null === (isset(\$context[\"foo\"]) ? \$context[\"foo\"] : null)))) ? ((isset(\$context[\"foo\"]) ? \$context[\"foo\"] : null)) : (2))"); - } else { - $tests[] = array($node, "(((// line 1\narray_key_exists(\"foo\", \$context) && !(null === \$this->getContext(\$context, \"foo\")))) ? (\$this->getContext(\$context, \"foo\")) : (2))"); - } - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php deleted file mode 100644 index b5394bcf4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php +++ /dev/null @@ -1,6 +0,0 @@ -addFilter(new Twig_SimpleFilter('anonymous', function () {})); - -return $env; diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php deleted file mode 100644 index e8f68c728..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php +++ /dev/null @@ -1,6 +0,0 @@ -addFunction(new Twig_SimpleFunction('anonymous', function () {})); - -return $env; diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php deleted file mode 100644 index 9f818bc41..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php +++ /dev/null @@ -1,6 +0,0 @@ -addTest(new Twig_SimpleTest('anonymous', function () {})); - -return $env; diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php deleted file mode 100644 index ab2bbe074..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php +++ /dev/null @@ -1,28 +0,0 @@ -assertEquals('foo', $node->getAttribute('name')); - } - - public function getTests() - { - $tests = array(); - $tests[] = array(new Twig_Node_Expression_Parent('foo', 1), '$this->renderParentBlock("foo", $context, $blocks)'); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php deleted file mode 100644 index a5f96d245..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php +++ /dev/null @@ -1,82 +0,0 @@ -assertEquals($expr, $node->getNode('node')); - $this->assertEquals($args, $node->getNode('arguments')); - $this->assertEquals($name, $node->getAttribute('name')); - } - - public function getTests() - { - $environment = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $environment->addTest(new Twig_SimpleTest('barbar', 'twig_tests_test_barbar', array('is_variadic' => true, 'need_context' => true))); - - $tests = array(); - - $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")'); - - // test as an anonymous function - if (PHP_VERSION_ID >= 50300) { - $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); - $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))'); - } - - // arbitrary named arguments - $string = new Twig_Node_Expression_Constant('abc', 1); - $node = $this->createTest($string, 'barbar'); - $tests[] = array($node, 'twig_tests_test_barbar("abc")', $environment); - - $node = $this->createTest($string, 'barbar', array('foo' => new Twig_Node_Expression_Constant('bar', 1))); - $tests[] = array($node, 'twig_tests_test_barbar("abc", null, null, array("foo" => "bar"))', $environment); - - $node = $this->createTest($string, 'barbar', array('arg2' => new Twig_Node_Expression_Constant('bar', 1))); - $tests[] = array($node, 'twig_tests_test_barbar("abc", null, "bar")', $environment); - - $node = $this->createTest($string, 'barbar', array( - new Twig_Node_Expression_Constant('1', 1), - new Twig_Node_Expression_Constant('2', 1), - new Twig_Node_Expression_Constant('3', 1), - 'foo' => new Twig_Node_Expression_Constant('bar', 1), - )); - $tests[] = array($node, 'twig_tests_test_barbar("abc", "1", "2", array(0 => "3", "foo" => "bar"))', $environment); - - return $tests; - } - - protected function createTest($node, $name, array $arguments = array()) - { - return new Twig_Node_Expression_Test($node, $name, new Twig_Node($arguments), 1); - } - - protected function getEnvironment() - { - if (PHP_VERSION_ID >= 50300) { - return include 'PHP53/TestInclude.php'; - } - - return parent::getEnvironment(); - } -} - -function twig_tests_test_barbar($string, $arg1 = null, $arg2 = null, array $args = array()) -{ -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php deleted file mode 100644 index b63337117..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php +++ /dev/null @@ -1,32 +0,0 @@ -assertEquals($expr, $node->getNode('node')); - } - - public function getTests() - { - $node = new Twig_Node_Expression_Constant(1, 1); - $node = new Twig_Node_Expression_Unary_Neg($node, 1); - - return array( - array($node, '-1'), - array(new Twig_Node_Expression_Unary_Neg($node, 1), '- -1'), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php deleted file mode 100644 index d7c6f85e7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php +++ /dev/null @@ -1,31 +0,0 @@ -assertEquals($expr, $node->getNode('node')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php deleted file mode 100644 index 057250f37..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php +++ /dev/null @@ -1,31 +0,0 @@ -assertEquals($expr, $node->getNode('node')); - } - - public function getTests() - { - $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/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php deleted file mode 100644 index 2bf4c7b43..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ForTest.php +++ /dev/null @@ -1,191 +0,0 @@ -setAttribute('with_loop', false); - - $this->assertEquals($keyTarget, $node->getNode('key_target')); - $this->assertEquals($valueTarget, $node->getNode('value_target')); - $this->assertEquals($seq, $node->getNode('seq')); - $this->assertTrue($node->getAttribute('ifexpr')); - $this->assertEquals('Twig_Node_If', get_class($node->getNode('body'))); - $this->assertEquals($body, $node->getNode('body')->getNode('tests')->getNode(1)->getNode(0)); - $this->assertFalse($node->hasNode('else')); - - $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')); - } - - public function getTests() - { - $tests = array(); - - $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', 1), 1)), array(), 1); - $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); - $node->setAttribute('with_loop', false); - - $tests[] = array($node, <<getVariableGetter('items')}); -foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) { - echo {$this->getVariableGetter('foo')}; -} -\$_parent = \$context['_parent']; -unset(\$context['_seq'], \$context['_iterated'], \$context['key'], \$context['item'], \$context['_parent'], \$context['loop']); -\$context = array_intersect_key(\$context, \$_parent) + \$_parent; -EOF - ); - - $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', 1), 1)), array(), 1); - $else = null; - $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1); - $node->setAttribute('with_loop', true); - - $tests[] = array($node, <<getVariableGetter('values')}); -\$context['loop'] = array( - 'parent' => \$context['_parent'], - 'index0' => 0, - 'index' => 1, - 'first' => true, -); -if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) { - \$length = count(\$context['_seq']); - \$context['loop']['revindex0'] = \$length - 1; - \$context['loop']['revindex'] = \$length; - \$context['loop']['length'] = \$length; - \$context['loop']['last'] = 1 === \$length; -} -foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) { - echo {$this->getVariableGetter('foo')}; - ++\$context['loop']['index0']; - ++\$context['loop']['index']; - \$context['loop']['first'] = false; - if (isset(\$context['loop']['length'])) { - --\$context['loop']['revindex0']; - --\$context['loop']['revindex']; - \$context['loop']['last'] = 0 === \$context['loop']['revindex0']; - } -} -\$_parent = \$context['_parent']; -unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']); -\$context = array_intersect_key(\$context, \$_parent) + \$_parent; -EOF - ); - - $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, 1); - $node->setAttribute('with_loop', true); - - $tests[] = array($node, <<getVariableGetter('values')}); -\$context['loop'] = array( - 'parent' => \$context['_parent'], - 'index0' => 0, - 'index' => 1, - 'first' => true, -); -foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) { - if (true) { - echo {$this->getVariableGetter('foo')}; - ++\$context['loop']['index0']; - ++\$context['loop']['index']; - \$context['loop']['first'] = false; - } -} -\$_parent = \$context['_parent']; -unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']); -\$context = array_intersect_key(\$context, \$_parent) + \$_parent; -EOF - ); - - $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', 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, <<getVariableGetter('values')}); -\$context['_iterated'] = false; -\$context['loop'] = array( - 'parent' => \$context['_parent'], - 'index0' => 0, - 'index' => 1, - 'first' => true, -); -if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) { - \$length = count(\$context['_seq']); - \$context['loop']['revindex0'] = \$length - 1; - \$context['loop']['revindex'] = \$length; - \$context['loop']['length'] = \$length; - \$context['loop']['last'] = 1 === \$length; -} -foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) { - echo {$this->getVariableGetter('foo')}; - \$context['_iterated'] = true; - ++\$context['loop']['index0']; - ++\$context['loop']['index']; - \$context['loop']['first'] = false; - if (isset(\$context['loop']['length'])) { - --\$context['loop']['revindex0']; - --\$context['loop']['revindex']; - \$context['loop']['last'] = 0 === \$context['loop']['revindex0']; - } -} -if (!\$context['_iterated']) { - echo {$this->getVariableGetter('foo')}; -} -\$_parent = \$context['_parent']; -unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']); -\$context = array_intersect_key(\$context, \$_parent) + \$_parent; -EOF - ); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php deleted file mode 100644 index 4ab0e4cc7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IfTest.php +++ /dev/null @@ -1,88 +0,0 @@ -assertEquals($t, $node->getNode('tests')); - $this->assertFalse($node->hasNode('else')); - - $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')); - } - - public function getTests() - { - $tests = array(); - - $t = new Twig_Node(array( - 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, 1); - - $tests[] = array($node, <<getVariableGetter('foo')}; -} -EOF - ); - - $t = new Twig_Node(array( - 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, 1); - - $tests[] = array($node, <<getVariableGetter('foo')}; -} elseif (false) { - echo {$this->getVariableGetter('bar')}; -} -EOF - ); - - $t = new Twig_Node(array( - 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, <<getVariableGetter('foo')}; -} else { - echo {$this->getVariableGetter('bar')}; -} -EOF - ); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php deleted file mode 100644 index 36525b251..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php +++ /dev/null @@ -1,40 +0,0 @@ -assertEquals($macro, $node->getNode('expr')); - $this->assertEquals($var, $node->getNode('var')); - } - - public function getTests() - { - $tests = array(); - - $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, <<loadTemplate("foo.twig", null, 1); -EOF - ); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php deleted file mode 100644 index d801f3387..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php +++ /dev/null @@ -1,83 +0,0 @@ -assertFalse($node->hasNode('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', 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')); - } - - public function getTests() - { - $tests = array(); - - $expr = new Twig_Node_Expression_Constant('foo.twig', 1); - $node = new Twig_Node_Include($expr, null, false, false, 1); - $tests[] = array($node, <<loadTemplate("foo.twig", null, 1)->display(\$context); -EOF - ); - - $expr = new Twig_Node_Expression_Conditional( - 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, 1); - $tests[] = array($node, <<loadTemplate(((true) ? ("foo") : ("foo")), null, 1)->display(\$context); -EOF - ); - - $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, <<loadTemplate("foo.twig", null, 1)->display(array_merge(\$context, array("foo" => true))); -EOF - ); - - $node = new Twig_Node_Include($expr, $vars, true, false, 1); - $tests[] = array($node, <<loadTemplate("foo.twig", null, 1)->display(array("foo" => true)); -EOF - ); - - $node = new Twig_Node_Include($expr, $vars, true, true, 1); - $tests[] = array($node, <<loadTemplate("foo.twig", null, 1)->display(array("foo" => true)); -} catch (Twig_Error_Loader \$e) { - // ignore missing template -} -EOF - ); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php deleted file mode 100644 index c7edfa251..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php +++ /dev/null @@ -1,74 +0,0 @@ -assertEquals($body, $node->getNode('body')); - $this->assertEquals($arguments, $node->getNode('arguments')); - $this->assertEquals('foo', $node->getAttribute('name')); - } - - public function getTests() - { - $body = new Twig_Node_Text('foo', 1); - $arguments = new Twig_Node(array( - 'foo' => new Twig_Node_Expression_Constant(null, 1), - 'bar' => new Twig_Node_Expression_Constant('Foo', 1), - ), array(), 1); - $node = new Twig_Node_Macro('foo', $body, $arguments, 1); - - if (PHP_VERSION_ID >= 50600) { - $declaration = ', ...$__varargs__'; - $varargs = '$__varargs__'; - } else { - $declaration = ''; - $varargs = 'func_num_args() > 2 ? array_slice(func_get_args(), 2) : array()'; - } - - return array( - array($node, <<env->mergeGlobals(array( - "foo" => \$__foo__, - "bar" => \$__bar__, - "varargs" => $varargs, - )); - - \$blocks = array(); - - ob_start(); - try { - echo "foo"; - } catch (Exception \$e) { - ob_end_clean(); - - throw \$e; - } catch (Throwable \$e) { - ob_end_clean(); - - throw \$e; - } - - return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset()); -} -EOF - ), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php deleted file mode 100644 index 54a8989c7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php +++ /dev/null @@ -1,223 +0,0 @@ -assertEquals($body, $node->getNode('body')); - $this->assertEquals($blocks, $node->getNode('blocks')); - $this->assertEquals($macros, $node->getNode('macros')); - $this->assertEquals($parent, $node->getNode('parent')); - $this->assertEquals($source->getName(), $node->getTemplateName()); - } - - public function getTests() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - - $tests = array(); - - $body = new Twig_Node_Text('foo', 1); - $extends = null; - $blocks = new Twig_Node(); - $macros = new Twig_Node(); - $traits = new Twig_Node(); - $source = new Twig_Source('{{ foo }}', 'foo.twig'); - - $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $source); - $tests[] = array($node, <<parent = false; - - \$this->blocks = array( - ); - } - - protected function doDisplay(array \$context, array \$blocks = array()) - { - // line 1 - echo "foo"; - } - - public function getTemplateName() - { - return "foo.twig"; - } - - public function getDebugInfo() - { - return array ( 19 => 1,); - } - - /** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */ - public function getSource() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED); - - return \$this->getSourceContext()->getCode(); - } - - public function getSourceContext() - { - return new Twig_Source("", "foo.twig", ""); - } -} -EOF - , $twig, true); - - $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 2); - - $body = new Twig_Node(array($import)); - $extends = new Twig_Node_Expression_Constant('layout.twig', 1); - - $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $source); - $tests[] = array($node, <<parent = \$this->loadTemplate("layout.twig", "foo.twig", 1); - \$this->blocks = array( - ); - } - - protected function doGetParent(array \$context) - { - return "layout.twig"; - } - - protected function doDisplay(array \$context, array \$blocks = array()) - { - // line 2 - \$context["macro"] = \$this->loadTemplate("foo.twig", "foo.twig", 2); - // line 1 - \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks)); - } - - public function getTemplateName() - { - return "foo.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 26 => 1, 24 => 2, 11 => 1,); - } - - /** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */ - public function getSource() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED); - - return \$this->getSourceContext()->getCode(); - } - - public function getSourceContext() - { - return new Twig_Source("", "foo.twig", ""); - } -} -EOF - , $twig, true); - - $set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 4))), 4); - $body = new Twig_Node(array($set)); - $extends = new Twig_Node_Expression_Conditional( - new Twig_Node_Expression_Constant(true, 2), - new Twig_Node_Expression_Constant('foo', 2), - new Twig_Node_Expression_Constant('foo', 2), - 2 - ); - - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('debug' => true)); - $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $source); - $tests[] = array($node, <<loadTemplate(((true) ? ("foo") : ("foo")), "foo.twig", 2); - } - - protected function doDisplay(array \$context, array \$blocks = array()) - { - // line 4 - \$context["foo"] = "foo"; - // line 2 - \$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks)); - } - - public function getTemplateName() - { - return "foo.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 17 => 2, 15 => 4, 9 => 2,); - } - - /** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */ - public function getSource() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED); - - return \$this->getSourceContext()->getCode(); - } - - public function getSourceContext() - { - return new Twig_Source("{{ foo }}", "foo.twig", ""); - } -} -EOF - , $twig, true); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php deleted file mode 100644 index 4e0990fac..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php +++ /dev/null @@ -1,29 +0,0 @@ -assertEquals($expr, $node->getNode('expr')); - } - - public function getTests() - { - $tests = array(); - $tests[] = array(new Twig_Node_Print(new Twig_Node_Expression_Constant('foo', 1), 1), "// line 1\necho \"foo\";"); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php deleted file mode 100644 index 56f487730..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php +++ /dev/null @@ -1,44 +0,0 @@ -assertEquals($body, $node->getNode('body')); - } - - public function getTests() - { - $tests = array(); - - $body = new Twig_Node_Text('foo', 1); - $node = new Twig_Node_Sandbox($body, 1); - - $tests[] = array($node, <<env->getExtension('Twig_Extension_Sandbox'); -if (!\$alreadySandboxed = \$sandbox->isSandboxed()) { - \$sandbox->enableSandbox(); -} -echo "foo"; -if (!\$alreadySandboxed) { - \$sandbox->disableSandbox(); -} -EOF - ); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php deleted file mode 100644 index 8bc8a755c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php +++ /dev/null @@ -1,33 +0,0 @@ -assertEquals($expr, $node->getNode('expr')); - } - - public function getTests() - { - $tests = array(); - - $tests[] = array(new Twig_Node_SandboxedPrint(new Twig_Node_Expression_Constant('foo', 1), 1), <<env->getExtension('Twig_Extension_Sandbox')->ensureToStringAllowed("foo"); -EOF - ); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php deleted file mode 100644 index 62ad2803e..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SetTest.php +++ /dev/null @@ -1,69 +0,0 @@ -assertEquals($names, $node->getNode('names')); - $this->assertEquals($values, $node->getNode('values')); - $this->assertFalse($node->getAttribute('capture')); - } - - public function getTests() - { - $tests = array(); - - $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, <<env->getCharset()); -EOF - ); - - $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, <<env->getCharset()); -EOF - ); - - $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, <<getVariableGetter('bar')}); -EOF - ); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php deleted file mode 100644 index 222ca0920..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php +++ /dev/null @@ -1,37 +0,0 @@ -
    foo
    ', 1))); - $node = new Twig_Node_Spaceless($body, 1); - - $this->assertEquals($body, $node->getNode('body')); - } - - public function getTests() - { - $body = new Twig_Node(array(new Twig_Node_Text('
    foo
    ', 1))); - $node = new Twig_Node_Spaceless($body, 1); - - return array( - array($node, <<
    foo
    "; -echo trim(preg_replace('/>\s+<', ob_get_clean())); -EOF - ), - ); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php deleted file mode 100644 index ceaf67f4c..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Node/TextTest.php +++ /dev/null @@ -1,28 +0,0 @@ -assertEquals('foo', $node->getAttribute('data')); - } - - public function getTests() - { - $tests = array(); - $tests[] = array(new Twig_Node_Text('foo', 1), "// line 1\necho \"foo\";"); - - return $tests; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php deleted file mode 100644 index 92c0ecac7..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php +++ /dev/null @@ -1,124 +0,0 @@ -getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - - $stream = $env->parse($env->tokenize(new Twig_Source('{{ block("foo") }}', 'index'))); - - $node = $stream->getNode('body')->getNode(0); - - $this->assertEquals('Twig_Node_Expression_BlockReference', get_class($node)); - $this->assertTrue($node->getAttribute('output')); - } - - public function testRenderParentBlockOptimizer() - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - - $stream = $env->parse($env->tokenize(new Twig_Source('{% extends "foo" %}{% block content %}{{ parent() }}{% endblock %}', 'index'))); - - $node = $stream->getNode('blocks')->getNode('content')->getNode(0)->getNode('body'); - - $this->assertEquals('Twig_Node_Expression_Parent', get_class($node)); - $this->assertTrue($node->getAttribute('output')); - } - - public function testRenderVariableBlockOptimizer() - { - if (PHP_VERSION_ID >= 50400) { - $this->markTestSkipped('not needed on PHP >= 5.4'); - } - - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false, 'autoescape' => false)); - $stream = $env->parse($env->tokenize(new Twig_Source('{{ block(name|lower) }}', 'index'))); - - $node = $stream->getNode('body')->getNode(0)->getNode(1); - - $this->assertEquals('Twig_Node_Expression_BlockReference', get_class($node)); - $this->assertTrue($node->getAttribute('output')); - } - - /** - * @dataProvider getTestsForForOptimizer - */ - public function testForOptimizer($template, $expected) - { - $env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('cache' => false)); - - $stream = $env->parse($env->tokenize(new Twig_Source($template, 'index'))); - - foreach ($expected as $target => $withLoop) { - $this->assertTrue($this->checkForConfiguration($stream, $target, $withLoop), sprintf('variable %s is %soptimized', $target, $withLoop ? 'not ' : '')); - } - } - - public function getTestsForForOptimizer() - { - return array( - array('{% for i in foo %}{% endfor %}', array('i' => false)), - - array('{% for i in foo %}{{ loop.index }}{% endfor %}', array('i' => true)), - - array('{% for i in foo %}{% for j in foo %}{% endfor %}{% endfor %}', array('i' => false, 'j' => false)), - - array('{% for i in foo %}{% include "foo" %}{% endfor %}', array('i' => true)), - - array('{% for i in foo %}{% include "foo" only %}{% endfor %}', array('i' => false)), - - array('{% for i in foo %}{% include "foo" with { "foo": "bar" } only %}{% endfor %}', array('i' => false)), - - array('{% for i in foo %}{% include "foo" with { "foo": loop.index } only %}{% endfor %}', array('i' => true)), - - array('{% for i in foo %}{% for j in foo %}{{ loop.index }}{% endfor %}{% endfor %}', array('i' => false, 'j' => true)), - - array('{% for i in foo %}{% for j in foo %}{{ loop.parent.loop.index }}{% endfor %}{% endfor %}', array('i' => true, 'j' => true)), - - array('{% for i in foo %}{% set l = loop %}{% for j in foo %}{{ l.index }}{% endfor %}{% endfor %}', array('i' => true, 'j' => false)), - - array('{% for i in foo %}{% for j in foo %}{{ foo.parent.loop.index }}{% endfor %}{% endfor %}', array('i' => false, 'j' => false)), - - array('{% for i in foo %}{% for j in foo %}{{ loop["parent"].loop.index }}{% endfor %}{% endfor %}', array('i' => true, 'j' => true)), - - array('{% for i in foo %}{{ include("foo") }}{% endfor %}', array('i' => true)), - - array('{% for i in foo %}{{ include("foo", with_context = false) }}{% endfor %}', array('i' => false)), - - array('{% for i in foo %}{{ include("foo", with_context = true) }}{% endfor %}', array('i' => true)), - - array('{% for i in foo %}{{ include("foo", { "foo": "bar" }, with_context = false) }}{% endfor %}', array('i' => false)), - - array('{% for i in foo %}{{ include("foo", { "foo": loop.index }, with_context = false) }}{% endfor %}', array('i' => true)), - ); - } - - public function checkForConfiguration(Twig_NodeInterface $node = null, $target, $withLoop) - { - if (null === $node) { - return; - } - - foreach ($node as $n) { - if ($n instanceof Twig_Node_For) { - if ($target === $n->getNode('value_target')->getAttribute('name')) { - return $withLoop == $n->getAttribute('with_loop'); - } - } - - $ret = $this->checkForConfiguration($n, $target, $withLoop); - if (null !== $ret) { - return $ret; - } - } - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/ParserTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/ParserTest.php deleted file mode 100644 index 342fb7bab..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/ParserTest.php +++ /dev/null @@ -1,198 +0,0 @@ -getParser(); - $parser->setMacro('parent', $this->getMockBuilder('Twig_Node_Macro')->disableOriginalConstructor()->getMock()); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "foo" tag. Did you mean "for" at line 1? - */ - public function testUnknownTag() - { - $stream = new Twig_TokenStream(array( - 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($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $parser->parse($stream); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unknown "foobar" tag at line 1. - */ - public function testUnknownTagWithoutSuggestions() - { - $stream = new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1), - new Twig_Token(Twig_Token::NAME_TYPE, 'foobar', 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($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $parser->parse($stream); - } - - /** - * @dataProvider getFilterBodyNodesData - */ - public function testFilterBodyNodes($input, $expected) - { - $parser = $this->getParser(); - - $this->assertEquals($expected, $parser->filterBodyNodes($input)); - } - - public function getFilterBodyNodesData() - { - return array( - array( - 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(), 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', 1))))), 1))), - $input, - ), - ); - } - - /** - * @dataProvider getFilterBodyNodesDataThrowsException - * @expectedException Twig_Error_Syntax - */ - public function testFilterBodyNodesThrowsException($input) - { - $parser = $this->getParser(); - - $parser->filterBodyNodes($input); - } - - public function getFilterBodyNodesDataThrowsException() - { - return array( - 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 start with a byte order mark (BOM); it must be removed at line 1 - */ - public function testFilterBodyNodesWithBOM() - { - $parser = $this->getParser(); - $parser->filterBodyNodes(new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF), 1)); - } - - public function testParseIsReentrant() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array( - 'autoescape' => false, - 'optimizations' => 0, - )); - $twig->addTokenParser(new TestTokenParser()); - - $parser = new Twig_Parser($twig); - - $parser->parse(new Twig_TokenStream(array( - 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->assertNull($parser->getParent()); - } - - public function testGetVarName() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array( - 'autoescape' => false, - 'optimizations' => 0, - )); - - $twig->parse($twig->tokenize(new Twig_Source(<<addToAssertionCount(1); - } - - protected function getParser() - { - $parser = new TestParser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - $parser->setParent(new Twig_Node()); - $parser->stream = new Twig_TokenStream(array()); - - return $parser; - } -} - -class TestParser extends Twig_Parser -{ - public $stream; - - public function filterBodyNodes(Twig_NodeInterface $node) - { - return parent::filterBodyNodes($node); - } -} - -class TestTokenParser extends Twig_TokenParser -{ - 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, '', 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); - - return new Twig_Node(array()); - } - - public function getTag() - { - return 'test'; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php deleted file mode 100644 index a71b97b97..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php +++ /dev/null @@ -1,101 +0,0 @@ -getMockBuilder('Twig_Profiler_Profile')->disableOriginalConstructor()->getMock(); - - $profile->expects($this->any())->method('isRoot')->will($this->returnValue(true)); - $profile->expects($this->any())->method('getName')->will($this->returnValue('main')); - $profile->expects($this->any())->method('getDuration')->will($this->returnValue(1)); - $profile->expects($this->any())->method('getMemoryUsage')->will($this->returnValue(0)); - $profile->expects($this->any())->method('getPeakMemoryUsage')->will($this->returnValue(0)); - - $subProfiles = array( - $this->getIndexProfile( - array( - $this->getEmbeddedBlockProfile(), - $this->getEmbeddedTemplateProfile( - array( - $this->getIncludedTemplateProfile(), - ) - ), - $this->getMacroProfile(), - $this->getEmbeddedTemplateProfile( - array( - $this->getIncludedTemplateProfile(), - ) - ), - ) - ), - ); - - $profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles)); - $profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles))); - - return $profile; - } - - private function getIndexProfile(array $subProfiles = array()) - { - return $this->generateProfile('main', 1, true, 'template', 'index.twig', $subProfiles); - } - - private function getEmbeddedBlockProfile(array $subProfiles = array()) - { - return $this->generateProfile('body', 0.0001, false, 'block', 'embedded.twig', $subProfiles); - } - - private function getEmbeddedTemplateProfile(array $subProfiles = array()) - { - return $this->generateProfile('main', 0.0001, true, 'template', 'embedded.twig', $subProfiles); - } - - private function getIncludedTemplateProfile(array $subProfiles = array()) - { - return $this->generateProfile('main', 0.0001, true, 'template', 'included.twig', $subProfiles); - } - - private function getMacroProfile(array $subProfiles = array()) - { - return $this->generateProfile('foo', 0.0001, false, 'macro', 'index.twig', $subProfiles); - } - - /** - * @param string $name - * @param float $duration - * @param bool $isTemplate - * @param string $type - * @param string $templateName - * @param array $subProfiles - * - * @return Twig_Profiler_Profile - */ - private function generateProfile($name, $duration, $isTemplate, $type, $templateName, array $subProfiles = array()) - { - $profile = $this->getMockBuilder('Twig_Profiler_Profile')->disableOriginalConstructor()->getMock(); - - $profile->expects($this->any())->method('isRoot')->will($this->returnValue(false)); - $profile->expects($this->any())->method('getName')->will($this->returnValue($name)); - $profile->expects($this->any())->method('getDuration')->will($this->returnValue($duration)); - $profile->expects($this->any())->method('getMemoryUsage')->will($this->returnValue(0)); - $profile->expects($this->any())->method('getPeakMemoryUsage')->will($this->returnValue(0)); - $profile->expects($this->any())->method('isTemplate')->will($this->returnValue($isTemplate)); - $profile->expects($this->any())->method('getType')->will($this->returnValue($type)); - $profile->expects($this->any())->method('getTemplate')->will($this->returnValue($templateName)); - $profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles)); - $profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles))); - - return $profile; - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/BlackfireTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/BlackfireTest.php deleted file mode 100644 index 1a1b9d299..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/BlackfireTest.php +++ /dev/null @@ -1,32 +0,0 @@ -assertStringMatchesFormat(<<index.twig//1 %d %d %d -index.twig==>embedded.twig::block(body)//1 %d %d 0 -index.twig==>embedded.twig//2 %d %d %d -embedded.twig==>included.twig//2 %d %d %d -index.twig==>index.twig::macro(foo)//1 %d %d %d -EOF - , $dumper->dump($this->getProfile())); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php deleted file mode 100644 index 66a68c4be..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php +++ /dev/null @@ -1,30 +0,0 @@ -assertStringMatchesFormat(<<main %d.%dms/%d% -└ index.twig %d.%dms/%d% - └ embedded.twig::block(body) - └ embedded.twig - │ └ included.twig - └ index.twig::macro(foo) - └ embedded.twig - └ included.twig - -EOF - , $dumper->dump($this->getProfile())); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php deleted file mode 100644 index e2ea165ac..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php +++ /dev/null @@ -1,30 +0,0 @@ -assertStringMatchesFormat(<<dump($this->getProfile())); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php deleted file mode 100644 index 08db96a90..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php +++ /dev/null @@ -1,110 +0,0 @@ -assertEquals('template', $profile->getTemplate()); - $this->assertEquals('type', $profile->getType()); - $this->assertEquals('name', $profile->getName()); - } - - public function testIsRoot() - { - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT); - $this->assertTrue($profile->isRoot()); - - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::TEMPLATE); - $this->assertFalse($profile->isRoot()); - } - - public function testIsTemplate() - { - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::TEMPLATE); - $this->assertTrue($profile->isTemplate()); - - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT); - $this->assertFalse($profile->isTemplate()); - } - - public function testIsBlock() - { - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::BLOCK); - $this->assertTrue($profile->isBlock()); - - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT); - $this->assertFalse($profile->isBlock()); - } - - public function testIsMacro() - { - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::MACRO); - $this->assertTrue($profile->isMacro()); - - $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT); - $this->assertFalse($profile->isMacro()); - } - - public function testGetAddProfile() - { - $profile = new Twig_Profiler_Profile(); - $profile->addProfile($a = new Twig_Profiler_Profile()); - $profile->addProfile($b = new Twig_Profiler_Profile()); - - $this->assertSame(array($a, $b), $profile->getProfiles()); - $this->assertSame(array($a, $b), iterator_to_array($profile)); - } - - public function testGetDuration() - { - $profile = new Twig_Profiler_Profile(); - usleep(1); - $profile->leave(); - - $this->assertTrue($profile->getDuration() > 0, sprintf('Expected duration > 0, got: %f', $profile->getDuration())); - } - - public function testSerialize() - { - $profile = new Twig_Profiler_Profile('template', 'type', 'name'); - $profile1 = new Twig_Profiler_Profile('template1', 'type1', 'name1'); - $profile->addProfile($profile1); - $profile->leave(); - $profile1->leave(); - - $profile2 = unserialize(serialize($profile)); - $profiles = $profile->getProfiles(); - $this->assertCount(1, $profiles); - $profile3 = $profiles[0]; - - $this->assertEquals($profile->getTemplate(), $profile2->getTemplate()); - $this->assertEquals($profile->getType(), $profile2->getType()); - $this->assertEquals($profile->getName(), $profile2->getName()); - $this->assertEquals($profile->getDuration(), $profile2->getDuration()); - - $this->assertEquals($profile1->getTemplate(), $profile3->getTemplate()); - $this->assertEquals($profile1->getType(), $profile3->getType()); - $this->assertEquals($profile1->getName(), $profile3->getName()); - } - - public function testReset() - { - $profile = new Twig_Profiler_Profile(); - usleep(1); - $profile->leave(); - $profile->reset(); - - $this->assertEquals(0, $profile->getDuration()); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateTest.php deleted file mode 100644 index c22a43336..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateTest.php +++ /dev/null @@ -1,761 +0,0 @@ -getMockForAbstractClass('Twig_Template', array(), '', false); - $template->displayBlock('foo', array(), array('foo' => array(new stdClass(), 'foo'))); - } - - /** - * @dataProvider getAttributeExceptions - */ - public function testGetAttributeExceptions($template, $message) - { - $templates = array('index' => $template); - $env = new Twig_Environment(new Twig_Loader_Array($templates), array('strict_variables' => true)); - $template = $env->loadTemplate('index'); - - $context = array( - 'string' => 'foo', - 'null' => null, - 'empty_array' => array(), - 'array' => array('foo' => 'foo'), - 'array_access' => new Twig_TemplateArrayAccessObject(), - 'magic_exception' => new Twig_TemplateMagicPropertyObjectWithException(), - 'object' => new stdClass(), - ); - - try { - $template->render($context); - $this->fail('Accessing an invalid attribute should throw an exception.'); - } catch (Twig_Error_Runtime $e) { - $this->assertSame(sprintf($message, 'index'), $e->getMessage()); - } - } - - public function getAttributeExceptions() - { - return array( - array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1.'), - array('{{ null["a"] }}', 'Impossible to access a key ("a") on a null variable in "%s" at line 1.'), - array('{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'), - array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'), - array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1.'), - array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1.'), - array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1.'), - array('{{ null.a }}', 'Impossible to access an attribute ("a") on a null variable in "%s" at line 1.'), - array('{{ null.a() }}', 'Impossible to invoke a method ("a") on a null variable in "%s" at line 1.'), - array('{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'), - array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'), - array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1.'), - array('{{ array_access.a }}', 'Neither the property "a" nor one of the methods "a()", "geta()"/"isa()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'), - array('{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Neither the property "missing_method" nor one of the methods "missing_method()", "getmissing_method()"/"ismissing_method()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'), - array('{{ magic_exception.test }}', 'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.'), - array('{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1.'), - ); - } - - /** - * @dataProvider getGetAttributeWithSandbox - */ - public function testGetAttributeWithSandbox($object, $item, $allowed) - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array()); - $twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed)); - $template = new Twig_TemplateTest($twig); - - try { - $template->getAttribute($object, $item, array(), 'any'); - - if (!$allowed) { - $this->fail(); - } else { - $this->addToAssertionCount(1); - } - } catch (Twig_Sandbox_SecurityError $e) { - if ($allowed) { - $this->fail(); - } else { - $this->addToAssertionCount(1); - } - - $this->assertContains('is not allowed', $e->getMessage()); - } - } - - public function getGetAttributeWithSandbox() - { - return array( - array(new Twig_TemplatePropertyObject(), 'defined', false), - array(new Twig_TemplatePropertyObject(), 'defined', true), - array(new Twig_TemplateMethodObject(), 'defined', false), - array(new Twig_TemplateMethodObject(), 'defined', true), - ); - } - - /** - * @group legacy - */ - public function testGetAttributeWithTemplateAsObject() - { - // to be removed in 2.0 - $twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock()); - //$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock()); - - $template = new Twig_TemplateTest($twig, 'index.twig'); - $template1 = new Twig_TemplateTest($twig, 'index1.twig'); - - $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string')); - $this->assertEquals('some_string', $template->getAttribute($template1, 'string')); - - $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'true')); - $this->assertEquals('1', $template->getAttribute($template1, 'true')); - - $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'zero')); - $this->assertEquals('0', $template->getAttribute($template1, 'zero')); - - $this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty')); - $this->assertSame('', $template->getAttribute($template1, 'empty')); - - $this->assertFalse($template->getAttribute($template1, 'env', array(), Twig_Template::ANY_CALL, true)); - $this->assertFalse($template->getAttribute($template1, 'environment', array(), Twig_Template::ANY_CALL, true)); - $this->assertFalse($template->getAttribute($template1, 'getEnvironment', array(), Twig_Template::METHOD_CALL, true)); - $this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', array(), Twig_Template::METHOD_CALL, true)); - } - - /** - * @group legacy - * @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. - * @expectedDeprecation Calling "renderBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead). - * @expectedDeprecation Calling "displayBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead). - * @expectedDeprecation Calling "hasBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name") is defined" instead). - * @expectedDeprecation Calling "render" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index.twig") instead). - * @expectedDeprecation Calling "display" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index.twig") instead). - * @expectedDeprecation Calling "renderBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name", template) instead). - * @expectedDeprecation Calling "displayBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name", template) instead). - * @expectedDeprecation Calling "hasBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name", template) is defined" instead). - * @expectedDeprecation Calling "render" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index1.twig") instead). - * @expectedDeprecation Calling "display" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index1.twig") instead). - */ - public function testGetAttributeWithTemplateAsObjectForDeprecations() - { - // to be removed in 2.0 - $twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock()); - //$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock()); - - $template = new Twig_TemplateTest($twig, 'index.twig'); - $template1 = new Twig_TemplateTest($twig, 'index1.twig'); - - $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string')); - $this->assertEquals('some_string', $template->getAttribute($template1, 'string')); - - $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'true')); - $this->assertEquals('1', $template->getAttribute($template1, 'true')); - - $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'zero')); - $this->assertEquals('0', $template->getAttribute($template1, 'zero')); - - $this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty')); - $this->assertSame('', $template->getAttribute($template1, 'empty')); - - $blocks = array('name' => array($template1, 'block_name')); - - // trigger some deprecation notice messages to check them with @expectedDeprecation - $template->getAttribute($template, 'renderBlock', array('name', array(), $blocks)); - $template->getAttribute($template, 'displayBlock', array('name', array(), $blocks)); - $template->getAttribute($template, 'hasBlock', array('name', array())); - $template->getAttribute($template, 'render', array(array())); - $template->getAttribute($template, 'display', array(array())); - - $template->getAttribute($template1, 'renderBlock', array('name', array(), $blocks)); - $template->getAttribute($template1, 'displayBlock', array('name', array(), $blocks)); - $template->getAttribute($template1, 'hasBlock', array('name', array())); - $template->getAttribute($template1, 'render', array(array())); - $template->getAttribute($template1, 'display', array(array())); - - $this->assertFalse($template->getAttribute($template1, 'env', array(), Twig_Template::ANY_CALL, true)); - $this->assertFalse($template->getAttribute($template1, 'environment', array(), Twig_Template::ANY_CALL, true)); - $this->assertFalse($template->getAttribute($template1, 'getEnvironment', array(), Twig_Template::METHOD_CALL, true)); - $this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', array(), Twig_Template::METHOD_CALL, true)); - } - - /** - * @group legacy - * @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence. - * @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence. - */ - public function testRenderBlockWithUndefinedBlock() - { - $twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock()); - - $template = new Twig_TemplateTest($twig, 'index.twig'); - $template->renderBlock('unknown', array()); - $template->displayBlock('unknown', array()); - } - - public function testGetAttributeOnArrayWithConfusableKey() - { - $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - - $array = array('Zero', 'One', -1 => 'MinusOne', '' => 'EmptyString', '1.5' => 'FloatButString', '01' => 'IntegerButStringWithLeadingZeros'); - - $this->assertSame('Zero', $array[false]); - $this->assertSame('One', $array[true]); - $this->assertSame('One', $array[1.5]); - $this->assertSame('One', $array['1']); - $this->assertSame('MinusOne', $array[-1.5]); - $this->assertSame('FloatButString', $array['1.5']); - $this->assertSame('IntegerButStringWithLeadingZeros', $array['01']); - $this->assertSame('EmptyString', $array[null]); - - $this->assertSame('Zero', $template->getAttribute($array, false), 'false is treated as 0 when accessing an array (equals PHP behavior)'); - $this->assertSame('One', $template->getAttribute($array, true), 'true is treated as 1 when accessing an array (equals PHP behavior)'); - $this->assertSame('One', $template->getAttribute($array, 1.5), 'float is casted to int when accessing an array (equals PHP behavior)'); - $this->assertSame('One', $template->getAttribute($array, '1'), '"1" is treated as integer 1 when accessing an array (equals PHP behavior)'); - $this->assertSame('MinusOne', $template->getAttribute($array, -1.5), 'negative float is casted to int when accessing an array (equals PHP behavior)'); - $this->assertSame('FloatButString', $template->getAttribute($array, '1.5'), '"1.5" is treated as-is when accessing an array (equals PHP behavior)'); - $this->assertSame('IntegerButStringWithLeadingZeros', $template->getAttribute($array, '01'), '"01" is treated as-is when accessing an array (equals PHP behavior)'); - $this->assertSame('EmptyString', $template->getAttribute($array, null), 'null is treated as "" when accessing an array (equals PHP behavior)'); - } - - /** - * @dataProvider getGetAttributeTests - */ - public function testGetAttribute($defined, $value, $object, $item, $arguments, $type) - { - $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - - $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); - } - - /** - * @dataProvider getGetAttributeTests - */ - public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null) - { - $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true))); - - if ($defined) { - $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); - } else { - if (method_exists($this, 'expectException')) { - $this->expectException('Twig_Error_Runtime'); - if (null !== $exceptionMessage) { - $this->expectExceptionMessage($exceptionMessage); - } - } else { - $this->setExpectedException('Twig_Error_Runtime', $exceptionMessage); - } - $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); - } - } - - /** - * @dataProvider getGetAttributeTests - */ - public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type) - { - $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - - $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true)); - } - - /** - * @dataProvider getGetAttributeTests - */ - public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type) - { - $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true))); - - $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true)); - } - - public function testGetAttributeCallExceptions() - { - $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())); - - $object = new Twig_TemplateMagicMethodExceptionObject(); - - $this->assertNull($template->getAttribute($object, 'foo')); - } - - public function getGetAttributeTests() - { - $array = array( - 'defined' => 'defined', - 'zero' => 0, - 'null' => null, - '1' => 1, - 'bar' => true, - 'baz' => 'baz', - '09' => '09', - '+4' => '+4', - ); - - $objectArray = new Twig_TemplateArrayAccessObject(); - $stdObject = (object) $array; - $magicPropertyObject = new Twig_TemplateMagicPropertyObject(); - $propertyObject = new Twig_TemplatePropertyObject(); - $propertyObject1 = new Twig_TemplatePropertyObjectAndIterator(); - $propertyObject2 = new Twig_TemplatePropertyObjectAndArrayAccess(); - $propertyObject3 = new Twig_TemplatePropertyObjectDefinedWithUndefinedValue(); - $methodObject = new Twig_TemplateMethodObject(); - $magicMethodObject = new Twig_TemplateMagicMethodObject(); - - $anyType = Twig_Template::ANY_CALL; - $methodType = Twig_Template::METHOD_CALL; - $arrayType = Twig_Template::ARRAY_CALL; - - $basicTests = array( - // array(defined, value, property to fetch) - array(true, 'defined', 'defined'), - array(false, null, 'undefined'), - array(false, null, 'protected'), - array(true, 0, 'zero'), - array(true, 1, 1), - array(true, 1, 1.0), - array(true, null, 'null'), - array(true, true, 'bar'), - array(true, 'baz', 'baz'), - array(true, '09', '09'), - array(true, '+4', '+4'), - ); - $testObjects = array( - // array(object, type of fetch) - array($array, $arrayType), - array($objectArray, $arrayType), - array($stdObject, $anyType), - array($magicPropertyObject, $anyType), - array($methodObject, $methodType), - array($methodObject, $anyType), - array($propertyObject, $anyType), - array($propertyObject1, $anyType), - array($propertyObject2, $anyType), - ); - - $tests = array(); - foreach ($testObjects as $testObject) { - foreach ($basicTests as $test) { - // properties cannot be numbers - if (($testObject[0] instanceof stdClass || $testObject[0] instanceof Twig_TemplatePropertyObject) && is_numeric($test[2])) { - continue; - } - - if ('+4' === $test[2] && $methodObject === $testObject[0]) { - continue; - } - - $tests[] = array($test[0], $test[1], $testObject[0], $test[2], array(), $testObject[1]); - } - } - - // additional properties tests - $tests = array_merge($tests, array( - array(true, null, $propertyObject3, 'foo', array(), $anyType), - )); - - // additional method tests - $tests = array_merge($tests, array( - array(true, 'defined', $methodObject, 'defined', array(), $methodType), - array(true, 'defined', $methodObject, 'DEFINED', array(), $methodType), - array(true, 'defined', $methodObject, 'getDefined', array(), $methodType), - array(true, 'defined', $methodObject, 'GETDEFINED', array(), $methodType), - array(true, 'static', $methodObject, 'static', array(), $methodType), - array(true, 'static', $methodObject, 'getStatic', array(), $methodType), - - array(true, '__call_undefined', $magicMethodObject, 'undefined', array(), $methodType), - array(true, '__call_UNDEFINED', $magicMethodObject, 'UNDEFINED', array(), $methodType), - )); - - // add the same tests for the any type - foreach ($tests as $test) { - if ($anyType !== $test[5]) { - $test[5] = $anyType; - $tests[] = $test; - } - } - - $methodAndPropObject = new Twig_TemplateMethodAndPropObject(); - - // additional method tests - $tests = array_merge($tests, array( - array(true, 'a', $methodAndPropObject, 'a', array(), $anyType), - array(true, 'a', $methodAndPropObject, 'a', array(), $methodType), - array(false, null, $methodAndPropObject, 'a', array(), $arrayType), - - array(true, 'b_prop', $methodAndPropObject, 'b', array(), $anyType), - array(true, 'b', $methodAndPropObject, 'B', array(), $anyType), - array(true, 'b', $methodAndPropObject, 'b', array(), $methodType), - array(true, 'b', $methodAndPropObject, 'B', array(), $methodType), - array(false, null, $methodAndPropObject, 'b', array(), $arrayType), - - array(false, null, $methodAndPropObject, 'c', array(), $anyType), - array(false, null, $methodAndPropObject, 'c', array(), $methodType), - array(false, null, $methodAndPropObject, 'c', array(), $arrayType), - )); - - // tests when input is not an array or object - $tests = array_merge($tests, array( - array(false, null, 42, 'a', array(), $anyType, 'Impossible to access an attribute ("a") on a integer variable ("42") in "index.twig".'), - array(false, null, 'string', 'a', array(), $anyType, 'Impossible to access an attribute ("a") on a string variable ("string") in "index.twig".'), - array(false, null, array(), 'a', array(), $anyType, 'Key "a" does not exist as the array is empty in "index.twig".'), - )); - - return $tests; - } - - /** - * @expectedException Twig_Error_Runtime - */ - public function testGetIsMethods() - { - $getIsObject = new Twig_TemplateGetIsMethods(); - $template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true))); - // first time should not create a cache for "get" - $this->assertNull($template->getAttribute($getIsObject, 'get')); - // 0 should be in the method cache now, so this should fail - $this->assertNull($template->getAttribute($getIsObject, 0)); - } -} - -class Twig_TemplateTest extends Twig_Template -{ - private $name; - - public function __construct(Twig_Environment $env, $name = 'index.twig') - { - parent::__construct($env); - self::$cache = array(); - $this->name = $name; - } - - public function getZero() - { - return 0; - } - - public function getEmpty() - { - return ''; - } - - public function getString() - { - return 'some_string'; - } - - public function getTrue() - { - return true; - } - - public function getTemplateName() - { - return $this->name; - } - - public function getDebugInfo() - { - return array(); - } - - protected function doGetParent(array $context) - { - return false; - } - - protected function doDisplay(array $context, array $blocks = array()) - { - } - - public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false) - { - if (function_exists('twig_template_get_attributes')) { - return twig_template_get_attributes($this, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck); - } else { - return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck); - } - } - - public function block_name($context, array $blocks = array()) - { - } -} - -class Twig_TemplateArrayAccessObject implements ArrayAccess -{ - protected $protected = 'protected'; - - public $attributes = array( - 'defined' => 'defined', - 'zero' => 0, - 'null' => null, - '1' => 1, - 'bar' => true, - 'baz' => 'baz', - '09' => '09', - '+4' => '+4', - ); - - public function offsetExists($name) - { - return array_key_exists($name, $this->attributes); - } - - public function offsetGet($name) - { - return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null; - } - - public function offsetSet($name, $value) - { - } - - public function offsetUnset($name) - { - } -} - -class Twig_TemplateMagicPropertyObject -{ - public $defined = 'defined'; - - public $attributes = array( - 'zero' => 0, - 'null' => null, - '1' => 1, - 'bar' => true, - 'baz' => 'baz', - '09' => '09', - '+4' => '+4', - ); - - protected $protected = 'protected'; - - public function __isset($name) - { - return array_key_exists($name, $this->attributes); - } - - public function __get($name) - { - return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null; - } -} - -class Twig_TemplateMagicPropertyObjectWithException -{ - public function __isset($key) - { - throw new Exception('Hey! Don\'t try to isset me!'); - } -} - -class Twig_TemplatePropertyObject -{ - public $defined = 'defined'; - public $zero = 0; - public $null = null; - public $bar = true; - public $baz = 'baz'; - - protected $protected = 'protected'; -} - -class Twig_TemplatePropertyObjectAndIterator extends Twig_TemplatePropertyObject implements IteratorAggregate -{ - public function getIterator() - { - return new ArrayIterator(array('foo', 'bar')); - } -} - -class Twig_TemplatePropertyObjectAndArrayAccess extends Twig_TemplatePropertyObject implements ArrayAccess -{ - private $data = array( - 'defined' => 'defined', - 'zero' => 0, - 'null' => null, - 'bar' => true, - 'baz' => 'baz', - ); - - 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_TemplatePropertyObjectDefinedWithUndefinedValue -{ - public $foo; - - public function __construct() - { - $this->foo = @$notExist; - } -} - -class Twig_TemplateMethodObject -{ - public function getDefined() - { - return 'defined'; - } - - public function get1() - { - return 1; - } - - public function get09() - { - return '09'; - } - - public function getZero() - { - return 0; - } - - public function getNull() - { - } - - public function isBar() - { - return true; - } - - public function isBaz() - { - return 'should never be returned'; - } - - public function getBaz() - { - return 'baz'; - } - - protected function getProtected() - { - return 'protected'; - } - - public static function getStatic() - { - return 'static'; - } -} - -class Twig_TemplateGetIsMethods -{ - public function get() - { - } - - public function is() - { - } -} - -class Twig_TemplateMethodAndPropObject -{ - private $a = 'a_prop'; - - public function getA() - { - return 'a'; - } - - public $b = 'b_prop'; - - public function getB() - { - return 'b'; - } - - private $c = 'c_prop'; - - private function getC() - { - return 'c'; - } -} - -class Twig_TemplateMagicMethodObject -{ - public function __call($method, $arguments) - { - return '__call_'.$method; - } -} - -class Twig_TemplateMagicMethodExceptionObject -{ - public function __call($method, $arguments) - { - throw new BadMethodCallException(sprintf('Unknown method "%s".', $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; - } -} - -// to be removed in 2.0 -interface Twig_TemplateTestLoaderInterface extends Twig_LoaderInterface, Twig_SourceContextLoaderInterface -{ -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateWrapperTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateWrapperTest.php deleted file mode 100644 index cc71052c4..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/TemplateWrapperTest.php +++ /dev/null @@ -1,64 +0,0 @@ - '{% block foo %}{% endblock %}', - 'index_with_use' => '{% use "imported" %}{% block foo %}{% endblock %}', - 'index_with_extends' => '{% extends "extended" %}{% block foo %}{% endblock %}', - 'imported' => '{% block imported %}{% endblock %}', - 'extended' => '{% block extended %}{% endblock %}', - ))); - - $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index')); - $this->assertTrue($wrapper->hasBlock('foo')); - $this->assertFalse($wrapper->hasBlock('bar')); - $this->assertEquals(array('foo'), $wrapper->getBlockNames()); - - $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index_with_use')); - $this->assertTrue($wrapper->hasBlock('foo')); - $this->assertTrue($wrapper->hasBlock('imported')); - $this->assertEquals(array('imported', 'foo'), $wrapper->getBlockNames()); - - $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index_with_extends')); - $this->assertTrue($wrapper->hasBlock('foo')); - $this->assertTrue($wrapper->hasBlock('extended')); - $this->assertEquals(array('foo', 'extended'), $wrapper->getBlockNames()); - } - - public function testRenderBlock() - { - $twig = new Twig_Environment(new Twig_Loader_Array(array( - 'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}', - ))); - $twig->addGlobal('bar', 'BAR'); - - $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index')); - $this->assertEquals('FOOBAR', $wrapper->renderBlock('foo', array('foo' => 'FOO'))); - } - - public function testDisplayBlock() - { - $twig = new Twig_Environment(new Twig_Loader_Array(array( - 'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}', - ))); - $twig->addGlobal('bar', 'BAR'); - - $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index')); - - ob_start(); - $wrapper->displayBlock('foo', array('foo' => 'FOO')); - - $this->assertEquals('FOOBAR', ob_get_clean()); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php deleted file mode 100644 index f219c9554..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/TokenStreamTest.php +++ /dev/null @@ -1,82 +0,0 @@ -assertEquals('foo', $stream->getFilename()); - $this->assertEquals('{{ foo }}', $stream->getSource()); - $this->assertEquals('foo', $stream->getSourceContext()->getName()); - $this->assertEquals('{{ foo }}', $stream->getSourceContext()->getCode()); - } - - public function testNext() - { - $stream = new Twig_TokenStream(self::$tokens); - $repr = array(); - while (!$stream->isEOF()) { - $token = $stream->next(); - - $repr[] = $token->getValue(); - } - $this->assertEquals('1, 2, 3, 4, 5, 6, 7', implode(', ', $repr), '->next() advances the pointer and returns the current token'); - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unexpected end of template - */ - public function testEndOfTemplateNext() - { - $stream = new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, 1, 1), - )); - while (!$stream->isEOF()) { - $stream->next(); - } - } - - /** - * @expectedException Twig_Error_Syntax - * @expectedExceptionMessage Unexpected end of template - */ - public function testEndOfTemplateLook() - { - $stream = new Twig_TokenStream(array( - new Twig_Token(Twig_Token::BLOCK_START_TYPE, 1, 1), - )); - while (!$stream->isEOF()) { - $stream->look(); - $stream->next(); - } - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/Util/DeprecationCollectorTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/Util/DeprecationCollectorTest.php deleted file mode 100644 index 887a90afa..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/Util/DeprecationCollectorTest.php +++ /dev/null @@ -1,42 +0,0 @@ -getMockBuilder('Twig_LoaderInterface')->getMock()); - $twig->addFunction(new Twig_SimpleFunction('deprec', array($this, 'deprec'), array('deprecated' => true))); - - $collector = new Twig_Util_DeprecationCollector($twig); - $deprecations = $collector->collect(new Twig_Tests_Util_Iterator()); - - $this->assertEquals(array('Twig Function "deprec" is deprecated in deprec.twig at line 1.'), $deprecations); - } - - public function deprec() - { - } -} - -class Twig_Tests_Util_Iterator implements IteratorAggregate -{ - public function getIterator() - { - return new ArrayIterator(array( - 'ok.twig' => '{{ foo }}', - 'deprec.twig' => '{{ deprec("foo") }}', - )); - } -} diff --git a/lib/silex/vendor/twig/twig/test/Twig/Tests/escapingTest.php b/lib/silex/vendor/twig/twig/test/Twig/Tests/escapingTest.php deleted file mode 100644 index 9b98dddcf..000000000 --- a/lib/silex/vendor/twig/twig/test/Twig/Tests/escapingTest.php +++ /dev/null @@ -1,320 +0,0 @@ - ''', - '"' => '"', - '<' => '<', - '>' => '>', - '&' => '&', - ); - - protected $htmlAttrSpecialChars = array( - '\'' => ''', - /* Characters beyond ASCII value 255 to unicode escape */ - 'Ā' => 'Ā', - /* Immune chars excluded */ - ',' => ',', - '.' => '.', - '-' => '-', - '_' => '_', - /* Basic alnums excluded */ - '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 excluded */ - '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 excluded */ - '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; - - protected function setUp() - { - $this->env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()); - } - - 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 $codepoint 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() - { - // 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/lib/silex/vendor/twig/twig/test/bootstrap.php b/lib/silex/vendor/twig/twig/test/bootstrap.php deleted file mode 100644 index aecb976f7..000000000 --- a/lib/silex/vendor/twig/twig/test/bootstrap.php +++ /dev/null @@ -1,13 +0,0 @@ -